From b87a5935b8d4f54496dc2fb9ea27b56a24614624 Mon Sep 17 00:00:00 2001 From: E3FxGaming <8276268+E3FxGaming@users.noreply.github.com> Date: Sun, 18 Jul 2021 12:29:43 +0200 Subject: [PATCH] Cubari release_date fix + volume null fix (#8163) * Fix for Cubari API response not containing chapter release_date Cubari API responses don't contain release_date information when the Cubari source is Imgur. The minor change made with this commit makes the existence of the release_date json property for the parsing process optional. * Fix for Cubari volume "null" and cleaned up chapter name generation If the volume is set to null in the json, it's now recognized as not specified. Also cleaned up the chapter name concatenation. --- src/all/cubari/build.gradle | 2 +- .../tachiyomi/extension/all/cubari/Cubari.kt | 20 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/all/cubari/build.gradle b/src/all/cubari/build.gradle index 636262a76..c5ddfac88 100644 --- a/src/all/cubari/build.gradle +++ b/src/all/cubari/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'Cubari' pkgNameSuffix = "all.cubari" extClass = '.CubariFactory' - extVersionCode = 8 + extVersionCode = 9 libVersion = '1.2' } diff --git a/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/Cubari.kt b/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/Cubari.kt index f4e91c497..c93880e59 100644 --- a/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/Cubari.kt +++ b/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/Cubari.kt @@ -255,6 +255,8 @@ open class Cubari(override val lang: String) : HttpSource() { // ------------- Helpers and whatnot --------------- + private val volumeNotSpecifiedTerms = setOf("Uncategorized", "null") + private fun parseChapterList(payload: String, manga: SManga): List { val jsonObj = json.parseToJsonElement(payload).jsonObject val groups = jsonObj["groups"]!!.jsonObject @@ -268,18 +270,21 @@ open class Cubari(override val lang: String) : HttpSource() { val chapterNum = chapterEntry.key val chapterObj = chapterEntry.value.jsonObject val chapterGroups = chapterObj["groups"]!!.jsonObject - val volume = chapterObj["volume"]!!.jsonPrimitive.content + val volume = chapterObj["volume"]!!.jsonPrimitive.content.let { + if (volumeNotSpecifiedTerms.contains(it)) null else it + } + val title = chapterObj["title"]!!.jsonPrimitive.content chapterGroups.entries.map { groupEntry -> val groupNum = groupEntry.key + val releaseDate = chapterObj["release_date"]?.jsonObject?.get(groupNum) SChapter.create().apply { scanlator = groups[groupNum]!!.jsonPrimitive.content chapter_number = chapterNum.toFloatOrNull() ?: -1f - if (chapterObj["release_date"]!!.jsonObject[groupNum] != null) { - val temp = chapterObj["release_date"]!!.jsonObject[groupNum]!!.jsonPrimitive.double - date_upload = temp.toLong() * 1000 + if (releaseDate != null) { + date_upload = releaseDate.jsonPrimitive.double.toLong() * 1000 } else { val currentTimeMillis = System.currentTimeMillis() @@ -290,13 +295,12 @@ open class Cubari(override val lang: String) : HttpSource() { date_upload = seriesPrefs.getLong(chapterNum, currentTimeMillis) } - name = if (volume.isNotEmpty() && volume != "Uncategorized") { + name = if (volume != null) { // Output "Vol. 1 Ch. 1 - Chapter Name" - "Vol. " + chapterObj["volume"]!!.jsonPrimitive.content + " Ch. " + - chapterNum + " - " + chapterObj["title"]!!.jsonPrimitive.content + "Vol. $volume Ch. $chapterNum - $title" } else { // Output "Ch. 1 - Chapter Name" - "Ch. " + chapterNum + " - " + chapterObj["title"]!!.jsonPrimitive.content + "Ch. $chapterNum - $title" } url = if (chapterGroups[groupNum] is JsonArray) {