Cubari: reddit gallery intent and fix empty group name causing `NullPointerException` (#15402)
* Cubari: add reddit gallery url intent * fix empty group name causing `NullPointerException`
This commit is contained in:
parent
bfabc9b304
commit
e6f26da39d
|
@ -53,6 +53,19 @@
|
||||||
android:pathPattern="/a/..*"
|
android:pathPattern="/a/..*"
|
||||||
android:scheme="https" />
|
android:scheme="https" />
|
||||||
|
|
||||||
|
<data
|
||||||
|
android:pathPattern="/gallery/..*"
|
||||||
|
android:scheme="https" />
|
||||||
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
|
<data android:host="*.reddit.com" />
|
||||||
|
<data android:host="reddit.com" />
|
||||||
|
|
||||||
<data
|
<data
|
||||||
android:pathPattern="/gallery/..*"
|
android:pathPattern="/gallery/..*"
|
||||||
android:scheme="https" />
|
android:scheme="https" />
|
||||||
|
|
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'Cubari'
|
extName = 'Cubari'
|
||||||
pkgNameSuffix = "all.cubari"
|
pkgNameSuffix = "all.cubari"
|
||||||
extClass = '.CubariFactory'
|
extClass = '.CubariFactory'
|
||||||
extVersionCode = 16
|
extVersionCode = 17
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -180,21 +180,20 @@ open class Cubari(override val lang: String) : HttpSource() {
|
||||||
private fun seriesJsonPageListParse(response: Response, chapter: SChapter): List<Page> {
|
private fun seriesJsonPageListParse(response: Response, chapter: SChapter): List<Page> {
|
||||||
val jsonObj = json.parseToJsonElement(response.body.string()).jsonObject
|
val jsonObj = json.parseToJsonElement(response.body.string()).jsonObject
|
||||||
val groups = jsonObj["groups"]!!.jsonObject
|
val groups = jsonObj["groups"]!!.jsonObject
|
||||||
val groupMap = groups.entries
|
val groupMap = groups.entries.associateBy({ it.value.jsonPrimitive.content.ifEmpty { "default" } }, { it.key })
|
||||||
.map { Pair(it.value.jsonPrimitive.content, it.key) }
|
val chapterScanlator = chapter.scanlator ?: "default" // workaround for "" as group causing NullPointerException (#13772)
|
||||||
.toMap()
|
|
||||||
|
|
||||||
val chapters = jsonObj["chapters"]!!.jsonObject
|
val chapters = jsonObj["chapters"]!!.jsonObject
|
||||||
|
|
||||||
val pages = if (chapters[chapter.chapter_number.toString()] != null) {
|
val pages = if (chapters[chapter.chapter_number.toString()] != null) {
|
||||||
chapters[chapter.chapter_number.toString()]!!
|
chapters[chapter.chapter_number.toString()]!!
|
||||||
.jsonObject["groups"]!!
|
.jsonObject["groups"]!!
|
||||||
.jsonObject[groupMap[chapter.scanlator]]!!
|
.jsonObject[groupMap[chapterScanlator]]!!
|
||||||
.jsonArray
|
.jsonArray
|
||||||
} else {
|
} else {
|
||||||
chapters[chapter.chapter_number.toInt().toString()]!!
|
chapters[chapter.chapter_number.toInt().toString()]!!
|
||||||
.jsonObject["groups"]!!
|
.jsonObject["groups"]!!
|
||||||
.jsonObject[groupMap[chapter.scanlator]]!!
|
.jsonObject[groupMap[chapterScanlator]]!!
|
||||||
.jsonArray
|
.jsonArray
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,8 +282,8 @@ open class Cubari(override val lang: String) : HttpSource() {
|
||||||
scanlator = groups[groupNum]!!.jsonPrimitive.content
|
scanlator = groups[groupNum]!!.jsonPrimitive.content
|
||||||
chapter_number = chapterNum.toFloatOrNull() ?: -1f
|
chapter_number = chapterNum.toFloatOrNull() ?: -1f
|
||||||
|
|
||||||
if (releaseDate != null) {
|
date_upload = if (releaseDate != null) {
|
||||||
date_upload = releaseDate.jsonPrimitive.double.toLong() * 1000
|
releaseDate.jsonPrimitive.double.toLong() * 1000
|
||||||
} else {
|
} else {
|
||||||
val currentTimeMillis = System.currentTimeMillis()
|
val currentTimeMillis = System.currentTimeMillis()
|
||||||
|
|
||||||
|
@ -292,7 +291,7 @@ open class Cubari(override val lang: String) : HttpSource() {
|
||||||
seriesPrefsEditor.putLong(chapterNum, currentTimeMillis)
|
seriesPrefsEditor.putLong(chapterNum, currentTimeMillis)
|
||||||
}
|
}
|
||||||
|
|
||||||
date_upload = seriesPrefs.getLong(chapterNum, currentTimeMillis)
|
seriesPrefs.getLong(chapterNum, currentTimeMillis)
|
||||||
}
|
}
|
||||||
|
|
||||||
name = if (volume != null) {
|
name = if (volume != null) {
|
||||||
|
|
|
@ -17,7 +17,8 @@ class CubariUrlActivity : Activity() {
|
||||||
if (host != null && pathSegments != null) {
|
if (host != null && pathSegments != null) {
|
||||||
val query = with(host) {
|
val query = with(host) {
|
||||||
when {
|
when {
|
||||||
equals("m.imgur.com") || equals("imgur.com") -> fromImgur(pathSegments)
|
equals("m.imgur.com") || equals("imgur.com") -> fromSource("imgur", pathSegments)
|
||||||
|
equals("m.reddit.com") || equals("reddit.com") || equals("www.reddit.com") -> fromSource("reddit", pathSegments)
|
||||||
else -> fromCubari(pathSegments)
|
else -> fromCubari(pathSegments)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,11 +46,11 @@ class CubariUrlActivity : Activity() {
|
||||||
exitProcess(0)
|
exitProcess(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fromImgur(pathSegments: List<String>): String? {
|
private fun fromSource(source: String, pathSegments: List<String>): String? {
|
||||||
if (pathSegments.size >= 2) {
|
if (pathSegments.size >= 2) {
|
||||||
val id = pathSegments[1]
|
val id = pathSegments[1]
|
||||||
|
|
||||||
return "${Cubari.PROXY_PREFIX}imgur/$id"
|
return "${Cubari.PROXY_PREFIX}$source/$id"
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue