DeviantArt: Order chapter list chronologically instead of by source (#8407)

Order chapter list chronologically instead of by source
This commit is contained in:
DokterKaj 2025-04-09 22:50:01 +08:00 committed by Draff
parent ac48b271c1
commit eb9b9b9aee
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 12 additions and 15 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'DeviantArt' extName = 'DeviantArt'
extClass = '.DeviantArt' extClass = '.DeviantArt'
extVersionCode = 7 extVersionCode = 8
isNsfw = true isNsfw = true
} }

View File

@ -134,12 +134,11 @@ class DeviantArt : HttpSource(), ConfigurableSource {
nextUrl = newDocument.selectFirst("[rel=next]")?.absUrl("href") nextUrl = newDocument.selectFirst("[rel=next]")?.absUrl("href")
} }
return chapterList.toList().also(::indexChapterList) return chapterList.also(::orderChapterList).toList()
} }
private fun parseToChapterList(document: Document): List<SChapter> { private fun parseToChapterList(document: Document): List<SChapter> {
val items = document.select("item") return document.select("item").map {
return items.map {
SChapter.create().apply { SChapter.create().apply {
setUrlWithoutDomain(it.selectFirst("link")!!.text()) setUrlWithoutDomain(it.selectFirst("link")!!.text())
name = it.selectFirst("title")!!.text() name = it.selectFirst("title")!!.text()
@ -149,17 +148,15 @@ class DeviantArt : HttpSource(), ConfigurableSource {
} }
} }
private fun indexChapterList(chapterList: List<SChapter>) { private fun orderChapterList(chapterList: MutableList<SChapter>) {
// DeviantArt allows users to arrange galleries arbitrarily so we will // In Mihon's updates tab, chapters are ordered by source instead
// primitively index the list by checking the first and last dates // of chapter number, so to avoid updates being shown in reverse,
if (chapterList.first().date_upload > chapterList.last().date_upload) { // disregard source order and order chronologically instead
chapterList.forEachIndexed { i, chapter -> if (chapterList.first().date_upload < chapterList.last().date_upload) {
chapter.chapter_number = chapterList.size - i.toFloat() chapterList.reverse()
} }
} else { chapterList.forEachIndexed { i, chapter ->
chapterList.forEachIndexed { i, chapter -> chapter.chapter_number = chapterList.size - i.toFloat()
chapter.chapter_number = i.toFloat() + 1
}
} }
} }