From eb5382e0de3232a2b18441a8a22d2c5b163771cf Mon Sep 17 00:00:00 2001 From: mutsumi <4182301+mutsumi63@users.noreply.github.com> Date: Tue, 7 Jan 2020 09:02:28 +0800 Subject: [PATCH] fix bangumi tracker crash in searching english manga title (#2452) fix bangumi tracker crash in searching english manga title --- .../eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt index c678372c6b..7180156aa3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt @@ -84,10 +84,13 @@ class BangumiApi(private val client: OkHttpClient, interceptor: BangumiIntercept return authClient.newCall(request) .asObservableSuccess() .map { netResponse -> - val responseBody = netResponse.body?.string().orEmpty() + var responseBody = netResponse.body?.string().orEmpty() if (responseBody.isEmpty()) { throw Exception("Null Response") } + if(responseBody.contains("\"code\":404")){ + responseBody = "{\"results\":0,\"list\":[]}" + } val response = parser.parse(responseBody).obj["list"]?.array response?.filter { it.obj["type"].asInt == 1 }?.map { jsonToSearch(it.obj) } }