Fixed GMANGA page sort (#18673)

* Update .gitignore

* Fixed Gmanga page sorting

* Formatting
This commit is contained in:
Saud-97 2023-10-23 19:45:42 +03:00 committed by GitHub
parent fc7598bdcf
commit 280583f53f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -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"

View File

@ -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())