fix manga group order and update time mismatch (#9213)
This commit is contained in:
parent
a03a505b78
commit
e57d8438fa
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'CopyManga'
|
extName = 'CopyManga'
|
||||||
pkgNameSuffix = 'zh.copymanga'
|
pkgNameSuffix = 'zh.copymanga'
|
||||||
extClass = '.CopyManga'
|
extClass = '.CopyManga'
|
||||||
extVersionCode = 17
|
extVersionCode = 18
|
||||||
}
|
}
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
||||||
|
|
|
@ -203,32 +203,24 @@ class CopyManga : ConfigurableSource, HttpSource() {
|
||||||
|
|
||||||
val retChapter = ArrayList<SChapter>()
|
val retChapter = ArrayList<SChapter>()
|
||||||
// Get chapters according to groups
|
// Get chapters according to groups
|
||||||
chapterGroups.keys().forEach { groupName ->
|
val keys = chapterGroups.keys().asSequence().toList()
|
||||||
|
keys.filter { it -> it == "default" }.forEach { groupName ->
|
||||||
run {
|
run {
|
||||||
val chapterGroup = chapterGroups.getJSONObject(groupName)
|
val chapterGroup = chapterGroups.getJSONObject(groupName)
|
||||||
|
fillChapters(chapterGroup, retChapter, comicPathWord)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// group's last update time
|
val otherChapters = ArrayList<SChapter>()
|
||||||
val groupLastUpdateTime =
|
keys.filter { it -> it != "default" }.forEach { groupName ->
|
||||||
chapterGroup.optJSONObject("last_chapter")?.optString("datetime_created")
|
run {
|
||||||
|
val chapterGroup = chapterGroups.getJSONObject(groupName)
|
||||||
// chapters in the group to
|
fillChapters(chapterGroup, otherChapters, comicPathWord)
|
||||||
val chapterArray = chapterGroup.optJSONArray("chapters")
|
|
||||||
if (chapterArray != null) {
|
|
||||||
for (i in 0 until chapterArray.length()) {
|
|
||||||
val chapter = chapterArray.getJSONObject(i)
|
|
||||||
retChapter.add(
|
|
||||||
SChapter.create().apply {
|
|
||||||
name = chapter.getString("name")
|
|
||||||
date_upload = stringToUnixTimestamp(groupLastUpdateTime)
|
|
||||||
url = "/comic/$comicPathWord/chapter/${chapter.getString("id")}"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// place others to top, as other group updates not so often
|
// place others to top, as other group updates not so often
|
||||||
|
retChapter.addAll(0, otherChapters)
|
||||||
return retChapter.asReversed()
|
return retChapter.asReversed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,6 +414,27 @@ class CopyManga : ConfigurableSource, HttpSource() {
|
||||||
return manga
|
return manga
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun fillChapters(chapterGroup: JSONObject, retChapter: ArrayList<SChapter>, comicPathWord: String?) {
|
||||||
|
// group's last update time
|
||||||
|
val groupLastUpdateTime =
|
||||||
|
chapterGroup.optJSONObject("last_chapter")?.optString("datetime_created")
|
||||||
|
|
||||||
|
// chapters in the group to
|
||||||
|
val chapterArray = chapterGroup.optJSONArray("chapters")
|
||||||
|
if (chapterArray != null) {
|
||||||
|
for (i in 0 until chapterArray.length()) {
|
||||||
|
val chapter = chapterArray.getJSONObject(i)
|
||||||
|
retChapter.add(
|
||||||
|
SChapter.create().apply {
|
||||||
|
name = chapter.getString("name")
|
||||||
|
url = "/comic/$comicPathWord/chapter/${chapter.getString("id")}"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
retChapter.lastOrNull()?.date_upload = stringToUnixTimestamp(groupLastUpdateTime)
|
||||||
|
}
|
||||||
|
|
||||||
private fun byteArrayToHexString(byteArray: ByteArray): String {
|
private fun byteArrayToHexString(byteArray: ByteArray): String {
|
||||||
var sb = ""
|
var sb = ""
|
||||||
for (b in byteArray) {
|
for (b in byteArray) {
|
||||||
|
|
Loading…
Reference in New Issue