From bb9dc35e48fca5f97314170e009f42e26d2874ad Mon Sep 17 00:00:00 2001 From: Mike <51273546+SnakeDoc83@users.noreply.github.com> Date: Sat, 21 Dec 2019 10:50:06 -0500 Subject: [PATCH] Webcomics: Limit to 20 chapters (#1305) * Webcomics: Limit to 20 chapters * Locked chapter notification --- src/en/webcomics/build.gradle | 2 +- .../extension/en/webcomics/Webcomics.kt | 20 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/en/webcomics/build.gradle b/src/en/webcomics/build.gradle index 36208dd9b..0ffd8b9f2 100644 --- a/src/en/webcomics/build.gradle +++ b/src/en/webcomics/build.gradle @@ -5,7 +5,7 @@ ext { appName = 'Tachiyomi: Webcomics' pkgNameSuffix = 'en.webcomics' extClass = '.Webcomics' - extVersionCode = 1 + extVersionCode = 2 libVersion = '1.2' } diff --git a/src/en/webcomics/src/eu/kanade/tachiyomi/extension/en/webcomics/Webcomics.kt b/src/en/webcomics/src/eu/kanade/tachiyomi/extension/en/webcomics/Webcomics.kt index 2ad19ad8b..1783cd4f6 100644 --- a/src/en/webcomics/src/eu/kanade/tachiyomi/extension/en/webcomics/Webcomics.kt +++ b/src/en/webcomics/src/eu/kanade/tachiyomi/extension/en/webcomics/Webcomics.kt @@ -56,6 +56,9 @@ class Webcomics : ParsedHttpSource() { manga.genre = infoElement.select(".labels > label").joinToString(", ") { it.text() } manga.description = infoElement.select("p.p-description").text() manga.thumbnail_url = infoElement.select("img").first()?.attr("src") + infoElement.select("p.p-schedule:first-of-type").text().let { + if (it.contains("IDK")) manga.status = SManga.COMPLETED else manga.status = SManga.ONGOING + } return manga } @@ -112,7 +115,22 @@ class Webcomics : ParsedHttpSource() { override fun chapterListParse(response: Response): List { val document = response.asJsoup() - return document.select(chapterListSelector()).asReversed().map {chapterFromElement(it)} + + /* Source only allows 20 chapters to be readable on their website, trying to read past + that results in a page list empty error; so might as well not grab them. */ + if (document.select("${chapterListSelector()}:nth-child(21)").isEmpty()) { + return document.select(chapterListSelector()).asReversed().map { chapterFromElement(it) } + } else { + val chapters = mutableListOf() + for (i in 1..20) + document.select("${chapterListSelector()}:nth-child($i)").map { chapters.add(chapterFromElement(it)) } + // Add a chapter notifying the user of the situation + val lockedNotification = SChapter.create() + lockedNotification.name = "[Attention] Additional chapters are restricted by the source to their own app" + lockedNotification.url = "wiki.html" + chapters.add(lockedNotification) + return chapters.reversed() + } } override fun chapterFromElement(element: Element): SChapter {