hitomi speed fix (#10290)

This commit is contained in:
Basara-Hatake 2021-12-31 18:13:39 +01:00 committed by GitHub
parent b2bbc6a803
commit b1d92188ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 22 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Hitomi.la'
pkgNameSuffix = 'all.hitomi'
extClass = '.HitomiFactory'
extVersionCode = 14
extVersionCode = 15
isNsfw = true
}

View File

@ -351,9 +351,16 @@ open class Hitomi(override val lang: String, private val nozomiLang: String) : H
}
override fun pageListParse(response: Response): List<Page> {
if (gg.isNullOrEmpty()) {
val response = client.newCall(GET("$LTN_BASE_URL/gg.js")).execute()
gg = response.body!!.string()
}
val duktape = Duktape.create()
duktape.evaluate(gg)
val str = response.body!!.string()
val json = json.decodeFromString<HitomiChapterDto>(str.removePrefix("var galleryinfo = "))
return json.files.mapIndexed { i, jsonElement ->
val pages = json.files.mapIndexed { i, jsonElement ->
// https://ltn.hitomi.la/reader.js
// function make_image_element()
val hash = jsonElement.hash
@ -371,28 +378,19 @@ open class Hitomi(override val lang: String, private val nozomiLang: String) : H
secondSubdomain = "a"
}
Page(i, "", buildImageUrl(path, hash, ext, secondSubdomain))
}
}
val b = duktape.evaluate("gg.b;") as String
val s = duktape.evaluate("gg.s(\"$hash\");") as String
val m = duktape.evaluate("gg.m($s).toString();") as String
private fun buildImageUrl(path: String, hash: String, ext: String, secondSubdomain: String): String {
if (gg.isNullOrEmpty()) {
val response = client.newCall(GET("$LTN_BASE_URL/gg.js")).execute()
gg = response.body!!.string()
}
var firstSubdomain = "a"
if (m == "1") {
firstSubdomain = "b"
}
val duktape = Duktape.create()
val b = duktape.evaluate(gg + """gg.b;""") as String
val s = duktape.evaluate(gg + """gg.s("""" + hash + """");""") as String
val m = duktape.evaluate(gg + """gg.m(""" + s + """).toString();""") as String
Page(i, "", "https://$firstSubdomain$secondSubdomain.hitomi.la/$path/$b$s/$hash.$ext")
}
duktape.close()
var firstSubdomain = "a"
if (m == "1") {
firstSubdomain = "b"
}
return "https://$firstSubdomain$secondSubdomain.hitomi.la/$path/$b$s/$hash.$ext"
return pages
}
override fun imageRequest(page: Page): Request {