fix Mangalife chapter numbers (#6066)

* fix chapter numbers in MangaLife chapter list

this commit adds the chapter regex used in MangaSee to MangaLife
before - "Chapter 0002"
after  - "Chapter 2"

* update MangaLife build.gradle

increments the version number by 1
This commit is contained in:
curche 2021-03-07 01:11:27 +05:30 committed by GitHub
parent f7adef8f91
commit 325ccc4ce3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'MangaLife' extName = 'MangaLife'
pkgNameSuffix = 'en.mangalife' pkgNameSuffix = 'en.mangalife'
extClass = '.MangaLife' extClass = '.MangaLife'
extVersionCode = 10 extVersionCode = 11
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -220,8 +220,10 @@ class MangaLife : HttpSource() {
return "-chapter-$n$index$suffix.html" return "-chapter-$n$index$suffix.html"
} }
private fun chapterImage(e: String): String { private val chapterImageRegex = Regex("""^0+""")
val a = e.substring(1, e.length - 1)
private fun chapterImage(e: String, cleanString: Boolean = false): String {
val a = e.substring(1, e.length - 1).let { if (cleanString) it.replace(chapterImageRegex, "") else it }
val b = e.substring(e.length - 1).toInt() val b = e.substring(e.length - 1).toInt()
return if (b == 0) { return if (b == 0) {
a a
@ -237,7 +239,7 @@ class MangaLife : HttpSource() {
return gson.fromJson<JsonArray>(vmChapters).map { json -> return gson.fromJson<JsonArray>(vmChapters).map { json ->
val indexChapter = json["Chapter"].string val indexChapter = json["Chapter"].string
SChapter.create().apply { SChapter.create().apply {
name = json["ChapterName"].nullString.let { if (it.isNullOrEmpty()) "${json["Type"].string} ${chapterImage(indexChapter)}" else it } name = json["ChapterName"].nullString.let { if (it.isNullOrEmpty()) "${json["Type"].string} ${chapterImage(indexChapter, true)}" else it }
url = "/read-online/" + response.request().url().toString().substringAfter("/manga/") + chapterURLEncode(indexChapter) url = "/read-online/" + response.request().url().toString().substringAfter("/manga/") + chapterURLEncode(indexChapter)
date_upload = try { date_upload = try {
json["Date"].nullString?.let { dateFormat.parse("$it +0600")?.time } ?: 0 json["Date"].nullString?.let { dateFormat.parse("$it +0600")?.time } ?: 0