StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.
Kotlin iptv-player
feat: Update catch-up ID handling and add tests for template variants
David Nashash0ac640f6d144
diff --git a/data/src/main/java/com/streamvault/data/sync/SyncManagerM3uImporter.kt b/data/src/main/java/com/streamvault/data/sync/SyncManagerM3uImporter.ktindex 47974934..2cbd763f 100644--- a/data/src/main/java/com/streamvault/data/sync/SyncManagerM3uImporter.kt+++ b/data/src/main/java/com/streamvault/data/sync/SyncManagerM3uImporter.kt@@ -51,7 +51,7 @@ private fun sanitizeCatchUpSource(source: String?, catchUpType: String?): Stringreturn value.takeIf { mode.isEmpty() || mode in setOf("default", "append", "shift", "timeshift") }}- val validationValue = value.replace(Regex("\\$?\\{[^}]{1,64}}"), "catchup-token")+ val validationValue = value.replace(Regex("\\$?\\{[^}]{1,64}\\}"), "catchup-token")return value.takeIf { UrlSecurityPolicy.isAllowedStreamEntryUrl(validationValue) }}diff --git a/domain/src/main/java/com/streamvault/domain/playback/ArchivePlayback.kt b/domain/src/main/java/com/streamvault/domain/playback/ArchivePlayback.ktindex 82fe2bea..2e7c9c1c 100644--- a/domain/src/main/java/com/streamvault/domain/playback/ArchivePlayback.kt+++ b/domain/src/main/java/com/streamvault/domain/playback/ArchivePlayback.kt@@ -34,7 +34,8 @@ fun Channel.archivePlaybackCapability(): ArchivePlaybackCapability {val hasXtreamReplayContext = stream.startsWith(XTREAM_INTERNAL_PREFIX) && streamId > 0Lval hasStalkerReplayContext =stream.startsWith(STALKER_INTERNAL_PREFIX) || normalizedSource.startsWith(STALKER_INTERNAL_PREFIX)- val needsUnmappedCatchUpId = Regex("\\$?\\{catchup-id}", RegexOption.IGNORE_CASE).containsMatchIn(source)+ val needsUnmappedCatchUpId = source.contains("{catchup-id}", ignoreCase = true) ||+ source.contains("{catchup-id:", ignoreCase = true)val hasM3uTemplate = source.isNotBlank() && !needsUnmappedCatchUpId &&!normalizedSource.startsWith(STALKER_INTERNAL_PREFIX)val needsConfiguredFallback = source.isBlank() && normalizedType in setOf("default", "append")diff --git a/domain/src/test/java/com/streamvault/domain/playback/ArchivePlaybackTest.kt b/domain/src/test/java/com/streamvault/domain/playback/ArchivePlaybackTest.ktindex 878c79e4..56fbe730 100644--- a/domain/src/test/java/com/streamvault/domain/playback/ArchivePlaybackTest.kt+++ b/domain/src/test/java/com/streamvault/domain/playback/ArchivePlaybackTest.kt@@ -178,6 +178,36 @@ class ArchivePlaybackTest {assertThat(channel.isArchivePlayable(program, now)).isFalse()}+ @Test+ fun `catchup id template variants are not offered before programme identifiers are mapped`() {+ val now = 5 * 86_400_000L+ val program = Program(+ channelId = "news",+ title = "Replay with identifier",+ startTime = now - 60_000L,+ endTime = now - 30_000L+ )+ val sources = listOf(+ "https://archive.example.com/program/${'$'}{catchup-id}.m3u8",+ "https://archive.example.com/program/{catchup-id:raw}.m3u8"+ )++ sources.forEach { source ->+ val channel = Channel(+ id = 42L,+ name = "News",+ providerId = 7L,+ streamUrl = "https://live.example.com/channel.m3u8",+ catchUpSupported = true,+ catchUpSource = source,+ catchUpType = "append"+ )++ assertThat(channel.archivePlaybackCapability().canBuildReplayCandidate).isFalse()+ assertThat(channel.isArchivePlayable(program, now)).isFalse()+ }+ }+@Testfun `auto mode is not offered for a template that still needs a programme identifier`() {val now = 5 * 86_400_000L