mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Part 2 update for named seasons
This commit is contained in:
parent
6f60298fc9
commit
e830595c5f
2 changed files with 39 additions and 23 deletions
|
@ -1118,6 +1118,11 @@ data class NextAiring(
|
||||||
val unixTime: Long,
|
val unixTime: Long,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param season To be mapped with episode season, not shown in UI if displaySeason is defined
|
||||||
|
* @param name To be shown next to the season like "Season $displaySeason $name" but if displaySeason is null then "$name"
|
||||||
|
* @param displaySeason What to be displayed next to the season name, if null then the name is the only thing shown.
|
||||||
|
* */
|
||||||
data class SeasonData(
|
data class SeasonData(
|
||||||
val season: Int,
|
val season: Int,
|
||||||
val name: String? = null,
|
val name: String? = null,
|
||||||
|
|
|
@ -1483,8 +1483,12 @@ class ResultViewModel2 : ViewModel() {
|
||||||
0 -> txt(R.string.no_season)
|
0 -> txt(R.string.no_season)
|
||||||
else -> {
|
else -> {
|
||||||
val seasonNames = (currentResponse as? EpisodeResponse)?.seasonNames
|
val seasonNames = (currentResponse as? EpisodeResponse)?.seasonNames
|
||||||
val seasonData =
|
val seasonData = seasonNames.getSeason(indexer.season)
|
||||||
seasonNames.getSeason(indexer.season)
|
|
||||||
|
// If displaySeason is null then only show the name!
|
||||||
|
if (seasonData?.name != null && seasonData.displaySeason == null) {
|
||||||
|
txt(seasonData.name)
|
||||||
|
} else {
|
||||||
val suffix = seasonData?.name?.let { " $it" } ?: ""
|
val suffix = seasonData?.name?.let { " $it" } ?: ""
|
||||||
txt(
|
txt(
|
||||||
R.string.season_format,
|
R.string.season_format,
|
||||||
|
@ -1494,6 +1498,7 @@ class ResultViewModel2 : ViewModel() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1598,7 +1603,7 @@ class ResultViewModel2 : ViewModel() {
|
||||||
i.posterUrl,
|
i.posterUrl,
|
||||||
episode,
|
episode,
|
||||||
null,
|
null,
|
||||||
seasonData?.displaySeason ?: i.season,
|
if (seasonData != null) seasonData.displaySeason else i.season,
|
||||||
i.data,
|
i.data,
|
||||||
loadResponse.apiName,
|
loadResponse.apiName,
|
||||||
id,
|
id,
|
||||||
|
@ -1633,7 +1638,7 @@ class ResultViewModel2 : ViewModel() {
|
||||||
if (!existingEpisodes.contains(id)) {
|
if (!existingEpisodes.contains(id)) {
|
||||||
existingEpisodes.add(id)
|
existingEpisodes.add(id)
|
||||||
val seasonIndex = episode.season?.minus(1)
|
val seasonIndex = episode.season?.minus(1)
|
||||||
val currentSeason =
|
val seasonData =
|
||||||
loadResponse.seasonNames.getSeason(episode.season)
|
loadResponse.seasonNames.getSeason(episode.season)
|
||||||
|
|
||||||
val ep =
|
val ep =
|
||||||
|
@ -1643,7 +1648,7 @@ class ResultViewModel2 : ViewModel() {
|
||||||
episode.posterUrl,
|
episode.posterUrl,
|
||||||
episodeIndex,
|
episodeIndex,
|
||||||
seasonIndex,
|
seasonIndex,
|
||||||
currentSeason?.displaySeason ?: episode.season,
|
if (seasonData != null) seasonData.displaySeason else episode.season,
|
||||||
episode.data,
|
episode.data,
|
||||||
loadResponse.apiName,
|
loadResponse.apiName,
|
||||||
id,
|
id,
|
||||||
|
@ -1747,16 +1752,17 @@ class ResultViewModel2 : ViewModel() {
|
||||||
val seasonData = loadResponse.seasonNames.getSeason(seasonNumber)
|
val seasonData = loadResponse.seasonNames.getSeason(seasonNumber)
|
||||||
val fixedSeasonNumber = seasonData?.displaySeason ?: seasonNumber
|
val fixedSeasonNumber = seasonData?.displaySeason ?: seasonNumber
|
||||||
val suffix = seasonData?.name?.let { " $it" } ?: ""
|
val suffix = seasonData?.name?.let { " $it" } ?: ""
|
||||||
|
// If displaySeason is null then only show the name!
|
||||||
val name =
|
val name = if (seasonData?.name != null && seasonData.displaySeason == null) {
|
||||||
/*loadResponse.seasonNames?.firstOrNull { it.season == seasonNumber }?.name?.let { seasonData ->
|
txt(seasonData.name)
|
||||||
txt(seasonData)
|
} else {
|
||||||
} ?:*/txt(
|
txt(
|
||||||
R.string.season_format,
|
R.string.season_format,
|
||||||
txt(R.string.season),
|
txt(R.string.season),
|
||||||
fixedSeasonNumber,
|
fixedSeasonNumber,
|
||||||
suffix
|
suffix
|
||||||
)
|
)
|
||||||
|
}
|
||||||
name to seasonNumber
|
name to seasonNumber
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1812,7 +1818,12 @@ class ResultViewModel2 : ViewModel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadTrailers(loadResponse: LoadResponse) = ioSafe {
|
private fun loadTrailers(loadResponse: LoadResponse) = ioSafe {
|
||||||
_trailers.postValue(getTrailers(loadResponse, 3)) // we dont want to fetch too many trailers
|
_trailers.postValue(
|
||||||
|
getTrailers(
|
||||||
|
loadResponse,
|
||||||
|
3
|
||||||
|
)
|
||||||
|
) // we dont want to fetch too many trailers
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun getTrailers(
|
private suspend fun getTrailers(
|
||||||
|
|
Loading…
Reference in a new issue