Address some OkHttp nullability issues
This commit is contained in:
@@ -32,7 +32,7 @@ class AzukiHandler(currentClient: OkHttpClient, userAgent: String) {
|
||||
}
|
||||
|
||||
fun pageListParse(response: Response): List<Page> {
|
||||
return Json.parseToJsonElement(response.body!!.string())
|
||||
return Json.parseToJsonElement(response.body.string())
|
||||
.jsonObject["pages"]!!
|
||||
.jsonArray.mapIndexed { index, element ->
|
||||
val url = element.jsonObject["image_wm"]!!.jsonObject["webp"]!!.jsonArray[1].jsonObject["url"]!!.jsonPrimitive.content
|
||||
|
||||
@@ -45,7 +45,7 @@ class ComikeyHandler(cloudflareClient: OkHttpClient, userAgent: String) {
|
||||
}
|
||||
|
||||
private fun getActualPageList(response: Response): Request? {
|
||||
val element = Json.parseToJsonElement(response.body!!.string()).jsonObject
|
||||
val element = Json.parseToJsonElement(response.body.string()).jsonObject
|
||||
val ok = element["ok"]?.jsonPrimitive?.booleanOrNull ?: false
|
||||
if (ok.not()) {
|
||||
return null
|
||||
@@ -55,7 +55,7 @@ class ComikeyHandler(cloudflareClient: OkHttpClient, userAgent: String) {
|
||||
}
|
||||
|
||||
fun pageListParse(response: Response): List<Page> {
|
||||
return Json.parseToJsonElement(response.body!!.string())
|
||||
return Json.parseToJsonElement(response.body.string())
|
||||
.jsonObject["readingOrder"]!!
|
||||
.jsonArray.mapIndexed { index, element ->
|
||||
val url = element.jsonObject["href"]!!.jsonPrimitive.content
|
||||
|
||||
@@ -26,7 +26,7 @@ class MangaHotHandler(currentClient: OkHttpClient, userAgent: String) {
|
||||
}
|
||||
|
||||
fun pageListParse(response: Response): List<Page> {
|
||||
return Json.parseToJsonElement(response.body!!.string())
|
||||
return Json.parseToJsonElement(response.body.string())
|
||||
.jsonObject["content"]!!.jsonObject["contentUrls"]!!
|
||||
.jsonArray.mapIndexed { index, element ->
|
||||
val url = element.jsonPrimitive.content
|
||||
|
||||
@@ -40,7 +40,7 @@ class MangaPlusHandler(currentClient: OkHttpClient) {
|
||||
}
|
||||
|
||||
private fun pageListParse(response: Response): List<Page> {
|
||||
val result = ProtoBuf.decodeFromByteArray<MangaPlusResponse>(response.body!!.bytes())
|
||||
val result = ProtoBuf.decodeFromByteArray<MangaPlusResponse>(response.body.bytes())
|
||||
|
||||
if (result.success == null) {
|
||||
throw Exception("error getting images")
|
||||
@@ -70,7 +70,7 @@ class MangaPlusHandler(currentClient: OkHttpClient) {
|
||||
|
||||
val response = chain.proceed(request)
|
||||
|
||||
val image = decodeImage(encryptionKey, response.body!!.bytes())
|
||||
val image = decodeImage(encryptionKey, response.body.bytes())
|
||||
|
||||
val body = image.toResponseBody("image/jpeg".toMediaTypeOrNull())
|
||||
return response.newBuilder().body(body).build()
|
||||
|
||||
Reference in New Issue
Block a user