[MyAnimeList] Handle cases where my_list_status.status is not present (#8931)

This commit is contained in:
beerpsi 2023-01-17 09:59:07 +07:00 committed by GitHub
parent dc2d470413
commit b7e6b4c28a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -208,7 +208,7 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
val obj = response.jsonObject val obj = response.jsonObject
return track.apply { return track.apply {
val isRereading = obj["is_rereading"]!!.jsonPrimitive.boolean val isRereading = obj["is_rereading"]!!.jsonPrimitive.boolean
status = if (isRereading) MyAnimeList.REREADING else getStatus(obj["status"]!!.jsonPrimitive.content) status = if (isRereading) MyAnimeList.REREADING else getStatus(obj["status"]?.jsonPrimitive?.content)
last_chapter_read = obj["num_chapters_read"]!!.jsonPrimitive.float last_chapter_read = obj["num_chapters_read"]!!.jsonPrimitive.float
score = obj["score"]!!.jsonPrimitive.int.toFloat() score = obj["score"]!!.jsonPrimitive.int.toFloat()
obj["start_date"]?.let { obj["start_date"]?.let {

View file

@ -24,7 +24,7 @@ fun Track.toMyAnimeListStatus() = when (status) {
else -> null else -> null
} }
fun getStatus(status: String) = when (status) { fun getStatus(status: String?) = when (status) {
"reading" -> MyAnimeList.READING "reading" -> MyAnimeList.READING
"completed" -> MyAnimeList.COMPLETED "completed" -> MyAnimeList.COMPLETED
"on_hold" -> MyAnimeList.ON_HOLD "on_hold" -> MyAnimeList.ON_HOLD