use the series id of upNextSeries to select the current season and only fall back to preferred local if not found

This commit is contained in:
Jannik 2022-11-26 15:52:20 +01:00
parent 8bdaa8122b
commit a95813e91e
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
2 changed files with 6 additions and 5 deletions

View File

@ -257,7 +257,7 @@ data class Seasons(
@SerialName("total") val total: Int, @SerialName("total") val total: Int,
@SerialName("items") val items: List<Season> @SerialName("items") val items: List<Season>
) { ) {
fun getPreferredSeason(local: Locale): Season { fun getPreferredSeasonByLocal(local: Locale): Season {
return items.firstOrNull { season -> return items.firstOrNull { season ->
// try to get the the first seasons which matches the preferred local // try to get the the first seasons which matches the preferred local
season.slugTitle.endsWith("${local.getDisplayLanguage(Locale.ENGLISH)}-dub", true) season.slugTitle.endsWith("${local.getDisplayLanguage(Locale.ENGLISH)}-dub", true)

View File

@ -57,10 +57,11 @@ class MediaFragmentViewModel(application: Application) : AndroidViewModel(applic
viewModelScope.launch { similarTo = Crunchyroll.similarTo(crunchyId) } viewModelScope.launch { similarTo = Crunchyroll.similarTo(crunchyId) }
).joinAll() ).joinAll()
// TODO use upNextSeries to find the next item to play, maybe fallback to preferredLocale // load the preferred season:
// load the preferred season (preferred language, language per season, not per stream) // next episode > preferred language (language per season, not per stream)
currentSeasonCrunchy = seasonsCrunchy.getPreferredSeason(Preferences.preferredLocale) currentSeasonCrunchy = seasonsCrunchy.items.firstOrNull{ season ->
season.id == upNextSeries.panel.episodeMetadata.seasonId
} ?: seasonsCrunchy.getPreferredSeasonByLocal(Preferences.preferredLocale)
// Note: if we need to query metaDB, do it now // Note: if we need to query metaDB, do it now
// load episodes and metaDB in parallel (tmdb needs mediaType, which is set via episodes) // load episodes and metaDB in parallel (tmdb needs mediaType, which is set via episodes)