From fa085065ea2236e16c6ffbdc27059f991488f4d1 Mon Sep 17 00:00:00 2001 From: Renzo Martin Poggio <63516530+Renzo904@users.noreply.github.com> Date: Thu, 5 Oct 2023 16:50:17 -0300 Subject: [PATCH] NineAnime: fix chapter pages (#18376) * NineAnime: fix chapter pages Closes #13315 * NineAnime: fix WebView of chapter * NineAnime: Calls moved to pageListParse --- src/en/nineanime/build.gradle | 2 +- .../extension/en/nineanime/NineAnime.kt | 22 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/en/nineanime/build.gradle b/src/en/nineanime/build.gradle index 608f1014a..94bcbe45c 100644 --- a/src/en/nineanime/build.gradle +++ b/src/en/nineanime/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'NineAnime' pkgNameSuffix = 'en.nineanime' extClass = '.NineAnime' - extVersionCode = 3 + extVersionCode = 4 } apply from: "$rootDir/common.gradle" diff --git a/src/en/nineanime/src/eu/kanade/tachiyomi/extension/en/nineanime/NineAnime.kt b/src/en/nineanime/src/eu/kanade/tachiyomi/extension/en/nineanime/NineAnime.kt index a9e6e89da..ba431b0a3 100644 --- a/src/en/nineanime/src/eu/kanade/tachiyomi/extension/en/nineanime/NineAnime.kt +++ b/src/en/nineanime/src/eu/kanade/tachiyomi/extension/en/nineanime/NineAnime.kt @@ -7,6 +7,7 @@ import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.ParsedHttpSource +import eu.kanade.tachiyomi.util.asJsoup import okhttp3.Headers import okhttp3.OkHttpClient import okhttp3.Request @@ -31,6 +32,10 @@ class NineAnime : ParsedHttpSource() { .followRedirects(true) .build() + companion object { + private const val PAGES_URL = "https://www.glanceoflife.com" + } + // not necessary for normal usage but added in an attempt to fix usage with VPN (see #3476) override fun headersBuilder(): Headers.Builder = Headers.Builder() .add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) Gecko/20100101 Firefox/77") @@ -118,6 +123,10 @@ class NineAnime : ParsedHttpSource() { return GET(baseUrl + "${manga.url}?waring=1", headers) } + override fun getChapterUrl(chapter: SChapter): String { + return baseUrl + chapter.url + } + override fun chapterListSelector() = "ul.detail-chlist li" override fun chapterFromElement(element: Element): SChapter { @@ -151,12 +160,21 @@ class NineAnime : ParsedHttpSource() { // Pages override fun pageListRequest(chapter: SChapter): Request { + val id: String = chapter.url.substring(chapter.url.lastIndexOf("/", chapter.url.length - 2)) + val pageListHeaders = headersBuilder().add("Referer", "$baseUrl/manga/").build() - return GET(baseUrl + chapter.url, pageListHeaders) + return GET("$PAGES_URL/c/nineanime$id", pageListHeaders) } override fun pageListParse(document: Document): List { - val script = document.select("script:containsData(all_imgs_url)").firstOrNull()?.data() + val pageListHeaders = headersBuilder().add("Referer", "$baseUrl/manga/").build() + + val scripturl = document.select("script").firstOrNull()?.data() + + val link = scripturl?.split("\"")?.get(1) + val pages = client.newCall(GET(PAGES_URL + link, pageListHeaders)).execute().asJsoup() + + val script = pages.select("script:containsData(all_imgs_url)").firstOrNull()?.data() ?: throw Exception("all_imgsurl not found") return Regex(""""(http.*)",""").findAll(script).mapIndexed { i, mr -> Page(i, "", mr.groupValues[1])