Webcomics: Limit to 20 chapters (#1305)

* Webcomics: Limit to 20 chapters

* Locked chapter notification
This commit is contained in:
Mike 2019-12-21 10:50:06 -05:00 committed by arkon
parent f399772ecb
commit bb9dc35e48
2 changed files with 20 additions and 2 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: Webcomics' appName = 'Tachiyomi: Webcomics'
pkgNameSuffix = 'en.webcomics' pkgNameSuffix = 'en.webcomics'
extClass = '.Webcomics' extClass = '.Webcomics'
extVersionCode = 1 extVersionCode = 2
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -56,6 +56,9 @@ class Webcomics : ParsedHttpSource() {
manga.genre = infoElement.select(".labels > label").joinToString(", ") { it.text() } manga.genre = infoElement.select(".labels > label").joinToString(", ") { it.text() }
manga.description = infoElement.select("p.p-description").text() manga.description = infoElement.select("p.p-description").text()
manga.thumbnail_url = infoElement.select("img").first()?.attr("src") 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 return manga
} }
@ -112,7 +115,22 @@ class Webcomics : ParsedHttpSource() {
override fun chapterListParse(response: Response): List<SChapter> { override fun chapterListParse(response: Response): List<SChapter> {
val document = response.asJsoup() 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<SChapter>()
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 { override fun chapterFromElement(element: Element): SChapter {