mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-16 23:12:12 +00:00
feat: add filtering for unavailable future seasons
This commit is contained in:
parent
4609398b59
commit
8020e15a40
3 changed files with 30 additions and 1 deletions
|
|
@ -21,6 +21,26 @@ internal fun MetaDetails.sortedPlayableEpisodes(): List<MetaVideo> =
|
||||||
.filter { it.season != null || it.episode != null }
|
.filter { it.season != null || it.episode != null }
|
||||||
.sortedWith(metaVideoSeasonEpisodeComparator)
|
.sortedWith(metaVideoSeasonEpisodeComparator)
|
||||||
|
|
||||||
|
internal fun List<MetaVideo>.filterUnavailableFutureSeasons(
|
||||||
|
todayIsoDate: String,
|
||||||
|
): List<MetaVideo> {
|
||||||
|
val unavailableSeasons = groupBy { episode -> normalizeSeasonNumber(episode.season) }
|
||||||
|
.filter { (seasonNumber, episodes) ->
|
||||||
|
if (seasonNumber <= 0) return@filter false
|
||||||
|
val firstEpisode = episodes.minWithOrNull(
|
||||||
|
compareBy<MetaVideo>({ it.episode ?: Int.MAX_VALUE }, { it.released.orEmpty() }),
|
||||||
|
) ?: return@filter false
|
||||||
|
!isReleasedBy(todayIsoDate = todayIsoDate, releasedDate = firstEpisode.released)
|
||||||
|
}
|
||||||
|
.keys
|
||||||
|
|
||||||
|
return if (unavailableSeasons.isEmpty()) {
|
||||||
|
this
|
||||||
|
} else {
|
||||||
|
filter { episode -> normalizeSeasonNumber(episode.season) !in unavailableSeasons }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal fun MetaDetails.firstPlayableEpisode(): MetaVideo? =
|
internal fun MetaDetails.firstPlayableEpisode(): MetaVideo? =
|
||||||
sortedPlayableEpisodes().firstOrNull()
|
sortedPlayableEpisodes().firstOrNull()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import com.nuvio.app.core.ui.NuvioScreen
|
||||||
import com.nuvio.app.core.ui.NuvioNetworkOfflineCard
|
import com.nuvio.app.core.ui.NuvioNetworkOfflineCard
|
||||||
import com.nuvio.app.features.addons.AddonRepository
|
import com.nuvio.app.features.addons.AddonRepository
|
||||||
import com.nuvio.app.features.details.MetaDetailsRepository
|
import com.nuvio.app.features.details.MetaDetailsRepository
|
||||||
|
import com.nuvio.app.features.details.filterUnavailableFutureSeasons
|
||||||
import com.nuvio.app.features.details.sortedPlayableEpisodes
|
import com.nuvio.app.features.details.sortedPlayableEpisodes
|
||||||
import com.nuvio.app.features.home.components.HomeCatalogRowSection
|
import com.nuvio.app.features.home.components.HomeCatalogRowSection
|
||||||
import com.nuvio.app.features.home.components.HomeContinueWatchingSection
|
import com.nuvio.app.features.home.components.HomeContinueWatchingSection
|
||||||
|
|
@ -568,6 +569,7 @@ internal fun buildHomeContinueWatchingItems(
|
||||||
compareByDescending<HomeContinueWatchingCandidate> { it.lastUpdatedEpochMs }
|
compareByDescending<HomeContinueWatchingCandidate> { it.lastUpdatedEpochMs }
|
||||||
.thenByDescending { it.isProgressEntry },
|
.thenByDescending { it.isProgressEntry },
|
||||||
)
|
)
|
||||||
|
.filter { candidate -> candidate.item.shouldDisplayInContinueWatching() }
|
||||||
.distinctBy { it.item.videoId }
|
.distinctBy { it.item.videoId }
|
||||||
.map(HomeContinueWatchingCandidate::item)
|
.map(HomeContinueWatchingCandidate::item)
|
||||||
}
|
}
|
||||||
|
|
@ -627,6 +629,7 @@ private fun com.nuvio.app.features.details.MetaDetails.nextReleasedEpisodeAfter(
|
||||||
}
|
}
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.filter { episode -> (episode.season ?: 0) > 0 }
|
.filter { episode -> (episode.season ?: 0) > 0 }
|
||||||
|
.filterUnavailableFutureSeasons(todayIsoDate = todayIsoDate)
|
||||||
|
|
||||||
if (showUnairedNextUp) {
|
if (showUnairedNextUp) {
|
||||||
return ordered.firstOrNull()
|
return ordered.firstOrNull()
|
||||||
|
|
@ -637,6 +640,9 @@ private fun com.nuvio.app.features.details.MetaDetails.nextReleasedEpisodeAfter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun ContinueWatchingItem.shouldDisplayInContinueWatching(): Boolean =
|
||||||
|
isNextUp || progressFraction < 0.995f
|
||||||
|
|
||||||
private fun CachedNextUpItem.toContinueWatchingItem(): ContinueWatchingItem? {
|
private fun CachedNextUpItem.toContinueWatchingItem(): ContinueWatchingItem? {
|
||||||
val subtitle = buildString {
|
val subtitle = buildString {
|
||||||
append("Up Next")
|
append("Up Next")
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,9 @@ import com.nuvio.app.features.watchprogress.ContinueWatchingItem
|
||||||
import com.nuvio.app.features.watchprogress.ContinueWatchingSectionStyle
|
import com.nuvio.app.features.watchprogress.ContinueWatchingSectionStyle
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
private fun continueWatchingProgressPercent(progressFraction: Float): Int =
|
||||||
|
(progressFraction * 100f).roundToInt().coerceIn(1, 99)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun HomeContinueWatchingSection(
|
internal fun HomeContinueWatchingSection(
|
||||||
items: List<ContinueWatchingItem>,
|
items: List<ContinueWatchingItem>,
|
||||||
|
|
@ -361,7 +364,7 @@ private fun ContinueWatchingWideCard(
|
||||||
trackColor = Color.White.copy(alpha = 0.10f),
|
trackColor = Color.White.copy(alpha = 0.10f),
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = "${(item.progressFraction * 100).roundToInt()}% watched",
|
text = "${continueWatchingProgressPercent(item.progressFraction)}% watched",
|
||||||
style = MaterialTheme.typography.labelSmall.copy(
|
style = MaterialTheme.typography.labelSmall.copy(
|
||||||
fontSize = layout.progressLabelSize,
|
fontSize = layout.progressLabelSize,
|
||||||
fontWeight = FontWeight.Medium,
|
fontWeight = FontWeight.Medium,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue