Fixed GMANGA page sort (#18673)
* Update .gitignore * Fixed Gmanga page sorting * Formatting
This commit is contained in:
parent
fc7598bdcf
commit
280583f53f
|
@ -6,7 +6,7 @@ ext {
|
|||
extName = 'GMANGA'
|
||||
pkgNameSuffix = 'ar.gmanga'
|
||||
extClass = '.Gmanga'
|
||||
extVersionCode = 12
|
||||
extVersionCode = 13
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
||||
|
|
|
@ -248,6 +248,7 @@ class Gmanga : ConfigurableSource, HttpSource() {
|
|||
|
||||
val hasWebP = releaseData["webp_pages"]!!.jsonArray.size > 0
|
||||
return releaseData[if (hasWebP) "webp_pages" else "pages"]!!.jsonArray.map { it.jsonPrimitive.content }
|
||||
.sortedWith(pageSort)
|
||||
.mapIndexed { index, pageUri ->
|
||||
Page(
|
||||
index,
|
||||
|
@ -257,6 +258,12 @@ class Gmanga : ConfigurableSource, HttpSource() {
|
|||
}
|
||||
}
|
||||
|
||||
private val pageSort =
|
||||
compareBy<String>({ parseNumber(0, it) ?: Double.MAX_VALUE }, { parseNumber(1, it) }, { parseNumber(2, it) })
|
||||
|
||||
private fun parseNumber(index: Int, string: String): Double? =
|
||||
Regex("\\d+").findAll(string).map { it.value }.toList().getOrNull(index)?.toDoubleOrNull()
|
||||
|
||||
override fun popularMangaParse(response: Response) = searchMangaParse(response)
|
||||
|
||||
override fun popularMangaRequest(page: Int) = searchMangaRequest(page, "", getFilterList())
|
||||
|
|
Loading…
Reference in New Issue