diff --git a/src/main/kotlin/fr/shikkanime/jobs/UpdateEpisodeJob.kt b/src/main/kotlin/fr/shikkanime/jobs/UpdateEpisodeJob.kt index ff44b0b3..21820eac 100644 --- a/src/main/kotlin/fr/shikkanime/jobs/UpdateEpisodeJob.kt +++ b/src/main/kotlin/fr/shikkanime/jobs/UpdateEpisodeJob.kt @@ -227,7 +227,19 @@ class UpdateEpisodeJob : AbstractJob { countryCode: CountryCode, crunchyrollId: String, ): List { - val crunchyrollEpisode = CrunchyrollWrapper.getObjects(countryCode.locale, crunchyrollPlatform.identifiers[countryCode]!!, crunchyrollId).first() + val crunchyrollEpisode = runCatching { + CrunchyrollWrapper.getObjects(countryCode.locale, crunchyrollPlatform.identifiers[countryCode]!!, crunchyrollId).first() + }.getOrElse { e -> + logger.warning("Error while fetching Crunchyroll Browse Object: ${e.message}") + + runCatching { + CrunchyrollWrapper.getEpisode(countryCode.locale, crunchyrollPlatform.identifiers[countryCode]!!, crunchyrollId) + .convertToBrowseObject() + }.getOrElse { e2 -> + logger.warning("Error while fetching Crunchyroll Episode: ${e2.message}") + return emptyList() + } + } val versionIds = crunchyrollEpisode.episodeMetadata!!.versions?.toMutableList() ?: mutableListOf(CrunchyrollWrapper.Version(crunchyrollEpisode.id, true)) versionIds.removeIf { it.guid.isBlank() || it.guid == crunchyrollId } diff --git a/src/main/kotlin/fr/shikkanime/wrappers/CrunchyrollWrapper.kt b/src/main/kotlin/fr/shikkanime/wrappers/CrunchyrollWrapper.kt index 52a0b548..795dade2 100644 --- a/src/main/kotlin/fr/shikkanime/wrappers/CrunchyrollWrapper.kt +++ b/src/main/kotlin/fr/shikkanime/wrappers/CrunchyrollWrapper.kt @@ -95,7 +95,16 @@ object CrunchyrollWrapper { val versions: List?, @SerializedName("next_episode_id") val nextEpisodeId: String?, - ) + ) { + fun convertToBrowseObject() = BrowseObject( + id = id!!, + images = images, + description = description, + title = title, + episodeMetadata = this, + slugTitle = slugTitle, + ) + } data class BrowseObject( val id: String,