Update firstSubdomainFromGalleryId in hitomi.la (#8092)

Updated with latest logic from ltn.hitomi.la/common.js
This commit is contained in:
Charles Lee 2021-07-13 23:27:17 +10:00 committed by GitHub
parent 25d955d116
commit f098832504
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 12 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Hitomi.la'
pkgNameSuffix = 'all.hitomi'
extClass = '.HitomiFactory'
extVersionCode = 8
extVersionCode = 9
libVersion = '1.2'
containsNsfw = true
}

View File

@ -365,19 +365,13 @@ open class Hitomi(override val lang: String, private val nozomiLang: String) : H
// https://ltn.hitomi.la/common.js
// function subdomain_from_url()
// Change g's if statment from !isNaN(g)
// Change g's if statement from !isNaN(g)
private fun firstSubdomainFromGalleryId(pathSegment: String): Char {
val source = getScrambler()
var numberOfFrontends = 3
var o = 0
var g = pathSegment.toInt(16)
if (g < source[0]) numberOfFrontends = 2
if (g < source[1]) g = 1
return (97 + g.rem(numberOfFrontends)).toChar()
}
private fun getScrambler(): List<Int> {
val response = client.newCall(GET("$LTN_BASE_URL/common.js")).execute()
return HEXADECIMAL.findAll(response.body!!.string()).map { Integer.decode(it.value) }.toList()
if (g < 0x80) o = 1
if (g < 0x40) o = 2
return (97 + o).toChar()
}
override fun imageRequest(page: Page): Request {