Load all chapters for Dynasty Doujins (#139)
* Added next page to all Copied implementation from `Chapters` to all other extensions. New pages load when scrolling now * Update DynastyDoujins.kt Circumvent `IndexOutOfBoundsException` when section has no chapters * Update build.gradle * Moved functionality to base class * Update DynastyDoujins.kt Lazy implementation to load all chapters for `Dynasty Doujins` * Update build.gradle * Update src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyDoujins.kt Co-authored-by: stevenyomi <95685115+stevenyomi@users.noreply.github.com> * Fix exceeding max retry behavior * Remove retry logic * Update DynastyDoujins.kt --------- Co-authored-by: stevenyomi <95685115+stevenyomi@users.noreply.github.com>
This commit is contained in:
parent
e6dba52ab9
commit
3045c7be96
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'Dynasty'
|
extName = 'Dynasty'
|
||||||
pkgNameSuffix = 'en.dynasty'
|
pkgNameSuffix = 'en.dynasty'
|
||||||
extClass = '.DynastyFactory'
|
extClass = '.DynastyFactory'
|
||||||
extVersionCode = 22
|
extVersionCode = 23
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -49,10 +49,18 @@ class DynastyDoujins : DynastyScans() {
|
||||||
|
|
||||||
override fun chapterListSelector() = "div#main > dl.chapter-list > dd"
|
override fun chapterListSelector() = "div#main > dl.chapter-list > dd"
|
||||||
|
|
||||||
|
private fun doujinChapterParse(document: Document): List<SChapter> {
|
||||||
|
return try {
|
||||||
|
document.select(chapterListSelector()).map { chapterFromElement(it) }
|
||||||
|
} catch (e: IndexOutOfBoundsException) {
|
||||||
|
emptyList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun chapterListParse(response: Response): List<SChapter> {
|
override fun chapterListParse(response: Response): List<SChapter> {
|
||||||
val document = response.asJsoup()
|
val document = response.asJsoup()
|
||||||
|
val chapters = mutableListOf<SChapter>()
|
||||||
val chapters = try { document.select(chapterListSelector()).map { chapterFromElement(it) }.toMutableList() } catch (e: IndexOutOfBoundsException) { mutableListOf() }
|
var page = 1
|
||||||
|
|
||||||
document.select("a.thumbnail img").let { images ->
|
document.select("a.thumbnail img").let { images ->
|
||||||
if (images.isNotEmpty()) {
|
if (images.isNotEmpty()) {
|
||||||
|
@ -64,7 +72,34 @@ class DynastyDoujins : DynastyScans() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
chapters.addAll(doujinChapterParse(document))
|
||||||
|
|
||||||
|
var hasNextPage = popularMangaNextPageSelector().let { selector ->
|
||||||
|
document.select(selector).first()
|
||||||
|
} != null
|
||||||
|
|
||||||
|
while (hasNextPage) {
|
||||||
|
page += 1
|
||||||
|
val doujinURL = document.location() + "?page=$page"
|
||||||
|
|
||||||
|
val newRequest = GET(doujinURL, headers)
|
||||||
|
val newResponse = client.newCall(newRequest).execute()
|
||||||
|
|
||||||
|
if (!newResponse.isSuccessful) {
|
||||||
|
/*
|
||||||
|
TODO: Toast to notify chapter parsing aborted.
|
||||||
|
Add possible retry logic.
|
||||||
|
*/
|
||||||
|
return chapters
|
||||||
|
}
|
||||||
|
|
||||||
|
val newDocument = newResponse.asJsoup()
|
||||||
|
chapters.addAll(doujinChapterParse(newDocument))
|
||||||
|
|
||||||
|
hasNextPage = popularMangaNextPageSelector().let { selector ->
|
||||||
|
newDocument.select(selector).first()
|
||||||
|
} != null
|
||||||
|
}
|
||||||
return chapters
|
return chapters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue