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.
This commit is contained in:
parent
5a8287c1fa
commit
b87a5935b8
|
@ -6,7 +6,7 @@ ext {
|
|||
extName = 'Cubari'
|
||||
pkgNameSuffix = "all.cubari"
|
||||
extClass = '.CubariFactory'
|
||||
extVersionCode = 8
|
||||
extVersionCode = 9
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
|
|
@ -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<SChapter> {
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue