fix chapter deeplink
(cherry picked from commit f0dd30587a98c27bca59088f119d85f2fc044f25) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/ApiMangaParser.kt
This commit is contained in:
parent
7b4311c7dc
commit
85425a66a2
@ -21,6 +21,7 @@ import kotlinx.serialization.decodeFromString
|
|||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
import kotlinx.serialization.json.intOrNull
|
import kotlinx.serialization.json.intOrNull
|
||||||
|
import kotlinx.serialization.json.jsonObject
|
||||||
import kotlinx.serialization.json.jsonPrimitive
|
import kotlinx.serialization.json.jsonPrimitive
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import rx.Completable
|
import rx.Completable
|
||||||
@ -253,13 +254,13 @@ class ApiMangaParser(private val lang: String) {
|
|||||||
fun chapterParseForMangaId(response: Response): Int {
|
fun chapterParseForMangaId(response: Response): Int {
|
||||||
try {
|
try {
|
||||||
if (response.code != 200) throw Exception("HTTP error ${response.code}")
|
if (response.code != 200) throw Exception("HTTP error ${response.code}")
|
||||||
val body = response.body?.string().orEmpty()
|
val body = response.body?.string()
|
||||||
if (body.isEmpty()) {
|
if (body.isNullOrBlank()) {
|
||||||
throw Exception("Null Response")
|
throw Exception("Null Response")
|
||||||
}
|
}
|
||||||
|
|
||||||
val jsonObject = Json.decodeFromString<JsonObject>(body)
|
val jsonObject = Json.decodeFromString<JsonObject>(body)
|
||||||
return jsonObject["manga_id"]?.jsonPrimitive?.intOrNull ?: throw Exception("No manga associated with chapter")
|
return jsonObject["data"]!!.jsonObject["mangaId"]?.jsonPrimitive?.intOrNull ?: throw Exception("No manga associated with chapter")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
XLog.tag("ApiMangaParser").enableStackTrace(2).e(e)
|
XLog.tag("ApiMangaParser").enableStackTrace(2).e(e)
|
||||||
throw e
|
throw e
|
||||||
|
Loading…
x
Reference in New Issue
Block a user