Fix Hitomi chapters (#75)
This commit is contained in:
parent
2bc845b1d2
commit
1211b2c86a
@ -372,7 +372,6 @@ class Hitomi(val context: Context) : HttpSource(), LewdSource<HitomiSearchMetada
|
||||
* @param response the response from the site.
|
||||
*/
|
||||
override fun pageListParse(response: Response): List<Page> {
|
||||
val hlId = response.request.url.pathSegments.last().removeSuffix(".js").toLong()
|
||||
val str = response.body!!.string()
|
||||
val json = JsonParser.parseString(str.removePrefix("var galleryinfo = "))
|
||||
return json["files"].array.mapIndexed { index, jsonElement ->
|
||||
@ -384,13 +383,24 @@ class Hitomi(val context: Context) : HttpSource(), LewdSource<HitomiSearchMetada
|
||||
Page(
|
||||
index,
|
||||
"",
|
||||
"https://${subdomainFromGalleryId(hlId)}a.hitomi.la/$path/$hashPath1/$hashPath2/$hash.$ext"
|
||||
"https://${subdomainFromGalleryId(hashPath2)}a.hitomi.la/$path/$hashPath1/$hashPath2/$hash.$ext"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun subdomainFromGalleryId(id: Long): Char {
|
||||
return (97 + id.rem(NUMBER_OF_FRONTENDS)).toChar()
|
||||
// https://ltn.hitomi.la/common.js
|
||||
private fun subdomainFromGalleryId(pathSegment: String): Char {
|
||||
var numberOfFrontends = 3
|
||||
val b = 16
|
||||
var g = Integer.parseInt(pathSegment, b)
|
||||
if (g < 0x30) {
|
||||
numberOfFrontends = 2
|
||||
}
|
||||
if (g < 0x09) {
|
||||
g = 1
|
||||
}
|
||||
|
||||
return (97 + g.rem(numberOfFrontends)).toChar()
|
||||
}
|
||||
|
||||
/**
|
||||
@ -431,7 +441,6 @@ class Hitomi(val context: Context) : HttpSource(), LewdSource<HitomiSearchMetada
|
||||
companion object {
|
||||
private val INDEX_VERSION_CACHE_TIME_MS = 1000 * 60 * 10
|
||||
private val PAGE_SIZE = 25
|
||||
private val NUMBER_OF_FRONTENDS = 2
|
||||
|
||||
private val DATE_FORMAT by lazy {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user