Fix order of chapters/volumes in manhuagui. (#19503)

* Groups chapters/volumes and special chapters together into blocks
This commit is contained in:
Thomas Meng 2024-01-01 01:18:19 +10:00 committed by GitHub
parent 828c6f7b46
commit 3a213c1ca8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 12 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'ManHuaGui'
pkgNameSuffix = 'zh.manhuagui'
extClass = '.Manhuagui'
extVersionCode = 17
extVersionCode = 18
}
apply from: "$rootDir/common.gradle"

View File

@ -312,9 +312,16 @@ class Manhuagui(
error("您需要打开R18作品显示开关并重启软件才能阅读此作品")
}
}
val chapterList = document.select("ul > li > a.status0")
val latestChapterHref = document.select("div.book-detail > ul.detail-list > li.status > span > a.blue").first()?.attr("href")
val chNumRegex = Regex("""\d+""")
val sectionList = document.select("[id^=chapter-list-]")
sectionList.forEach { section ->
val pageList = section.select("ul")
pageList.reverse()
pageList.forEach { page ->
val pageChapters = mutableListOf<SChapter>()
val chapterList = page.select("li > a.status0")
chapterList.forEach {
val currentChapter = SChapter.create()
currentChapter.url = it.attr("href")
@ -325,10 +332,14 @@ class Manhuagui(
if (currentChapter.url == latestChapterHref) {
currentChapter.date_upload = parseDate(document.select("div.book-detail > ul.detail-list > li.status > span > span.red").last()!!)
}
chapters.add(currentChapter)
pageChapters.add(currentChapter)
}
return chapters.sortedByDescending { it.chapter_number }
chapters.addAll(pageChapters)
}
}
return chapters
}
private fun parseDate(element: Element): Long = SimpleDateFormat("yyyy-MM-dd", Locale.CHINA).parse(element.text())?.time ?: 0