From 1b1bd56c953442971d69448d101504c5ff7159a1 Mon Sep 17 00:00:00 2001 From: Mike <51273546+SnakeDoc83@users.noreply.github.com> Date: Sat, 13 Jun 2020 23:56:21 -0400 Subject: [PATCH] WP Comics - fix xoxocomics chapters (#3528) --- src/all/wpcomics/build.gradle | 2 +- .../extension/all/wpcomics/WPComicsFactory.kt | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/all/wpcomics/build.gradle b/src/all/wpcomics/build.gradle index fffd0f21b..4bd8fef8c 100644 --- a/src/all/wpcomics/build.gradle +++ b/src/all/wpcomics/build.gradle @@ -5,7 +5,7 @@ ext { appName = 'Tachiyomi: WP-Comics' pkgNameSuffix = 'all.wpcomics' extClass = '.WPComicsFactory' - extVersionCode = 7 + extVersionCode = 8 libVersion = '1.2' } diff --git a/src/all/wpcomics/src/eu/kanade/tachiyomi/extension/all/wpcomics/WPComicsFactory.kt b/src/all/wpcomics/src/eu/kanade/tachiyomi/extension/all/wpcomics/WPComicsFactory.kt index 3d127e640..87367dc33 100644 --- a/src/all/wpcomics/src/eu/kanade/tachiyomi/extension/all/wpcomics/WPComicsFactory.kt +++ b/src/all/wpcomics/src/eu/kanade/tachiyomi/extension/all/wpcomics/WPComicsFactory.kt @@ -8,10 +8,13 @@ import eu.kanade.tachiyomi.source.model.FilterList 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.util.asJsoup import java.text.SimpleDateFormat import java.util.Locale import okhttp3.HttpUrl import okhttp3.Request +import okhttp3.Response +import org.jsoup.nodes.Document import org.jsoup.nodes.Element class WPComicsFactory : SourceFactory { @@ -64,6 +67,21 @@ private class XoxoComics : WPComics("XOXO Comics", "https://xoxocomics.com", "en override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { return GET("$baseUrl/search?keyword=$query&page=$page", headers) } + + override fun chapterListParse(response: Response): List { + val chapters = mutableListOf() + + // recursively add chapters from paginated chapter list + fun parseChapters(document: Document) { + document.select(chapterListSelector()).map { chapters.add(chapterFromElement(it)) } + document.select("ul.pagination a[rel=next]").firstOrNull()?.let { a -> + parseChapters(client.newCall(GET(a.attr("abs:href"), headers)).execute().asJsoup()) + } + } + + parseChapters(response.asJsoup()) + return chapters + } override fun pageListRequest(chapter: SChapter): Request = GET(baseUrl + "${chapter.url}/all") }