Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Jay 2020-01-06 18:12:09 -08:00
commit 2afd068780

View File

@ -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) }
}