Skip to content

Commit

Permalink
Merge pull request #167 from Shikkanime/dev
Browse files Browse the repository at this point in the history
Fix Crunchyroll image error
  • Loading branch information
Ziedelth committed Feb 11, 2024
2 parents 7f4e77e + 1a2a58d commit e6930d3
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,8 @@ class CrunchyrollPlatform : AbstractPlatform<CrunchyrollConfiguration, CountryCo
val title = jsonObject.getAsString("title")
val url = "https://www.crunchyroll.com/media-$id"

val biggestImage = requireNotNull(
jsonObject.getAsJsonObject("images").getAsJsonArray("thumbnail")[0].asJsonArray.maxByOrNull { it.asJsonObject.getAsInt("width")!! }
) { IMAGE_NULL_ERROR }
val thumbnailArray = requireNotNull(jsonObject.getAsJsonObject("images").getAsJsonArray("thumbnail")) { IMAGE_NULL_ERROR }
val biggestImage = requireNotNull(thumbnailArray[0].asJsonArray.maxByOrNull { it.asJsonObject.getAsInt("width")!! }) { IMAGE_NULL_ERROR }
val image = requireNotNull(biggestImage.asJsonObject.getAsString("source")?.takeIf { it.isNotBlank() }) { IMAGE_NULL_ERROR }

var duration = episodeMetadata.getAsLong("duration_ms", -1000) / 1000
Expand Down

0 comments on commit e6930d3

Please sign in to comment.