From 422e95944aee5dfaedbf654acdba92e907a92602 Mon Sep 17 00:00:00 2001 From: bapeey <90949336+bapeey@users.noreply.github.com> Date: Sun, 24 Dec 2023 18:49:04 -0500 Subject: [PATCH] NovelCool: Fix pages not found (#19404) * Fix pages not found * Unnecessary toString() * Rename val --- src/all/novelcool/build.gradle | 2 +- .../extension/all/novelcool/NovelCool.kt | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/all/novelcool/build.gradle b/src/all/novelcool/build.gradle index 92f2e091e..fa6b8d647 100644 --- a/src/all/novelcool/build.gradle +++ b/src/all/novelcool/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'NovelCool' pkgNameSuffix = 'all.novelcool' extClass = '.NovelCoolFactory' - extVersionCode = 2 + extVersionCode = 3 isNsfw = true } diff --git a/src/all/novelcool/src/eu/kanade/tachiyomi/extension/all/novelcool/NovelCool.kt b/src/all/novelcool/src/eu/kanade/tachiyomi/extension/all/novelcool/NovelCool.kt index 5ae003886..f15eac962 100644 --- a/src/all/novelcool/src/eu/kanade/tachiyomi/extension/all/novelcool/NovelCool.kt +++ b/src/all/novelcool/src/eu/kanade/tachiyomi/extension/all/novelcool/NovelCool.kt @@ -313,11 +313,21 @@ open class NovelCool( } override fun pageListParse(document: Document): List { - 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>("[$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()