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 {
extName = 'DeviantArt'
extClass = '.DeviantArt'
extVersionCode = 7
extVersionCode = 8
isNsfw = true
}

View File

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