Happymh: Do not show images from next chapter (#11863)

This commit is contained in:
anenasa 2022-05-17 02:52:34 +08:00 committed by GitHub
parent 1e922cfdcc
commit f9560eff2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Happymh' extName = 'Happymh'
pkgNameSuffix = 'zh.happymh' pkgNameSuffix = 'zh.happymh'
extClass = '.Happymh' extClass = '.Happymh'
extVersionCode = 1 extVersionCode = 2
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.util.asJsoup import eu.kanade.tachiyomi.util.asJsoup
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import kotlinx.serialization.json.boolean import kotlinx.serialization.json.boolean
import kotlinx.serialization.json.int
import kotlinx.serialization.json.jsonArray import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive import kotlinx.serialization.json.jsonPrimitive
@ -107,10 +108,14 @@ class Happymh : HttpSource() {
return GET(baseUrl + chapter.url, header) return GET(baseUrl + chapter.url, header)
} }
override fun pageListParse(response: Response): List<Page> = mutableListOf<Page>().apply { override fun pageListParse(response: Response): List<Page> {
json.parseToJsonElement(response.body!!.string()).jsonObject["data"]!!.jsonObject["scans"]!!.jsonArray.mapIndexed() { index, it -> return json.parseToJsonElement(response.body!!.string())
add(Page(index, "", it.jsonObject["url"]!!.jsonPrimitive.content)) .jsonObject["data"]!!.jsonObject["scans"]!!.jsonArray
} // If n == 1, the image is from next chapter
.filter { it.jsonObject["n"]!!.jsonPrimitive.int == 0 }
.mapIndexed { index, it ->
Page(index, "", it.jsonObject["url"]!!.jsonPrimitive.content)
}
} }
override fun imageUrlParse(response: Response): String = throw Exception("Not Used") override fun imageUrlParse(response: Response): String = throw Exception("Not Used")