NovelCool: Fix pages not found (#19404)

* Fix pages not found

* Unnecessary toString()

* Rename val
This commit is contained in:
bapeey 2023-12-24 18:49:04 -05:00 committed by GitHub
parent 331e845116
commit 422e95944a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'NovelCool'
pkgNameSuffix = 'all.novelcool'
extClass = '.NovelCoolFactory'
extVersionCode = 2
extVersionCode = 3
isNsfw = true
}

View File

@ -313,11 +313,21 @@ open class NovelCool(
}
override fun pageListParse(document: Document): List<Page> {
val script = document.select("script:containsData(all_imgs_url)").html()
var doc = document
val serverUrl = doc.selectFirst("section.section div.post-content-body > a")?.attr("href")
if (serverUrl != null) {
val serverHeaders = headers.newBuilder()
.set("Referer", doc.baseUri())
.build()
doc = pageClient.newCall(GET(serverUrl, serverHeaders)).execute().asJsoup()
}
val script = doc.select("script:containsData(all_imgs_url)").html()
val images = imgRegex.find(script)?.groupValues?.get(1)
?.let { json.decodeFromString<List<String>>("[$it]") }
?: return singlePageParse(document)
?: return singlePageParse(doc)
return images.mapIndexed { idx, img ->
Page(idx, "", img)
@ -356,7 +366,10 @@ open class NovelCool(
private fun jsRedirect(chain: Interceptor.Chain): Response {
val request = chain.request()
val response = chain.proceed(request)
val headers = request.headers.newBuilder()
.removeAll("Accept-Encoding")
.build()
val response = chain.proceed(request.newBuilder().headers(headers).build())
val document = Jsoup.parse(response.peekBody(Long.MAX_VALUE).string())
val jsRedirect = document.selectFirst("script:containsData(window.location.href)")?.html()