mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Update MainAPI.kt
This commit is contained in:
parent
3dcf7076d0
commit
9ea7674a0f
1 changed files with 15 additions and 3 deletions
|
@ -1587,8 +1587,15 @@ data class AnimeLoadResponse(
|
|||
}
|
||||
|
||||
override fun getTotalEpisodeIndex(episode: Int, season: Int): Int {
|
||||
val displayMap = this.seasonNames?.associate { it.season to it.displaySeason } ?: emptyMap()
|
||||
|
||||
return this.episodes.maxOf { (_, episodes) ->
|
||||
episodes.count { ((it.season ?: Int.MIN_VALUE) < season) && it.season != 0 }
|
||||
episodes.count { episodeData ->
|
||||
// Prioritize display season as actual season may be something random to fit multiple seasons into one.
|
||||
val episodeSeason = displayMap[episodeData.season] ?: episodeData.season ?: Int.MIN_VALUE
|
||||
// Count all episodes from season 1 to below the current season.
|
||||
episodeSeason in 1..<season
|
||||
}
|
||||
} + episode
|
||||
}
|
||||
|
||||
|
@ -1895,8 +1902,13 @@ data class TvSeriesLoadResponse(
|
|||
}
|
||||
|
||||
override fun getTotalEpisodeIndex(episode: Int, season: Int): Int {
|
||||
return episodes.count {
|
||||
(it.season ?: Int.MIN_VALUE) < season && it.season != 0
|
||||
val displayMap = this.seasonNames?.associate { it.season to it.displaySeason } ?: emptyMap()
|
||||
|
||||
return episodes.count { episodeData ->
|
||||
// Prioritize display season as actual season may be something random to fit multiple seasons into one.
|
||||
val episodeSeason = displayMap[episodeData.season] ?: episodeData.season ?: Int.MIN_VALUE
|
||||
// Count all episodes from season 1 to below the current season.
|
||||
episodeSeason in 1..<season
|
||||
} + episode
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue