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'
|
extName = 'GMANGA'
|
||||||
pkgNameSuffix = 'ar.gmanga'
|
pkgNameSuffix = 'ar.gmanga'
|
||||||
extClass = '.Gmanga'
|
extClass = '.Gmanga'
|
||||||
extVersionCode = 12
|
extVersionCode = 13
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -248,6 +248,7 @@ class Gmanga : ConfigurableSource, HttpSource() {
|
||||||
|
|
||||||
val hasWebP = releaseData["webp_pages"]!!.jsonArray.size > 0
|
val hasWebP = releaseData["webp_pages"]!!.jsonArray.size > 0
|
||||||
return releaseData[if (hasWebP) "webp_pages" else "pages"]!!.jsonArray.map { it.jsonPrimitive.content }
|
return releaseData[if (hasWebP) "webp_pages" else "pages"]!!.jsonArray.map { it.jsonPrimitive.content }
|
||||||
|
.sortedWith(pageSort)
|
||||||
.mapIndexed { index, pageUri ->
|
.mapIndexed { index, pageUri ->
|
||||||
Page(
|
Page(
|
||||||
index,
|
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 popularMangaParse(response: Response) = searchMangaParse(response)
|
||||||
|
|
||||||
override fun popularMangaRequest(page: Int) = searchMangaRequest(page, "", getFilterList())
|
override fun popularMangaRequest(page: Int) = searchMangaRequest(page, "", getFilterList())
|
||||||
|
|
Loading…
Reference in New Issue