fix(myanimelist): Fix nullability and fallback to medium cover if large
cover is null (cherry picked from commit a3672be7282c553017d35b310fb5a148d677ff14)
This commit is contained in:
parent
eddabbc04e
commit
136bfe2833
2 changed files with 5 additions and 5 deletions
|
|
@ -113,7 +113,7 @@ class MyAnimeListApi(
|
|||
summary = it.synopsis
|
||||
total_chapters = it.numChapters
|
||||
score = it.mean
|
||||
cover_url = it.covers.large
|
||||
cover_url = (it.covers?.large ?: it.covers?.medium).orEmpty()
|
||||
tracking_url = "https://myanimelist.net/manga/$remote_id"
|
||||
publishing_status = it.status.replace("_", " ")
|
||||
publishing_type = it.mediaType.replace("_", " ")
|
||||
|
|
@ -195,7 +195,7 @@ class MyAnimeListApi(
|
|||
}
|
||||
}
|
||||
|
||||
suspend fun getMangaMetadata(track: DomainTrack): TrackMangaMetadata? {
|
||||
suspend fun getMangaMetadata(track: DomainTrack): TrackMangaMetadata {
|
||||
return withIOContext {
|
||||
val url = "$BASE_API_URL/manga".toUri().buildUpon()
|
||||
.appendPath(track.remoteId.toString())
|
||||
|
|
@ -212,7 +212,7 @@ class MyAnimeListApi(
|
|||
TrackMangaMetadata(
|
||||
remoteId = it.id,
|
||||
title = it.title,
|
||||
thumbnailUrl = it.covers.large.ifEmpty { null } ?: it.covers.medium,
|
||||
thumbnailUrl = it.covers.large?.ifEmpty { null } ?: it.covers.medium,
|
||||
description = it.synopsis,
|
||||
authors = it.authors
|
||||
.filter { it.role == "Story" || it.role == "Story & Art" }
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ data class MALManga(
|
|||
val numChapters: Long,
|
||||
val mean: Double = -1.0,
|
||||
@SerialName("main_picture")
|
||||
val covers: MALMangaCovers,
|
||||
val covers: MALMangaCovers?,
|
||||
val status: String,
|
||||
@SerialName("media_type")
|
||||
val mediaType: String,
|
||||
|
|
@ -22,7 +22,7 @@ data class MALManga(
|
|||
|
||||
@Serializable
|
||||
data class MALMangaCovers(
|
||||
val large: String = "",
|
||||
val large: String?,
|
||||
val medium: String,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue