From 05792a34e98ddd703e3fb1699b48fc0b7d2c04ad Mon Sep 17 00:00:00 2001 From: happywillow0 <45346080+happywillow0@users.noreply.github.com> Date: Sat, 27 Feb 2021 20:45:53 -0500 Subject: [PATCH] Changes Chapter Fetch (#5999) - Use recursive fetching to ensure all pages are processed --- src/en/comicextra/build.gradle | 2 +- .../extension/en/comicextra/ComicExtra.kt | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/en/comicextra/build.gradle b/src/en/comicextra/build.gradle index 7d8963e03..b3708b700 100644 --- a/src/en/comicextra/build.gradle +++ b/src/en/comicextra/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'ComicExtra' pkgNameSuffix = 'en.comicextra' extClass = '.ComicExtra' - extVersionCode = 6 + extVersionCode = 7 libVersion = '1.2' } diff --git a/src/en/comicextra/src/eu/kanade/tachiyomi/extension/en/comicextra/ComicExtra.kt b/src/en/comicextra/src/eu/kanade/tachiyomi/extension/en/comicextra/ComicExtra.kt index 5cb1c0fd7..8ba50afca 100644 --- a/src/en/comicextra/src/eu/kanade/tachiyomi/extension/en/comicextra/ComicExtra.kt +++ b/src/en/comicextra/src/eu/kanade/tachiyomi/extension/en/comicextra/ComicExtra.kt @@ -71,7 +71,7 @@ class ComicExtra : ParsedHttpSource() { private fun fetchThumbnailURL(url: String) = client.newCall(GET(url, headers)).execute().asJsoup().select("div.movie-l-img > img").attr("src") - private fun fetchChaptersFromNav(url: String) = client.newCall(GET(url, headers)).execute().asJsoup().select(chapterListSelector()) + private fun fetchPagesFromNav(url: String) = client.newCall(GET(url, headers)).execute().asJsoup() override fun popularMangaNextPageSelector() = "div.general-nav > a:contains(Next)" @@ -114,16 +114,21 @@ class ComicExtra : ParsedHttpSource() { return chapters } - val links = nav.getElementsByTag("a") + val pg2url = nav.select("a:contains(next)").attr("href") - links.forEach { - if (it.text() != "Next") { - fetchChaptersFromNav(it.attr("href")).forEach { page -> - chapters.add(chapterFromElement(page)) - } + // recursively build the chapter list + + fun parseChapters(nextURL: String) { + val newpage = fetchPagesFromNav(nextURL) + newpage.select(chapterListSelector()).forEach { + chapters.add(chapterFromElement(it)) } + val newURL = newpage.select(".general-nav a:contains(next)")?.attr("href") + if (!newURL.isNullOrBlank()) parseChapters(newURL) } + parseChapters(pg2url) + return chapters }