Merge pull request #85 from tom5079/Pupil-84
Pupil-84 Title doesn't show up when using hiyobi
This commit is contained in:
@@ -20,7 +20,7 @@ import kotlinx.serialization.UnstableDefault
|
|||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import java.net.Proxy
|
import java.net.Proxy
|
||||||
|
|
||||||
var proxy = Proxy.NO_PROXY
|
var proxy : Proxy = Proxy.NO_PROXY
|
||||||
|
|
||||||
@OptIn(UnstableDefault::class)
|
@OptIn(UnstableDefault::class)
|
||||||
var json = Json {
|
var json = Json {
|
||||||
|
|||||||
@@ -16,31 +16,54 @@
|
|||||||
|
|
||||||
package xyz.quaver.hiyobi
|
package xyz.quaver.hiyobi
|
||||||
|
|
||||||
import org.jsoup.Jsoup
|
import kotlinx.serialization.json.contentOrNull
|
||||||
|
import kotlinx.serialization.json.intOrNull
|
||||||
import xyz.quaver.Code
|
import xyz.quaver.Code
|
||||||
import xyz.quaver.hitomi.GalleryBlock
|
import xyz.quaver.hitomi.GalleryBlock
|
||||||
import xyz.quaver.hitomi.protocol
|
import xyz.quaver.hitomi.protocol
|
||||||
|
import xyz.quaver.json
|
||||||
import xyz.quaver.proxy
|
import xyz.quaver.proxy
|
||||||
|
import java.net.URL
|
||||||
|
import javax.net.ssl.HttpsURLConnection
|
||||||
|
|
||||||
fun getGalleryBlock(galleryID: Int) : GalleryBlock? {
|
fun getGalleryBlock(galleryID: Int) : GalleryBlock? {
|
||||||
val url = "$protocol//$hiyobi/info/$galleryID"
|
val url = "$protocol//api.$hiyobi/gallery/$galleryID"
|
||||||
|
|
||||||
val doc = Jsoup.connect(url).proxy(proxy).get()
|
val galleryBlock = with (URL(url).openConnection(proxy) as HttpsURLConnection) {
|
||||||
|
setRequestProperty("User-Agent", user_agent)
|
||||||
|
setRequestProperty("Cookie", cookie)
|
||||||
|
connectTimeout = 1000
|
||||||
|
connect()
|
||||||
|
|
||||||
val galleryBlock = doc.selectFirst(".gallery-content")
|
inputStream.bufferedReader().use { it.readText() }
|
||||||
|
}.let {
|
||||||
|
json.parseJson(it).jsonObject
|
||||||
|
}
|
||||||
|
|
||||||
val galleryUrl = galleryBlock.selectFirst("a").attr("href")
|
val galleryUrl = "reader/$galleryID"
|
||||||
|
|
||||||
val thumbnails = listOf(galleryBlock.selectFirst("img").attr("abs:src"))
|
val thumbnails = listOf("$protocol//cdn.$hiyobi/tn/$galleryID.jpg")
|
||||||
|
|
||||||
val title = galleryBlock.selectFirst("b").text()
|
val title = galleryBlock["title"]?.contentOrNull ?: ""
|
||||||
val artists = galleryBlock.select("tr:matches(작가) a[href~=artist]").map { it.text() }
|
val artists = galleryBlock["artists"]?.jsonArray?.mapNotNull {
|
||||||
val series = galleryBlock.select("tr:matches(원작) a").map { it.attr("href").substringAfter("series:").replace('_', ' ') }
|
it.jsonObject["value"]?.contentOrNull
|
||||||
val type = galleryBlock.selectFirst("tr:matches(종류) a").attr("href").substringAfter("type:").replace('_', ' ')
|
} ?: listOf()
|
||||||
|
val series = galleryBlock["parodys"]?.jsonArray?.mapNotNull {
|
||||||
|
it.jsonObject["value"]?.contentOrNull
|
||||||
|
} ?: listOf()
|
||||||
|
val type = when (galleryBlock["type"]?.intOrNull) {
|
||||||
|
1 -> "doujinshi"
|
||||||
|
2 -> "manga"
|
||||||
|
3 -> "artistcg"
|
||||||
|
4 -> "gamecg"
|
||||||
|
else -> ""
|
||||||
|
}
|
||||||
|
|
||||||
val language = "korean"
|
val language = "korean"
|
||||||
|
|
||||||
val relatedTags = galleryBlock.select("tr:matches(태그) a").map { it.attr("href").substringAfterLast('/').replace('_', ' ') }
|
val relatedTags = galleryBlock["tags"]?.jsonArray?.mapNotNull {
|
||||||
|
it.jsonObject["value"]?.contentOrNull
|
||||||
|
} ?: listOf()
|
||||||
|
|
||||||
return GalleryBlock(Code.HIYOBI, galleryID, galleryUrl, thumbnails, title, artists, series, type, language, relatedTags)
|
return GalleryBlock(Code.HIYOBI, galleryID, galleryUrl, thumbnails, title, artists, series, type, language, relatedTags)
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ package xyz.quaver.hiyobi
|
|||||||
|
|
||||||
import kotlinx.serialization.UnstableDefault
|
import kotlinx.serialization.UnstableDefault
|
||||||
import kotlinx.serialization.builtins.list
|
import kotlinx.serialization.builtins.list
|
||||||
import org.jsoup.Jsoup
|
import kotlinx.serialization.json.contentOrNull
|
||||||
import xyz.quaver.Code
|
import xyz.quaver.Code
|
||||||
import xyz.quaver.hitomi.GalleryFiles
|
import xyz.quaver.hitomi.GalleryFiles
|
||||||
import xyz.quaver.hitomi.GalleryInfo
|
import xyz.quaver.hitomi.GalleryInfo
|
||||||
@@ -64,14 +64,23 @@ fun renewCookie() : String {
|
|||||||
|
|
||||||
@OptIn(UnstableDefault::class)
|
@OptIn(UnstableDefault::class)
|
||||||
fun getReader(galleryID: Int) : Reader {
|
fun getReader(galleryID: Int) : Reader {
|
||||||
val reader = "https://$hiyobi/reader/$galleryID"
|
val data = "https://cdn.$hiyobi/data/json/$galleryID.json"
|
||||||
val url = "https://cdn.hiyobi.me/data/json/${galleryID}_list.json"
|
val list = "https://cdn.$hiyobi/data/json/${galleryID}_list.json"
|
||||||
|
|
||||||
val title = Jsoup.connect(reader).proxy(proxy).get().title()
|
val title = with(URL(data).openConnection(proxy) as HttpsURLConnection) {
|
||||||
|
setRequestProperty("User-Agent", user_agent)
|
||||||
|
setRequestProperty("Cookie", cookie)
|
||||||
|
connectTimeout = 1000
|
||||||
|
connect()
|
||||||
|
|
||||||
|
inputStream.bufferedReader().use { it.readText() }
|
||||||
|
}.let {
|
||||||
|
json.parseJson(it).jsonObject["n"]?.contentOrNull
|
||||||
|
}
|
||||||
|
|
||||||
val galleryFiles = json.parse(
|
val galleryFiles = json.parse(
|
||||||
GalleryFiles.serializer().list,
|
GalleryFiles.serializer().list,
|
||||||
with(URL(url).openConnection(proxy) as HttpsURLConnection) {
|
with(URL(list).openConnection(proxy) as HttpsURLConnection) {
|
||||||
setRequestProperty("User-Agent", user_agent)
|
setRequestProperty("User-Agent", user_agent)
|
||||||
setRequestProperty("Cookie", cookie)
|
setRequestProperty("Cookie", cookie)
|
||||||
connectTimeout = 1000
|
connectTimeout = 1000
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class UnitTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun test_hiyobi() {
|
fun test_hiyobi() {
|
||||||
val reader = xyz.quaver.hiyobi.getReader(1663418)
|
val reader = xyz.quaver.hiyobi.getReader(1664762)
|
||||||
|
|
||||||
print(reader)
|
print(reader)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user