fix nhentai cdn script selection (#9857)
* fix nhentai cdn script selection * apply suggestions
This commit is contained in:
parent
e18a2f732c
commit
a8fad4b5c2
@ -1,7 +1,7 @@
|
|||||||
ext {
|
ext {
|
||||||
extName = 'NHentai'
|
extName = 'NHentai'
|
||||||
extClass = '.NHFactory'
|
extClass = '.NHFactory'
|
||||||
extVersionCode = 51
|
extVersionCode = 52
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,18 +255,20 @@ open class NHentai(
|
|||||||
|
|
||||||
override fun chapterListSelector() = throw UnsupportedOperationException()
|
override fun chapterListSelector() = throw UnsupportedOperationException()
|
||||||
|
|
||||||
override fun pageListParse(document: Document): List<Page> {
|
override fun pageListParse(document: Document) = throw UnsupportedOperationException()
|
||||||
val script = document.selectFirst("script:containsData(media_server)")!!.data()
|
|
||||||
val script2 = document.selectFirst(hentaiSelector)!!.data()
|
|
||||||
|
|
||||||
val mediaServer = Regex("""media_server\s*:\s*(\d+)""").find(script)?.groupValues!![1]
|
override fun pageListParse(response: Response): List<Page> {
|
||||||
val json = dataRegex.find(script2)?.groupValues!![1]
|
val html = response.body.string()
|
||||||
|
|
||||||
|
val json = dataRegex.find(html)?.groupValues!![1]
|
||||||
val data = json.parseAs<Hentai>()
|
val data = json.parseAs<Hentai>()
|
||||||
|
val cdnJson = Regex("""image_cdn_urls:\s*(\[.*])""").find(html)?.groupValues!![1]
|
||||||
|
val cdnList = cdnJson.parseAs<List<String>>()
|
||||||
|
|
||||||
return data.images.pages.mapIndexed { i, image ->
|
return data.images.pages.mapIndexed { i, image ->
|
||||||
Page(
|
Page(
|
||||||
i,
|
i,
|
||||||
imageUrl = "${baseUrl.replace("https://", "https://i$mediaServer.")}/galleries/${data.media_id}/${i + 1}" +
|
imageUrl = "https://${cdnList.random()}/galleries/${data.media_id}/${i + 1}" +
|
||||||
when (image.t) {
|
when (image.t) {
|
||||||
"w" -> ".webp"
|
"w" -> ".webp"
|
||||||
"p" -> ".png"
|
"p" -> ".png"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user