fix(en/cloudrecess): Fix chapter list on entries with 100+ chapters (#19442)

* fix: Fix chapter list on entries with 100+ chapters

* chore: Bump version
This commit is contained in:
Claudemirovsky 2023-12-28 13:16:07 -03:00 committed by GitHub
parent 4763371472
commit cab16d3f2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'CloudRecess'
pkgNameSuffix = 'en.cloudrecess'
extClass = '.CloudRecess'
extVersionCode = 1
extVersionCode = 2
isNsfw = true
}

View File

@ -128,6 +128,27 @@ class CloudRecess : ParsedHttpSource() {
// ============================== Chapters ==============================
override fun chapterListSelector() = "div#chapters-list > a[href]"
override fun chapterListParse(response: Response): List<SChapter> {
val originalUrl = response.request.url.toString()
val chapterList = buildList {
var page = 1
do {
val doc = when {
isEmpty() -> response // First page
else -> {
page++
client.newCall(GET("$originalUrl?page=$page", headers)).execute()
}
}.use { it.asJsoup() }
addAll(doc.select(chapterListSelector()).map(::chapterFromElement))
} while (doc.selectFirst(latestUpdatesNextPageSelector()) != null)
}
return chapterList
}
override fun chapterFromElement(element: Element) = SChapter.create().apply {
setUrlWithoutDomain(element.attr("href"))
name = element.selectFirst("span")?.ownText() ?: "Chapter"