Skip to content

StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.

feat: checkpoint stalker variants support work

David Nashash3f8dc11749fb
diff --git a/app/src/main/java/com/streamvault/app/di/DatabaseModule.kt b/app/src/main/java/com/streamvault/app/di/DatabaseModule.kt
index 91ab68d2..c3285a66 100644
--- a/app/src/main/java/com/streamvault/app/di/DatabaseModule.kt
+++ b/app/src/main/java/com/streamvault/app/di/DatabaseModule.kt
@@ -92,7 +92,8 @@ object DatabaseModule {
StreamVaultDatabase.MIGRATION_50_51,
StreamVaultDatabase.MIGRATION_51_52,
StreamVaultDatabase.MIGRATION_52_53,
- StreamVaultDatabase.MIGRATION_53_54
+ StreamVaultDatabase.MIGRATION_53_54,
+ StreamVaultDatabase.MIGRATION_54_55
)
// NOTE: fallbackToDestructiveMigration() intentionally removed.
// All future schema changes MUST add a corresponding Migration in StreamVaultDatabase.
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerContentResolutionSupport.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerContentResolutionSupport.kt
index 5aed5ce3..af0a698e 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerContentResolutionSupport.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerContentResolutionSupport.kt
@@ -1,6 +1,7 @@
package com.streamvault.app.ui.screens.player
import com.streamvault.data.remote.xtream.XtreamStreamUrlResolver
+import com.streamvault.data.remote.stalker.StalkerPlaybackResolutionException
import com.streamvault.data.security.CredentialDecryptionException
import com.streamvault.domain.model.ContentType
import com.streamvault.domain.model.Episode
@@ -23,7 +24,8 @@ internal data class SeriesEpisodeResolution(
internal data class PlayerPlaybackStreamResolution(
val streamInfo: StreamInfo?,
- val credentialFailureMessage: String? = null
+ val credentialFailureMessage: String? = null,
+ val resolutionFailureMessage: String? = null
)
internal fun buildSeriesEpisodeResolution(
@@ -145,6 +147,19 @@ internal suspend fun resolvePlayerPlaybackStreamInfo(
streamInfo = null,
credentialFailureMessage = e.message ?: CredentialDecryptionException.MESSAGE
)
+ } catch (e: StalkerPlaybackResolutionException) {
+ return PlayerPlaybackStreamResolution(
+ streamInfo = null,
+ resolutionFailureMessage = e.message ?: "We couldn't resolve a playable Stalker stream for this item."
+ )
+ }
+
+ val isLogicalInternalUrl = xtreamStreamUrlResolver.isInternalStreamUrl(logicalUrl)
+ if (isLogicalInternalUrl) {
+ return PlayerPlaybackStreamResolution(
+ streamInfo = null,
+ resolutionFailureMessage = "This portal requires a different playback path than the default command."
+ )
}
return PlayerPlaybackStreamResolution(
@@ -157,4 +172,4 @@ internal suspend fun resolvePlayerPlaybackStreamInfo(
)
}
)
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerPlaybackProbeSupport.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerPlaybackProbeSupport.kt
index 9a3911b3..d480f3b4 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerPlaybackProbeSupport.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerPlaybackProbeSupport.kt
@@ -6,6 +6,11 @@ internal data class PlaybackProbeFailure(
)
internal fun resolvePlaybackProbeFailure(responseCode: Int): PlaybackProbeFailure? = when (responseCode) {
+ 204 -> PlaybackProbeFailure(
+ message = "Portal issued an empty temporary link for this stream (HTTP 204). Retrying the channel may refresh the portal session.",
+ recoveryType = PlayerRecoveryType.SOURCE
+ )
+
401, 403 -> PlaybackProbeFailure(
message = "This provider stream was rejected ($responseCode Unauthorized/Forbidden).",
recoveryType = PlayerRecoveryType.SOURCE
@@ -27,4 +32,4 @@ internal fun resolvePlaybackProbeFailure(responseCode: Int): PlaybackProbeFailur
)
else -> null
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerPlaybackRecoverySupport.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerPlaybackRecoverySupport.kt
index 71ff9281..ebcc9c87 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerPlaybackRecoverySupport.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerPlaybackRecoverySupport.kt
@@ -8,7 +8,9 @@ internal fun classifyPlaybackError(error: PlayerError): PlayerRecoveryType = whe
PlayerRecoveryType.BUFFER_TIMEOUT
} else if (
error.message.contains("HTTP 456", ignoreCase = true) ||
- error.message.contains("access denied", ignoreCase = true)
+ error.message.contains("access denied", ignoreCase = true) ||
+ error.message.contains("temporary link", ignoreCase = true) ||
+ error.message.contains("playback path", ignoreCase = true)
) {
PlayerRecoveryType.SOURCE
} else {
@@ -35,6 +37,12 @@ internal fun resolvePlaybackErrorMessage(error: PlayerError): String = when (cla
error.message.contains("access denied", ignoreCase = true) ->
"This provider rejected playback for this channel. The MAC or subscription may not have access to this stream."
+ error.message.contains("temporary link", ignoreCase = true) ->
+ "This portal issued an empty or invalid temporary link for playback."
+
+ error.message.contains("playback path", ignoreCase = true) ->
+ "This portal requires a different playback path than the default stream command."
+
else -> "We couldn't start this stream on the available paths."
}
@@ -43,4 +51,4 @@ internal fun resolvePlaybackErrorMessage(error: PlayerError): String = when (cla
PlayerRecoveryType.BUFFER_TIMEOUT -> "Playback stayed stuck buffering for too long on this stream."
PlayerRecoveryType.CATCH_UP -> "Replay is unavailable for the selected program."
PlayerRecoveryType.UNKNOWN -> error.message.ifBlank { "Playback failed for an unknown reason." }
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt
index b267c119..d2f18ba2 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt
@@ -1540,6 +1540,11 @@ class PlayerViewModel @Inject constructor(
showPlayerNotice(message = message, recoveryType = PlayerRecoveryType.SOURCE)
return null
}
+ resolution.resolutionFailureMessage?.let { message ->
+ setLastFailureReason(message)
+ showPlayerNotice(message = message, recoveryType = PlayerRecoveryType.SOURCE)
+ return null
+ }
return resolution.streamInfo
}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/provider/ProviderSetupScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/provider/ProviderSetupScreen.kt
index 53beaa8c..df8a7ecd 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/provider/ProviderSetupScreen.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/provider/ProviderSetupScreen.kt
@@ -73,6 +73,7 @@ import com.streamvault.app.ui.theme.*
import com.streamvault.data.util.ProviderInputSanitizer
import com.streamvault.domain.model.ProviderEpgSyncMode
import com.streamvault.domain.model.ProviderXtreamLiveSyncMode
+import com.streamvault.domain.model.StalkerAuthMode
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
@@ -109,6 +110,7 @@ fun ProviderSetupScreen(
var httpUserAgent by rememberSaveable { mutableStateOf("") }
var httpHeaders by rememberSaveable { mutableStateOf("") }
var stalkerMacAddress by rememberSaveable { mutableStateOf("") }
+ var stalkerAuthMode by rememberSaveable { mutableStateOf(StalkerAuthMode.AUTO) }
var stalkerDeviceProfile by rememberSaveable { mutableStateOf("") }
var stalkerDeviceTimezone by rememberSaveable { mutableStateOf("") }
var stalkerDeviceLocale by rememberSaveable { mutableStateOf("") }
@@ -220,6 +222,7 @@ fun ProviderSetupScreen(
httpUserAgent = uiState.httpUserAgent
httpHeaders = uiState.httpHeaders
stalkerMacAddress = uiState.stalkerMacAddress
+ stalkerAuthMode = uiState.stalkerAuthMode
stalkerDeviceProfile = uiState.stalkerDeviceProfile
stalkerDeviceTimezone = uiState.stalkerDeviceTimezone
stalkerDeviceLocale = uiState.stalkerDeviceLocale
@@ -269,6 +272,7 @@ fun ProviderSetupScreen(
httpUserAgent.isNotBlank() ||
httpHeaders.isNotBlank() ||
stalkerMacAddress.isNotBlank() ||
+ stalkerAuthMode != StalkerAuthMode.AUTO ||
stalkerDeviceProfile.isNotBlank() ||
stalkerDeviceTimezone.isNotBlank() ||
stalkerDeviceLocale.isNotBlank() ||
@@ -326,6 +330,7 @@ fun ProviderSetupScreen(
httpUserAgent = httpUserAgent, onHttpUserAgentChange = { httpUserAgent = ProviderInputSanitizer.sanitizeHttpUserAgentForEditing(it) },
httpHeaders = httpHeaders, onHttpHeadersChange = { httpHeaders = ProviderInputSanitizer.sanitizeHttpHeadersForEditing(it) },
stalkerMacAddress = stalkerMacAddress, onStalkerMacAddressChange = { stalkerMacAddress = ProviderInputSanitizer.sanitizeMacAddressForEditing(it) },
+ stalkerAuthMode = stalkerAuthMode, onStalkerAuthModeChange = { stalkerAuthMode = it },
stalkerDeviceProfile = stalkerDeviceProfile, onStalkerDeviceProfileChange = { stalkerDeviceProfile = ProviderInputSanitizer.sanitizeDeviceProfileForEditing(it) },
stalkerDeviceTimezone = stalkerDeviceTimezone, onStalkerDeviceTimezoneChange = { stalkerDeviceTimezone = ProviderInputSanitizer.sanitizeTimezoneForEditing(it) },
stalkerDeviceLocale = stalkerDeviceLocale, onStalkerDeviceLocaleChange = { stalkerDeviceLocale = ProviderInputSanitizer.sanitizeLocaleForEditing(it) },
@@ -336,7 +341,7 @@ fun ProviderSetupScreen(
fileImportError = fileImportError,
onFilePick = { filePickerLauncher.launch(arrayOf("*/*")) },
onLoginXtream = { viewModel.loginXtream(serverUrl, username, password, name, httpUserAgent, httpHeaders) },
- onLoginStalker = { viewModel.loginStalker(serverUrl, stalkerMacAddress, name, stalkerDeviceProfile, stalkerDeviceTimezone, stalkerDeviceLocale, stalkerSerialNumber, stalkerDeviceId, stalkerDeviceId2, stalkerSignature) },
+ onLoginStalker = { viewModel.loginStalker(serverUrl, stalkerMacAddress, stalkerAuthMode, username, password, name, stalkerDeviceProfile, stalkerDeviceTimezone, stalkerDeviceLocale, stalkerSerialNumber, stalkerDeviceId, stalkerDeviceId2, stalkerSignature) },
onAddM3u = { viewModel.addM3u(m3uUrl, name, httpUserAgent, httpHeaders) },
onToggleM3uVodClassification = { viewModel.updateM3uVodClassificationEnabled(!uiState.m3uVodClassificationEnabled) },
onSelectEpgSyncMode = viewModel::updateEpgSyncMode,
@@ -372,6 +377,7 @@ fun ProviderSetupScreen(
httpUserAgent = httpUserAgent, onHttpUserAgentChange = { httpUserAgent = ProviderInputSanitizer.sanitizeHttpUserAgentForEditing(it) },
httpHeaders = httpHeaders, onHttpHeadersChange = { httpHeaders = ProviderInputSanitizer.sanitizeHttpHeadersForEditing(it) },
stalkerMacAddress = stalkerMacAddress, onStalkerMacAddressChange = { stalkerMacAddress = ProviderInputSanitizer.sanitizeMacAddressForEditing(it) },
+ stalkerAuthMode = stalkerAuthMode, onStalkerAuthModeChange = { stalkerAuthMode = it },
stalkerDeviceProfile = stalkerDeviceProfile, onStalkerDeviceProfileChange = { stalkerDeviceProfile = ProviderInputSanitizer.sanitizeDeviceProfileForEditing(it) },
stalkerDeviceTimezone = stalkerDeviceTimezone, onStalkerDeviceTimezoneChange = { stalkerDeviceTimezone = ProviderInputSanitizer.sanitizeTimezoneForEditing(it) },
stalkerDeviceLocale = stalkerDeviceLocale, onStalkerDeviceLocaleChange = { stalkerDeviceLocale = ProviderInputSanitizer.sanitizeLocaleForEditing(it) },
@@ -382,7 +388,7 @@ fun ProviderSetupScreen(
fileImportError = fileImportError,
onFilePick = { filePickerLauncher.launch(arrayOf("*/*")) },
onLoginXtream = { viewModel.loginXtream(serverUrl, username, password, name, httpUserAgent, httpHeaders) },
- onLoginStalker = { viewModel.loginStalker(serverUrl, stalkerMacAddress, name, stalkerDeviceProfile, stalkerDeviceTimezone, stalkerDeviceLocale, stalkerSerialNumber, stalkerDeviceId, stalkerDeviceId2, stalkerSignature) },
+ onLoginStalker = { viewModel.loginStalker(serverUrl, stalkerMacAddress, stalkerAuthMode, username, password, name, stalkerDeviceProfile, stalkerDeviceTimezone, stalkerDeviceLocale, stalkerSerialNumber, stalkerDeviceId, stalkerDeviceId2, stalkerSignature) },
onAddM3u = { viewModel.addM3u(m3uUrl, name, httpUserAgent, httpHeaders) },
onToggleM3uVodClassification = { viewModel.updateM3uVodClassificationEnabled(!uiState.m3uVodClassificationEnabled) },
onSelectEpgSyncMode = viewModel::updateEpgSyncMode,
@@ -529,6 +535,7 @@ private fun ProviderFormContent(
httpUserAgent: String, onHttpUserAgentChange: (String) -> Unit,
httpHeaders: String, onHttpHeadersChange: (String) -> Unit,
stalkerMacAddress: String, onStalkerMacAddressChange: (String) -> Unit,
+ stalkerAuthMode: StalkerAuthMode, onStalkerAuthModeChange: (StalkerAuthMode) -> Unit,
stalkerDeviceProfile: String, onStalkerDeviceProfileChange: (String) -> Unit,
stalkerDeviceTimezone: String, onStalkerDeviceTimezoneChange: (String) -> Unit,
stalkerDeviceLocale: String, onStalkerDeviceLocaleChange: (String) -> Unit,
@@ -621,6 +628,13 @@ private fun ProviderFormContent(
onToggleM3uVodClassification = onToggleM3uVodClassification,
onSelectEpgSyncMode = onSelectEpgSyncMode,
onSelectXtreamLiveSyncMode = onSelectXtreamLiveSyncMode,
+ username = username,
+ onUsernameChange = onUsernameChange,
+ password = password,
+ onPasswordChange = onPasswordChange,
+ stalkerAuthMode = stalkerAuthMode,
+ onStalkerAuthModeChange = onStalkerAuthModeChange,
+ stalkerMacAddress = stalkerMacAddress,
stalkerDeviceProfile = stalkerDeviceProfile,
onStalkerDeviceProfileChange = onStalkerDeviceProfileChange,
stalkerDeviceTimezone = stalkerDeviceTimezone,
@@ -661,7 +675,11 @@ private fun ProviderFormContent(
)
ProviderTextField(
value = stalkerMacAddress, onValueChange = onStalkerMacAddressChange,
- placeholder = "MAC address",
+ placeholder = if (stalkerAuthMode == StalkerAuthMode.CREDENTIALS_ONLY) {
+ "MAC address (optional)"
+ } else {
+ "MAC address"
+ },
keyboardOptions = KeyboardOptions(
capitalization = KeyboardCapitalization.Characters,
autoCorrectEnabled = false,
@@ -679,6 +697,13 @@ private fun ProviderFormContent(
onToggleM3uVodClassification = onToggleM3uVodClassification,
onSelectEpgSyncMode = onSelectEpgSyncMode,
onSelectXtreamLiveSyncMode = onSelectXtreamLiveSyncMode,
+ username = username,
+ onUsernameChange = onUsernameChange,
+ password = password,
+ onPasswordChange = onPasswordChange,
+ stalkerAuthMode = stalkerAuthMode,
+ onStalkerAuthModeChange = onStalkerAuthModeChange,
+ stalkerMacAddress = stalkerMacAddress,
stalkerDeviceProfile = stalkerDeviceProfile,
onStalkerDeviceProfileChange = onStalkerDeviceProfileChange,
stalkerDeviceTimezone = stalkerDeviceTimezone,
@@ -722,6 +747,13 @@ private fun ProviderFormContent(
onToggleM3uVodClassification = onToggleM3uVodClassification,
onSelectEpgSyncMode = onSelectEpgSyncMode,
onSelectXtreamLiveSyncMode = onSelectXtreamLiveSyncMode,
+ username = username,
+ onUsernameChange = onUsernameChange,
+ password = password,
+ onPasswordChange = onPasswordChange,
+ stalkerAuthMode = stalkerAuthMode,
+ onStalkerAuthModeChange = onStalkerAuthModeChange,
+ stalkerMacAddress = stalkerMacAddress,
stalkerDeviceProfile = stalkerDeviceProfile,
onStalkerDeviceProfileChange = onStalkerDeviceProfileChange,
stalkerDeviceTimezone = stalkerDeviceTimezone,
@@ -770,6 +802,13 @@ private fun ProviderFormContent(
onToggleM3uVodClassification = onToggleM3uVodClassification,
onSelectEpgSyncMode = onSelectEpgSyncMode,
onSelectXtreamLiveSyncMode = onSelectXtreamLiveSyncMode,
+ username = username,
+ onUsernameChange = onUsernameChange,
+ password = password,
+ onPasswordChange = onPasswordChange,
+ stalkerAuthMode = stalkerAuthMode,
+ onStalkerAuthModeChange = onStalkerAuthModeChange,
+ stalkerMacAddress = stalkerMacAddress,
stalkerDeviceProfile = stalkerDeviceProfile,
onStalkerDeviceProfileChange = onStalkerDeviceProfileChange,
stalkerDeviceTimezone = stalkerDeviceTimezone,
@@ -832,6 +871,13 @@ private fun AdvancedProviderOptionsSection(
onToggleM3uVodClassification: () -> Unit,
onSelectEpgSyncMode: (ProviderEpgSyncMode) -> Unit,
onSelectXtreamLiveSyncMode: (ProviderXtreamLiveSyncMode) -> Unit,
+ username: String,
+ onUsernameChange: (String) -> Unit,
+ password: String,
+ onPasswordChange: (String) -> Unit,
+ stalkerAuthMode: StalkerAuthMode,
+ onStalkerAuthModeChange: (StalkerAuthMode) -> Unit,
+ stalkerMacAddress: String,
stalkerDeviceProfile: String,
onStalkerDeviceProfileChange: (String) -> Unit,
stalkerDeviceTimezone: String,
@@ -862,6 +908,10 @@ private fun AdvancedProviderOptionsSection(
((sourceType == SourceType.XTREAM || sourceType == SourceType.M3U_URL || sourceType == SourceType.M3U_FILE) &&
(httpUserAgent.isNotBlank() || httpHeaders.isNotBlank())) ||
(sourceType == SourceType.STALKER && (
+ stalkerAuthMode != StalkerAuthMode.AUTO ||
+ username.isNotBlank() ||
+ password.isNotBlank() ||
+ stalkerMacAddress.isBlank() ||
stalkerDeviceProfile.isNotBlank() ||
stalkerDeviceTimezone.isNotBlank() ||
stalkerDeviceLocale.isNotBlank() ||
@@ -1069,6 +1119,65 @@ private fun AdvancedProviderOptionsSection(
}
if (sourceType == SourceType.STALKER) {
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .background(Surface, RoundedCornerShape(12.dp))
+ .border(1.dp, SurfaceHighlight, RoundedCornerShape(12.dp))
+ .padding(horizontal = 16.dp, vertical = 12.dp),
+ verticalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ Text(
+ text = "Stalker auth mode",
+ style = MaterialTheme.typography.titleSmall,
+ color = TextPrimary
+ )
+ Text(
+ text = "Auto-detect is the default. Override it only when the portal needs credentials or a mixed MAG + account login flow.",
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ StalkerAuthMode.entries.forEach { mode ->
+ StalkerAuthModeOptionRow(
+ mode = mode,
+ selected = stalkerAuthMode == mode,
+ onSelect = { onStalkerAuthModeChange(mode) }
+ )
+ }
+ }
+ if (stalkerAuthMode != StalkerAuthMode.MAC_ONLY) {
+ ProviderTextField(
+ value = username,
+ onValueChange = onUsernameChange,
+ placeholder = if (stalkerAuthMode == StalkerAuthMode.AUTO) {
+ "Portal username (optional)"
+ } else {
+ "Portal username"
+ },
+ keyboardOptions = KeyboardOptions(
+ capitalization = KeyboardCapitalization.None,
+ autoCorrectEnabled = false,
+ keyboardType = KeyboardType.Ascii,
+ imeAction = ImeAction.Next
+ )
+ )
+ ProviderTextField(
+ value = password,
+ onValueChange = onPasswordChange,
+ placeholder = if (stalkerAuthMode == StalkerAuthMode.AUTO) {
+ "Portal password (optional)"
+ } else {
+ "Portal password"
+ },
+ isPassword = true,
+ keyboardOptions = KeyboardOptions(
+ capitalization = KeyboardCapitalization.None,
+ autoCorrectEnabled = false,
+ keyboardType = KeyboardType.Password,
+ imeAction = ImeAction.Next
+ )
+ )
+ }
ProviderTextField(
value = stalkerDeviceProfile,
onValueChange = onStalkerDeviceProfileChange,
@@ -1172,6 +1281,70 @@ private fun XtreamLiveSyncModeOptionRow(
}
}
+@Composable
+private fun StalkerAuthModeOptionRow(
+ mode: StalkerAuthMode,
+ selected: Boolean,
+ onSelect: () -> Unit
+) {
+ val title = when (mode) {
+ StalkerAuthMode.AUTO -> "Auto-detect"
+ StalkerAuthMode.MAC_ONLY -> "MAC only"
+ StalkerAuthMode.MAC_PLUS_CREDENTIALS -> "MAC + credentials"
+ StalkerAuthMode.CREDENTIALS_ONLY -> "Credentials only"
+ }
+ val description = when (mode) {
+ StalkerAuthMode.AUTO -> "Try the portal's likely auth flow first and retry once if a different Stalker mode fits better."
+ StalkerAuthMode.MAC_ONLY -> "Use MAG-style MAC authentication without a portal account login."
+ StalkerAuthMode.MAC_PLUS_CREDENTIALS -> "Keep the MAG identity and add portal account credentials for stricter portals."
+ StalkerAuthMode.CREDENTIALS_ONLY -> "Use portal account credentials even if the MAC address is optional or ignored."
+ }
+ Surface(
+ onClick = onSelect,
+ modifier = Modifier
+ .fillMaxWidth()
+ .mouseClickable(onClick = onSelect),
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(10.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = if (selected) Primary.copy(alpha = 0.12f) else Color.Transparent,
+ focusedContainerColor = if (selected) Primary.copy(alpha = 0.26f) else SurfaceHighlight.copy(alpha = 0.9f)
+ ),
+ border = ClickableSurfaceDefaults.border(
+ border = Border(
+ BorderStroke(
+ 1.dp,
+ if (selected) Primary.copy(alpha = 0.45f) else Color.Transparent
+ )
+ ),
+ focusedBorder = Border(BorderStroke(3.dp, PrimaryLight))
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f)
+ ) {
+ Row(
+ modifier = Modifier.padding(horizontal = 8.dp, vertical = 8.dp),
+ horizontalArrangement = Arrangement.spacedBy(12.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ RadioButton(
+ selected = selected,
+ onClick = onSelect
+ )
+ Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
+ Text(
+ text = title,
+ style = MaterialTheme.typography.bodyMedium,
+ color = TextPrimary
+ )
+ Text(
+ text = description,
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ }
+ }
+}
+
@Composable
private fun EpgSyncModeOptionRow(
mode: ProviderEpgSyncMode,
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/provider/ProviderSetupViewModel.kt b/app/src/main/java/com/streamvault/app/ui/screens/provider/ProviderSetupViewModel.kt
index 8c684ffa..154252db 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/provider/ProviderSetupViewModel.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/provider/ProviderSetupViewModel.kt
@@ -19,6 +19,7 @@ import com.streamvault.domain.model.ActiveLiveSource
import com.streamvault.domain.model.ProviderEpgSyncMode
import com.streamvault.domain.model.ProviderXtreamLiveSyncMode
import com.streamvault.domain.model.ProviderType
+import com.streamvault.domain.model.StalkerAuthMode
import com.streamvault.domain.repository.CombinedM3uRepository
import com.streamvault.domain.repository.ProviderRepository
import com.streamvault.domain.usecase.ImportBackup
@@ -196,6 +197,7 @@ class ProviderSetupViewModel @Inject constructor(
httpUserAgent = provider.httpUserAgent,
httpHeaders = provider.httpHeaders,
stalkerMacAddress = provider.stalkerMacAddress,
+ stalkerAuthMode = provider.stalkerAuthMode,
stalkerDeviceProfile = provider.stalkerDeviceProfile,
stalkerDeviceTimezone = provider.stalkerDeviceTimezone,
stalkerDeviceLocale = provider.stalkerDeviceLocale,
@@ -250,6 +252,9 @@ class ProviderSetupViewModel @Inject constructor(
fun loginStalker(
portalUrl: String,
macAddress: String,
+ authMode: StalkerAuthMode,
+ username: String,
+ password: String,
name: String,
deviceProfile: String,
timezone: String,
@@ -277,6 +282,9 @@ class ProviderSetupViewModel @Inject constructor(
StalkerProviderSetupCommand(
portalUrl = portalUrl,
macAddress = macAddress,
+ authMode = authMode,
+ username = username,
+ password = password,
name = name,
deviceProfile = deviceProfile,
timezone = timezone,
@@ -746,6 +754,18 @@ class ProviderSetupViewModel @Inject constructor(
}
val failure = result.exception
return when {
+ result.message.contains("requires account credentials", ignoreCase = true) ->
+ "Portal requires account credentials - switch the Stalker auth mode or add the username and password"
+
+ result.message.contains("partially accepted MAC identity", ignoreCase = true) ->
+ "Portal accepted the MAC address, but playback entitlement is incomplete for this session"
+
+ result.message.contains("stricter MAG emulation", ignoreCase = true) ->
+ "Portal requires stricter MAG emulation - keep the MAC and advanced device identity fields aligned with the working device"
+
+ result.message.contains("unsupported portal profile", ignoreCase = true) ->
+ "Portal authenticated, but this Stalker profile is not supported yet"
+
failure.hasCause<CredentialDecryptionException>() ->
failure.findCause<CredentialDecryptionException>()?.message
?: CredentialDecryptionException.MESSAGE
@@ -806,6 +826,7 @@ data class ProviderSetupState(
val httpUserAgent: String = "",
val httpHeaders: String = "",
val stalkerMacAddress: String = "",
+ val stalkerAuthMode: StalkerAuthMode = StalkerAuthMode.AUTO,
val stalkerDeviceProfile: String = "",
val stalkerDeviceTimezone: String = "",
val stalkerDeviceLocale: String = "",
diff --git a/app/src/test/java/com/streamvault/app/ui/screens/player/PlayerPlaybackProbeSupportTest.kt b/app/src/test/java/com/streamvault/app/ui/screens/player/PlayerPlaybackProbeSupportTest.kt
new file mode 100644
index 00000000..12374ea9
--- /dev/null
+++ b/app/src/test/java/com/streamvault/app/ui/screens/player/PlayerPlaybackProbeSupportTest.kt
@@ -0,0 +1,16 @@
+package com.streamvault.app.ui.screens.player
+
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+
+class PlayerPlaybackProbeSupportTest {
+
+ @Test
+ fun `204 maps to empty temporary link failure`() {
+ val failure = resolvePlaybackProbeFailure(204)
+
+ assertThat(failure).isNotNull()
+ assertThat(failure?.recoveryType).isEqualTo(PlayerRecoveryType.SOURCE)
+ assertThat(failure?.message).contains("empty temporary link")
+ }
+}
diff --git a/app/src/test/java/com/streamvault/app/ui/screens/provider/ProviderSetupViewModelTest.kt b/app/src/test/java/com/streamvault/app/ui/screens/provider/ProviderSetupViewModelTest.kt
index 3fdf72d8..c1b7a635 100644
--- a/app/src/test/java/com/streamvault/app/ui/screens/provider/ProviderSetupViewModelTest.kt
+++ b/app/src/test/java/com/streamvault/app/ui/screens/provider/ProviderSetupViewModelTest.kt
@@ -6,6 +6,7 @@ import com.streamvault.domain.model.CombinedM3uProfile
import com.streamvault.domain.model.Provider
import com.streamvault.domain.model.ProviderEpgSyncMode
import com.streamvault.domain.model.ProviderType
+import com.streamvault.domain.model.StalkerAuthMode
import com.streamvault.domain.repository.CombinedM3uRepository
import com.streamvault.domain.repository.ProviderRepository
import com.streamvault.domain.manager.BackupImportPlan
@@ -390,6 +391,9 @@ class ProviderSetupViewModelTest {
viewModel.loginStalker(
portalUrl = "https://portal.example.com",
macAddress = "00:1A:79:12:34:56",
+ authMode = StalkerAuthMode.AUTO,
+ username = "",
+ password = "",
name = "MAG",
deviceProfile = "MAG250",
timezone = "UTC",
diff --git a/data/schemas/com.streamvault.data.local.StreamVaultDatabase/54.json b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/54.json
index dca96f5e..66a26932 100644
--- a/data/schemas/com.streamvault.data.local.StreamVaultDatabase/54.json
+++ b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/54.json
@@ -2,11 +2,11 @@
"formatVersion": 1,
"database": {
"version": 54,
- "identityHash": "8912f51da9e21a7ff428a90ea975ef78",
+ "identityHash": "2a71b96adf0a77ffe760c7204a475ed0",
"entities": [
{
"tableName": "providers",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `type` TEXT NOT NULL, `server_url` TEXT NOT NULL, `username` TEXT NOT NULL, `password` TEXT NOT NULL, `m3u_url` TEXT NOT NULL, `epg_url` TEXT NOT NULL, `http_user_agent` TEXT NOT NULL, `http_headers` TEXT NOT NULL, `stalker_mac_address` TEXT NOT NULL, `stalker_device_profile` TEXT NOT NULL, `stalker_device_timezone` TEXT NOT NULL, `stalker_device_locale` TEXT NOT NULL, `stalker_serial_number` TEXT NOT NULL, `stalker_device_id` TEXT NOT NULL, `stalker_device_id2` TEXT NOT NULL, `stalker_signature` TEXT NOT NULL, `is_active` INTEGER NOT NULL, `max_connections` INTEGER NOT NULL, `expiration_date` INTEGER, `api_version` TEXT, `allowed_output_formats_json` TEXT NOT NULL, `epg_sync_mode` TEXT NOT NULL, `xtream_fast_sync_enabled` INTEGER NOT NULL, `xtream_live_sync_mode` TEXT NOT NULL, `m3u_vod_classification_enabled` INTEGER NOT NULL, `status` TEXT NOT NULL, `last_synced_at` INTEGER NOT NULL, `created_at` INTEGER NOT NULL)",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `type` TEXT NOT NULL, `server_url` TEXT NOT NULL, `username` TEXT NOT NULL, `password` TEXT NOT NULL, `m3u_url` TEXT NOT NULL, `epg_url` TEXT NOT NULL, `http_user_agent` TEXT NOT NULL, `http_headers` TEXT NOT NULL, `stalker_mac_address` TEXT NOT NULL, `stalker_device_profile` TEXT NOT NULL, `stalker_device_timezone` TEXT NOT NULL, `stalker_device_locale` TEXT NOT NULL, `stalker_serial_number` TEXT NOT NULL, `stalker_device_id` TEXT NOT NULL, `stalker_device_id2` TEXT NOT NULL, `stalker_signature` TEXT NOT NULL, `stalker_auth_mode` TEXT NOT NULL, `stalker_portal_profile` TEXT NOT NULL, `stalker_last_playback_mode` TEXT, `stalker_credentials_required` INTEGER NOT NULL, `stalker_mac_required` INTEGER NOT NULL, `stalker_uses_temp_links` INTEGER NOT NULL, `stalker_module_restricted` INTEGER NOT NULL, `is_active` INTEGER NOT NULL, `max_connections` INTEGER NOT NULL, `expiration_date` INTEGER, `api_version` TEXT, `allowed_output_formats_json` TEXT NOT NULL, `epg_sync_mode` TEXT NOT NULL, `xtream_fast_sync_enabled` INTEGER NOT NULL, `xtream_live_sync_mode` TEXT NOT NULL, `m3u_vod_classification_enabled` INTEGER NOT NULL, `status` TEXT NOT NULL, `last_synced_at` INTEGER NOT NULL, `created_at` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
@@ -116,6 +116,47 @@
"affinity": "TEXT",
"notNull": true
},
+ {
+ "fieldPath": "stalkerAuthMode",
+ "columnName": "stalker_auth_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerPortalProfile",
+ "columnName": "stalker_portal_profile",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerLastPlaybackMode",
+ "columnName": "stalker_last_playback_mode",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "stalkerCredentialsRequired",
+ "columnName": "stalker_credentials_required",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerMacRequired",
+ "columnName": "stalker_mac_required",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerUsesTemporaryLinks",
+ "columnName": "stalker_uses_temp_links",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerModuleRestricted",
+ "columnName": "stalker_module_restricted",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
{
"fieldPath": "isActive",
"columnName": "is_active",
@@ -5075,7 +5116,7 @@
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
- "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '8912f51da9e21a7ff428a90ea975ef78')"
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '2a71b96adf0a77ffe760c7204a475ed0')"
]
}
}
\ No newline at end of file
diff --git a/data/schemas/com.streamvault.data.local.StreamVaultDatabase/55.json b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/55.json
new file mode 100644
index 00000000..8b36cd3b
--- /dev/null
+++ b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/55.json
@@ -0,0 +1,5122 @@
+{
+ "formatVersion": 1,
+ "database": {
+ "version": 55,
+ "identityHash": "2a71b96adf0a77ffe760c7204a475ed0",
+ "entities": [
+ {
+ "tableName": "providers",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `type` TEXT NOT NULL, `server_url` TEXT NOT NULL, `username` TEXT NOT NULL, `password` TEXT NOT NULL, `m3u_url` TEXT NOT NULL, `epg_url` TEXT NOT NULL, `http_user_agent` TEXT NOT NULL, `http_headers` TEXT NOT NULL, `stalker_mac_address` TEXT NOT NULL, `stalker_device_profile` TEXT NOT NULL, `stalker_device_timezone` TEXT NOT NULL, `stalker_device_locale` TEXT NOT NULL, `stalker_serial_number` TEXT NOT NULL, `stalker_device_id` TEXT NOT NULL, `stalker_device_id2` TEXT NOT NULL, `stalker_signature` TEXT NOT NULL, `stalker_auth_mode` TEXT NOT NULL, `stalker_portal_profile` TEXT NOT NULL, `stalker_last_playback_mode` TEXT, `stalker_credentials_required` INTEGER NOT NULL, `stalker_mac_required` INTEGER NOT NULL, `stalker_uses_temp_links` INTEGER NOT NULL, `stalker_module_restricted` INTEGER NOT NULL, `is_active` INTEGER NOT NULL, `max_connections` INTEGER NOT NULL, `expiration_date` INTEGER, `api_version` TEXT, `allowed_output_formats_json` TEXT NOT NULL, `epg_sync_mode` TEXT NOT NULL, `xtream_fast_sync_enabled` INTEGER NOT NULL, `xtream_live_sync_mode` TEXT NOT NULL, `m3u_vod_classification_enabled` INTEGER NOT NULL, `status` TEXT NOT NULL, `last_synced_at` INTEGER NOT NULL, `created_at` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "serverUrl",
+ "columnName": "server_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "username",
+ "columnName": "username",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "password",
+ "columnName": "password",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "m3uUrl",
+ "columnName": "m3u_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgUrl",
+ "columnName": "epg_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "httpUserAgent",
+ "columnName": "http_user_agent",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "httpHeaders",
+ "columnName": "http_headers",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerMacAddress",
+ "columnName": "stalker_mac_address",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceProfile",
+ "columnName": "stalker_device_profile",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceTimezone",
+ "columnName": "stalker_device_timezone",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceLocale",
+ "columnName": "stalker_device_locale",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerSerialNumber",
+ "columnName": "stalker_serial_number",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceId",
+ "columnName": "stalker_device_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceId2",
+ "columnName": "stalker_device_id2",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerSignature",
+ "columnName": "stalker_signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerAuthMode",
+ "columnName": "stalker_auth_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerPortalProfile",
+ "columnName": "stalker_portal_profile",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerLastPlaybackMode",
+ "columnName": "stalker_last_playback_mode",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "stalkerCredentialsRequired",
+ "columnName": "stalker_credentials_required",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerMacRequired",
+ "columnName": "stalker_mac_required",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerUsesTemporaryLinks",
+ "columnName": "stalker_uses_temp_links",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerModuleRestricted",
+ "columnName": "stalker_module_restricted",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isActive",
+ "columnName": "is_active",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "maxConnections",
+ "columnName": "max_connections",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "expirationDate",
+ "columnName": "expiration_date",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "apiVersion",
+ "columnName": "api_version",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "allowedOutputFormatsJson",
+ "columnName": "allowed_output_formats_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSyncMode",
+ "columnName": "epg_sync_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xtreamFastSyncEnabled",
+ "columnName": "xtream_fast_sync_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xtreamLiveSyncMode",
+ "columnName": "xtream_live_sync_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "m3uVodClassificationEnabled",
+ "columnName": "m3u_vod_classification_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSyncedAt",
+ "columnName": "last_synced_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_providers_server_url_username_stalker_mac_address",
+ "unique": true,
+ "columnNames": [
+ "server_url",
+ "username",
+ "stalker_mac_address"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_providers_server_url_username_stalker_mac_address` ON `${TABLE_NAME}` (`server_url`, `username`, `stalker_mac_address`)"
+ }
+ ]
+ },
+ {
+ "tableName": "channels",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `logo_url` TEXT, `group_title` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `epg_channel_id` TEXT, `number` INTEGER NOT NULL, `catch_up_supported` INTEGER NOT NULL, `catch_up_days` INTEGER NOT NULL, `catchUpSource` TEXT, `provider_id` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `logical_group_id` TEXT NOT NULL, `error_count` INTEGER NOT NULL, `quality_options_json` TEXT, `sync_fingerprint` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logoUrl",
+ "columnName": "logo_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupTitle",
+ "columnName": "group_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgChannelId",
+ "columnName": "epg_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "number",
+ "columnName": "number",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSupported",
+ "columnName": "catch_up_supported",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpDays",
+ "columnName": "catch_up_days",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSource",
+ "columnName": "catchUpSource",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logicalGroupId",
+ "columnName": "logical_group_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "errorCount",
+ "columnName": "error_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "qualityOptionsJson",
+ "columnName": "quality_options_json",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channels_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_category_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id_category_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_stream_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "stream_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channels_provider_id_stream_id` ON `${TABLE_NAME}` (`provider_id`, `stream_id`)"
+ },
+ {
+ "name": "index_channels_logical_group_id",
+ "unique": false,
+ "columnNames": [
+ "logical_group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_logical_group_id` ON `${TABLE_NAME}` (`logical_group_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_category_id_logical_group_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id",
+ "logical_group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id_category_id_logical_group_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`, `logical_group_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channel_preferences",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `channel_id` INTEGER NOT NULL, `aspect_ratio` TEXT, `audio_video_offset_ms` INTEGER, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`channel_id`) REFERENCES `channels`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "aspectRatio",
+ "columnName": "aspect_ratio",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "audioVideoOffsetMs",
+ "columnName": "audio_video_offset_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_preferences_channel_id",
+ "unique": true,
+ "columnNames": [
+ "channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channel_preferences_channel_id` ON `${TABLE_NAME}` (`channel_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "channels",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "channel_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channels_fts",
+ "createSql": "CREATE VIRTUAL TABLE IF NOT EXISTS `${TABLE_NAME}` USING FTS4(`name` TEXT NOT NULL, content=`channels`)",
+ "fields": [
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": []
+ },
+ "ftsVersion": "FTS4",
+ "ftsOptions": {
+ "tokenizer": "simple",
+ "tokenizerArgs": [],
+ "contentTable": "channels",
+ "languageIdColumnName": "",
+ "matchInfo": "FTS4",
+ "notIndexedColumns": [],
+ "prefixSizes": [],
+ "preferredOrder": "ASC"
+ },
+ "contentSyncTriggers": [
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_BEFORE_UPDATE BEFORE UPDATE ON `channels` BEGIN DELETE FROM `channels_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_BEFORE_DELETE BEFORE DELETE ON `channels` BEGIN DELETE FROM `channels_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_AFTER_UPDATE AFTER UPDATE ON `channels` BEGIN INSERT INTO `channels_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_AFTER_INSERT AFTER INSERT ON `channels` BEGIN INSERT INTO `channels_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END"
+ ]
+ },
+ {
+ "tableName": "movies",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `container_extension` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `duration` TEXT, `duration_seconds` INTEGER NOT NULL, `rating` REAL NOT NULL, `year` TEXT, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `provider_id` INTEGER NOT NULL, `watch_progress` INTEGER NOT NULL, `watch_count` INTEGER NOT NULL, `last_watched_at` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, `added_at` INTEGER NOT NULL, `cache_state` TEXT NOT NULL, `detail_hydrated_at` INTEGER NOT NULL, `remote_stale_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "duration",
+ "columnName": "duration",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "durationSeconds",
+ "columnName": "duration_seconds",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "year",
+ "columnName": "year",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchProgress",
+ "columnName": "watch_progress",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchCount",
+ "columnName": "watch_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastWatchedAt",
+ "columnName": "last_watched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "cacheState",
+ "columnName": "cache_state",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "detailHydratedAt",
+ "columnName": "detail_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "remoteStaleAt",
+ "columnName": "remote_stale_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_movies_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movies_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_movies_provider_id_category_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movies_provider_id_category_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`)"
+ },
+ {
+ "name": "index_movies_provider_id_stream_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "stream_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_movies_provider_id_stream_id` ON `${TABLE_NAME}` (`provider_id`, `stream_id`)"
+ },
+ {
+ "name": "index_movies_provider_id_name_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "name",
+ "id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movies_provider_id_name_id` ON `${TABLE_NAME}` (`provider_id`, `name`, `id`)"
+ },
+ {
+ "name": "index_movies_provider_id_category_id_name_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id",
+ "name",
+ "id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movies_provider_id_category_id_name_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`, `name`, `id`)"
+ },
+ {
+ "name": "index_movies_provider_id_rating_name_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "rating",
+ "name",
+ "id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movies_provider_id_rating_name_id` ON `${TABLE_NAME}` (`provider_id`, `rating`, `name`, `id`)"
+ },
+ {
+ "name": "index_movies_provider_id_added_at_release_date_name_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "added_at",
+ "release_date",
+ "name",
+ "id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movies_provider_id_added_at_release_date_name_id` ON `${TABLE_NAME}` (`provider_id`, `added_at`, `release_date`, `name`, `id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "movies_fts",
+ "createSql": "CREATE VIRTUAL TABLE IF NOT EXISTS `${TABLE_NAME}` USING FTS4(`name` TEXT NOT NULL, content=`movies`)",
+ "fields": [
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": []
+ },
+ "ftsVersion": "FTS4",
+ "ftsOptions": {
+ "tokenizer": "simple",
+ "tokenizerArgs": [],
+ "contentTable": "movies",
+ "languageIdColumnName": "",
+ "matchInfo": "FTS4",
+ "notIndexedColumns": [],
+ "prefixSizes": [],
+ "preferredOrder": "ASC"
+ },
+ "contentSyncTriggers": [
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_movies_fts_BEFORE_UPDATE BEFORE UPDATE ON `movies` BEGIN DELETE FROM `movies_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_movies_fts_BEFORE_DELETE BEFORE DELETE ON `movies` BEGIN DELETE FROM `movies_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_movies_fts_AFTER_UPDATE AFTER UPDATE ON `movies` BEGIN INSERT INTO `movies_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_movies_fts_AFTER_INSERT AFTER INSERT ON `movies` BEGIN INSERT INTO `movies_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END"
+ ]
+ },
+ {
+ "tableName": "series",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `series_id` INTEGER NOT NULL, `provider_series_id` TEXT, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `rating` REAL NOT NULL, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `episode_run_time` TEXT, `last_modified` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, `cache_state` TEXT NOT NULL, `detail_hydrated_at` INTEGER NOT NULL, `remote_stale_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesId",
+ "columnName": "series_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerSeriesId",
+ "columnName": "provider_series_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "episodeRunTime",
+ "columnName": "episode_run_time",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastModified",
+ "columnName": "last_modified",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "cacheState",
+ "columnName": "cache_state",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "detailHydratedAt",
+ "columnName": "detail_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "remoteStaleAt",
+ "columnName": "remote_stale_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_series_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_series_provider_id_category_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_provider_id_category_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`)"
+ },
+ {
+ "name": "index_series_provider_id_series_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "series_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_series_provider_id_series_id` ON `${TABLE_NAME}` (`provider_id`, `series_id`)"
+ },
+ {
+ "name": "index_series_provider_id_name_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "name",
+ "id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_provider_id_name_id` ON `${TABLE_NAME}` (`provider_id`, `name`, `id`)"
+ },
+ {
+ "name": "index_series_provider_id_category_id_name_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id",
+ "name",
+ "id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_provider_id_category_id_name_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`, `name`, `id`)"
+ },
+ {
+ "name": "index_series_provider_id_rating_name_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "rating",
+ "name",
+ "id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_provider_id_rating_name_id` ON `${TABLE_NAME}` (`provider_id`, `rating`, `name`, `id`)"
+ },
+ {
+ "name": "index_series_provider_id_last_modified_name_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "last_modified",
+ "name",
+ "id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_provider_id_last_modified_name_id` ON `${TABLE_NAME}` (`provider_id`, `last_modified`, `name`, `id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "series_fts",
+ "createSql": "CREATE VIRTUAL TABLE IF NOT EXISTS `${TABLE_NAME}` USING FTS4(`name` TEXT NOT NULL, content=`series`)",
+ "fields": [
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": []
+ },
+ "ftsVersion": "FTS4",
+ "ftsOptions": {
+ "tokenizer": "simple",
+ "tokenizerArgs": [],
+ "contentTable": "series",
+ "languageIdColumnName": "",
+ "matchInfo": "FTS4",
+ "notIndexedColumns": [],
+ "prefixSizes": [],
+ "preferredOrder": "ASC"
+ },
+ "contentSyncTriggers": [
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_series_fts_BEFORE_UPDATE BEFORE UPDATE ON `series` BEGIN DELETE FROM `series_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_series_fts_BEFORE_DELETE BEFORE DELETE ON `series` BEGIN DELETE FROM `series_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_series_fts_AFTER_UPDATE AFTER UPDATE ON `series` BEGIN INSERT INTO `series_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_series_fts_AFTER_INSERT AFTER INSERT ON `series` BEGIN INSERT INTO `series_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END"
+ ]
+ },
+ {
+ "tableName": "episodes",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `episode_id` INTEGER NOT NULL, `title` TEXT NOT NULL, `episode_number` INTEGER NOT NULL, `season_number` INTEGER NOT NULL, `stream_url` TEXT NOT NULL, `container_extension` TEXT, `cover_url` TEXT, `plot` TEXT, `duration` TEXT, `duration_seconds` INTEGER NOT NULL, `rating` REAL NOT NULL, `release_date` TEXT, `series_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `watch_progress` INTEGER NOT NULL, `last_watched_at` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`series_id`) REFERENCES `series`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "episodeId",
+ "columnName": "episode_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "episodeNumber",
+ "columnName": "episode_number",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seasonNumber",
+ "columnName": "season_number",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "coverUrl",
+ "columnName": "cover_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "duration",
+ "columnName": "duration",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "durationSeconds",
+ "columnName": "duration_seconds",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "seriesId",
+ "columnName": "series_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchProgress",
+ "columnName": "watch_progress",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastWatchedAt",
+ "columnName": "last_watched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_episodes_series_id",
+ "unique": false,
+ "columnNames": [
+ "series_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_episodes_series_id` ON `${TABLE_NAME}` (`series_id`)"
+ },
+ {
+ "name": "index_episodes_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_episodes_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_episodes_provider_id_episode_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "episode_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_episodes_provider_id_episode_id` ON `${TABLE_NAME}` (`provider_id`, `episode_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "series",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "series_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "categories",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `category_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `parent_id` INTEGER, `type` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "parentId",
+ "columnName": "parent_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_categories_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_categories_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_categories_provider_id_type",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_categories_provider_id_type` ON `${TABLE_NAME}` (`provider_id`, `type`)"
+ },
+ {
+ "name": "index_categories_provider_id_category_id_type",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "category_id",
+ "type"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_categories_provider_id_category_id_type` ON `${TABLE_NAME}` (`provider_id`, `category_id`, `type`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channel_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `logo_url` TEXT, `group_title` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `epg_channel_id` TEXT, `number` INTEGER NOT NULL, `catch_up_supported` INTEGER NOT NULL, `catch_up_days` INTEGER NOT NULL, `catchUpSource` TEXT, `is_adult` INTEGER NOT NULL, `logical_group_id` TEXT NOT NULL, `error_count` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `stream_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logoUrl",
+ "columnName": "logo_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupTitle",
+ "columnName": "group_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgChannelId",
+ "columnName": "epg_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "number",
+ "columnName": "number",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSupported",
+ "columnName": "catch_up_supported",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpDays",
+ "columnName": "catch_up_days",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSource",
+ "columnName": "catchUpSource",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logicalGroupId",
+ "columnName": "logical_group_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "errorCount",
+ "columnName": "error_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "stream_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_channel_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "movie_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `container_extension` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `duration` TEXT, `duration_seconds` INTEGER NOT NULL, `rating` REAL NOT NULL, `year` TEXT, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, `added_at` INTEGER NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `stream_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "duration",
+ "columnName": "duration",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "durationSeconds",
+ "columnName": "duration_seconds",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "year",
+ "columnName": "year",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "stream_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_movie_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_movie_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "series_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `series_id` INTEGER NOT NULL, `provider_series_id` TEXT, `provider_series_key` TEXT NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `rating` REAL NOT NULL, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `episode_run_time` TEXT, `last_modified` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `provider_series_key`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesId",
+ "columnName": "series_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerSeriesId",
+ "columnName": "provider_series_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "providerSeriesKey",
+ "columnName": "provider_series_key",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "episodeRunTime",
+ "columnName": "episode_run_time",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastModified",
+ "columnName": "last_modified",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "provider_series_key"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_series_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_series_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "category_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `parent_id` INTEGER, `type` TEXT NOT NULL, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `category_id`, `type`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "parentId",
+ "columnName": "parent_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "category_id",
+ "type"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_category_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_category_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_category_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_category_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ },
+ {
+ "name": "index_category_import_stage_provider_id_type",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_category_import_stage_provider_id_type` ON `${TABLE_NAME}` (`provider_id`, `type`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "programs",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` TEXT NOT NULL, `title` TEXT NOT NULL, `description` TEXT NOT NULL, `start_time` INTEGER NOT NULL, `end_time` INTEGER NOT NULL, `lang` TEXT NOT NULL, `rating` TEXT, `image_url` TEXT, `genre` TEXT, `category` TEXT, `has_archive` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "startTime",
+ "columnName": "start_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "endTime",
+ "columnName": "end_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lang",
+ "columnName": "lang",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "imageUrl",
+ "columnName": "image_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "category",
+ "columnName": "category",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "hasArchive",
+ "columnName": "has_archive",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_programs_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_programs_provider_id_channel_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_channel_id` ON `${TABLE_NAME}` (`provider_id`, `channel_id`)"
+ },
+ {
+ "name": "index_programs_provider_id_end_time_channel_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "end_time",
+ "channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_end_time_channel_id` ON `${TABLE_NAME}` (`provider_id`, `end_time`, `channel_id`)"
+ },
+ {
+ "name": "index_programs_provider_id_start_time_end_time",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "start_time",
+ "end_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_start_time_end_time` ON `${TABLE_NAME}` (`provider_id`, `start_time`, `end_time`)"
+ },
+ {
+ "name": "index_programs_start_time",
+ "unique": false,
+ "columnNames": [
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_start_time` ON `${TABLE_NAME}` (`start_time`)"
+ },
+ {
+ "name": "index_programs_provider_id_channel_id_start_time",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_channel_id_start_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `start_time`)"
+ },
+ {
+ "name": "index_programs_provider_id_channel_id_start_time_end_time",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "start_time",
+ "end_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_programs_provider_id_channel_id_start_time_end_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `start_time`, `end_time`)"
+ }
+ ]
+ },
+ {
+ "tableName": "favorites",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `content_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `position` INTEGER NOT NULL, `group_id` INTEGER, `group_key` INTEGER NOT NULL, `added_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`group_id`) REFERENCES `virtual_groups`(`id`) ON UPDATE NO ACTION ON DELETE SET NULL )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentId",
+ "columnName": "content_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "position",
+ "columnName": "position",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "groupId",
+ "columnName": "group_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "groupKey",
+ "columnName": "group_key",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_favorites_provider_id_content_id_content_type_group_key",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "content_id",
+ "content_type",
+ "group_key"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_favorites_provider_id_content_id_content_type_group_key` ON `${TABLE_NAME}` (`provider_id`, `content_id`, `content_type`, `group_key`)"
+ },
+ {
+ "name": "index_favorites_provider_id_content_type_group_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type",
+ "group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_favorites_provider_id_content_type_group_id` ON `${TABLE_NAME}` (`provider_id`, `content_type`, `group_id`)"
+ },
+ {
+ "name": "index_favorites_group_id_position",
+ "unique": false,
+ "columnNames": [
+ "group_id",
+ "position"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_favorites_group_id_position` ON `${TABLE_NAME}` (`group_id`, `position`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "virtual_groups",
+ "onDelete": "SET NULL",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "group_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "virtual_groups",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `icon_emoji` TEXT, `position` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `content_type` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "iconEmoji",
+ "columnName": "icon_emoji",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "position",
+ "columnName": "position",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_virtual_groups_provider_id_content_type",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_virtual_groups_provider_id_content_type` ON `${TABLE_NAME}` (`provider_id`, `content_type`)"
+ },
+ {
+ "name": "index_virtual_groups_position",
+ "unique": false,
+ "columnNames": [
+ "position"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_virtual_groups_position` ON `${TABLE_NAME}` (`position`)"
+ },
+ {
+ "name": "index_virtual_groups_content_type",
+ "unique": false,
+ "columnNames": [
+ "content_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_virtual_groups_content_type` ON `${TABLE_NAME}` (`content_type`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "playback_history",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `content_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `title` TEXT NOT NULL, `poster_url` TEXT, `stream_url` TEXT NOT NULL, `resume_position_ms` INTEGER NOT NULL, `total_duration_ms` INTEGER NOT NULL, `last_watched_at` INTEGER NOT NULL, `watch_count` INTEGER NOT NULL, `watched_status` TEXT NOT NULL, `series_id` INTEGER, `season_number` INTEGER, `episode_number` INTEGER, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentId",
+ "columnName": "content_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "resumePositionMs",
+ "columnName": "resume_position_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalDurationMs",
+ "columnName": "total_duration_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastWatchedAt",
+ "columnName": "last_watched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchCount",
+ "columnName": "watch_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchedStatus",
+ "columnName": "watched_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesId",
+ "columnName": "series_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "seasonNumber",
+ "columnName": "season_number",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "episodeNumber",
+ "columnName": "episode_number",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_playback_history_content_id_content_type_provider_id",
+ "unique": true,
+ "columnNames": [
+ "content_id",
+ "content_type",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_playback_history_content_id_content_type_provider_id` ON `${TABLE_NAME}` (`content_id`, `content_type`, `provider_id`)"
+ },
+ {
+ "name": "index_playback_history_last_watched_at",
+ "unique": false,
+ "columnNames": [
+ "last_watched_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_history_last_watched_at` ON `${TABLE_NAME}` (`last_watched_at`)"
+ },
+ {
+ "name": "index_playback_history_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_history_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_playback_history_provider_id_content_type_content_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type",
+ "content_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_history_provider_id_content_type_content_id` ON `${TABLE_NAME}` (`provider_id`, `content_type`, `content_id`)"
+ },
+ {
+ "name": "index_playback_history_provider_id_content_type_last_watched_at",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type",
+ "last_watched_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_history_provider_id_content_type_last_watched_at` ON `${TABLE_NAME}` (`provider_id`, `content_type`, `last_watched_at`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "tmdb_identity",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`tmdb_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `canonical_provider_id` INTEGER NOT NULL, `first_seen_at` INTEGER NOT NULL, PRIMARY KEY(`tmdb_id`, `content_type`), FOREIGN KEY(`canonical_provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "canonicalProviderId",
+ "columnName": "canonical_provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "firstSeenAt",
+ "columnName": "first_seen_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "tmdb_id",
+ "content_type"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_tmdb_identity_content_type",
+ "unique": false,
+ "columnNames": [
+ "content_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_tmdb_identity_content_type` ON `${TABLE_NAME}` (`content_type`)"
+ },
+ {
+ "name": "index_tmdb_identity_canonical_provider_id",
+ "unique": false,
+ "columnNames": [
+ "canonical_provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_tmdb_identity_canonical_provider_id` ON `${TABLE_NAME}` (`canonical_provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "canonical_provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "search_history",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `query` TEXT NOT NULL, `content_scope` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `used_at` INTEGER NOT NULL, `use_count` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "query",
+ "columnName": "query",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentScope",
+ "columnName": "content_scope",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "usedAt",
+ "columnName": "used_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "useCount",
+ "columnName": "use_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_search_history_content_scope_provider_id_used_at",
+ "unique": false,
+ "columnNames": [
+ "content_scope",
+ "provider_id",
+ "used_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_search_history_content_scope_provider_id_used_at` ON `${TABLE_NAME}` (`content_scope`, `provider_id`, `used_at`)"
+ },
+ {
+ "name": "index_search_history_used_at",
+ "unique": false,
+ "columnNames": [
+ "used_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_search_history_used_at` ON `${TABLE_NAME}` (`used_at`)"
+ },
+ {
+ "name": "index_search_history_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_search_history_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_search_history_query_content_scope_provider_id",
+ "unique": true,
+ "columnNames": [
+ "query",
+ "content_scope",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_search_history_query_content_scope_provider_id` ON `${TABLE_NAME}` (`query`, `content_scope`, `provider_id`)"
+ }
+ ]
+ },
+ {
+ "tableName": "sync_metadata",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `last_live_sync` INTEGER NOT NULL, `last_live_success` INTEGER NOT NULL, `last_movie_sync` INTEGER NOT NULL, `last_series_sync` INTEGER NOT NULL, `last_series_success` INTEGER NOT NULL, `last_epg_sync` INTEGER NOT NULL, `last_epg_success` INTEGER NOT NULL, `last_movie_attempt` INTEGER NOT NULL, `last_movie_success` INTEGER NOT NULL, `last_movie_partial` INTEGER NOT NULL, `live_count` INTEGER NOT NULL, `movie_count` INTEGER NOT NULL, `series_count` INTEGER NOT NULL, `epg_count` INTEGER NOT NULL, `last_sync_status` TEXT NOT NULL, `movie_sync_mode` TEXT NOT NULL, `movie_warnings_count` INTEGER NOT NULL, `movie_catalog_stale` INTEGER NOT NULL, `live_avoid_full_until` INTEGER NOT NULL, `movie_avoid_full_until` INTEGER NOT NULL, `series_avoid_full_until` INTEGER NOT NULL, `live_sequential_failures_remembered` INTEGER NOT NULL, `live_healthy_sync_streak` INTEGER NOT NULL, `movie_parallel_failures_remembered` INTEGER NOT NULL, `movie_healthy_sync_streak` INTEGER NOT NULL, `series_sequential_failures_remembered` INTEGER NOT NULL, `series_healthy_sync_streak` INTEGER NOT NULL, PRIMARY KEY(`provider_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastLiveSync",
+ "columnName": "last_live_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastLiveSuccess",
+ "columnName": "last_live_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMovieSync",
+ "columnName": "last_movie_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSeriesSync",
+ "columnName": "last_series_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSeriesSuccess",
+ "columnName": "last_series_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastEpgSync",
+ "columnName": "last_epg_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastEpgSuccess",
+ "columnName": "last_epg_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMovieAttempt",
+ "columnName": "last_movie_attempt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMovieSuccess",
+ "columnName": "last_movie_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMoviePartial",
+ "columnName": "last_movie_partial",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveCount",
+ "columnName": "live_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieCount",
+ "columnName": "movie_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesCount",
+ "columnName": "series_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgCount",
+ "columnName": "epg_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSyncStatus",
+ "columnName": "last_sync_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieSyncMode",
+ "columnName": "movie_sync_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieWarningsCount",
+ "columnName": "movie_warnings_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieCatalogStale",
+ "columnName": "movie_catalog_stale",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveAvoidFullUntil",
+ "columnName": "live_avoid_full_until",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieAvoidFullUntil",
+ "columnName": "movie_avoid_full_until",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesAvoidFullUntil",
+ "columnName": "series_avoid_full_until",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveSequentialFailuresRemembered",
+ "columnName": "live_sequential_failures_remembered",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveHealthySyncStreak",
+ "columnName": "live_healthy_sync_streak",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieParallelFailuresRemembered",
+ "columnName": "movie_parallel_failures_remembered",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieHealthySyncStreak",
+ "columnName": "movie_healthy_sync_streak",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesSequentialFailuresRemembered",
+ "columnName": "series_sequential_failures_remembered",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesHealthySyncStreak",
+ "columnName": "series_healthy_sync_streak",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "movie_category_hydration",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `last_hydrated_at` INTEGER NOT NULL, `item_count` INTEGER NOT NULL, `last_status` TEXT NOT NULL, `last_error` TEXT, `last_loaded_page` INTEGER NOT NULL, `last_attempted_page` INTEGER NOT NULL, `last_successful_page` INTEGER NOT NULL, `total_pages` INTEGER NOT NULL, `is_complete` INTEGER NOT NULL, `page_size` INTEGER NOT NULL, `retry_after_ms` INTEGER NOT NULL, `failure_count` INTEGER NOT NULL, `retry_budget_remaining` INTEGER NOT NULL, `last_page_fingerprint` TEXT, PRIMARY KEY(`provider_id`, `category_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastHydratedAt",
+ "columnName": "last_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemCount",
+ "columnName": "item_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastStatus",
+ "columnName": "last_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastLoadedPage",
+ "columnName": "last_loaded_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastAttemptedPage",
+ "columnName": "last_attempted_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSuccessfulPage",
+ "columnName": "last_successful_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalPages",
+ "columnName": "total_pages",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isComplete",
+ "columnName": "is_complete",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "pageSize",
+ "columnName": "page_size",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryAfterMs",
+ "columnName": "retry_after_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureCount",
+ "columnName": "failure_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryBudgetRemaining",
+ "columnName": "retry_budget_remaining",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastPageFingerprint",
+ "columnName": "last_page_fingerprint",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_movie_category_hydration_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_category_hydration_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "series_category_hydration",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `last_hydrated_at` INTEGER NOT NULL, `item_count` INTEGER NOT NULL, `last_status` TEXT NOT NULL, `last_error` TEXT, `last_loaded_page` INTEGER NOT NULL, `last_attempted_page` INTEGER NOT NULL, `last_successful_page` INTEGER NOT NULL, `total_pages` INTEGER NOT NULL, `is_complete` INTEGER NOT NULL, `page_size` INTEGER NOT NULL, `retry_after_ms` INTEGER NOT NULL, `failure_count` INTEGER NOT NULL, `retry_budget_remaining` INTEGER NOT NULL, `last_page_fingerprint` TEXT, PRIMARY KEY(`provider_id`, `category_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastHydratedAt",
+ "columnName": "last_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemCount",
+ "columnName": "item_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastStatus",
+ "columnName": "last_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastLoadedPage",
+ "columnName": "last_loaded_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastAttemptedPage",
+ "columnName": "last_attempted_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSuccessfulPage",
+ "columnName": "last_successful_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalPages",
+ "columnName": "total_pages",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isComplete",
+ "columnName": "is_complete",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "pageSize",
+ "columnName": "page_size",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryAfterMs",
+ "columnName": "retry_after_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureCount",
+ "columnName": "failure_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryBudgetRemaining",
+ "columnName": "retry_budget_remaining",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastPageFingerprint",
+ "columnName": "last_page_fingerprint",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_series_category_hydration_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_category_hydration_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "epg_sources",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `url` TEXT NOT NULL, `enabled` INTEGER NOT NULL, `last_refresh_at` INTEGER NOT NULL, `last_success_at` INTEGER NOT NULL, `last_error` TEXT, `priority` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, `etag` TEXT, `last_modified_header` TEXT)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "url",
+ "columnName": "url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastRefreshAt",
+ "columnName": "last_refresh_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSuccessAt",
+ "columnName": "last_success_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "etag",
+ "columnName": "etag",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastModifiedHeader",
+ "columnName": "last_modified_header",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_epg_sources_url",
+ "unique": true,
+ "columnNames": [
+ "url"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_sources_url` ON `${TABLE_NAME}` (`url`)"
+ }
+ ]
+ },
+ {
+ "tableName": "provider_epg_sources",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `epg_source_id` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_provider_epg_sources_provider_id_epg_source_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_provider_epg_sources_provider_id_epg_source_id` ON `${TABLE_NAME}` (`provider_id`, `epg_source_id`)"
+ },
+ {
+ "name": "index_provider_epg_sources_epg_source_id",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_provider_epg_sources_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "epg_sources",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "epg_source_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "epg_channels",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `epg_source_id` INTEGER NOT NULL, `xmltv_channel_id` TEXT NOT NULL, `display_name` TEXT NOT NULL, `normalized_name` TEXT NOT NULL, `icon_url` TEXT, FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "displayName",
+ "columnName": "display_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "normalizedName",
+ "columnName": "normalized_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "iconUrl",
+ "columnName": "icon_url",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_epg_channels_epg_source_id_xmltv_channel_id",
+ "unique": true,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_channels_epg_source_id_xmltv_channel_id` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`)"
+ },
+ {
+ "name": "index_epg_channels_epg_source_id",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_channels_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
+ },
+ {
+ "name": "index_epg_channels_normalized_name",
+ "unique": false,
+ "columnNames": [
+ "normalized_name"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_channels_normalized_name` ON `${TABLE_NAME}` (`normalized_name`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "epg_sources",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "epg_source_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "epg_programmes",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `epg_source_id` INTEGER NOT NULL, `xmltv_channel_id` TEXT NOT NULL, `start_time` INTEGER NOT NULL, `end_time` INTEGER NOT NULL, `title` TEXT NOT NULL, `subtitle` TEXT, `description` TEXT NOT NULL, `category` TEXT, `lang` TEXT NOT NULL, `rating` TEXT, `image_url` TEXT, `episode_info` TEXT, FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "startTime",
+ "columnName": "start_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "endTime",
+ "columnName": "end_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "subtitle",
+ "columnName": "subtitle",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "category",
+ "columnName": "category",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lang",
+ "columnName": "lang",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "imageUrl",
+ "columnName": "image_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "episodeInfo",
+ "columnName": "episode_info",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_epg_programmes_epg_source_id_xmltv_channel_id_start_time",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id",
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id_xmltv_channel_id_start_time` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`, `start_time`)"
+ },
+ {
+ "name": "index_epg_programmes_epg_source_id_xmltv_channel_id_start_time_end_time",
+ "unique": true,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id",
+ "start_time",
+ "end_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id_xmltv_channel_id_start_time_end_time` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`, `start_time`, `end_time`)"
+ },
+ {
+ "name": "index_epg_programmes_epg_source_id",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
+ },
+ {
+ "name": "index_epg_programmes_start_time",
+ "unique": false,
+ "columnNames": [
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_start_time` ON `${TABLE_NAME}` (`start_time`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "epg_sources",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "epg_source_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channel_epg_mappings",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_channel_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `source_type` TEXT NOT NULL, `epg_source_id` INTEGER, `xmltv_channel_id` TEXT, `match_type` TEXT, `confidence` REAL NOT NULL, `matched_at` INTEGER NOT NULL, `failed_attempts` INTEGER NOT NULL, `source` TEXT, `is_manual_override` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerChannelId",
+ "columnName": "provider_channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sourceType",
+ "columnName": "source_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "matchType",
+ "columnName": "match_type",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "confidence",
+ "columnName": "confidence",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "matchedAt",
+ "columnName": "matched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failedAttempts",
+ "columnName": "failed_attempts",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "source",
+ "columnName": "source",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isManualOverride",
+ "columnName": "is_manual_override",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_epg_mappings_provider_id_provider_channel_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "provider_channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channel_epg_mappings_provider_id_provider_channel_id` ON `${TABLE_NAME}` (`provider_id`, `provider_channel_id`)"
+ },
+ {
+ "name": "index_channel_epg_mappings_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_epg_mappings_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "combined_m3u_profiles",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `enabled` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ }
+ },
+ {
+ "tableName": "combined_m3u_profile_members",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `profile_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, FOREIGN KEY(`profile_id`) REFERENCES `combined_m3u_profiles`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profileId",
+ "columnName": "profile_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_combined_m3u_profile_members_profile_id",
+ "unique": false,
+ "columnNames": [
+ "profile_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_profile_id` ON `${TABLE_NAME}` (`profile_id`)"
+ },
+ {
+ "name": "index_combined_m3u_profile_members_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_combined_m3u_profile_members_profile_id_provider_id",
+ "unique": true,
+ "columnNames": [
+ "profile_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_profile_id_provider_id` ON `${TABLE_NAME}` (`profile_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "combined_m3u_profiles",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "profile_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_schedules",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` INTEGER NOT NULL, `channel_name` TEXT NOT NULL, `stream_url` TEXT NOT NULL, `program_title` TEXT, `requested_start_ms` INTEGER NOT NULL, `requested_end_ms` INTEGER NOT NULL, `recurrence` TEXT NOT NULL, `recurring_rule_id` TEXT, `enabled` INTEGER NOT NULL, `is_manual` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "requestedStartMs",
+ "columnName": "requested_start_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "requestedEndMs",
+ "columnName": "requested_end_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurrence",
+ "columnName": "recurrence",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurringRuleId",
+ "columnName": "recurring_rule_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isManual",
+ "columnName": "is_manual",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_recording_schedules_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_recording_schedules_enabled_requested_start_ms",
+ "unique": false,
+ "columnNames": [
+ "enabled",
+ "requested_start_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_enabled_requested_start_ms` ON `${TABLE_NAME}` (`enabled`, `requested_start_ms`)"
+ },
+ {
+ "name": "index_recording_schedules_recurring_rule_id",
+ "unique": false,
+ "columnNames": [
+ "recurring_rule_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_recurring_rule_id` ON `${TABLE_NAME}` (`recurring_rule_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_runs",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `schedule_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` INTEGER NOT NULL, `channel_name` TEXT NOT NULL, `stream_url` TEXT NOT NULL, `program_title` TEXT, `scheduled_start_ms` INTEGER NOT NULL, `scheduled_end_ms` INTEGER NOT NULL, `recurrence` TEXT NOT NULL, `recurring_rule_id` TEXT, `status` TEXT NOT NULL, `source_type` TEXT NOT NULL, `resolved_url` TEXT, `headers_json` TEXT NOT NULL, `user_agent` TEXT, `expiration_time` INTEGER, `provider_label` TEXT, `output_uri` TEXT, `output_display_path` TEXT, `bytes_written` INTEGER NOT NULL, `average_throughput_bps` INTEGER NOT NULL, `retry_count` INTEGER NOT NULL, `last_progress_at_ms` INTEGER, `failure_category` TEXT NOT NULL, `failure_reason` TEXT, `terminal_at_ms` INTEGER, `started_at_ms` INTEGER, `ended_at_ms` INTEGER, `schedule_enabled` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `alarm_start_at_ms` INTEGER, `alarm_stop_at_ms` INTEGER, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`schedule_id`) REFERENCES `recording_schedules`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "scheduleId",
+ "columnName": "schedule_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "scheduledStartMs",
+ "columnName": "scheduled_start_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "scheduledEndMs",
+ "columnName": "scheduled_end_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurrence",
+ "columnName": "recurrence",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurringRuleId",
+ "columnName": "recurring_rule_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sourceType",
+ "columnName": "source_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "resolvedUrl",
+ "columnName": "resolved_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "headersJson",
+ "columnName": "headers_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userAgent",
+ "columnName": "user_agent",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "expirationTime",
+ "columnName": "expiration_time",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "providerLabel",
+ "columnName": "provider_label",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputUri",
+ "columnName": "output_uri",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputDisplayPath",
+ "columnName": "output_display_path",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "bytesWritten",
+ "columnName": "bytes_written",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "averageThroughputBytesPerSecond",
+ "columnName": "average_throughput_bps",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryCount",
+ "columnName": "retry_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastProgressAtMs",
+ "columnName": "last_progress_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "failureCategory",
+ "columnName": "failure_category",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failure_reason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "terminalAtMs",
+ "columnName": "terminal_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "startedAtMs",
+ "columnName": "started_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "endedAtMs",
+ "columnName": "ended_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "scheduleEnabled",
+ "columnName": "schedule_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "alarmStartAtMs",
+ "columnName": "alarm_start_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "alarmStopAtMs",
+ "columnName": "alarm_stop_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_recording_runs_schedule_id",
+ "unique": false,
+ "columnNames": [
+ "schedule_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_schedule_id` ON `${TABLE_NAME}` (`schedule_id`)"
+ },
+ {
+ "name": "index_recording_runs_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_recording_runs_status_scheduled_start_ms",
+ "unique": false,
+ "columnNames": [
+ "status",
+ "scheduled_start_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_status_scheduled_start_ms` ON `${TABLE_NAME}` (`status`, `scheduled_start_ms`)"
+ },
+ {
+ "name": "index_recording_runs_alarm_start_at_ms",
+ "unique": false,
+ "columnNames": [
+ "alarm_start_at_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_alarm_start_at_ms` ON `${TABLE_NAME}` (`alarm_start_at_ms`)"
+ },
+ {
+ "name": "index_recording_runs_alarm_stop_at_ms",
+ "unique": false,
+ "columnNames": [
+ "alarm_stop_at_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_alarm_stop_at_ms` ON `${TABLE_NAME}` (`alarm_stop_at_ms`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "recording_schedules",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "schedule_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "program_reminders",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` TEXT NOT NULL, `channel_name` TEXT NOT NULL, `program_title` TEXT NOT NULL, `program_start_time` INTEGER NOT NULL, `remind_at` INTEGER NOT NULL, `lead_time_minutes` INTEGER NOT NULL, `is_dismissed` INTEGER NOT NULL, `notified_at` INTEGER, `created_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programStartTime",
+ "columnName": "program_start_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "remindAt",
+ "columnName": "remind_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "leadTimeMinutes",
+ "columnName": "lead_time_minutes",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isDismissed",
+ "columnName": "is_dismissed",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "notifiedAt",
+ "columnName": "notified_at",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_program_reminders_provider_id_remind_at",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "remind_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_provider_id_remind_at` ON `${TABLE_NAME}` (`provider_id`, `remind_at`)"
+ },
+ {
+ "name": "index_program_reminders_is_dismissed_notified_at_remind_at",
+ "unique": false,
+ "columnNames": [
+ "is_dismissed",
+ "notified_at",
+ "remind_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_is_dismissed_notified_at_remind_at` ON `${TABLE_NAME}` (`is_dismissed`, `notified_at`, `remind_at`)"
+ },
+ {
+ "name": "index_program_reminders_provider_id_channel_id_program_start_time",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "program_start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_provider_id_channel_id_program_start_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `program_start_time`)"
+ },
+ {
+ "name": "index_program_reminders_provider_id_channel_id_program_title_program_start_time",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "program_title",
+ "program_start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_program_reminders_provider_id_channel_id_program_title_program_start_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `program_title`, `program_start_time`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_storage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `tree_uri` TEXT, `display_name` TEXT, `output_directory` TEXT, `available_bytes` INTEGER, `is_writable` INTEGER NOT NULL, `file_name_pattern` TEXT NOT NULL, `retention_days` INTEGER, `max_simultaneous_recordings` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "treeUri",
+ "columnName": "tree_uri",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "displayName",
+ "columnName": "display_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputDirectory",
+ "columnName": "output_directory",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "availableBytes",
+ "columnName": "available_bytes",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "isWritable",
+ "columnName": "is_writable",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "fileNamePattern",
+ "columnName": "file_name_pattern",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retentionDays",
+ "columnName": "retention_days",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "maxSimultaneousRecordings",
+ "columnName": "max_simultaneous_recordings",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ }
+ },
+ {
+ "tableName": "playback_compatibility_records",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `device_fingerprint` TEXT NOT NULL, `device_model` TEXT NOT NULL, `android_sdk` INTEGER NOT NULL, `stream_type` TEXT NOT NULL, `video_mime_type` TEXT NOT NULL, `resolution_bucket` TEXT NOT NULL, `decoder_name` TEXT NOT NULL, `surface_type` TEXT NOT NULL, `failure_type` TEXT NOT NULL, `last_failed_at` INTEGER NOT NULL, `last_succeeded_at` INTEGER NOT NULL, `failure_count` INTEGER NOT NULL, `success_count` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deviceFingerprint",
+ "columnName": "device_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deviceModel",
+ "columnName": "device_model",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "androidSdk",
+ "columnName": "android_sdk",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamType",
+ "columnName": "stream_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "videoMimeType",
+ "columnName": "video_mime_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "resolutionBucket",
+ "columnName": "resolution_bucket",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "decoderName",
+ "columnName": "decoder_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "surfaceType",
+ "columnName": "surface_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureType",
+ "columnName": "failure_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastFailedAt",
+ "columnName": "last_failed_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSucceededAt",
+ "columnName": "last_succeeded_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureCount",
+ "columnName": "failure_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "successCount",
+ "columnName": "success_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket_decoder_name_surface_type",
+ "unique": true,
+ "columnNames": [
+ "device_fingerprint",
+ "stream_type",
+ "video_mime_type",
+ "resolution_bucket",
+ "decoder_name",
+ "surface_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket_decoder_name_surface_type` ON `${TABLE_NAME}` (`device_fingerprint`, `stream_type`, `video_mime_type`, `resolution_bucket`, `decoder_name`, `surface_type`)"
+ },
+ {
+ "name": "index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket",
+ "unique": false,
+ "columnNames": [
+ "device_fingerprint",
+ "stream_type",
+ "video_mime_type",
+ "resolution_bucket"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket` ON `${TABLE_NAME}` (`device_fingerprint`, `stream_type`, `video_mime_type`, `resolution_bucket`)"
+ },
+ {
+ "name": "index_playback_compatibility_records_last_failed_at",
+ "unique": false,
+ "columnNames": [
+ "last_failed_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_compatibility_records_last_failed_at` ON `${TABLE_NAME}` (`last_failed_at`)"
+ },
+ {
+ "name": "index_playback_compatibility_records_last_succeeded_at",
+ "unique": false,
+ "columnNames": [
+ "last_succeeded_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_compatibility_records_last_succeeded_at` ON `${TABLE_NAME}` (`last_succeeded_at`)"
+ }
+ ]
+ },
+ {
+ "tableName": "xtream_content_index",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `remote_id` TEXT NOT NULL, `local_content_id` INTEGER, `name` TEXT NOT NULL, `category_id` INTEGER, `category_name` TEXT, `image_url` TEXT, `container_extension` TEXT, `rating` REAL NOT NULL, `added_at` INTEGER NOT NULL, `remote_updated_at` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `indexed_at` INTEGER NOT NULL, `detail_hydrated_at` INTEGER NOT NULL, `stale_state` TEXT NOT NULL, `error_state` TEXT, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`provider_id`, `content_type`, `remote_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "remoteId",
+ "columnName": "remote_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "localContentId",
+ "columnName": "local_content_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "imageUrl",
+ "columnName": "image_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "remoteUpdatedAt",
+ "columnName": "remote_updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "indexedAt",
+ "columnName": "indexed_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "detailHydratedAt",
+ "columnName": "detail_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "staleState",
+ "columnName": "stale_state",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "errorState",
+ "columnName": "error_state",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "content_type",
+ "remote_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_xtream_content_index_provider_id_content_type",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_content_index_provider_id_content_type` ON `${TABLE_NAME}` (`provider_id`, `content_type`)"
+ },
+ {
+ "name": "index_xtream_content_index_provider_id_content_type_category_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type",
+ "category_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_content_index_provider_id_content_type_category_id` ON `${TABLE_NAME}` (`provider_id`, `content_type`, `category_id`)"
+ },
+ {
+ "name": "index_xtream_content_index_provider_id_content_type_name",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type",
+ "name"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_content_index_provider_id_content_type_name` ON `${TABLE_NAME}` (`provider_id`, `content_type`, `name`)"
+ },
+ {
+ "name": "index_xtream_content_index_provider_id_content_type_local_content_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type",
+ "local_content_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_content_index_provider_id_content_type_local_content_id` ON `${TABLE_NAME}` (`provider_id`, `content_type`, `local_content_id`)"
+ },
+ {
+ "name": "index_xtream_content_index_provider_id_indexed_at",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "indexed_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_content_index_provider_id_indexed_at` ON `${TABLE_NAME}` (`provider_id`, `indexed_at`)"
+ },
+ {
+ "name": "index_xtream_content_index_stale_state",
+ "unique": false,
+ "columnNames": [
+ "stale_state"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_content_index_stale_state` ON `${TABLE_NAME}` (`stale_state`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "xtream_index_jobs",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `section` TEXT NOT NULL, `state` TEXT NOT NULL, `total_categories` INTEGER NOT NULL, `completed_categories` INTEGER NOT NULL, `next_category_index` INTEGER NOT NULL, `failed_categories` INTEGER NOT NULL, `indexed_rows` INTEGER NOT NULL, `skipped_malformed_rows` INTEGER NOT NULL, `deleted_pruned_rows` INTEGER NOT NULL, `priority_category_id` INTEGER, `priority_requested_at` INTEGER NOT NULL, `last_error` TEXT, `last_attempt_at` INTEGER NOT NULL, `last_success_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`provider_id`, `section`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "section",
+ "columnName": "section",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "state",
+ "columnName": "state",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalCategories",
+ "columnName": "total_categories",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "completedCategories",
+ "columnName": "completed_categories",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nextCategoryIndex",
+ "columnName": "next_category_index",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failedCategories",
+ "columnName": "failed_categories",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "indexedRows",
+ "columnName": "indexed_rows",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "skippedMalformedRows",
+ "columnName": "skipped_malformed_rows",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedPrunedRows",
+ "columnName": "deleted_pruned_rows",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priorityCategoryId",
+ "columnName": "priority_category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "priorityRequestedAt",
+ "columnName": "priority_requested_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastAttemptAt",
+ "columnName": "last_attempt_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSuccessAt",
+ "columnName": "last_success_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "section"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_xtream_index_jobs_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_index_jobs_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_xtream_index_jobs_section",
+ "unique": false,
+ "columnNames": [
+ "section"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_index_jobs_section` ON `${TABLE_NAME}` (`section`)"
+ },
+ {
+ "name": "index_xtream_index_jobs_state",
+ "unique": false,
+ "columnNames": [
+ "state"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_index_jobs_state` ON `${TABLE_NAME}` (`state`)"
+ },
+ {
+ "name": "index_xtream_index_jobs_updated_at",
+ "unique": false,
+ "columnNames": [
+ "updated_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_index_jobs_updated_at` ON `${TABLE_NAME}` (`updated_at`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "xtream_live_onboarding_state",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `provider_type` TEXT NOT NULL, `content_type` TEXT NOT NULL, `phase` TEXT NOT NULL, `staged_session_id` INTEGER, `import_strategy` TEXT, `next_category_index` INTEGER NOT NULL, `accepted_row_count` INTEGER NOT NULL, `staged_flush_count` INTEGER NOT NULL, `sync_profile_tier` TEXT, `sync_profile_batch_size` INTEGER NOT NULL, `sync_profile_strategy` TEXT, `sync_profile_low_memory` INTEGER NOT NULL, `sync_profile_memory_class_mb` INTEGER NOT NULL, `sync_profile_available_mem_mb` INTEGER NOT NULL, `last_error` TEXT, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, `completed_at` INTEGER, PRIMARY KEY(`provider_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerType",
+ "columnName": "provider_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "phase",
+ "columnName": "phase",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stagedSessionId",
+ "columnName": "staged_session_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "importStrategy",
+ "columnName": "import_strategy",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nextCategoryIndex",
+ "columnName": "next_category_index",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "acceptedRowCount",
+ "columnName": "accepted_row_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stagedFlushCount",
+ "columnName": "staged_flush_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncProfileTier",
+ "columnName": "sync_profile_tier",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "syncProfileBatchSize",
+ "columnName": "sync_profile_batch_size",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncProfileStrategy",
+ "columnName": "sync_profile_strategy",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "syncProfileLowMemory",
+ "columnName": "sync_profile_low_memory",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncProfileMemoryClassMb",
+ "columnName": "sync_profile_memory_class_mb",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncProfileAvailableMemMb",
+ "columnName": "sync_profile_available_mem_mb",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "completedAt",
+ "columnName": "completed_at",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_xtream_live_onboarding_state_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_live_onboarding_state_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_xtream_live_onboarding_state_phase",
+ "unique": false,
+ "columnNames": [
+ "phase"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_live_onboarding_state_phase` ON `${TABLE_NAME}` (`phase`)"
+ },
+ {
+ "name": "index_xtream_live_onboarding_state_updated_at",
+ "unique": false,
+ "columnNames": [
+ "updated_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_live_onboarding_state_updated_at` ON `${TABLE_NAME}` (`updated_at`)"
+ },
+ {
+ "name": "index_xtream_live_onboarding_state_staged_session_id",
+ "unique": false,
+ "columnNames": [
+ "staged_session_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_live_onboarding_state_staged_session_id` ON `${TABLE_NAME}` (`staged_session_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ }
+ ],
+ "setupQueries": [
+ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '2a71b96adf0a77ffe760c7204a475ed0')"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/data/src/main/java/com/streamvault/data/local/RoomEnumConverters.kt b/data/src/main/java/com/streamvault/data/local/RoomEnumConverters.kt
index 95d968c2..3cd76d56 100644
--- a/data/src/main/java/com/streamvault/data/local/RoomEnumConverters.kt
+++ b/data/src/main/java/com/streamvault/data/local/RoomEnumConverters.kt
@@ -6,6 +6,8 @@ import com.streamvault.domain.model.ProviderEpgSyncMode
import com.streamvault.domain.model.ProviderStatus
import com.streamvault.domain.model.ProviderType
import com.streamvault.domain.model.ProviderXtreamLiveSyncMode
+import com.streamvault.domain.model.StalkerAuthMode
+import com.streamvault.domain.model.StalkerPortalProfile
import java.util.logging.Logger
class RoomEnumConverters {
@@ -40,6 +42,20 @@ class RoomEnumConverters {
fun toProviderXtreamLiveSyncMode(value: String?): ProviderXtreamLiveSyncMode? =
enumValueOrDefault(value, ProviderXtreamLiveSyncMode.AUTO, providerXtreamLiveSyncModeAliases())
+ @TypeConverter
+ fun fromStalkerAuthMode(value: StalkerAuthMode?): String? = value?.name
+
+ @TypeConverter
+ fun toStalkerAuthMode(value: String?): StalkerAuthMode? =
+ enumValueOrDefault(value, StalkerAuthMode.AUTO)
+
+ @TypeConverter
+ fun fromStalkerPortalProfile(value: StalkerPortalProfile?): String? = value?.name
+
+ @TypeConverter
+ fun toStalkerPortalProfile(value: String?): StalkerPortalProfile? =
+ enumValueOrDefault(value, StalkerPortalProfile.MAG_BASIC)
+
@TypeConverter
fun fromContentType(value: ContentType?): String? = value?.name
@@ -93,4 +109,4 @@ class RoomEnumConverters {
"VOD" to ContentType.MOVIE,
"CHANNEL" to ContentType.LIVE
)
-}
\ No newline at end of file
+}
diff --git a/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt b/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt
index 98139fa5..6aabdcba 100644
--- a/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt
+++ b/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt
@@ -49,7 +49,7 @@ import com.streamvault.data.local.entity.*
XtreamIndexJobEntity::class,
XtreamLiveOnboardingStateEntity::class
],
- version = 54,
+ version = 55,
exportSchema = true // ← was false; schema JSON now tracked in version control
)
@TypeConverters(RoomEnumConverters::class)
@@ -2597,6 +2597,19 @@ abstract class StreamVaultDatabase : RoomDatabase() {
}
}
+ val MIGRATION_54_55 = object : Migration(54, 55) {
+ override fun migrate(database: SupportSQLiteDatabase) {
+ database.execSQL("ALTER TABLE providers ADD COLUMN stalker_auth_mode TEXT NOT NULL DEFAULT 'AUTO'")
+ database.execSQL("ALTER TABLE providers ADD COLUMN stalker_portal_profile TEXT NOT NULL DEFAULT 'MAG_BASIC'")
+ database.execSQL("ALTER TABLE providers ADD COLUMN stalker_last_playback_mode TEXT")
+ database.execSQL("ALTER TABLE providers ADD COLUMN stalker_credentials_required INTEGER NOT NULL DEFAULT 0")
+ database.execSQL("ALTER TABLE providers ADD COLUMN stalker_mac_required INTEGER NOT NULL DEFAULT 1")
+ database.execSQL("ALTER TABLE providers ADD COLUMN stalker_uses_temp_links INTEGER NOT NULL DEFAULT 0")
+ database.execSQL("ALTER TABLE providers ADD COLUMN stalker_module_restricted INTEGER NOT NULL DEFAULT 0")
+ validateForeignKeys(database, "providers")
+ }
+ }
+
private fun addStalkerHardeningColumns(database: SupportSQLiteDatabase, tableName: String) {
database.execSQL("ALTER TABLE $tableName ADD COLUMN last_attempted_page INTEGER NOT NULL DEFAULT 0")
database.execSQL("ALTER TABLE $tableName ADD COLUMN last_successful_page INTEGER NOT NULL DEFAULT 0")
diff --git a/data/src/main/java/com/streamvault/data/local/entity/Entities.kt b/data/src/main/java/com/streamvault/data/local/entity/Entities.kt
index 1182600f..06dce474 100644
--- a/data/src/main/java/com/streamvault/data/local/entity/Entities.kt
+++ b/data/src/main/java/com/streamvault/data/local/entity/Entities.kt
@@ -10,6 +10,8 @@ import com.streamvault.domain.model.ContentType
import com.streamvault.domain.model.ProviderEpgSyncMode
import com.streamvault.domain.model.ProviderStatus
import com.streamvault.domain.model.ProviderType
+import com.streamvault.domain.model.StalkerAuthMode
+import com.streamvault.domain.model.StalkerPortalProfile
import com.streamvault.domain.model.ProviderXtreamLiveSyncMode
@Entity(
@@ -36,6 +38,13 @@ data class ProviderEntity(
@ColumnInfo(name = "stalker_device_id") val stalkerDeviceId: String = "",
@ColumnInfo(name = "stalker_device_id2") val stalkerDeviceId2: String = "",
@ColumnInfo(name = "stalker_signature") val stalkerSignature: String = "",
+ @ColumnInfo(name = "stalker_auth_mode") val stalkerAuthMode: StalkerAuthMode = StalkerAuthMode.AUTO,
+ @ColumnInfo(name = "stalker_portal_profile") val stalkerPortalProfile: StalkerPortalProfile = StalkerPortalProfile.MAG_BASIC,
+ @ColumnInfo(name = "stalker_last_playback_mode") val stalkerLastPlaybackMode: String? = null,
+ @ColumnInfo(name = "stalker_credentials_required") val stalkerCredentialsRequired: Boolean = false,
+ @ColumnInfo(name = "stalker_mac_required") val stalkerMacRequired: Boolean = true,
+ @ColumnInfo(name = "stalker_uses_temp_links") val stalkerUsesTemporaryLinks: Boolean = false,
+ @ColumnInfo(name = "stalker_module_restricted") val stalkerModuleRestricted: Boolean = false,
@ColumnInfo(name = "is_active") val isActive: Boolean = true,
@ColumnInfo(name = "max_connections") val maxConnections: Int = 1,
@ColumnInfo(name = "expiration_date") val expirationDate: Long? = null,
diff --git a/data/src/main/java/com/streamvault/data/mapper/EntityMappers.kt b/data/src/main/java/com/streamvault/data/mapper/EntityMappers.kt
index 208236a2..d8935f54 100644
--- a/data/src/main/java/com/streamvault/data/mapper/EntityMappers.kt
+++ b/data/src/main/java/com/streamvault/data/mapper/EntityMappers.kt
@@ -3,6 +3,8 @@ package com.streamvault.data.mapper
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.streamvault.data.local.entity.*
+import com.streamvault.data.remote.stalker.StalkerPlaybackDescriptor
+import com.streamvault.data.remote.stalker.StalkerUrlFactory
import com.streamvault.data.remote.xtream.XtreamStreamKind
import com.streamvault.data.remote.xtream.XtreamUrlFactory
import com.streamvault.domain.model.*
@@ -32,6 +34,13 @@ fun ProviderEntity.toDomain() = Provider(
stalkerDeviceId = stalkerDeviceId,
stalkerDeviceId2 = stalkerDeviceId2,
stalkerSignature = stalkerSignature,
+ stalkerAuthMode = stalkerAuthMode,
+ stalkerPortalProfile = stalkerPortalProfile,
+ stalkerLastPlaybackMode = stalkerLastPlaybackMode,
+ stalkerCredentialsRequired = stalkerCredentialsRequired,
+ stalkerMacRequired = stalkerMacRequired,
+ stalkerUsesTemporaryLinks = stalkerUsesTemporaryLinks,
+ stalkerModuleRestricted = stalkerModuleRestricted,
isActive = isActive,
maxConnections = maxConnections,
expirationDate = expirationDate,
@@ -65,6 +74,13 @@ fun Provider.toEntity() = ProviderEntity(
stalkerDeviceId = stalkerDeviceId,
stalkerDeviceId2 = stalkerDeviceId2,
stalkerSignature = stalkerSignature,
+ stalkerAuthMode = stalkerAuthMode,
+ stalkerPortalProfile = stalkerPortalProfile,
+ stalkerLastPlaybackMode = stalkerLastPlaybackMode,
+ stalkerCredentialsRequired = stalkerCredentialsRequired,
+ stalkerMacRequired = stalkerMacRequired,
+ stalkerUsesTemporaryLinks = stalkerUsesTemporaryLinks,
+ stalkerModuleRestricted = stalkerModuleRestricted,
isActive = isActive,
maxConnections = maxConnections,
expirationDate = expirationDate,
@@ -103,6 +119,28 @@ fun CombinedM3uProfileMemberWithProvider.toDomain() = CombinedM3uProfileMember(
fun ChannelEntity.toDomain(): Channel {
val qualityOptions = decodeQualityOptions(qualityOptionsJson)
+ val stalkerToken = StalkerUrlFactory.parseInternalStreamUrl(streamUrl)
+ val stalkerAlternateStreams = stalkerToken?.playbackDescriptor
+ ?.candidates
+ ?.drop(1)
+ ?.mapIndexed { index, variant ->
+ StalkerUrlFactory.buildInternalStreamUrl(
+ providerId = stalkerToken.providerId,
+ kind = stalkerToken.kind,
+ itemId = stalkerToken.itemId,
+ cmd = variant.cmd,
+ containerExtension = stalkerToken.containerExtension,
+ seriesNumber = stalkerToken.seriesNumber,
+ playbackDescriptor = StalkerPlaybackDescriptor(
+ primaryMode = variant.playbackMode,
+ candidates = listOf(
+ variant.copy(priority = 0)
+ ),
+ capabilities = stalkerToken.playbackDescriptor.capabilities
+ )
+ )
+ }
+ .orEmpty()
return Channel(
id = id,
name = name,
@@ -122,7 +160,10 @@ fun ChannelEntity.toDomain(): Channel {
logicalGroupId = logicalGroupId,
errorCount = errorCount,
qualityOptions = qualityOptions,
- alternativeStreams = qualityOptions.mapNotNull { it.url }.filter { it != streamUrl }.distinct(),
+ alternativeStreams = (
+ qualityOptions.mapNotNull { it.url }.filter { it != streamUrl } +
+ stalkerAlternateStreams.filter { it != streamUrl }
+ ).distinct(),
streamId = streamId
)
}
diff --git a/data/src/main/java/com/streamvault/data/remote/stalker/OkHttpStalkerApiService.kt b/data/src/main/java/com/streamvault/data/remote/stalker/OkHttpStalkerApiService.kt
index 4a7c3300..793e93ac 100644
--- a/data/src/main/java/com/streamvault/data/remote/stalker/OkHttpStalkerApiService.kt
+++ b/data/src/main/java/com/streamvault/data/remote/stalker/OkHttpStalkerApiService.kt
@@ -6,6 +6,8 @@ import com.google.gson.JsonParser
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonToken
import com.streamvault.domain.model.Result
+import com.streamvault.domain.model.StalkerAuthMode
+import com.streamvault.domain.model.StalkerPortalProfile
import com.streamvault.domain.util.StreamEntryUrlPolicy
import java.io.ByteArrayOutputStream
import java.io.IOException
@@ -24,6 +26,7 @@ import java.time.format.DateTimeFormatterBuilder
import java.time.format.ResolverStyle
import java.util.Base64
import java.util.Locale
+import java.util.concurrent.ConcurrentHashMap
import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.Dispatchers
@@ -39,59 +42,182 @@ import kotlinx.serialization.json.doubleOrNull
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.longOrNull
+import okhttp3.Cookie
+import okhttp3.CookieJar
+import okhttp3.HttpUrl
import okhttp3.OkHttpClient
import okhttp3.Request
+import okhttp3.MediaType.Companion.toMediaType
+import okhttp3.RequestBody.Companion.toRequestBody
+import okhttp3.Response
+import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
@Singleton
class OkHttpStalkerApiService @Inject constructor(
private val okHttpClient: OkHttpClient,
private val json: Json
) : StalkerApiService {
+ private val cookieJar = InMemoryStalkerCookieJar()
+ private val stalkerHttpClient: OkHttpClient = okHttpClient.newBuilder()
+ .cookieJar(cookieJar)
+ .build()
override suspend fun authenticate(profile: StalkerDeviceProfile): Result<Pair<StalkerSession, StalkerProviderProfile>> {
var lastError: Throwable? = null
- for (loadUrl in StalkerUrlFactory.loadUrlCandidates(profile.portalUrl)) {
- val referer = StalkerUrlFactory.portalReferer(loadUrl)
- val handshakeResult = runCatching {
- requestJson(
- url = loadUrl,
- profile = profile,
- referer = referer,
- query = mapOf(
- "type" to "stb",
- "action" to "handshake",
- "token" to "",
- "JsHttpRequest" to "1-xml"
+ val authModes = candidateAuthModes(profile)
+ for (effectiveAuthMode in authModes) {
+ val attemptProfile = profile.copy(authMode = effectiveAuthMode)
+ for (loadUrl in StalkerUrlFactory.loadUrlCandidates(profile.portalUrl)) {
+ cookieJar.clear()
+ val referer = StalkerUrlFactory.portalReferer(loadUrl)
+ val evidence = mutableListOf<String>()
+ val handshakePayload = runCatching {
+ requestJson(
+ url = loadUrl,
+ profile = attemptProfile,
+ referer = referer,
+ query = mapOf(
+ "type" to "stb",
+ "action" to "handshake",
+ "token" to "",
+ "JsHttpRequest" to "1-xml"
+ )
)
+ }.getOrElse { error ->
+ lastError = error
+ continue
+ }
+ evidence += "handshake"
+ val token = handshakePayload.findString("token")
+ ?.takeIf { it.isNotBlank() }
+ ?: run {
+ lastError = IOException("Portal handshake did not return a token.")
+ continue
+ }
+
+ if (effectiveAuthMode.requiresCredentials()) {
+ if (attemptProfile.username.isBlank()) {
+ lastError = IOException("Portal requires account credentials for this connection.")
+ continue
+ }
+ val authPayload = runCatching {
+ requestCredentialAuth(
+ url = loadUrl,
+ profile = attemptProfile,
+ referer = referer,
+ token = token
+ )
+ }.getOrElse { error ->
+ lastError = error
+ continue
+ }
+ evidence += "do_auth"
+ authPayload.ensureNoPortalError()
+ }
+
+ var session = StalkerSession(
+ loadUrl = loadUrl,
+ portalReferer = referer,
+ token = token
)
- }
- val handshakePayload = handshakeResult.getOrElse { error ->
- lastError = error
- continue
- }
- val token = handshakePayload.findString("token")
- ?.takeIf { it.isNotBlank() }
- ?: run {
- lastError = IOException("Portal handshake did not return a token.")
+ val profilePayload = runCatching {
+ requestJson(
+ url = loadUrl,
+ profile = attemptProfile,
+ referer = referer,
+ token = token,
+ query = buildProfileQuery(attemptProfile)
+ )
+ }.getOrElse { error ->
+ lastError = error
continue
}
+ evidence += "get_profile"
+
+ var providerProfile = profilePayload.toProviderProfile()
+ var bootstrapStrategy = when (effectiveAuthMode) {
+ StalkerAuthMode.MAC_ONLY -> StalkerBootstrapStrategy.MAC_ONLY
+ StalkerAuthMode.CREDENTIALS_ONLY,
+ StalkerAuthMode.MAC_PLUS_CREDENTIALS -> StalkerBootstrapStrategy.MAC_WITH_ACCOUNT_INFO
+ StalkerAuthMode.AUTO -> StalkerBootstrapStrategy.AUTO
+ }
+ if (providerProfile.shouldRequestAccountInfo()) {
+ runCatching {
+ requestJson(
+ url = loadUrl,
+ profile = attemptProfile,
+ referer = referer,
+ token = token,
+ query = mapOf(
+ "type" to "account_info",
+ "action" to "get_main_info",
+ "JsHttpRequest" to "1-xml"
+ )
+ )
+ }.getOrNull()?.let { accountInfoPayload ->
+ providerProfile = providerProfile.merge(accountInfoPayload.toProviderProfile())
+ bootstrapStrategy = StalkerBootstrapStrategy.MAC_WITH_ACCOUNT_INFO
+ evidence += "get_account_info"
+ }
+ }
+ if (providerProfile.shouldRequestModules()) {
+ runCatching {
+ requestJson(
+ url = loadUrl,
+ profile = attemptProfile,
+ referer = referer,
+ token = token,
+ query = mapOf(
+ "type" to "stb",
+ "action" to "get_modules",
+ "JsHttpRequest" to "1-xml"
+ )
+ )
+ }.getOrNull()?.let { modulesPayload ->
+ val modules = modulesPayload.toModuleNames()
+ if (modules.isNotEmpty()) {
+ bootstrapStrategy = StalkerBootstrapStrategy.MAC_WITH_MODULES
+ evidence += "get_modules"
+ }
+ providerProfile = providerProfile.copy(moduleNames = modules)
+ }
+ }
- val session = StalkerSession(loadUrl = loadUrl, portalReferer = referer, token = token)
- val profileResult = runCatching {
- requestJson(
- url = loadUrl,
- profile = profile,
- referer = referer,
- token = token,
- query = buildProfileQuery(profile)
+ val ambiguousState = providerProfile.isAmbiguousAccountState()
+ val portalProfile = resolvePortalProfile(
+ authMode = effectiveAuthMode,
+ providerProfile = providerProfile,
+ requestedProfile = attemptProfile
)
+ val credentialRequired = portalProfile == StalkerPortalProfile.AUTH_REQUIRED ||
+ portalProfile == StalkerPortalProfile.AUTH_PLUS_MAG
+ val macRequired = portalProfile != StalkerPortalProfile.AUTH_REQUIRED
+ if (effectiveAuthMode == StalkerAuthMode.MAC_ONLY && credentialRequired) {
+ lastError = IOException("Portal requires account credentials for this connection.")
+ continue
+ }
+ providerProfile = providerProfile.copy(
+ bootstrapStrategy = bootstrapStrategy,
+ effectiveAuthMode = effectiveAuthMode,
+ portalProfile = portalProfile,
+ credentialRequired = credentialRequired,
+ macRequired = macRequired,
+ bootstrapEvidence = evidence.toList(),
+ portalCapabilities = providerProfile.portalCapabilities.copy(
+ bootstrapStrategy = bootstrapStrategy,
+ moduleRestricted = providerProfile.moduleNames.isNotEmpty(),
+ ambiguousAccountState = ambiguousState
+ ),
+ ambiguousState = ambiguousState
+ )
+ session = session.copy(
+ serverCookieHeader = cookieJar.cookieHeaderFor(loadUrl),
+ effectiveAuthMode = effectiveAuthMode,
+ portalProfile = portalProfile,
+ bootstrapEvidence = evidence.toList()
+ )
+ return Result.success(session to providerProfile)
}
- val profilePayload = profileResult.getOrElse { error ->
- lastError = error
- continue
- }
-
- return Result.success(session to profilePayload.toProviderProfile())
}
return Result.error(
@@ -598,21 +724,26 @@ class OkHttpStalkerApiService @Inject constructor(
profile: StalkerDeviceProfile,
referer: String,
query: Map<String, String>,
- token: String? = null
+ token: String? = null,
+ method: String = "GET",
+ body: String? = null
): JsonElement = withContext(Dispatchers.IO) {
val action = query["action"]
val canRetryAlternateEndpoint = !token.isNullOrBlank()
- val request = Request.Builder()
- .url(buildUrl(url, query))
+ val fullUrl = buildUrl(url, query)
+ val requestBuilder = Request.Builder()
+ .url(fullUrl)
.header("User-Agent", profile.userAgent)
.header("X-User-Agent", profile.xUserAgent)
.header("Referer", referer)
.header("Accept", "*/*")
- .header("Cookie", "mac=${profile.macAddress}; stb_lang=${profile.locale}; timezone=${profile.timezone}")
+ .header("Cookie", buildCookieHeader(fullUrl, profile))
.apply {
token?.takeIf { it.isNotBlank() }?.let { header("Authorization", "Bearer $it") }
}
- .get()
+ val requestBody = body?.toRequestBody(FORM_URL_ENCODED_MEDIA_TYPE)
+ val request = requestBuilder
+ .method(method, requestBody)
.build()
runCatching {
@@ -629,13 +760,16 @@ class OkHttpStalkerApiService @Inject constructor(
val alternateRequest = request.newBuilder()
.url(buildUrl(alternateUrl, query))
.header("Referer", StalkerUrlFactory.portalReferer(alternateUrl))
+ .header("Cookie", buildCookieHeader(buildUrl(alternateUrl, query), profile))
+ .method(method, requestBody)
.build()
executeJsonRequest(alternateRequest, action)
}.getOrElse { throw it }
}
private fun executeJsonRequest(request: Request, action: String?): JsonElement {
- return okHttpClient.newCall(request).execute().use { response ->
+ return stalkerHttpClient.newCall(request).execute().use { response ->
+ captureResponseCookies(response)
if (!response.isSuccessful) {
response.body?.close()
throw IOException("Portal request failed with HTTP ${response.code}.")
@@ -715,13 +849,14 @@ class OkHttpStalkerApiService @Inject constructor(
onItem: suspend (StalkerItemRecord) -> Unit
): Int = withContext(Dispatchers.IO) {
val action = query["action"]
+ val fullUrl = buildUrl(url, query)
val request = Request.Builder()
- .url(buildUrl(url, query))
+ .url(fullUrl)
.header("User-Agent", profile.userAgent)
.header("X-User-Agent", profile.xUserAgent)
.header("Referer", referer)
.header("Accept", "*/*")
- .header("Cookie", "mac=${profile.macAddress}; stb_lang=${profile.locale}; timezone=${profile.timezone}")
+ .header("Cookie", buildCookieHeader(fullUrl, profile))
.header("Authorization", "Bearer $token")
.get()
.build()
@@ -739,6 +874,7 @@ class OkHttpStalkerApiService @Inject constructor(
val alternateRequest = request.newBuilder()
.url(buildUrl(alternateUrl, query))
.header("Referer", StalkerUrlFactory.portalReferer(alternateUrl))
+ .header("Cookie", buildCookieHeader(buildUrl(alternateUrl, query), profile))
.build()
executeStreamingRequest(alternateRequest, action, onItem)
}.getOrElse { throw it }
@@ -749,7 +885,8 @@ class OkHttpStalkerApiService @Inject constructor(
action: String?,
onItem: suspend (StalkerItemRecord) -> Unit
): Int {
- return okHttpClient.newCall(request).execute().use { response ->
+ return stalkerHttpClient.newCall(request).execute().use { response ->
+ captureResponseCookies(response)
if (!response.isSuccessful) {
throw IOException("Portal request failed with HTTP ${response.code}.")
}
@@ -860,13 +997,14 @@ class OkHttpStalkerApiService @Inject constructor(
onProgram: suspend (StalkerProgramRecord) -> Unit
): Int = withContext(Dispatchers.IO) {
val action = query["action"]
+ val fullUrl = buildUrl(url, query)
val request = Request.Builder()
- .url(buildUrl(url, query))
+ .url(fullUrl)
.header("User-Agent", profile.userAgent)
.header("X-User-Agent", profile.xUserAgent)
.header("Referer", referer)
.header("Accept", "*/*")
- .header("Cookie", "mac=${profile.macAddress}; stb_lang=${profile.locale}; timezone=${profile.timezone}")
+ .header("Cookie", buildCookieHeader(fullUrl, profile))
.header("Authorization", "Bearer $token")
.get()
.build()
@@ -884,6 +1022,7 @@ class OkHttpStalkerApiService @Inject constructor(
val alternateRequest = request.newBuilder()
.url(buildUrl(alternateUrl, query))
.header("Referer", StalkerUrlFactory.portalReferer(alternateUrl))
+ .header("Cookie", buildCookieHeader(buildUrl(alternateUrl, query), profile))
.build()
executeStreamingPrograms(alternateRequest, action, channelIdOverride, onProgram)
}.getOrElse { throw it }
@@ -895,7 +1034,8 @@ class OkHttpStalkerApiService @Inject constructor(
channelIdOverride: String?,
onProgram: suspend (StalkerProgramRecord) -> Unit
): Int {
- return okHttpClient.newCall(request).execute().use { response ->
+ return stalkerHttpClient.newCall(request).execute().use { response ->
+ captureResponseCookies(response)
if (!response.isSuccessful) {
throw IOException("Portal request failed with HTTP ${response.code}.")
}
@@ -1125,6 +1265,72 @@ class OkHttpStalkerApiService @Inject constructor(
)
}
+ private fun buildCookieHeader(url: String, profile: StalkerDeviceProfile): String {
+ val cookies = linkedMapOf<String, String>()
+ profile.macAddress.takeIf { it.isNotBlank() }?.let { cookies["mac"] = it }
+ profile.locale.takeIf { it.isNotBlank() }?.let { cookies["stb_lang"] = it }
+ profile.timezone.takeIf { it.isNotBlank() }?.let { cookies["timezone"] = it }
+ profile.serialNumber.takeIf { it.isNotBlank() }?.let { cookies["sn"] = it }
+ profile.deviceId.takeIf { it.isNotBlank() }?.let { cookies["device_id"] = it }
+ profile.deviceId2.takeIf { it.isNotBlank() }?.let { cookies["device_id2"] = it }
+ profile.signature.takeIf { it.isNotBlank() }?.let { cookies["signature"] = it }
+ cookieJar.cookieHeaderFor(url).split(';')
+ .mapNotNull { part ->
+ val key = part.substringBefore('=', missingDelimiterValue = "").trim()
+ val value = part.substringAfter('=', missingDelimiterValue = "").trim()
+ key.takeIf { it.isNotBlank() && value.isNotBlank() }?.let { it to value }
+ }.forEach { (key, value) ->
+ cookies.putIfAbsent(key, value)
+ }
+ return cookies.entries.joinToString("; ") { (key, value) -> "$key=$value" }
+ }
+
+ private suspend fun requestCredentialAuth(
+ url: String,
+ profile: StalkerDeviceProfile,
+ referer: String,
+ token: String
+ ): JsonElement {
+ val formBody = listOf(
+ "login" to profile.username,
+ "password" to profile.password
+ ).joinToString("&") { (key, value) -> "${encode(key)}=${encode(value)}" }
+ val query = mapOf(
+ "type" to "stb",
+ "action" to "do_auth",
+ "JsHttpRequest" to "1-xml"
+ )
+ return runCatching {
+ requestJson(
+ url = url,
+ profile = profile,
+ referer = referer,
+ token = token,
+ query = query,
+ method = "POST",
+ body = formBody
+ )
+ }.getOrElse {
+ requestJson(
+ url = url,
+ profile = profile,
+ referer = referer,
+ token = token,
+ query = query + mapOf(
+ "login" to profile.username,
+ "password" to profile.password
+ )
+ )
+ }
+ }
+
+ private fun captureResponseCookies(response: Response) {
+ val cookies = Cookie.parseAll(response.request.url, response.headers)
+ if (cookies.isNotEmpty()) {
+ cookieJar.saveFromResponse(response.request.url, cookies)
+ }
+ }
+
private fun JsonElement.totalPages(): Int {
val payload = payloadObjectOrNull() ?: return 1
val totalItems = payload["total_items"]?.primitiveContentOrNull()?.toIntOrNull() ?: return 1
@@ -1159,6 +1365,89 @@ class OkHttpStalkerApiService @Inject constructor(
)
}
+ private fun StalkerProviderProfile.merge(other: StalkerProviderProfile): StalkerProviderProfile =
+ copy(
+ accountId = other.accountId ?: accountId,
+ accountName = other.accountName ?: accountName,
+ maxConnections = other.maxConnections ?: maxConnections,
+ expirationDate = other.expirationDate ?: expirationDate,
+ statusLabel = other.statusLabel ?: statusLabel,
+ authAccess = other.authAccess ?: authAccess,
+ moduleNames = if (other.moduleNames.isNotEmpty()) other.moduleNames else moduleNames,
+ bootstrapStrategy = if (other.bootstrapStrategy != StalkerBootstrapStrategy.AUTO) {
+ other.bootstrapStrategy
+ } else {
+ bootstrapStrategy
+ },
+ effectiveAuthMode = if (other.effectiveAuthMode != StalkerAuthMode.AUTO) {
+ other.effectiveAuthMode
+ } else {
+ effectiveAuthMode
+ },
+ portalProfile = if (other.portalProfile != StalkerPortalProfile.MAG_BASIC) {
+ other.portalProfile
+ } else {
+ portalProfile
+ },
+ portalCapabilities = portalCapabilities.copy(
+ bootstrapStrategy = other.portalCapabilities.bootstrapStrategy
+ .takeUnless { it == StalkerBootstrapStrategy.AUTO }
+ ?: portalCapabilities.bootstrapStrategy,
+ useHttpTemporaryLink = portalCapabilities.useHttpTemporaryLink || other.portalCapabilities.useHttpTemporaryLink,
+ nginxSecureLink = portalCapabilities.nginxSecureLink || other.portalCapabilities.nginxSecureLink,
+ flussonicTemporaryLink = portalCapabilities.flussonicTemporaryLink || other.portalCapabilities.flussonicTemporaryLink,
+ wowzaTemporaryLink = portalCapabilities.wowzaTemporaryLink || other.portalCapabilities.wowzaTemporaryLink,
+ useLoadBalancing = portalCapabilities.useLoadBalancing || other.portalCapabilities.useLoadBalancing,
+ allowLocalTimeshift = portalCapabilities.allowLocalTimeshift || other.portalCapabilities.allowLocalTimeshift,
+ allowLocalPvr = portalCapabilities.allowLocalPvr || other.portalCapabilities.allowLocalPvr,
+ allowRemotePvr = portalCapabilities.allowRemotePvr || other.portalCapabilities.allowRemotePvr,
+ archiveAvailable = portalCapabilities.archiveAvailable || other.portalCapabilities.archiveAvailable,
+ moduleRestricted = portalCapabilities.moduleRestricted || other.portalCapabilities.moduleRestricted,
+ ambiguousAccountState = portalCapabilities.ambiguousAccountState || other.portalCapabilities.ambiguousAccountState
+ ),
+ credentialRequired = credentialRequired || other.credentialRequired,
+ macRequired = macRequired && other.macRequired,
+ bootstrapEvidence = (bootstrapEvidence + other.bootstrapEvidence).distinct(),
+ ambiguousState = ambiguousState || other.ambiguousState
+ )
+
+ private fun StalkerProviderProfile.shouldRequestAccountInfo(): Boolean =
+ authAccess == false || isAmbiguousAccountState()
+
+ private fun StalkerProviderProfile.shouldRequestModules(): Boolean =
+ authAccess == false || isAmbiguousAccountState()
+
+ private fun StalkerProviderProfile.isAmbiguousAccountState(): Boolean {
+ val normalizedStatus = statusLabel?.trim()?.lowercase(Locale.ROOT).orEmpty()
+ val normalizedAccountId = accountId?.trim().orEmpty()
+ val normalizedAccountName = accountName?.trim().orEmpty()
+ return normalizedStatus == "0" ||
+ authAccess == false ||
+ normalizedAccountId.isBlank() ||
+ normalizedAccountId == "0" ||
+ normalizedAccountName.isBlank() ||
+ normalizedAccountName == "0"
+ }
+
+ private fun JsonElement.toModuleNames(): List<String> {
+ val payload = payloadObjectOrNull()
+ val modulesValue = payload?.get("modules")
+ ?: rootObjectOrNull()?.get("js")
+ ?: return emptyList()
+ return when (modulesValue) {
+ is JsonArray -> modulesValue.mapNotNull { element ->
+ element.primitiveContentOrNull()
+ ?: element.jsonObjectOrNull()?.findString("id")
+ ?: element.jsonObjectOrNull()?.findString("name")
+ }
+ is JsonObject -> modulesValue.keys.toList()
+ is JsonPrimitive -> listOfNotNull(modulesValue.contentOrNull?.trim()?.takeIf { it.isNotBlank() })
+ else -> emptyList()
+ }.map { it.trim() }
+ .filter { it.isNotBlank() }
+ .distinct()
+ }
+
private fun JsonElement.toCategoryRecords(): List<StalkerCategoryRecord> {
return extractListElements().mapNotNull { entry ->
val id = entry.findString("id")
@@ -1191,6 +1480,23 @@ class OkHttpStalkerApiService @Inject constructor(
val name = findString("name")
?: findString("title")
?: return null
+ val capabilities = StalkerPortalCapabilities(
+ useHttpTemporaryLink = findBoolean("use_http_tmp_link") == true || findString("use_http_tmp_link") == "1",
+ nginxSecureLink = findBoolean("nginx_secure_link") == true || findString("nginx_secure_link") == "1",
+ flussonicTemporaryLink = findBoolean("flussonic_tmp_link") == true || findString("flussonic_tmp_link") == "1",
+ wowzaTemporaryLink = findBoolean("wowza_tmp_link") == true || findString("wowza_tmp_link") == "1",
+ useLoadBalancing = findBoolean("use_load_balancing") == true || findString("use_load_balancing") == "1",
+ allowLocalTimeshift = findBoolean("allow_local_timeshift") == true || findString("allow_local_timeshift") == "1",
+ allowLocalPvr = findBoolean("allow_local_pvr") == true || findString("allow_local_pvr") == "1",
+ allowRemotePvr = findBoolean("allow_remote_pvr") == true || findString("allow_remote_pvr") == "1",
+ archiveAvailable = findBoolean("archive") == true || findString("archive") == "1"
+ )
+ val alternateCommands = extractAlternateCommands()
+ val descriptor = buildStalkerPlaybackDescriptor(
+ primaryCmd = findString("cmd"),
+ alternateCommands = alternateCommands,
+ capabilities = capabilities
+ )
return StalkerItemRecord(
id = id,
name = name,
@@ -1205,6 +1511,19 @@ class OkHttpStalkerApiService @Inject constructor(
epgChannelId = findString("xmltv_id") ?: findString("epg_id"),
cmd = findString("cmd"),
streamUrl = sanitizeUrl(findString("cmd")),
+ playbackDescriptor = descriptor,
+ commandVariants = descriptor?.candidates.orEmpty(),
+ portalCapabilities = capabilities,
+ mcCmd = findString("mc_cmd"),
+ useHttpTemporaryLink = capabilities.useHttpTemporaryLink,
+ nginxSecureLink = capabilities.nginxSecureLink,
+ flussonicTemporaryLink = capabilities.flussonicTemporaryLink,
+ wowzaTemporaryLink = capabilities.wowzaTemporaryLink,
+ useLoadBalancing = capabilities.useLoadBalancing,
+ allowLocalTimeshift = capabilities.allowLocalTimeshift,
+ allowLocalPvr = capabilities.allowLocalPvr,
+ allowRemotePvr = capabilities.allowRemotePvr,
+ archiveAvailable = capabilities.archiveAvailable,
plot = findString("description") ?: findString("plot"),
cast = findString("censored")?.takeIf { false } ?: findString("actors"),
director = findString("director"),
@@ -1237,6 +1556,23 @@ class OkHttpStalkerApiService @Inject constructor(
val name = findString("name")
?: findString("title")
?: return null
+ val capabilities = StalkerPortalCapabilities(
+ useHttpTemporaryLink = findBoolean("use_http_tmp_link") == true || findString("use_http_tmp_link") == "1",
+ nginxSecureLink = findBoolean("nginx_secure_link") == true || findString("nginx_secure_link") == "1",
+ flussonicTemporaryLink = findBoolean("flussonic_tmp_link") == true || findString("flussonic_tmp_link") == "1",
+ wowzaTemporaryLink = findBoolean("wowza_tmp_link") == true || findString("wowza_tmp_link") == "1",
+ useLoadBalancing = findBoolean("use_load_balancing") == true || findString("use_load_balancing") == "1",
+ allowLocalTimeshift = findBoolean("allow_local_timeshift") == true || findString("allow_local_timeshift") == "1",
+ allowLocalPvr = findBoolean("allow_local_pvr") == true || findString("allow_local_pvr") == "1",
+ allowRemotePvr = findBoolean("allow_remote_pvr") == true || findString("allow_remote_pvr") == "1",
+ archiveAvailable = findBoolean("archive") == true || findString("archive") == "1"
+ )
+ val alternateCommands = extractAlternateCommands()
+ val descriptor = buildStalkerPlaybackDescriptor(
+ primaryCmd = findString("cmd"),
+ alternateCommands = alternateCommands,
+ capabilities = capabilities
+ )
return StalkerItemRecord(
id = id,
name = name,
@@ -1251,6 +1587,19 @@ class OkHttpStalkerApiService @Inject constructor(
epgChannelId = findString("xmltv_id") ?: findString("epg_id"),
cmd = findString("cmd"),
streamUrl = sanitizeUrl(findString("cmd")),
+ playbackDescriptor = descriptor,
+ commandVariants = descriptor?.candidates.orEmpty(),
+ portalCapabilities = capabilities,
+ mcCmd = findString("mc_cmd"),
+ useHttpTemporaryLink = capabilities.useHttpTemporaryLink,
+ nginxSecureLink = capabilities.nginxSecureLink,
+ flussonicTemporaryLink = capabilities.flussonicTemporaryLink,
+ wowzaTemporaryLink = capabilities.wowzaTemporaryLink,
+ useLoadBalancing = capabilities.useLoadBalancing,
+ allowLocalTimeshift = capabilities.allowLocalTimeshift,
+ allowLocalPvr = capabilities.allowLocalPvr,
+ allowRemotePvr = capabilities.allowRemotePvr,
+ archiveAvailable = capabilities.archiveAvailable,
plot = findString("description") ?: findString("plot"),
cast = findString("actors"),
director = findString("director"),
@@ -1274,6 +1623,40 @@ class OkHttpStalkerApiService @Inject constructor(
)
}
+ private fun JsonObject.extractAlternateCommands(): List<Pair<String, String>> {
+ val directVariants = buildList {
+ listOf("cmd_1", "cmd_2", "cmd_3", "mc_cmd").forEach { key ->
+ findString(key)?.takeIf { it.isNotBlank() }?.let { add(key to it) }
+ }
+ }
+ val commandArrayVariants = (this["cmds"] as? JsonArray).orEmpty().mapIndexedNotNull { index, element ->
+ val entry = element.jsonObjectOrNull() ?: return@mapIndexedNotNull null
+ val cmd = entry.findString("url")
+ ?: entry.findString("cmd")
+ ?: return@mapIndexedNotNull null
+ "cmds[$index]" to cmd
+ }
+ return (directVariants + commandArrayVariants).distinctBy { it.second.trim() }
+ }
+
+ private fun GsonJsonObject.extractAlternateCommands(): List<Pair<String, String>> {
+ val directVariants = buildList {
+ listOf("cmd_1", "cmd_2", "cmd_3", "mc_cmd").forEach { key ->
+ findString(key)?.takeIf { it.isNotBlank() }?.let { add(key to it) }
+ }
+ }
+ val commandArrayVariants = getAsJsonArray("cmds")
+ ?.mapIndexedNotNull { index, element ->
+ val entry = element.asJsonObjectOrNull() ?: return@mapIndexedNotNull null
+ val cmd = entry.findString("url")
+ ?: entry.findString("cmd")
+ ?: return@mapIndexedNotNull null
+ "cmds[$index]" to cmd
+ }
+ .orEmpty()
+ return (directVariants + commandArrayVariants).distinctBy { it.second.trim() }
+ }
+
private fun StalkerItemRecord.looksLikeSeasonShell(): Boolean {
val normalizedName = name.trim()
if (normalizedName.startsWith("Season ", ignoreCase = true)) {
@@ -1595,6 +1978,45 @@ class OkHttpStalkerApiService @Inject constructor(
private fun actionSuffix(action: String?): String =
action?.takeIf { it.isNotBlank() }?.let { " for $it" }.orEmpty()
+ private fun candidateAuthModes(profile: StalkerDeviceProfile): List<StalkerAuthMode> {
+ return when (profile.authMode) {
+ StalkerAuthMode.AUTO -> buildList {
+ val hasMac = profile.macAddress.isNotBlank()
+ val hasCredentials = profile.username.isNotBlank()
+ if (hasMac) add(StalkerAuthMode.MAC_ONLY)
+ if (hasMac && hasCredentials) add(StalkerAuthMode.MAC_PLUS_CREDENTIALS)
+ if (hasCredentials) add(StalkerAuthMode.CREDENTIALS_ONLY)
+ if (isEmpty()) add(StalkerAuthMode.MAC_ONLY)
+ }
+ else -> listOf(profile.authMode)
+ }.distinct()
+ }
+
+ private fun StalkerAuthMode.requiresCredentials(): Boolean =
+ this == StalkerAuthMode.CREDENTIALS_ONLY || this == StalkerAuthMode.MAC_PLUS_CREDENTIALS
+
+ private fun resolvePortalProfile(
+ authMode: StalkerAuthMode,
+ providerProfile: StalkerProviderProfile,
+ requestedProfile: StalkerDeviceProfile
+ ): StalkerPortalProfile {
+ val hasCredentials = requestedProfile.username.isNotBlank()
+ val modulesRestricted = providerProfile.moduleNames.isNotEmpty()
+ val strictFingerprint = requestedProfile.serialNumber.isNotBlank() ||
+ requestedProfile.deviceId.isNotBlank() ||
+ requestedProfile.deviceId2.isNotBlank() ||
+ requestedProfile.signature.isNotBlank()
+ return when {
+ modulesRestricted -> StalkerPortalProfile.MODULE_GATED
+ authMode == StalkerAuthMode.MAC_PLUS_CREDENTIALS -> StalkerPortalProfile.AUTH_PLUS_MAG
+ authMode == StalkerAuthMode.CREDENTIALS_ONLY -> StalkerPortalProfile.AUTH_REQUIRED
+ providerProfile.authAccess == false && hasCredentials -> StalkerPortalProfile.AUTH_PLUS_MAG
+ providerProfile.authAccess == false && requestedProfile.macAddress.isBlank() -> StalkerPortalProfile.AUTH_REQUIRED
+ providerProfile.portalCapabilities.usesTemporaryLinks && strictFingerprint -> StalkerPortalProfile.MAG_STRICT
+ else -> StalkerPortalProfile.MAG_BASIC
+ }
+ }
+
private fun extractContainerExtension(cmd: String?, fallback: String?): String? {
fallback?.trim()?.removePrefix(".")?.takeIf { it.isNotBlank() }?.let { return it.lowercase(Locale.ROOT) }
val path = runCatching { URI(cmd).path }.getOrNull() ?: cmd
@@ -1616,6 +2038,7 @@ class OkHttpStalkerApiService @Inject constructor(
private const val MAX_EPG_BYTES = 64L * 1024L * 1024L
/** Records retained by the legacy buffered [getBulkEpg]/[getEpg] APIs to keep callers heap-safe. */
private const val MAX_INLINE_EPG_RECORDS = 1500
+ private val FORM_URL_ENCODED_MEDIA_TYPE = "application/x-www-form-urlencoded".toMediaType()
private const val DEFAULT_VERSION_STRING =
"ImageDescription: 0.2.18-r23-250; ImageDate: Wed Oct 31 15:22:54 EEST 2018; PORTAL version: 5.6.2; API Version: JS API version: 343; STB API version: 146; Player Engine version: 0x58c"
}
@@ -1624,6 +2047,9 @@ class OkHttpStalkerApiService @Inject constructor(
internal fun buildStalkerDeviceProfile(
portalUrl: String,
macAddress: String,
+ authMode: StalkerAuthMode = StalkerAuthMode.AUTO,
+ username: String = "",
+ password: String = "",
deviceProfile: String,
timezone: String,
locale: String,
@@ -1636,7 +2062,7 @@ internal fun buildStalkerDeviceProfile(
val normalizedTimezone = timezone.ifBlank { java.util.TimeZone.getDefault().id }
val normalizedLocale = locale.ifBlank { Locale.getDefault().language.ifBlank { "en" } }
val normalizedMac = macAddress.uppercase(Locale.ROOT)
- val serialSeed = normalizedMac.replace(":", "")
+ val serialSeed = normalizedMac.replace(":", "").ifBlank { username.trim().uppercase(Locale.ROOT) }
val serialNumber = serialNumberOverride.ifBlank { serialSeed.takeLast(13).padStart(13, '0') }
val deviceId = deviceIdOverride.ifBlank { stalkerDigest("device:$normalizedProfile:$normalizedMac") }
val deviceId2 = deviceId2Override.ifBlank { stalkerDigest("device2:$normalizedProfile:$normalizedMac") }
@@ -1644,6 +2070,9 @@ internal fun buildStalkerDeviceProfile(
return StalkerDeviceProfile(
portalUrl = portalUrl,
macAddress = normalizedMac,
+ authMode = authMode,
+ username = username.trim(),
+ password = password,
deviceProfile = normalizedProfile,
timezone = normalizedTimezone,
locale = normalizedLocale,
@@ -1748,3 +2177,44 @@ private class ByteSizeLimitInputStream(
}
}
}
+
+private class InMemoryStalkerCookieJar : CookieJar {
+ private val store = ConcurrentHashMap<String, MutableList<Cookie>>()
+
+ override fun saveFromResponse(url: HttpUrl, cookies: List<Cookie>) {
+ if (cookies.isEmpty()) return
+ val key = url.topPrivateDomain() ?: url.host
+ val existing = store.getOrPut(key) { mutableListOf() }
+ cookies.forEach { incoming ->
+ existing.removeAll { current ->
+ current.name == incoming.name &&
+ current.domain == incoming.domain &&
+ current.path == incoming.path
+ }
+ if (!incoming.expiresAt.let { it > 0L } || incoming.expiresAt > System.currentTimeMillis()) {
+ existing += incoming
+ }
+ }
+ }
+
+ override fun loadForRequest(url: HttpUrl): List<Cookie> {
+ val key = url.topPrivateDomain() ?: url.host
+ val existing = store[key].orEmpty()
+ val now = System.currentTimeMillis()
+ val valid = existing.filter { cookie -> cookie.expiresAt > now && cookie.matches(url) }
+ if (valid.size != existing.size) {
+ store[key] = valid.toMutableList()
+ }
+ return valid
+ }
+
+ fun cookieHeaderFor(url: String): String {
+ val httpUrl = url.toHttpUrlOrNull() ?: return ""
+ return loadForRequest(httpUrl)
+ .joinToString("; ") { cookie -> "${cookie.name}=${cookie.value}" }
+ }
+
+ fun clear() {
+ store.clear()
+ }
+}
diff --git a/data/src/main/java/com/streamvault/data/remote/stalker/StalkerApiService.kt b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerApiService.kt
index 102b2326..1e4aea81 100644
--- a/data/src/main/java/com/streamvault/data/remote/stalker/StalkerApiService.kt
+++ b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerApiService.kt
@@ -1,10 +1,15 @@
package com.streamvault.data.remote.stalker
import com.streamvault.domain.model.Result
+import com.streamvault.domain.model.StalkerAuthMode
+import com.streamvault.domain.model.StalkerPortalProfile
data class StalkerDeviceProfile(
val portalUrl: String,
val macAddress: String,
+ val authMode: StalkerAuthMode,
+ val username: String,
+ val password: String,
val deviceProfile: String,
val timezone: String,
val locale: String,
@@ -19,7 +24,11 @@ data class StalkerDeviceProfile(
data class StalkerSession(
val loadUrl: String,
val portalReferer: String,
- val token: String
+ val token: String,
+ val serverCookieHeader: String = "",
+ val effectiveAuthMode: StalkerAuthMode = StalkerAuthMode.AUTO,
+ val portalProfile: StalkerPortalProfile = StalkerPortalProfile.MAG_BASIC,
+ val bootstrapEvidence: List<String> = emptyList()
)
data class StalkerProviderProfile(
@@ -28,7 +37,16 @@ data class StalkerProviderProfile(
val maxConnections: Int? = null,
val expirationDate: Long? = null,
val statusLabel: String? = null,
- val authAccess: Boolean? = null
+ val authAccess: Boolean? = null,
+ val moduleNames: List<String> = emptyList(),
+ val bootstrapStrategy: StalkerBootstrapStrategy = StalkerBootstrapStrategy.AUTO,
+ val effectiveAuthMode: StalkerAuthMode = StalkerAuthMode.AUTO,
+ val portalProfile: StalkerPortalProfile = StalkerPortalProfile.MAG_BASIC,
+ val portalCapabilities: StalkerPortalCapabilities = StalkerPortalCapabilities(),
+ val credentialRequired: Boolean = false,
+ val macRequired: Boolean = true,
+ val bootstrapEvidence: List<String> = emptyList(),
+ val ambiguousState: Boolean = false
)
data class StalkerCategoryRecord(
@@ -57,6 +75,19 @@ data class StalkerItemRecord(
val youtubeTrailer: String? = null,
val backdropUrl: String? = null,
val containerExtension: String? = null,
+ val playbackDescriptor: StalkerPlaybackDescriptor? = null,
+ val commandVariants: List<StalkerCommandVariant> = emptyList(),
+ val portalCapabilities: StalkerPortalCapabilities = StalkerPortalCapabilities(),
+ val mcCmd: String? = null,
+ val useHttpTemporaryLink: Boolean? = null,
+ val nginxSecureLink: Boolean? = null,
+ val flussonicTemporaryLink: Boolean? = null,
+ val wowzaTemporaryLink: Boolean? = null,
+ val useLoadBalancing: Boolean? = null,
+ val allowLocalTimeshift: Boolean? = null,
+ val allowLocalPvr: Boolean? = null,
+ val allowRemotePvr: Boolean? = null,
+ val archiveAvailable: Boolean? = null,
val addedAt: Long = 0L,
val isAdult: Boolean = false,
val isSeries: Boolean = false
diff --git a/data/src/main/java/com/streamvault/data/remote/stalker/StalkerCompatibility.kt b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerCompatibility.kt
new file mode 100644
index 00000000..bb94268e
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerCompatibility.kt
@@ -0,0 +1,140 @@
+package com.streamvault.data.remote.stalker
+
+import com.streamvault.data.util.UrlSecurityPolicy
+import java.net.URI
+
+enum class StalkerBootstrapStrategy {
+ AUTO,
+ MAC_ONLY,
+ MAC_WITH_ACCOUNT_INFO,
+ MAC_WITH_MODULES
+}
+
+enum class StalkerPlaybackMode {
+ DIRECT_URL,
+ LOCALHOST_CMD,
+ TEMP_LINK_NGINX,
+ TEMP_LINK_FLUSSONIC,
+ TEMP_LINK_WOWZA,
+ MULTI_CMD
+}
+
+data class StalkerPortalCapabilities(
+ val bootstrapStrategy: StalkerBootstrapStrategy = StalkerBootstrapStrategy.AUTO,
+ val useHttpTemporaryLink: Boolean = false,
+ val nginxSecureLink: Boolean = false,
+ val flussonicTemporaryLink: Boolean = false,
+ val wowzaTemporaryLink: Boolean = false,
+ val useLoadBalancing: Boolean = false,
+ val allowLocalTimeshift: Boolean = false,
+ val allowLocalPvr: Boolean = false,
+ val allowRemotePvr: Boolean = false,
+ val archiveAvailable: Boolean = false,
+ val moduleRestricted: Boolean = false,
+ val ambiguousAccountState: Boolean = false
+) {
+ val usesTemporaryLinks: Boolean
+ get() = useHttpTemporaryLink || nginxSecureLink || flussonicTemporaryLink || wowzaTemporaryLink
+}
+
+data class StalkerCommandVariant(
+ val cmd: String,
+ val playbackMode: StalkerPlaybackMode,
+ val sourceKey: String = "cmd",
+ val priority: Int = 0
+)
+
+data class StalkerPlaybackDescriptor(
+ val primaryMode: StalkerPlaybackMode,
+ val candidates: List<StalkerCommandVariant>,
+ val capabilities: StalkerPortalCapabilities = StalkerPortalCapabilities()
+)
+
+internal fun buildStalkerPlaybackDescriptor(
+ primaryCmd: String?,
+ alternateCommands: List<Pair<String, String>> = emptyList(),
+ capabilities: StalkerPortalCapabilities = StalkerPortalCapabilities()
+): StalkerPlaybackDescriptor? {
+ val candidates = orderStalkerCommandVariants(buildList {
+ primaryCmd?.trim()
+ ?.takeIf { it.isNotBlank() }
+ ?.let { cmd ->
+ add(
+ StalkerCommandVariant(
+ cmd = cmd,
+ playbackMode = detectStalkerPlaybackMode(cmd, capabilities),
+ sourceKey = "cmd",
+ priority = 0
+ )
+ )
+ }
+ alternateCommands.forEachIndexed { index, (sourceKey, value) ->
+ value.trim()
+ .takeIf { it.isNotBlank() }
+ ?.let { cmd ->
+ add(
+ StalkerCommandVariant(
+ cmd = cmd,
+ playbackMode = detectStalkerPlaybackMode(cmd, capabilities),
+ sourceKey = sourceKey,
+ priority = index + 1
+ )
+ )
+ }
+ }
+ })
+
+ if (candidates.isEmpty()) return null
+ return StalkerPlaybackDescriptor(
+ primaryMode = if (candidates.size > 1) StalkerPlaybackMode.MULTI_CMD else candidates.first().playbackMode,
+ candidates = candidates,
+ capabilities = capabilities
+ )
+}
+
+internal fun detectStalkerPlaybackMode(
+ cmd: String,
+ capabilities: StalkerPortalCapabilities = StalkerPortalCapabilities()
+): StalkerPlaybackMode {
+ val directCandidate = cmd.substringAfter(' ', missingDelimiterValue = cmd).trim()
+ val uri = runCatching { URI(directCandidate) }.getOrNull()
+ val host = uri?.host?.trim()?.lowercase().orEmpty()
+ val path = uri?.path?.trim()?.lowercase().orEmpty()
+
+ return when {
+ host.isBlank() || host == "localhost" || host == "127.0.0.1" || host == "0.0.0.0" ->
+ StalkerPlaybackMode.LOCALHOST_CMD
+
+ capabilities.flussonicTemporaryLink ->
+ StalkerPlaybackMode.TEMP_LINK_FLUSSONIC
+
+ capabilities.wowzaTemporaryLink ->
+ StalkerPlaybackMode.TEMP_LINK_WOWZA
+
+ capabilities.nginxSecureLink ||
+ capabilities.useHttpTemporaryLink ||
+ path.endsWith("/play/live.php") ||
+ path.endsWith("/play/movie.php") ->
+ StalkerPlaybackMode.TEMP_LINK_NGINX
+
+ UrlSecurityPolicy.isAllowedStreamEntryUrl(directCandidate) ->
+ StalkerPlaybackMode.DIRECT_URL
+
+ else -> StalkerPlaybackMode.LOCALHOST_CMD
+ }
+}
+
+internal fun orderStalkerCommandVariants(
+ variants: List<StalkerCommandVariant>
+): List<StalkerCommandVariant> = variants
+ .distinctBy { it.cmd.trim() }
+ .sortedWith(compareBy<StalkerCommandVariant>({ playbackModeRank(it.playbackMode) }, { it.priority }))
+
+private fun playbackModeRank(mode: StalkerPlaybackMode): Int = when (mode) {
+ StalkerPlaybackMode.DIRECT_URL -> 0
+ StalkerPlaybackMode.MULTI_CMD -> 1
+ StalkerPlaybackMode.LOCALHOST_CMD -> 2
+ StalkerPlaybackMode.TEMP_LINK_NGINX,
+ StalkerPlaybackMode.TEMP_LINK_FLUSSONIC,
+ StalkerPlaybackMode.TEMP_LINK_WOWZA -> 3
+}
diff --git a/data/src/main/java/com/streamvault/data/remote/stalker/StalkerPlaybackAdapters.kt b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerPlaybackAdapters.kt
new file mode 100644
index 00000000..68b0ff64
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerPlaybackAdapters.kt
@@ -0,0 +1,134 @@
+package com.streamvault.data.remote.stalker
+
+import com.streamvault.domain.model.StalkerPortalProfile
+
+internal interface StalkerPlaybackAdapter {
+ val adapterMode: StalkerPlaybackMode
+
+ fun matches(
+ descriptor: StalkerPlaybackDescriptor,
+ variant: StalkerCommandVariant,
+ portalProfileHint: StalkerPortalProfile,
+ preferredMode: StalkerPlaybackMode?
+ ): Boolean
+
+ fun allowsDirectBypass(variant: StalkerCommandVariant): Boolean
+
+ fun requiresCreateLink(variant: StalkerCommandVariant): Boolean
+
+ fun allowsRebootstrap(
+ descriptor: StalkerPlaybackDescriptor,
+ accountProfile: StalkerProviderProfile
+ ): Boolean = descriptor.capabilities.usesTemporaryLinks ||
+ accountProfile.ambiguousState ||
+ descriptor.primaryMode == StalkerPlaybackMode.MULTI_CMD
+}
+
+internal object DirectOrCreateLinkAdapter : StalkerPlaybackAdapter {
+ override val adapterMode: StalkerPlaybackMode = StalkerPlaybackMode.DIRECT_URL
+
+ override fun matches(
+ descriptor: StalkerPlaybackDescriptor,
+ variant: StalkerCommandVariant,
+ portalProfileHint: StalkerPortalProfile,
+ preferredMode: StalkerPlaybackMode?
+ ): Boolean = variant.playbackMode == StalkerPlaybackMode.DIRECT_URL ||
+ variant.playbackMode == StalkerPlaybackMode.LOCALHOST_CMD ||
+ descriptor.primaryMode == StalkerPlaybackMode.MULTI_CMD
+
+ override fun allowsDirectBypass(variant: StalkerCommandVariant): Boolean =
+ variant.playbackMode == StalkerPlaybackMode.DIRECT_URL
+
+ override fun requiresCreateLink(variant: StalkerCommandVariant): Boolean =
+ variant.playbackMode != StalkerPlaybackMode.DIRECT_URL
+}
+
+internal object NginxSecureLinkAdapter : StalkerPlaybackAdapter {
+ override val adapterMode: StalkerPlaybackMode = StalkerPlaybackMode.TEMP_LINK_NGINX
+
+ override fun matches(
+ descriptor: StalkerPlaybackDescriptor,
+ variant: StalkerCommandVariant,
+ portalProfileHint: StalkerPortalProfile,
+ preferredMode: StalkerPlaybackMode?
+ ): Boolean = variant.playbackMode == StalkerPlaybackMode.TEMP_LINK_NGINX ||
+ descriptor.capabilities.nginxSecureLink ||
+ descriptor.capabilities.useHttpTemporaryLink ||
+ portalProfileHint == StalkerPortalProfile.MAG_STRICT
+
+ override fun allowsDirectBypass(variant: StalkerCommandVariant): Boolean = true
+
+ override fun requiresCreateLink(variant: StalkerCommandVariant): Boolean = true
+}
+
+internal object FlussonicTemporaryLinkAdapter : StalkerPlaybackAdapter {
+ override val adapterMode: StalkerPlaybackMode = StalkerPlaybackMode.TEMP_LINK_FLUSSONIC
+
+ override fun matches(
+ descriptor: StalkerPlaybackDescriptor,
+ variant: StalkerCommandVariant,
+ portalProfileHint: StalkerPortalProfile,
+ preferredMode: StalkerPlaybackMode?
+ ): Boolean = variant.playbackMode == StalkerPlaybackMode.TEMP_LINK_FLUSSONIC ||
+ descriptor.capabilities.flussonicTemporaryLink
+
+ override fun allowsDirectBypass(variant: StalkerCommandVariant): Boolean = true
+
+ override fun requiresCreateLink(variant: StalkerCommandVariant): Boolean = true
+}
+
+internal object WowzaTemporaryLinkAdapter : StalkerPlaybackAdapter {
+ override val adapterMode: StalkerPlaybackMode = StalkerPlaybackMode.TEMP_LINK_WOWZA
+
+ override fun matches(
+ descriptor: StalkerPlaybackDescriptor,
+ variant: StalkerCommandVariant,
+ portalProfileHint: StalkerPortalProfile,
+ preferredMode: StalkerPlaybackMode?
+ ): Boolean = variant.playbackMode == StalkerPlaybackMode.TEMP_LINK_WOWZA ||
+ descriptor.capabilities.wowzaTemporaryLink
+
+ override fun allowsDirectBypass(variant: StalkerCommandVariant): Boolean = true
+
+ override fun requiresCreateLink(variant: StalkerCommandVariant): Boolean = true
+}
+
+internal fun resolveStalkerPlaybackAdapter(
+ descriptor: StalkerPlaybackDescriptor,
+ variant: StalkerCommandVariant,
+ portalProfileHint: StalkerPortalProfile,
+ preferredMode: StalkerPlaybackMode?
+): StalkerPlaybackAdapter {
+ val ordered = buildList {
+ if (preferredMode != null) {
+ adapterForMode(preferredMode)?.let(::add)
+ }
+ add(
+ when (variant.playbackMode) {
+ StalkerPlaybackMode.TEMP_LINK_FLUSSONIC -> FlussonicTemporaryLinkAdapter
+ StalkerPlaybackMode.TEMP_LINK_WOWZA -> WowzaTemporaryLinkAdapter
+ StalkerPlaybackMode.TEMP_LINK_NGINX -> NginxSecureLinkAdapter
+ else -> DirectOrCreateLinkAdapter
+ }
+ )
+ if (portalProfileHint == StalkerPortalProfile.MAG_STRICT) add(NginxSecureLinkAdapter)
+ if (descriptor.capabilities.flussonicTemporaryLink) add(FlussonicTemporaryLinkAdapter)
+ if (descriptor.capabilities.wowzaTemporaryLink) add(WowzaTemporaryLinkAdapter)
+ if (descriptor.capabilities.nginxSecureLink || descriptor.capabilities.useHttpTemporaryLink) {
+ add(NginxSecureLinkAdapter)
+ }
+ add(DirectOrCreateLinkAdapter)
+ }.distinctBy { it.adapterMode }
+ return ordered.firstOrNull { adapter ->
+ adapter.matches(descriptor, variant, portalProfileHint, preferredMode)
+ } ?: DirectOrCreateLinkAdapter
+}
+
+private fun adapterForMode(mode: StalkerPlaybackMode): StalkerPlaybackAdapter? = when (mode) {
+ StalkerPlaybackMode.TEMP_LINK_FLUSSONIC -> FlussonicTemporaryLinkAdapter
+ StalkerPlaybackMode.TEMP_LINK_WOWZA -> WowzaTemporaryLinkAdapter
+ StalkerPlaybackMode.TEMP_LINK_NGINX -> NginxSecureLinkAdapter
+ StalkerPlaybackMode.DIRECT_URL,
+ StalkerPlaybackMode.LOCALHOST_CMD,
+ StalkerPlaybackMode.MULTI_CMD -> DirectOrCreateLinkAdapter
+}
diff --git a/data/src/main/java/com/streamvault/data/remote/stalker/StalkerPlaybackResolutionException.kt b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerPlaybackResolutionException.kt
new file mode 100644
index 00000000..aff0a23c
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerPlaybackResolutionException.kt
@@ -0,0 +1,8 @@
+package com.streamvault.data.remote.stalker
+
+import java.io.IOException
+
+class StalkerPlaybackResolutionException(
+ message: String,
+ cause: Throwable? = null
+) : IOException(message, cause)
diff --git a/data/src/main/java/com/streamvault/data/remote/stalker/StalkerProvider.kt b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerProvider.kt
index 6b6c2463..1e39458f 100644
--- a/data/src/main/java/com/streamvault/data/remote/stalker/StalkerProvider.kt
+++ b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerProvider.kt
@@ -14,8 +14,11 @@ import com.streamvault.domain.model.ProviderType
import com.streamvault.domain.model.Result
import com.streamvault.domain.model.Season
import com.streamvault.domain.model.Series
+import com.streamvault.domain.model.StalkerAuthMode
+import com.streamvault.domain.model.StalkerPortalProfile
import com.streamvault.domain.provider.IptvProvider
import com.streamvault.domain.util.ChannelNormalizer
+import java.io.IOException
import java.net.URI
import java.util.Base64
import java.util.Locale
@@ -25,7 +28,8 @@ import kotlinx.coroutines.sync.withLock
data class StalkerPlaybackInfo(
val url: String,
val headers: Map<String, String> = emptyMap(),
- val userAgent: String? = null
+ val userAgent: String? = null,
+ val playbackMode: StalkerPlaybackMode = StalkerPlaybackMode.DIRECT_URL
)
data class StalkerPagedResult<T>(
@@ -42,6 +46,11 @@ class StalkerProvider(
private val api: StalkerApiService,
private val portalUrl: String,
private val macAddress: String,
+ private val authMode: StalkerAuthMode = StalkerAuthMode.AUTO,
+ private val username: String = "",
+ private val password: String = "",
+ private val portalProfileHint: StalkerPortalProfile = StalkerPortalProfile.MAG_BASIC,
+ private val preferredPlaybackMode: StalkerPlaybackMode? = null,
private val deviceProfile: String,
private val timezone: String,
private val locale: String,
@@ -76,6 +85,7 @@ class StalkerProvider(
val profile = authResult.data.second
val hostLabel = portalUrl.substringAfter("://").substringBefore('/').ifBlank { "portal" }
val providerName = profile.accountName?.takeUnless { it.isBlank() || it == "0" }
+ ?: normalizedUsername().takeIf { it.isNotBlank() }
?: "${normalizedMacAddress().takeLast(8)}@$hostLabel"
Result.success(
Provider(
@@ -83,6 +93,8 @@ class StalkerProvider(
name = providerName,
type = ProviderType.STALKER_PORTAL,
serverUrl = StalkerUrlFactory.normalizePortalUrl(portalUrl),
+ username = normalizedUsername(),
+ password = normalizedPassword(),
stalkerMacAddress = normalizedMacAddress(),
stalkerDeviceProfile = normalizedDeviceProfile(),
stalkerDeviceTimezone = normalizedTimezone(),
@@ -91,15 +103,17 @@ class StalkerProvider(
stalkerDeviceId = normalizedDeviceId(),
stalkerDeviceId2 = normalizedDeviceId2(),
stalkerSignature = normalizedSignature(),
+ stalkerAuthMode = profile.effectiveAuthMode,
+ stalkerPortalProfile = profile.portalProfile,
+ stalkerLastPlaybackMode = null,
+ stalkerCredentialsRequired = profile.credentialRequired,
+ stalkerMacRequired = profile.macRequired,
+ stalkerUsesTemporaryLinks = profile.portalCapabilities.usesTemporaryLinks,
+ stalkerModuleRestricted = profile.portalCapabilities.moduleRestricted,
maxConnections = profile.maxConnections ?: 1,
expirationDate = profile.expirationDate,
apiVersion = "Stalker/MAG Portal",
- status = when (profile.statusLabel?.trim()?.lowercase(Locale.ROOT)) {
- "active", "enabled", "1" -> ProviderStatus.ACTIVE
- "expired", "0" -> ProviderStatus.EXPIRED
- "disabled", "blocked", "banned" -> ProviderStatus.DISABLED
- else -> ProviderStatus.ACTIVE
- }
+ status = resolveProviderStatus(profile)
)
)
}
@@ -322,34 +336,121 @@ class StalkerProvider(
kind: StalkerStreamKind,
cmd: String,
seriesNumber: Int? = null
+ ): Result<StalkerPlaybackInfo> = resolvePlaybackInfo(
+ kind = kind,
+ descriptor = buildStalkerPlaybackDescriptor(cmd),
+ seriesNumber = seriesNumber
+ )
+
+ suspend fun resolvePlaybackInfo(
+ kind: StalkerStreamKind,
+ descriptor: StalkerPlaybackDescriptor?,
+ seriesNumber: Int? = null
+ ): Result<StalkerPlaybackInfo> {
+ val resolvedDescriptor = descriptor ?: return Result.error("This portal requires a different playback path than the default command.")
+ return resolvePlaybackInfoInternal(kind, resolvedDescriptor, seriesNumber, allowRebootstrap = true)
+ }
+
+ private suspend fun resolvePlaybackInfoInternal(
+ kind: StalkerStreamKind,
+ descriptor: StalkerPlaybackDescriptor,
+ seriesNumber: Int?,
+ allowRebootstrap: Boolean
): Result<StalkerPlaybackInfo> {
return when (val authResult = ensureAuthenticated()) {
is Result.Success -> {
- val (session, _) = authResult.data
+ val (session, accountProfile) = authResult.data
val profile = currentDeviceProfile()
- val directUrl = extractDirectPlaybackUrl(cmd)
- directUrl
- ?.takeIf { candidate -> shouldBypassCreateLink(kind, candidate) }
- ?.let { candidate ->
- return Result.success(
- StalkerPlaybackInfo(
- url = candidate,
- headers = buildPlaybackHeaders(session, profile),
- userAgent = profile.userAgent
+ var lastError: Result.Error? = null
+ val orderedCandidates = descriptor.candidates.sortedBy { variant ->
+ if (preferredPlaybackMode != null && variant.playbackMode == preferredPlaybackMode) 0 else 1
+ }
+ orderedCandidates.forEach { variant ->
+ val adapter = resolveStalkerPlaybackAdapter(
+ descriptor = descriptor,
+ variant = variant,
+ portalProfileHint = accountProfile.portalProfile.takeUnless {
+ it == StalkerPortalProfile.MAG_BASIC
+ } ?: portalProfileHint,
+ preferredMode = preferredPlaybackMode
+ )
+ val directUrl = extractDirectPlaybackUrl(variant.cmd)
+ directUrl
+ ?.takeIf { candidate ->
+ adapter.allowsDirectBypass(variant) &&
+ shouldBypassCreateLink(kind, candidate)
+ }
+ ?.let { candidate ->
+ return Result.success(
+ StalkerPlaybackInfo(
+ url = candidate,
+ headers = buildPlaybackHeaders(session, profile),
+ userAgent = profile.userAgent,
+ playbackMode = adapter.adapterMode
+ )
)
- )
+ }
+
+ if (!adapter.requiresCreateLink(variant)) {
+ lastError = Result.error("This portal requires a different playback path than the default command.")
+ return@forEach
}
- when (val linkResult = api.createLink(session, profile, kind, cmd, seriesNumber)) {
- is Result.Success -> Result.success(
- StalkerPlaybackInfo(
- url = repairCreateLinkUrl(kind, linkResult.data, directUrl),
- headers = buildPlaybackHeaders(session, profile),
- userAgent = profile.userAgent
- )
+
+ when (val linkResult = api.createLink(session, profile, kind, variant.cmd, seriesNumber)) {
+ is Result.Success -> {
+ return Result.success(
+ StalkerPlaybackInfo(
+ url = repairCreateLinkUrl(kind, linkResult.data, directUrl),
+ headers = buildPlaybackHeaders(session, profile),
+ userAgent = profile.userAgent,
+ playbackMode = adapter.adapterMode
+ )
+ )
+ }
+ is Result.Error -> lastError = linkResult
+ is Result.Loading -> {
+ lastError = Result.error("Unexpected loading state")
+ }
+ }
+ }
+
+ val needsRebootstrap = allowRebootstrap &&
+ orderedCandidates.any { variant ->
+ resolveStalkerPlaybackAdapter(
+ descriptor = descriptor,
+ variant = variant,
+ portalProfileHint = accountProfile.portalProfile.takeUnless {
+ it == StalkerPortalProfile.MAG_BASIC
+ } ?: portalProfileHint,
+ preferredMode = preferredPlaybackMode
+ ).allowsRebootstrap(descriptor, accountProfile)
+ } &&
+ isLikelyAuthOrSessionFailure(lastError?.message.orEmpty(), lastError?.exception)
+ if (needsRebootstrap) {
+ invalidateAuthentication()
+ return resolvePlaybackInfoInternal(
+ kind = kind,
+ descriptor = descriptor,
+ seriesNumber = seriesNumber,
+ allowRebootstrap = false
)
- is Result.Error -> Result.error(linkResult.message, linkResult.exception)
- is Result.Loading -> Result.error("Unexpected loading state")
}
+
+ val message = when {
+ descriptor.capabilities.ambiguousAccountState || accountProfile.ambiguousState ->
+ "Portal profile is ambiguous; playback/session validation failed."
+
+ descriptor.primaryMode == StalkerPlaybackMode.MULTI_CMD || descriptor.candidates.size > 1 ->
+ "This portal requires a different playback path than the default command."
+
+ descriptor.capabilities.usesTemporaryLinks ->
+ lastError?.message?.takeIf { it.isNotBlank() }
+ ?: "Portal could not issue a valid temporary playback link for this stream."
+
+ else -> lastError?.message?.takeIf { it.isNotBlank() }
+ ?: "We couldn't resolve a playable Stalker stream for this item."
+ }
+ Result.error(message, lastError?.exception)
}
is Result.Error -> Result.error(authResult.message, authResult.exception)
is Result.Loading -> Result.error("Unexpected loading state")
@@ -450,6 +551,9 @@ class StalkerProvider(
val profile = buildStalkerDeviceProfile(
portalUrl = portalUrl,
macAddress = normalizedMacAddress(),
+ authMode = authMode,
+ username = normalizedUsername(),
+ password = normalizedPassword(),
deviceProfile = normalizedDeviceProfile(),
timezone = normalizedTimezone(),
locale = normalizedLocale(),
@@ -473,6 +577,9 @@ class StalkerProvider(
return buildStalkerDeviceProfile(
portalUrl = portalUrl,
macAddress = normalizedMacAddress(),
+ authMode = authMode,
+ username = normalizedUsername(),
+ password = normalizedPassword(),
deviceProfile = normalizedDeviceProfile(),
timezone = normalizedTimezone(),
locale = normalizedLocale(),
@@ -489,24 +596,37 @@ class StalkerProvider(
): Map<String, String> = buildMap {
put("Referer", session.portalReferer)
put("Accept", "*/*")
- put(
- "Cookie",
- listOf(
- "mac=${profile.macAddress}",
- "stb_lang=${profile.locale}",
- "timezone=${profile.timezone}",
- "sn=${profile.serialNumber}",
- "device_id=${profile.deviceId}",
- "device_id2=${profile.deviceId2}",
- "signature=${profile.signature}"
- ).joinToString("; ")
- )
+ put("Cookie", buildPlaybackCookieHeader(session, profile))
put("X-User-Agent", profile.xUserAgent)
session.token.takeIf { it.isNotBlank() }?.let { token ->
put("Authorization", "Bearer $token")
}
}
+ private fun buildPlaybackCookieHeader(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile
+ ): String {
+ val cookies = linkedMapOf(
+ "mac" to profile.macAddress,
+ "stb_lang" to profile.locale,
+ "timezone" to profile.timezone,
+ "sn" to profile.serialNumber,
+ "device_id" to profile.deviceId,
+ "device_id2" to profile.deviceId2,
+ "signature" to profile.signature
+ )
+ session.serverCookieHeader.split(';')
+ .mapNotNull { part ->
+ val key = part.substringBefore('=', missingDelimiterValue = "").trim()
+ val value = part.substringAfter('=', missingDelimiterValue = "").trim()
+ key.takeIf { it.isNotBlank() && value.isNotBlank() }?.let { it to value }
+ }.forEach { (key, value) ->
+ cookies.putIfAbsent(key, value)
+ }
+ return cookies.entries.joinToString("; ") { (key, value) -> "$key=$value" }
+ }
+
private fun extractDirectPlaybackUrl(cmd: String): String? {
return cmd
.substringAfter(' ', missingDelimiterValue = cmd)
@@ -628,7 +748,8 @@ class StalkerProvider(
kind = StalkerStreamKind.LIVE,
itemId = numericId,
cmd = cmd,
- containerExtension = item.containerExtension
+ containerExtension = item.containerExtension,
+ playbackDescriptor = item.playbackDescriptor
)
} ?: directStreamUrl
?: return null
@@ -664,7 +785,8 @@ class StalkerProvider(
kind = StalkerStreamKind.MOVIE,
itemId = numericId,
cmd = cmd,
- containerExtension = item.containerExtension
+ containerExtension = item.containerExtension,
+ playbackDescriptor = item.playbackDescriptor
)
} ?: directStreamUrl
?: return null
@@ -782,7 +904,11 @@ class StalkerProvider(
itemId = numericId,
cmd = resolvedCmd,
containerExtension = containerExtension,
- seriesNumber = seasonShellEpisodeSelector(resolvedCmd, episodeNumber)
+ seriesNumber = seasonShellEpisodeSelector(resolvedCmd, episodeNumber),
+ playbackDescriptor = buildStalkerPlaybackDescriptor(
+ primaryCmd = resolvedCmd,
+ capabilities = StalkerPortalCapabilities()
+ )
)
} ?: directStreamUrl.orEmpty()
return Episode(
@@ -868,6 +994,12 @@ class StalkerProvider(
private fun normalizedMacAddress(): String =
macAddress.trim().uppercase(Locale.ROOT)
+ private fun normalizedUsername(): String =
+ username.trim()
+
+ private fun normalizedPassword(): String =
+ password
+
private fun normalizedDeviceProfile(): String =
deviceProfile.trim().ifBlank { "MAG250" }
@@ -888,6 +1020,42 @@ class StalkerProvider(
private fun normalizedSignature(): String =
signature.trim().uppercase(Locale.ROOT)
+
+ private fun resolveProviderStatus(profile: StalkerProviderProfile): ProviderStatus {
+ val normalizedStatus = profile.statusLabel?.trim()?.lowercase(Locale.ROOT).orEmpty()
+ if (normalizedStatus in setOf("disabled", "blocked", "banned")) {
+ return ProviderStatus.DISABLED
+ }
+ val expirationDate = profile.expirationDate
+ if (expirationDate != null && expirationDate in 1 until System.currentTimeMillis()) {
+ return ProviderStatus.EXPIRED
+ }
+ if (normalizedStatus in setOf("active", "enabled", "1")) {
+ return ProviderStatus.ACTIVE
+ }
+ if (normalizedStatus == "0" || profile.authAccess == false || profile.ambiguousState) {
+ return ProviderStatus.PARTIAL
+ }
+ return ProviderStatus.UNKNOWN
+ }
+
+ private fun isLikelyAuthOrSessionFailure(message: String, exception: Throwable?): Boolean {
+ val normalizedMessage = message.lowercase(Locale.ROOT)
+ val exceptionMessage = exception?.message?.lowercase(Locale.ROOT).orEmpty()
+ return normalizedMessage.contains("http 401") ||
+ normalizedMessage.contains("http 403") ||
+ normalizedMessage.contains("http 456") ||
+ normalizedMessage.contains("authorization") ||
+ normalizedMessage.contains("token") ||
+ normalizedMessage.contains("access denied") ||
+ normalizedMessage.contains("forbidden") ||
+ normalizedMessage.contains("temporary playback link") ||
+ exceptionMessage.contains("http 401") ||
+ exceptionMessage.contains("http 403") ||
+ exceptionMessage.contains("http 456") ||
+ exceptionMessage.contains("authorization") ||
+ exceptionMessage.contains("token")
+ }
}
private inline fun <T, R> Result<T>.mapData(transform: (T) -> R): Result<R> = when (this) {
diff --git a/data/src/main/java/com/streamvault/data/remote/stalker/StalkerUrlFactory.kt b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerUrlFactory.kt
index 6164903b..6188bad1 100644
--- a/data/src/main/java/com/streamvault/data/remote/stalker/StalkerUrlFactory.kt
+++ b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerUrlFactory.kt
@@ -3,6 +3,7 @@ package com.streamvault.data.remote.stalker
import java.net.URI
import java.net.URLDecoder
import java.net.URLEncoder
+import java.util.Base64
import java.util.Locale
enum class StalkerStreamKind(val pathSegment: String) {
@@ -17,7 +18,8 @@ data class StalkerStreamToken(
val itemId: Long,
val cmd: String,
val containerExtension: String? = null,
- val seriesNumber: Int? = null
+ val seriesNumber: Int? = null,
+ val playbackDescriptor: StalkerPlaybackDescriptor? = null
)
object StalkerUrlFactory {
@@ -68,16 +70,29 @@ object StalkerUrlFactory {
itemId: Long,
cmd: String,
containerExtension: String? = null,
- seriesNumber: Int? = null
+ seriesNumber: Int? = null,
+ playbackDescriptor: StalkerPlaybackDescriptor? = null
): String {
+ val resolvedDescriptor = playbackDescriptor?.copy(
+ candidates = orderStalkerCommandVariants(playbackDescriptor.candidates)
+ )
+ val primaryCmd = resolvedDescriptor?.candidates?.firstOrNull()?.cmd ?: cmd
val query = buildList {
- add("cmd=${encode(cmd)}")
+ add("cmd=${encode(primaryCmd)}")
containerExtension?.trim()
?.removePrefix(".")
?.takeIf { it.isNotBlank() }
?.let { ext -> add("ext=${encode(ext.lowercase(Locale.ROOT))}") }
seriesNumber?.takeIf { it > 0 }
?.let { episode -> add("series=${encode(episode.toString())}") }
+ resolvedDescriptor?.let { descriptor ->
+ add("mode=${encode(descriptor.candidates.firstOrNull()?.playbackMode?.name ?: descriptor.primaryMode.name)}")
+ add("pm=${encode(descriptor.primaryMode.name)}")
+ encodePortalCapabilities(descriptor.capabilities)
+ ?.let { encoded -> add("caps=${encode(encoded)}") }
+ encodeCommandVariants(descriptor.candidates.drop(1))
+ ?.let { encoded -> add("alts=${encode(encoded)}") }
+ }
}.joinToString("&")
return "$INTERNAL_SCHEME://$providerId/${kind.pathSegment}/$itemId?$query"
}
@@ -94,13 +109,33 @@ object StalkerUrlFactory {
val cmd = query["cmd"] ?: return null
val ext = query["ext"]?.trim()?.takeIf { it.isNotBlank() }
val seriesNumber = query["series"]?.toIntOrNull()?.takeIf { it > 0 }
+ val capabilities = decodePortalCapabilities(query["caps"])
+ val primaryMode = query["mode"]
+ ?.let { runCatching { StalkerPlaybackMode.valueOf(it) }.getOrNull() }
+ ?: detectStalkerPlaybackMode(cmd, capabilities)
+ val alternateVariants = decodeCommandVariants(query["alts"])
+ val primaryCandidate = StalkerCommandVariant(
+ cmd = cmd,
+ playbackMode = primaryMode,
+ sourceKey = "cmd",
+ priority = 0
+ )
+ val orderedCandidates = orderStalkerCommandVariants(listOf(primaryCandidate) + alternateVariants)
+ val playbackDescriptor = StalkerPlaybackDescriptor(
+ primaryMode = query["pm"]
+ ?.let { runCatching { StalkerPlaybackMode.valueOf(it) }.getOrNull() }
+ ?: if (orderedCandidates.size > 1) StalkerPlaybackMode.MULTI_CMD else primaryMode,
+ candidates = orderedCandidates,
+ capabilities = capabilities
+ )
return StalkerStreamToken(
providerId = providerId,
kind = kind,
itemId = itemId,
cmd = cmd,
containerExtension = ext,
- seriesNumber = seriesNumber
+ seriesNumber = seriesNumber,
+ playbackDescriptor = playbackDescriptor
)
}
@@ -130,4 +165,80 @@ object StalkerUrlFactory {
private fun decode(value: String): String =
URLDecoder.decode(value, Charsets.UTF_8.name())
+
+ private fun encodeCommandVariants(variants: List<StalkerCommandVariant>): String? {
+ if (variants.isEmpty()) return null
+ return variants.joinToString(";") { variant ->
+ listOf(
+ variant.sourceKey,
+ variant.playbackMode.name,
+ Base64.getUrlEncoder().withoutPadding().encodeToString(variant.cmd.toByteArray(Charsets.UTF_8))
+ ).joinToString(",")
+ }
+ }
+
+ private fun decodeCommandVariants(value: String?): List<StalkerCommandVariant> {
+ if (value.isNullOrBlank()) return emptyList()
+ return value.split(';')
+ .mapIndexedNotNull { index, encoded ->
+ val parts = encoded.split(',', limit = 3)
+ if (parts.size != 3) return@mapIndexedNotNull null
+ val sourceKey = parts[0].trim().ifBlank { "cmd_$index" }
+ val mode = runCatching { StalkerPlaybackMode.valueOf(parts[1]) }.getOrNull() ?: return@mapIndexedNotNull null
+ val cmd = runCatching {
+ String(Base64.getUrlDecoder().decode(parts[2]), Charsets.UTF_8)
+ }.getOrNull()?.trim()?.takeIf { it.isNotBlank() } ?: return@mapIndexedNotNull null
+ StalkerCommandVariant(
+ cmd = cmd,
+ playbackMode = mode,
+ sourceKey = sourceKey,
+ priority = index + 1
+ )
+ }
+ }
+
+ private fun encodePortalCapabilities(capabilities: StalkerPortalCapabilities): String? {
+ val encoded = buildList {
+ if (capabilities.useHttpTemporaryLink) add("uhtl=1")
+ if (capabilities.nginxSecureLink) add("nginx=1")
+ if (capabilities.flussonicTemporaryLink) add("flus=1")
+ if (capabilities.wowzaTemporaryLink) add("wowza=1")
+ if (capabilities.useLoadBalancing) add("lb=1")
+ if (capabilities.allowLocalTimeshift) add("lts=1")
+ if (capabilities.allowLocalPvr) add("lpvr=1")
+ if (capabilities.allowRemotePvr) add("rpvr=1")
+ if (capabilities.archiveAvailable) add("arch=1")
+ if (capabilities.moduleRestricted) add("mods=1")
+ if (capabilities.ambiguousAccountState) add("amb=1")
+ if (capabilities.bootstrapStrategy != StalkerBootstrapStrategy.AUTO) {
+ add("boot=${capabilities.bootstrapStrategy.name}")
+ }
+ }.joinToString(",")
+ return encoded.takeIf { it.isNotBlank() }
+ }
+
+ private fun decodePortalCapabilities(value: String?): StalkerPortalCapabilities {
+ if (value.isNullOrBlank()) return StalkerPortalCapabilities()
+ val parts = value.split(',').mapNotNull { token ->
+ val key = token.substringBefore('=').trim()
+ val rawValue = token.substringAfter('=', missingDelimiterValue = "").trim()
+ key.takeIf { it.isNotBlank() }?.let { it to rawValue }
+ }.toMap()
+ return StalkerPortalCapabilities(
+ bootstrapStrategy = parts["boot"]
+ ?.let { runCatching { StalkerBootstrapStrategy.valueOf(it) }.getOrNull() }
+ ?: StalkerBootstrapStrategy.AUTO,
+ useHttpTemporaryLink = parts["uhtl"] == "1",
+ nginxSecureLink = parts["nginx"] == "1",
+ flussonicTemporaryLink = parts["flus"] == "1",
+ wowzaTemporaryLink = parts["wowza"] == "1",
+ useLoadBalancing = parts["lb"] == "1",
+ allowLocalTimeshift = parts["lts"] == "1",
+ allowLocalPvr = parts["lpvr"] == "1",
+ allowRemotePvr = parts["rpvr"] == "1",
+ archiveAvailable = parts["arch"] == "1",
+ moduleRestricted = parts["mods"] == "1",
+ ambiguousAccountState = parts["amb"] == "1"
+ )
+ }
}
diff --git a/data/src/main/java/com/streamvault/data/remote/xtream/XtreamStreamUrlResolver.kt b/data/src/main/java/com/streamvault/data/remote/xtream/XtreamStreamUrlResolver.kt
index ee505ec4..f4bc4578 100644
--- a/data/src/main/java/com/streamvault/data/remote/xtream/XtreamStreamUrlResolver.kt
+++ b/data/src/main/java/com/streamvault/data/remote/xtream/XtreamStreamUrlResolver.kt
@@ -4,11 +4,15 @@ import com.streamvault.data.local.dao.ProviderDao
import com.streamvault.data.local.entity.ProviderEntity
import com.streamvault.data.remote.stalker.StalkerProvider
import com.streamvault.data.remote.stalker.StalkerApiService
+import com.streamvault.data.remote.stalker.StalkerPlaybackMode
+import com.streamvault.data.remote.stalker.StalkerPlaybackResolutionException
import com.streamvault.data.remote.stalker.StalkerStreamKind
import com.streamvault.data.remote.stalker.StalkerUrlFactory
+import com.streamvault.data.remote.stalker.buildStalkerPlaybackDescriptor
import com.streamvault.data.security.CredentialCrypto
import com.streamvault.data.util.UrlSecurityPolicy
import com.streamvault.domain.model.ContentType
+import com.streamvault.domain.model.StalkerAuthMode
import com.streamvault.domain.model.ProviderType
import java.net.URI
import java.util.concurrent.ConcurrentHashMap
@@ -32,6 +36,9 @@ class XtreamStreamUrlResolver @Inject constructor(
private data class CachedStalkerProvider(
val serverUrl: String,
val macAddress: String,
+ val authMode: StalkerAuthMode,
+ val username: String,
+ val password: String,
val deviceProfile: String,
val timezone: String,
val locale: String,
@@ -134,11 +141,16 @@ class XtreamStreamUrlResolver @Inject constructor(
}
val playbackInfo = when (
val resolvedResult = getOrCreateStalkerProvider(resolvedProvider)
- .resolvePlaybackInfo(token.kind, token.cmd, token.seriesNumber)
+ .resolvePlaybackInfo(token.kind, token.playbackDescriptor, token.seriesNumber)
) {
is com.streamvault.domain.model.Result.Success -> resolvedResult.data
+ is com.streamvault.domain.model.Result.Error -> throw StalkerPlaybackResolutionException(
+ resolvedResult.message,
+ resolvedResult.exception
+ )
else -> return null
}
+ persistStalkerPlaybackMode(resolvedProvider, playbackInfo.playbackMode)
ResolvedStreamUrl(
url = playbackInfo.url,
expirationTime = extractStreamExpirationTime(playbackInfo.url),
@@ -173,10 +185,19 @@ class XtreamStreamUrlResolver @Inject constructor(
if (!UrlSecurityPolicy.isAllowedStreamEntryUrl(repairedUrl)) {
return null
}
- val playbackInfo = when (val resolvedResult = getOrCreateStalkerProvider(provider).resolvePlaybackInfo(kind, repairedUrl)) {
+ val descriptor = buildStalkerPlaybackDescriptor(
+ primaryCmd = repairedUrl,
+ capabilities = com.streamvault.data.remote.stalker.StalkerPortalCapabilities()
+ )
+ val playbackInfo = when (val resolvedResult = getOrCreateStalkerProvider(provider).resolvePlaybackInfo(kind, descriptor)) {
is com.streamvault.domain.model.Result.Success -> resolvedResult.data
+ is com.streamvault.domain.model.Result.Error -> throw StalkerPlaybackResolutionException(
+ resolvedResult.message,
+ resolvedResult.exception
+ )
else -> return null
}
+ persistStalkerPlaybackMode(provider, playbackInfo.playbackMode)
return ResolvedStreamUrl(
url = playbackInfo.url,
expirationTime = extractStreamExpirationTime(playbackInfo.url),
@@ -246,6 +267,9 @@ class XtreamStreamUrlResolver @Inject constructor(
if (cached != null &&
cached.serverUrl == provider.serverUrl &&
cached.macAddress == provider.stalkerMacAddress &&
+ cached.authMode == provider.stalkerAuthMode &&
+ cached.username == provider.username &&
+ cached.password == provider.password &&
cached.deviceProfile == provider.stalkerDeviceProfile &&
cached.timezone == provider.stalkerDeviceTimezone &&
cached.locale == provider.stalkerDeviceLocale &&
@@ -257,11 +281,18 @@ class XtreamStreamUrlResolver @Inject constructor(
return cached.provider
}
+ val decryptedPassword = credentialCrypto.decryptIfNeeded(provider.password)
val resolvedProvider = StalkerProvider(
providerId = provider.id,
api = stalkerApiService,
portalUrl = provider.serverUrl,
macAddress = provider.stalkerMacAddress,
+ authMode = provider.stalkerAuthMode,
+ username = provider.username,
+ password = decryptedPassword,
+ portalProfileHint = provider.stalkerPortalProfile,
+ preferredPlaybackMode = provider.stalkerLastPlaybackMode
+ ?.let { value -> runCatching { StalkerPlaybackMode.valueOf(value) }.getOrNull() },
deviceProfile = provider.stalkerDeviceProfile,
timezone = provider.stalkerDeviceTimezone,
locale = provider.stalkerDeviceLocale,
@@ -273,6 +304,9 @@ class XtreamStreamUrlResolver @Inject constructor(
stalkerProviders[providerId] = CachedStalkerProvider(
serverUrl = provider.serverUrl,
macAddress = provider.stalkerMacAddress,
+ authMode = provider.stalkerAuthMode,
+ username = provider.username,
+ password = provider.password,
deviceProfile = provider.stalkerDeviceProfile,
timezone = provider.stalkerDeviceTimezone,
locale = provider.stalkerDeviceLocale,
@@ -284,6 +318,16 @@ class XtreamStreamUrlResolver @Inject constructor(
)
return resolvedProvider
}
+
+ private suspend fun persistStalkerPlaybackMode(
+ provider: ProviderEntity,
+ mode: com.streamvault.data.remote.stalker.StalkerPlaybackMode
+ ) {
+ if (provider.stalkerLastPlaybackMode == mode.name) {
+ return
+ }
+ providerDao.update(provider.copy(stalkerLastPlaybackMode = mode.name))
+ }
}
internal fun extractStreamExpirationTime(url: String): Long? {
diff --git a/data/src/main/java/com/streamvault/data/repository/MovieRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/MovieRepositoryImpl.kt
index 9a3f1da0..402b63f0 100644
--- a/data/src/main/java/com/streamvault/data/repository/MovieRepositoryImpl.kt
+++ b/data/src/main/java/com/streamvault/data/repository/MovieRepositoryImpl.kt
@@ -20,6 +20,7 @@ import com.streamvault.data.mapper.toDomain
import com.streamvault.data.preferences.PreferencesRepository
import com.streamvault.data.remote.http.toGenericRequestProfile
import com.streamvault.data.remote.stalker.StalkerApiService
+import com.streamvault.data.remote.stalker.StalkerPlaybackMode
import com.streamvault.data.remote.stalker.StalkerProvider
import com.streamvault.data.remote.xtream.XtreamApiService
import com.streamvault.data.remote.xtream.XtreamStreamUrlResolver
@@ -1485,6 +1486,12 @@ class MovieRepositoryImpl @Inject constructor(
api = stalkerApiService,
portalUrl = provider.serverUrl,
macAddress = provider.stalkerMacAddress,
+ authMode = provider.stalkerAuthMode,
+ username = provider.username,
+ password = credentialCrypto.decryptIfNeeded(provider.password),
+ portalProfileHint = provider.stalkerPortalProfile,
+ preferredPlaybackMode = provider.stalkerLastPlaybackMode
+ ?.let { value -> runCatching { StalkerPlaybackMode.valueOf(value) }.getOrNull() },
deviceProfile = provider.stalkerDeviceProfile,
timezone = provider.stalkerDeviceTimezone,
locale = provider.stalkerDeviceLocale,
diff --git a/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt
index 6c4c5811..87f9535a 100644
--- a/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt
+++ b/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt
@@ -9,6 +9,7 @@ import com.streamvault.data.mapper.*
import com.streamvault.data.preferences.PreferencesRepository
import com.streamvault.data.remote.http.buildGenericProviderRequestProfile
import com.streamvault.data.remote.stalker.StalkerApiService
+import com.streamvault.data.remote.stalker.StalkerPlaybackMode
import com.streamvault.data.remote.stalker.StalkerProvider
import com.streamvault.data.remote.xtream.XtreamApiService
import com.streamvault.data.remote.xtream.XtreamProvider
@@ -347,6 +348,9 @@ class ProviderRepositoryImpl @Inject constructor(
portalUrl: String,
macAddress: String,
name: String,
+ authMode: StalkerAuthMode,
+ username: String,
+ password: String,
deviceProfile: String,
timezone: String,
locale: String,
@@ -361,6 +365,7 @@ class ProviderRepositoryImpl @Inject constructor(
val normalizedPortalUrl = ProviderInputSanitizer.normalizeUrl(portalUrl)
val normalizedMacAddress = ProviderInputSanitizer.normalizeMacAddress(macAddress)
val normalizedName = ProviderInputSanitizer.normalizeProviderName(name)
+ val normalizedUsername = ProviderInputSanitizer.normalizeUsername(username)
val normalizedDeviceProfile = ProviderInputSanitizer.normalizeDeviceProfile(deviceProfile)
val normalizedTimezone = ProviderInputSanitizer.normalizeTimezone(timezone)
val normalizedLocale = ProviderInputSanitizer.normalizeLocale(locale)
@@ -375,27 +380,39 @@ class ProviderRepositoryImpl @Inject constructor(
UrlSecurityPolicy.validateStalkerPortalUrl(normalizedPortalUrl)?.let { message ->
return Result.error(message)
}
- ProviderInputSanitizer.validateMacAddress(normalizedMacAddress)?.let { message ->
- return Result.error(message)
+ if (normalizedMacAddress.isNotBlank()) {
+ ProviderInputSanitizer.validateMacAddress(normalizedMacAddress)?.let { message ->
+ return Result.error(message)
+ }
}
onProgress?.invoke("Authenticating...")
val existingProvider = if (id != null) {
// Edit path: check that the new normalized identity does not collide with a
// different provider before we commit the update.
- val collision = providerDao.getByUrlAndUser(normalizedPortalUrl, "", normalizedMacAddress)
+ val collision = providerDao.getByUrlAndUser(normalizedPortalUrl, normalizedUsername, normalizedMacAddress)
if (collision != null && collision.id != id) {
- return Result.error("A Stalker provider with this portal URL and MAC address already exists.")
+ return Result.error("A Stalker provider with this portal URL and identity already exists.")
}
providerDao.getById(id)
} else {
- providerDao.getByUrlAndUser(normalizedPortalUrl, "", normalizedMacAddress)
+ providerDao.getByUrlAndUser(normalizedPortalUrl, normalizedUsername, normalizedMacAddress)
+ }
+ val effectivePassword = try {
+ password.takeIf { it.isNotBlank() }
+ ?: existingProvider?.password?.let(credentialCrypto::decryptIfNeeded)
+ ?: ""
+ } catch (e: CredentialDecryptionException) {
+ return Result.error(e.message ?: CredentialDecryptionException.MESSAGE, e)
}
val provider = createStalkerProvider(
providerId = 0L,
portalUrl = normalizedPortalUrl,
macAddress = normalizedMacAddress,
+ authMode = authMode,
+ username = normalizedUsername,
+ password = effectivePassword,
deviceProfile = normalizedDeviceProfile,
timezone = normalizedTimezone,
locale = normalizedLocale,
@@ -413,6 +430,8 @@ class ProviderRepositoryImpl @Inject constructor(
id = existingProvider.id,
name = normalizedName.ifBlank { existingProvider.name },
serverUrl = normalizedPortalUrl,
+ username = normalizedUsername,
+ password = effectivePassword,
stalkerMacAddress = normalizedMacAddress,
stalkerDeviceProfile = normalizedDeviceProfile,
stalkerDeviceTimezone = normalizedTimezone,
@@ -436,6 +455,8 @@ class ProviderRepositoryImpl @Inject constructor(
val newData = authResult.data.copy(
name = normalizedName.ifBlank { authResult.data.name },
serverUrl = normalizedPortalUrl,
+ username = normalizedUsername,
+ password = effectivePassword,
stalkerMacAddress = normalizedMacAddress,
stalkerDeviceProfile = normalizedDeviceProfile,
stalkerDeviceTimezone = normalizedTimezone,
@@ -754,6 +775,11 @@ class ProviderRepositoryImpl @Inject constructor(
providerId: Long,
portalUrl: String,
macAddress: String,
+ authMode: StalkerAuthMode,
+ username: String,
+ password: String,
+ portalProfileHint: StalkerPortalProfile = StalkerPortalProfile.MAG_BASIC,
+ preferredPlaybackMode: StalkerPlaybackMode? = null,
deviceProfile: String,
timezone: String,
locale: String,
@@ -767,6 +793,11 @@ class ProviderRepositoryImpl @Inject constructor(
api = stalkerApiService,
portalUrl = portalUrl,
macAddress = macAddress,
+ authMode = authMode,
+ username = username,
+ password = password,
+ portalProfileHint = portalProfileHint,
+ preferredPlaybackMode = preferredPlaybackMode,
deviceProfile = deviceProfile,
timezone = timezone,
locale = locale,
@@ -782,6 +813,16 @@ class ProviderRepositoryImpl @Inject constructor(
providerId = entity.id,
portalUrl = entity.serverUrl,
macAddress = entity.stalkerMacAddress,
+ authMode = entity.stalkerAuthMode,
+ username = entity.username,
+ password = try {
+ credentialCrypto.decryptIfNeeded(entity.password)
+ } catch (_: Throwable) {
+ ""
+ },
+ portalProfileHint = entity.stalkerPortalProfile,
+ preferredPlaybackMode = entity.stalkerLastPlaybackMode
+ ?.let { runCatching { StalkerPlaybackMode.valueOf(it) }.getOrNull() },
deviceProfile = entity.stalkerDeviceProfile,
timezone = entity.stalkerDeviceTimezone,
locale = entity.stalkerDeviceLocale,
diff --git a/data/src/main/java/com/streamvault/data/repository/SeriesRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/SeriesRepositoryImpl.kt
index 73ff09ae..6f77bb68 100644
--- a/data/src/main/java/com/streamvault/data/repository/SeriesRepositoryImpl.kt
+++ b/data/src/main/java/com/streamvault/data/repository/SeriesRepositoryImpl.kt
@@ -7,6 +7,7 @@ import com.streamvault.data.local.entity.*
import com.streamvault.data.mapper.*
import com.streamvault.data.remote.http.toGenericRequestProfile
import com.streamvault.data.remote.stalker.StalkerApiService
+import com.streamvault.data.remote.stalker.StalkerPlaybackMode
import com.streamvault.data.remote.stalker.StalkerProvider
import com.streamvault.data.remote.xtream.XtreamApiService
import com.streamvault.data.remote.xtream.XtreamProvider
@@ -1441,6 +1442,12 @@ class SeriesRepositoryImpl @Inject constructor(
api = stalkerApiService,
portalUrl = provider.serverUrl,
macAddress = provider.stalkerMacAddress,
+ authMode = provider.stalkerAuthMode,
+ username = provider.username,
+ password = credentialCrypto.decryptIfNeeded(provider.password),
+ portalProfileHint = provider.stalkerPortalProfile,
+ preferredPlaybackMode = provider.stalkerLastPlaybackMode
+ ?.let { value -> runCatching { StalkerPlaybackMode.valueOf(value) }.getOrNull() },
deviceProfile = provider.stalkerDeviceProfile,
timezone = provider.stalkerDeviceTimezone,
locale = provider.stalkerDeviceLocale,
diff --git a/data/src/main/java/com/streamvault/data/sync/SyncManager.kt b/data/src/main/java/com/streamvault/data/sync/SyncManager.kt
index 5f3d3000..787e20fb 100644
--- a/data/src/main/java/com/streamvault/data/sync/SyncManager.kt
+++ b/data/src/main/java/com/streamvault/data/sync/SyncManager.kt
@@ -30,6 +30,7 @@ import com.streamvault.data.parser.M3uParser
import com.streamvault.data.remote.http.buildAppRequestProfile
import com.streamvault.data.remote.http.toGenericRequestProfile
import com.streamvault.data.remote.stalker.StalkerApiService
+import com.streamvault.data.remote.stalker.StalkerPlaybackMode
import com.streamvault.data.remote.stalker.StalkerProvider
import com.streamvault.data.remote.stalker.StalkerProviderProfile
import com.streamvault.data.remote.dto.XtreamCategory
@@ -4318,6 +4319,12 @@ class SyncManager @Inject constructor(
api = stalkerApiService,
portalUrl = provider.serverUrl,
macAddress = provider.stalkerMacAddress,
+ authMode = provider.stalkerAuthMode,
+ username = provider.username,
+ password = provider.password,
+ portalProfileHint = provider.stalkerPortalProfile,
+ preferredPlaybackMode = provider.stalkerLastPlaybackMode
+ ?.let { value -> runCatching { StalkerPlaybackMode.valueOf(value) }.getOrNull() },
deviceProfile = provider.stalkerDeviceProfile,
timezone = provider.stalkerDeviceTimezone,
locale = provider.stalkerDeviceLocale,
@@ -4545,6 +4552,9 @@ class SyncManager @Inject constructor(
is com.streamvault.domain.model.Result.Success -> profileResult.data
else -> return null
}
+ if (profile.ambiguousState) {
+ return "Portal profile is ambiguous; playback/session validation failed. Check that the MAC is activated and that this portal supports MAG-style playback for the assigned account."
+ }
if (!profile.hasLikelyMissingCatalogAccess()) {
return null
}
diff --git a/data/src/main/java/com/streamvault/data/validation/ProviderSetupInputValidatorImpl.kt b/data/src/main/java/com/streamvault/data/validation/ProviderSetupInputValidatorImpl.kt
index 5ab4bdf6..5b80ccda 100644
--- a/data/src/main/java/com/streamvault/data/validation/ProviderSetupInputValidatorImpl.kt
+++ b/data/src/main/java/com/streamvault/data/validation/ProviderSetupInputValidatorImpl.kt
@@ -7,6 +7,7 @@ import com.streamvault.domain.manager.ValidatedM3uProviderInput
import com.streamvault.domain.manager.ValidatedStalkerProviderInput
import com.streamvault.domain.manager.ValidatedXtreamProviderInput
import com.streamvault.domain.model.Result
+import com.streamvault.domain.model.StalkerAuthMode
import java.time.ZoneId
import javax.inject.Inject
import javax.inject.Singleton
@@ -100,6 +101,10 @@ class ProviderSetupInputValidatorImpl @Inject constructor() : ProviderSetupInput
portalUrl: String,
macAddress: String,
name: String,
+ authMode: StalkerAuthMode,
+ username: String,
+ password: String,
+ allowBlankPassword: Boolean,
deviceProfile: String,
timezone: String,
locale: String,
@@ -111,6 +116,8 @@ class ProviderSetupInputValidatorImpl @Inject constructor() : ProviderSetupInput
val normalizedPortalUrl = ProviderInputSanitizer.normalizeUrl(portalUrl)
val normalizedMacAddress = ProviderInputSanitizer.normalizeMacAddress(macAddress)
val normalizedName = ProviderInputSanitizer.normalizeProviderName(name)
+ val normalizedUsername = ProviderInputSanitizer.normalizeUsername(username)
+ val normalizedPassword = ProviderInputSanitizer.normalizePassword(password)
val normalizedDeviceProfile = ProviderInputSanitizer.normalizeDeviceProfile(deviceProfile)
val normalizedTimezone = ProviderInputSanitizer.normalizeTimezone(timezone)
val normalizedLocale = ProviderInputSanitizer.normalizeLocale(locale)
@@ -128,8 +135,60 @@ class ProviderSetupInputValidatorImpl @Inject constructor() : ProviderSetupInput
UrlSecurityPolicy.validateStalkerPortalUrl(normalizedPortalUrl)?.let { message ->
return Result.error(message)
}
- ProviderInputSanitizer.validateMacAddress(normalizedMacAddress)?.let { message ->
- return Result.error(message)
+
+ when (authMode) {
+ StalkerAuthMode.MAC_ONLY -> {
+ ProviderInputSanitizer.validateMacAddress(normalizedMacAddress)?.let { message ->
+ return Result.error(message)
+ }
+ }
+
+ StalkerAuthMode.MAC_PLUS_CREDENTIALS -> {
+ ProviderInputSanitizer.validateMacAddress(normalizedMacAddress)?.let { message ->
+ return Result.error(message)
+ }
+ if (normalizedUsername.isBlank()) {
+ return Result.error("Please enter username")
+ }
+ ProviderInputSanitizer.validatePassword(normalizedPassword, allowBlankPassword)?.let { message ->
+ return Result.error(message)
+ }
+ }
+
+ StalkerAuthMode.CREDENTIALS_ONLY -> {
+ if (normalizedUsername.isBlank()) {
+ return Result.error("Please enter username")
+ }
+ ProviderInputSanitizer.validatePassword(normalizedPassword, allowBlankPassword)?.let { message ->
+ return Result.error(message)
+ }
+ if (normalizedMacAddress.isNotBlank()) {
+ ProviderInputSanitizer.validateMacAddress(normalizedMacAddress)?.let { message ->
+ return Result.error(message)
+ }
+ }
+ }
+
+ StalkerAuthMode.AUTO -> {
+ val hasMac = normalizedMacAddress.isNotBlank()
+ val hasUsername = normalizedUsername.isNotBlank()
+ if (!hasMac && !hasUsername) {
+ return Result.error("Please enter a MAC address or username")
+ }
+ if (hasMac) {
+ ProviderInputSanitizer.validateMacAddress(normalizedMacAddress)?.let { message ->
+ return Result.error(message)
+ }
+ }
+ if (hasUsername || password.isNotBlank()) {
+ if (!hasUsername) {
+ return Result.error("Please enter username")
+ }
+ ProviderInputSanitizer.validatePassword(normalizedPassword, allowBlankPassword)?.let { message ->
+ return Result.error(message)
+ }
+ }
+ }
}
// deviceProfile becomes the X-User-Agent model and part of the device signature. Blank
@@ -177,6 +236,9 @@ class ProviderSetupInputValidatorImpl @Inject constructor() : ProviderSetupInput
portalUrl = normalizedPortalUrl,
macAddress = normalizedMacAddress,
name = normalizedName,
+ authMode = authMode,
+ username = normalizedUsername,
+ password = normalizedPassword,
deviceProfile = normalizedDeviceProfile,
timezone = normalizedTimezone,
locale = normalizedLocale,
diff --git a/data/src/test/java/com/streamvault/data/remote/stalker/OkHttpStalkerApiServiceTest.kt b/data/src/test/java/com/streamvault/data/remote/stalker/OkHttpStalkerApiServiceTest.kt
index fc1a56bc..9e6912af 100644
--- a/data/src/test/java/com/streamvault/data/remote/stalker/OkHttpStalkerApiServiceTest.kt
+++ b/data/src/test/java/com/streamvault/data/remote/stalker/OkHttpStalkerApiServiceTest.kt
@@ -145,6 +145,66 @@ class OkHttpStalkerApiServiceTest {
assertThat(success.data.second.accountName).isEqualTo("Living Room")
}
+ @Test
+ fun authenticate_retains_server_cookies_for_follow_up_playback_requests() = runTest {
+ val observedCookies = mutableListOf<String>()
+ val service = OkHttpStalkerApiService(
+ okHttpClient = OkHttpClient.Builder()
+ .addInterceptor { chain ->
+ val request = chain.request()
+ val action = request.url.queryParameter("action").orEmpty()
+ if (action == "create_link") {
+ observedCookies += request.header("Cookie").orEmpty()
+ }
+ val body = when (action) {
+ "handshake" -> """{"js":{"token":"token-123"}}"""
+ "get_profile" -> """{"js":{"name":"Living Room","status":"1"}}"""
+ "create_link" -> """{"js":{"cmd":"ffmpeg http://cdn.example.com/live/stream.ts"}}"""
+ else -> error("Unexpected action '$action'")
+ }
+ val responseBuilder = Response.Builder()
+ .request(request)
+ .protocol(Protocol.HTTP_1_1)
+ .code(200)
+ .message("OK")
+ .body(body.toResponseBody("application/json".toMediaType()))
+ if (action == "handshake") {
+ responseBuilder.addHeader("Set-Cookie", "PHPSESSID=session-42; Path=/; HttpOnly")
+ }
+ responseBuilder.build()
+ }
+ .build(),
+ json = Json { ignoreUnknownKeys = true }
+ )
+
+ val authResult = service.authenticate(
+ buildStalkerDeviceProfile(
+ portalUrl = "https://portal.example.com/c",
+ macAddress = "00:1A:79:12:34:56",
+ deviceProfile = "MAG250",
+ timezone = "UTC",
+ locale = "en"
+ )
+ ) as Result.Success
+
+ val createLinkResult = service.createLink(
+ session = authResult.data.first,
+ profile = buildStalkerDeviceProfile(
+ portalUrl = "https://portal.example.com/c",
+ macAddress = "00:1A:79:12:34:56",
+ deviceProfile = "MAG250",
+ timezone = "UTC",
+ locale = "en"
+ ),
+ kind = StalkerStreamKind.LIVE,
+ cmd = "ffmpeg http://localhost/ch/1234_"
+ )
+
+ assertThat(createLinkResult).isInstanceOf(Result.Success::class.java)
+ assertThat(authResult.data.first.serverCookieHeader).contains("PHPSESSID=session-42")
+ assertThat(observedCookies.single()).contains("PHPSESSID=session-42")
+ }
+
@Test
fun authenticate_reports_access_denied_html_clearly() = runTest {
val service = OkHttpStalkerApiService(
@@ -271,6 +331,61 @@ class OkHttpStalkerApiServiceTest {
assertThat(requestedActions).containsExactly("get_all_channels")
}
+ @Test
+ fun getLiveStreams_preserves_command_variants_and_temp_link_flags() = runTest {
+ val service = OkHttpStalkerApiService(
+ okHttpClient = fakeClient(
+ "get_all_channels" to """
+ {"js":{"data":[
+ {
+ "id":"100",
+ "name":"News",
+ "tv_genre_id":"10",
+ "cmd":"ffmpeg http://localhost/ch/100_",
+ "cmd_1":"ffmpeg http://backup.example.com/play/live.php?stream=100",
+ "cmd_2":"ffmpeg http://edge.example.com/live/news.m3u8",
+ "mc_cmd":"ffmpeg http://mc.example.com/live/100.ts",
+ "cmds":[{"url":"ffmpeg http://multi.example.com/live/100.ts"}],
+ "use_http_tmp_link":"1",
+ "nginx_secure_link":"1",
+ "allow_local_timeshift":"1",
+ "archive":"1"
+ }
+ ]}}
+ """.trimIndent()
+ ),
+ json = Json { ignoreUnknownKeys = true }
+ )
+
+ val result = service.getLiveStreams(
+ session = StalkerSession(
+ loadUrl = "https://portal.example.com/server/load.php",
+ portalReferer = "https://portal.example.com/c/",
+ token = "token-123"
+ ),
+ profile = buildStalkerDeviceProfile(
+ portalUrl = "https://portal.example.com/c",
+ macAddress = "00:1A:79:12:34:56",
+ deviceProfile = "MAG250",
+ timezone = "UTC",
+ locale = "en"
+ ),
+ categoryId = null
+ )
+
+ assertThat(result).isInstanceOf(Result.Success::class.java)
+ val item = (result as Result.Success).data.single()
+ assertThat(item.commandVariants.map { it.sourceKey })
+ .containsAtLeast("cmd", "cmd_1", "cmd_2", "mc_cmd", "cmds[0]")
+ assertThat(item.commandVariants.map { it.cmd })
+ .contains("ffmpeg http://edge.example.com/live/news.m3u8")
+ assertThat(item.playbackDescriptor?.primaryMode).isEqualTo(StalkerPlaybackMode.MULTI_CMD)
+ assertThat(item.portalCapabilities.useHttpTemporaryLink).isTrue()
+ assertThat(item.portalCapabilities.nginxSecureLink).isTrue()
+ assertThat(item.portalCapabilities.allowLocalTimeshift).isTrue()
+ assertThat(item.portalCapabilities.archiveAvailable).isTrue()
+ }
+
@Test
fun streamLiveStreams_emits_bulk_channels_from_js_data_without_list_materialization() = runTest {
val service = OkHttpStalkerApiService(
diff --git a/data/src/test/java/com/streamvault/data/remote/stalker/StalkerPortalReplayHarnessTest.kt b/data/src/test/java/com/streamvault/data/remote/stalker/StalkerPortalReplayHarnessTest.kt
new file mode 100644
index 00000000..94256438
--- /dev/null
+++ b/data/src/test/java/com/streamvault/data/remote/stalker/StalkerPortalReplayHarnessTest.kt
@@ -0,0 +1,152 @@
+package com.streamvault.data.remote.stalker
+
+import com.google.common.truth.Truth.assertThat
+import com.streamvault.domain.model.Result
+import com.streamvault.domain.model.StalkerAuthMode
+import com.streamvault.domain.model.StalkerPortalProfile
+import java.io.InputStreamReader
+import kotlinx.coroutines.test.runTest
+import kotlinx.serialization.Serializable
+import kotlinx.serialization.json.Json
+import okhttp3.MediaType.Companion.toMediaType
+import okhttp3.OkHttpClient
+import okhttp3.Protocol
+import okhttp3.Response
+import okhttp3.ResponseBody.Companion.toResponseBody
+import org.junit.Test
+
+class StalkerPortalReplayHarnessTest {
+
+ private val json = Json { ignoreUnknownKeys = true }
+
+ @Test
+ fun replayFixtures_cover_supported_portal_families() = runTest {
+ listOf(
+ "stalker/fixtures/mac_basic.json",
+ "stalker/fixtures/auth_required.json",
+ "stalker/fixtures/auth_plus_mag.json",
+ "stalker/fixtures/module_gated.json",
+ "stalker/fixtures/nginx_temp_link.json"
+ ).forEach { path ->
+ val fixture = loadFixture(path)
+ val requestedActions = mutableListOf<String>()
+ val service = OkHttpStalkerApiService(
+ okHttpClient = fakeReplayClient(fixture, requestedActions),
+ json = json
+ )
+
+ val profile = buildStalkerDeviceProfile(
+ portalUrl = fixture.device.portalUrl,
+ macAddress = fixture.device.macAddress,
+ authMode = StalkerAuthMode.valueOf(fixture.device.authMode),
+ username = fixture.device.username,
+ password = fixture.device.password,
+ deviceProfile = fixture.device.deviceProfile,
+ timezone = fixture.device.timezone,
+ locale = fixture.device.locale
+ )
+ val authResult = service.authenticate(profile)
+ assertThat(authResult).isInstanceOf(Result.Success::class.java)
+ val authSuccess = authResult as Result.Success
+ assertThat(authSuccess.data.first.effectiveAuthMode.name).isEqualTo(fixture.expected.authMode)
+ assertThat(authSuccess.data.first.portalProfile.name).isEqualTo(fixture.expected.portalProfile)
+ assertThat(authSuccess.data.first.bootstrapEvidence).containsExactlyElementsIn(fixture.expected.bootstrapEvidence).inOrder()
+
+ fixture.expected.playbackMode?.let { expectedPlaybackMode ->
+ val liveResult = service.getLiveStreams(
+ session = authSuccess.data.first,
+ profile = profile,
+ categoryId = null
+ )
+ assertThat(liveResult).isInstanceOf(Result.Success::class.java)
+ val firstItem = (liveResult as Result.Success).data.first()
+ fixture.expected.resolvedPlaybackUrl?.let { expectedUrl ->
+ val createLinkResult = service.createLink(
+ session = authSuccess.data.first,
+ profile = profile,
+ kind = StalkerStreamKind.LIVE,
+ cmd = firstItem.cmd.orEmpty(),
+ seriesNumber = null
+ )
+ assertThat(createLinkResult).isInstanceOf(Result.Success::class.java)
+ val resolvedUrl = (createLinkResult as Result.Success).data
+ assertThat(resolvedUrl).isEqualTo(expectedUrl)
+ assertThat(detectStalkerPlaybackMode(resolvedUrl, firstItem.portalCapabilities).name)
+ .isEqualTo(expectedPlaybackMode)
+ } ?: assertThat(firstItem.playbackDescriptor?.primaryMode?.name).isEqualTo(expectedPlaybackMode)
+ }
+ assertThat(requestedActions).containsAtLeastElementsIn(fixture.expected.requestOrder).inOrder()
+ }
+ }
+
+ private fun fakeReplayClient(
+ fixture: ReplayFixture,
+ requestedActions: MutableList<String>
+ ): OkHttpClient {
+ val responsesByAction = fixture.responses.groupBy { "${it.method.uppercase()}:${it.action}" }
+ .mapValues { (_, items) -> items.toMutableList() }
+ return OkHttpClient.Builder()
+ .addInterceptor { chain ->
+ val request = chain.request()
+ val action = request.url.queryParameter("action").orEmpty()
+ val method = request.method.uppercase()
+ requestedActions += action
+ val key = "$method:$action"
+ val scripted = responsesByAction[key]?.removeFirstOrNull()
+ ?: error("Missing replay response for $key in fixture ${fixture.name}")
+ Response.Builder()
+ .request(request)
+ .protocol(Protocol.HTTP_1_1)
+ .code(scripted.code)
+ .message("OK")
+ .body(scripted.body.toResponseBody("application/json".toMediaType()))
+ .build()
+ }
+ .build()
+ }
+
+ private fun loadFixture(path: String): ReplayFixture {
+ val stream = checkNotNull(javaClass.classLoader?.getResourceAsStream(path)) {
+ "Missing replay fixture $path"
+ }
+ return stream.use { json.decodeFromString(ReplayFixture.serializer(), InputStreamReader(it).readText()) }
+ }
+}
+
+@Serializable
+private data class ReplayFixture(
+ val name: String,
+ val device: ReplayDevice,
+ val responses: List<ReplayResponse>,
+ val expected: ReplayExpectation
+)
+
+@Serializable
+private data class ReplayDevice(
+ val portalUrl: String,
+ val macAddress: String,
+ val authMode: String,
+ val username: String = "",
+ val password: String = "",
+ val deviceProfile: String = "MAG250",
+ val timezone: String = "UTC",
+ val locale: String = "en"
+)
+
+@Serializable
+private data class ReplayResponse(
+ val action: String,
+ val method: String = "GET",
+ val code: Int = 200,
+ val body: String
+)
+
+@Serializable
+private data class ReplayExpectation(
+ val authMode: String,
+ val portalProfile: String,
+ val bootstrapEvidence: List<String>,
+ val requestOrder: List<String>,
+ val playbackMode: String? = null,
+ val resolvedPlaybackUrl: String? = null
+)
diff --git a/data/src/test/java/com/streamvault/data/remote/stalker/StalkerProviderTest.kt b/data/src/test/java/com/streamvault/data/remote/stalker/StalkerProviderTest.kt
new file mode 100644
index 00000000..510d33a4
--- /dev/null
+++ b/data/src/test/java/com/streamvault/data/remote/stalker/StalkerProviderTest.kt
@@ -0,0 +1,179 @@
+package com.streamvault.data.remote.stalker
+
+import com.google.common.truth.Truth.assertThat
+import com.streamvault.domain.model.ProviderStatus
+import com.streamvault.domain.model.Result
+import kotlinx.coroutines.test.runTest
+import org.junit.Test
+
+class StalkerProviderTest {
+
+ @Test
+ fun authenticate_treats_status_zero_as_partial_not_expired() = runTest {
+ val provider = StalkerProvider(
+ providerId = 7,
+ api = FakeStalkerApiService(
+ profile = StalkerProviderProfile(
+ accountId = "758423",
+ accountName = "Room",
+ statusLabel = "0",
+ authAccess = false
+ )
+ ),
+ portalUrl = "https://portal.example.com/c/",
+ macAddress = "00:1A:79:12:34:56",
+ deviceProfile = "MAG250",
+ timezone = "UTC",
+ locale = "en"
+ )
+
+ val result = provider.authenticate()
+
+ assertThat(result).isInstanceOf(Result.Success::class.java)
+ val success = result as Result.Success
+ assertThat(success.data.status).isEqualTo(ProviderStatus.PARTIAL)
+ }
+
+ @Test
+ fun authenticate_maps_expired_date_to_expired() = runTest {
+ val provider = StalkerProvider(
+ providerId = 7,
+ api = FakeStalkerApiService(
+ profile = StalkerProviderProfile(
+ accountName = "Room",
+ expirationDate = 1L
+ )
+ ),
+ portalUrl = "https://portal.example.com/c/",
+ macAddress = "00:1A:79:12:34:56",
+ deviceProfile = "MAG250",
+ timezone = "UTC",
+ locale = "en"
+ )
+
+ val result = provider.authenticate()
+
+ assertThat(result).isInstanceOf(Result.Success::class.java)
+ val success = result as Result.Success
+ assertThat(success.data.status).isEqualTo(ProviderStatus.EXPIRED)
+ }
+
+ private class FakeStalkerApiService(
+ private val profile: StalkerProviderProfile
+ ) : StalkerApiService {
+ override suspend fun authenticate(profile: StalkerDeviceProfile): Result<Pair<StalkerSession, StalkerProviderProfile>> =
+ Result.success(
+ StalkerSession(
+ loadUrl = "https://portal.example.com/server/load.php",
+ portalReferer = "https://portal.example.com/c/",
+ token = "token"
+ ) to this.profile
+ )
+
+ override suspend fun getLiveCategories(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile
+ ) = Result.success(emptyList<StalkerCategoryRecord>())
+
+ override suspend fun getLiveStreams(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ categoryId: String?
+ ) = Result.success(emptyList<StalkerItemRecord>())
+
+ override suspend fun streamLiveStreams(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ onItem: suspend (StalkerItemRecord) -> Unit
+ ) = Result.success(0)
+
+ override suspend fun getVodCategories(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile
+ ) = Result.success(emptyList<StalkerCategoryRecord>())
+
+ override suspend fun getVodStreams(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ categoryId: String?
+ ) = Result.success(emptyList<StalkerItemRecord>())
+
+ override suspend fun getVodStreamsPage(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ categoryId: String?,
+ page: Int
+ ) = Result.success(StalkerPagedItems(emptyList(), page, page, 0))
+
+ override suspend fun getSeriesCategories(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile
+ ) = Result.success(emptyList<StalkerCategoryRecord>())
+
+ override suspend fun getSeries(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ categoryId: String?
+ ) = Result.success(emptyList<StalkerItemRecord>())
+
+ override suspend fun getSeriesPage(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ categoryId: String?,
+ page: Int
+ ) = Result.success(StalkerPagedItems(emptyList(), page, page, 0))
+
+ override suspend fun getSeriesDetails(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ seriesId: String
+ ) = Result.success(
+ StalkerSeriesDetails(
+ series = StalkerItemRecord(id = seriesId, name = "Series"),
+ seasons = emptyList()
+ )
+ )
+
+ override suspend fun getShortEpg(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ channelId: String,
+ limit: Int
+ ) = Result.success(emptyList<StalkerProgramRecord>())
+
+ override suspend fun getEpg(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ channelId: String
+ ) = Result.success(emptyList<StalkerProgramRecord>())
+
+ override suspend fun getBulkEpg(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ periodHours: Int
+ ) = Result.success(emptyList<StalkerProgramRecord>())
+
+ override suspend fun streamBulkEpg(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ periodHours: Int,
+ onProgram: suspend (StalkerProgramRecord) -> Unit
+ ) = Result.success(0)
+
+ override suspend fun streamEpg(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ channelId: String,
+ periodHours: Int,
+ onProgram: suspend (StalkerProgramRecord) -> Unit
+ ) = Result.success(0)
+
+ override suspend fun createLink(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ kind: StalkerStreamKind,
+ cmd: String,
+ seriesNumber: Int?
+ ) = Result.success("http://cdn.example.com/stream.ts")
+ }
+}
diff --git a/data/src/test/java/com/streamvault/data/remote/xtream/XtreamStreamUrlResolverTest.kt b/data/src/test/java/com/streamvault/data/remote/xtream/XtreamStreamUrlResolverTest.kt
index d184c14c..21179d4c 100644
--- a/data/src/test/java/com/streamvault/data/remote/xtream/XtreamStreamUrlResolverTest.kt
+++ b/data/src/test/java/com/streamvault/data/remote/xtream/XtreamStreamUrlResolverTest.kt
@@ -4,13 +4,17 @@ import com.google.common.truth.Truth.assertThat
import com.streamvault.data.local.dao.ProviderDao
import com.streamvault.data.local.entity.ProviderEntity
import com.streamvault.data.remote.stalker.StalkerApiService
+import com.streamvault.data.remote.stalker.StalkerCommandVariant
import com.streamvault.data.remote.stalker.StalkerCategoryRecord
import com.streamvault.data.remote.stalker.StalkerDeviceProfile
import com.streamvault.data.remote.stalker.StalkerEpisodeRecord
import com.streamvault.data.remote.stalker.StalkerItemRecord
import com.streamvault.data.remote.stalker.StalkerPagedItems
+import com.streamvault.data.remote.stalker.StalkerPlaybackDescriptor
+import com.streamvault.data.remote.stalker.StalkerPlaybackMode
import com.streamvault.data.remote.stalker.StalkerProgramRecord
import com.streamvault.data.remote.stalker.StalkerProviderProfile
+import com.streamvault.data.remote.stalker.StalkerPortalCapabilities
import com.streamvault.data.remote.stalker.StalkerSeasonRecord
import com.streamvault.data.remote.stalker.StalkerSeriesDetails
import com.streamvault.data.remote.stalker.StalkerSession
@@ -343,6 +347,58 @@ class XtreamStreamUrlResolverTest {
assertThat(fakeStalkerApiService.lastCreateLinkSeriesNumber).isEqualTo(11)
}
+ @Test
+ fun resolveWithMetadata_uses_ranked_stalker_multi_command_candidates() = runBlocking {
+ val fakeStalkerApiService = FakeStalkerApiService()
+ val resolver = XtreamStreamUrlResolver(
+ providerDao = FakeProviderDao(
+ ProviderEntity(
+ id = 14,
+ name = "Stalker",
+ type = ProviderType.STALKER_PORTAL,
+ serverUrl = "https://portal.example.com",
+ stalkerMacAddress = "00:1A:79:12:34:56",
+ stalkerDeviceProfile = "MAG250",
+ stalkerDeviceTimezone = "UTC",
+ stalkerDeviceLocale = "en"
+ )
+ ),
+ credentialCrypto = credentialCrypto,
+ stalkerApiService = fakeStalkerApiService
+ )
+ val descriptor = StalkerPlaybackDescriptor(
+ primaryMode = StalkerPlaybackMode.MULTI_CMD,
+ candidates = listOf(
+ StalkerCommandVariant(
+ cmd = "ffmpeg http://localhost/ch/77_",
+ playbackMode = StalkerPlaybackMode.LOCALHOST_CMD,
+ sourceKey = "cmd",
+ priority = 2
+ ),
+ StalkerCommandVariant(
+ cmd = "http://edge.example.com/live/77.m3u8",
+ playbackMode = StalkerPlaybackMode.DIRECT_URL,
+ sourceKey = "cmd_1",
+ priority = 1
+ )
+ ),
+ capabilities = StalkerPortalCapabilities()
+ )
+ val internalUrl = StalkerUrlFactory.buildInternalStreamUrl(
+ providerId = 14,
+ kind = StalkerStreamKind.LIVE,
+ itemId = 77,
+ cmd = "ffmpeg http://localhost/ch/77_",
+ containerExtension = "ts",
+ playbackDescriptor = descriptor
+ )
+
+ val resolved = resolver.resolveWithMetadata(internalUrl)
+
+ assertThat(resolved?.url).isEqualTo("http://edge.example.com/live/77.m3u8")
+ assertThat(fakeStalkerApiService.createLinkCalls).isEqualTo(0)
+ }
+
@Test
fun resolveWithMetadata_repairs_stale_direct_stalker_live_url_and_applies_headers() = runBlocking {
val fakeStalkerApiService = FakeStalkerApiService()
diff --git a/data/src/test/java/com/streamvault/data/validation/ProviderSetupInputValidatorImplTest.kt b/data/src/test/java/com/streamvault/data/validation/ProviderSetupInputValidatorImplTest.kt
index 65cbd7ca..60d18f8b 100644
--- a/data/src/test/java/com/streamvault/data/validation/ProviderSetupInputValidatorImplTest.kt
+++ b/data/src/test/java/com/streamvault/data/validation/ProviderSetupInputValidatorImplTest.kt
@@ -2,6 +2,7 @@ package com.streamvault.data.validation
import com.google.common.truth.Truth.assertThat
import com.streamvault.domain.model.Result
+import com.streamvault.domain.model.StalkerAuthMode
import org.junit.Test
class ProviderSetupInputValidatorImplTest {
@@ -55,11 +56,18 @@ class ProviderSetupInputValidatorImplTest {
private fun stalkerResult(
timezone: String = "UTC",
locale: String = "en",
- deviceProfile: String = "MAG250"
+ deviceProfile: String = "MAG250",
+ authMode: StalkerAuthMode = StalkerAuthMode.AUTO,
+ username: String = "",
+ password: String = "",
+ macAddress: String = "00:1A:79:12:34:56"
) = validator.validateStalker(
portalUrl = "https://portal.example.com",
- macAddress = "00:1A:79:12:34:56",
+ macAddress = macAddress,
name = "MAG",
+ authMode = authMode,
+ username = username,
+ password = password,
deviceProfile = deviceProfile,
timezone = timezone,
locale = locale,
@@ -146,4 +154,53 @@ class ProviderSetupInputValidatorImplTest {
assertThat(result).isInstanceOf(Result.Error::class.java)
assertThat((result as Result.Error).message).contains("Device profile must contain only")
}
+
+ @Test
+ fun `validateStalker auto mode accepts credentials without mac`() {
+ val result = stalkerResult(
+ authMode = StalkerAuthMode.AUTO,
+ username = "portalUser",
+ password = "portalPass",
+ macAddress = ""
+ )
+ assertThat(result).isInstanceOf(Result.Success::class.java)
+ }
+
+ @Test
+ fun `validateStalker credentials only requires username and password`() {
+ val success = stalkerResult(
+ authMode = StalkerAuthMode.CREDENTIALS_ONLY,
+ username = "portalUser",
+ password = "portalPass",
+ macAddress = ""
+ )
+ assertThat(success).isInstanceOf(Result.Success::class.java)
+
+ val failure = stalkerResult(
+ authMode = StalkerAuthMode.CREDENTIALS_ONLY,
+ username = "portalUser",
+ password = "",
+ macAddress = ""
+ )
+ assertThat(failure).isInstanceOf(Result.Error::class.java)
+ }
+
+ @Test
+ fun `validateStalker mac plus credentials requires both identities`() {
+ val result = stalkerResult(
+ authMode = StalkerAuthMode.MAC_PLUS_CREDENTIALS,
+ username = "portalUser",
+ password = "portalPass",
+ macAddress = "00:1A:79:12:34:56"
+ )
+ assertThat(result).isInstanceOf(Result.Success::class.java)
+
+ val missingMac = stalkerResult(
+ authMode = StalkerAuthMode.MAC_PLUS_CREDENTIALS,
+ username = "portalUser",
+ password = "portalPass",
+ macAddress = ""
+ )
+ assertThat(missingMac).isInstanceOf(Result.Error::class.java)
+ }
}
diff --git a/data/src/test/resources/stalker/fixtures/auth_plus_mag.json b/data/src/test/resources/stalker/fixtures/auth_plus_mag.json
new file mode 100644
index 00000000..5f25fa69
--- /dev/null
+++ b/data/src/test/resources/stalker/fixtures/auth_plus_mag.json
@@ -0,0 +1,23 @@
+{
+ "name": "auth_plus_mag",
+ "device": {
+ "portalUrl": "https://portal.example.com/server/load.php",
+ "macAddress": "00:1A:79:AA:BB:CC",
+ "authMode": "AUTO",
+ "username": "alice",
+ "password": "secret"
+ },
+ "responses": [
+ { "action": "handshake", "body": "{\"js\":{\"token\":\"token-789\"}}" },
+ { "action": "get_profile", "body": "{\"js\":{\"name\":\"Partial\",\"status\":\"0\",\"auth_access\":false}}" },
+ { "action": "handshake", "body": "{\"js\":{\"token\":\"token-789\"}}" },
+ { "action": "do_auth", "method": "POST", "body": "{\"js\":{\"status\":1}}" },
+ { "action": "get_profile", "body": "{\"js\":{\"id\":\"42\",\"name\":\"Full Access\",\"status\":\"1\",\"auth_access\":true}}" }
+ ],
+ "expected": {
+ "authMode": "MAC_PLUS_CREDENTIALS",
+ "portalProfile": "AUTH_PLUS_MAG",
+ "bootstrapEvidence": ["handshake", "do_auth", "get_profile"],
+ "requestOrder": ["handshake", "get_profile", "handshake", "do_auth", "get_profile"]
+ }
+}
diff --git a/data/src/test/resources/stalker/fixtures/auth_required.json b/data/src/test/resources/stalker/fixtures/auth_required.json
new file mode 100644
index 00000000..8bf42164
--- /dev/null
+++ b/data/src/test/resources/stalker/fixtures/auth_required.json
@@ -0,0 +1,21 @@
+{
+ "name": "auth_required",
+ "device": {
+ "portalUrl": "https://portal.example.com/c",
+ "macAddress": "",
+ "authMode": "CREDENTIALS_ONLY",
+ "username": "alice",
+ "password": "secret"
+ },
+ "responses": [
+ { "action": "handshake", "body": "{\"js\":{\"token\":\"token-456\"}}" },
+ { "action": "do_auth", "method": "POST", "body": "{\"js\":{\"status\":1}}" },
+ { "action": "get_profile", "body": "{\"js\":{\"id\":\"88\",\"name\":\"Bedroom\",\"status\":\"1\",\"auth_access\":true}}" }
+ ],
+ "expected": {
+ "authMode": "CREDENTIALS_ONLY",
+ "portalProfile": "AUTH_REQUIRED",
+ "bootstrapEvidence": ["handshake", "do_auth", "get_profile"],
+ "requestOrder": ["handshake", "do_auth", "get_profile"]
+ }
+}
diff --git a/data/src/test/resources/stalker/fixtures/mac_basic.json b/data/src/test/resources/stalker/fixtures/mac_basic.json
new file mode 100644
index 00000000..c4f9d8ad
--- /dev/null
+++ b/data/src/test/resources/stalker/fixtures/mac_basic.json
@@ -0,0 +1,18 @@
+{
+ "name": "mac_basic",
+ "device": {
+ "portalUrl": "https://portal.example.com/c",
+ "macAddress": "00:1A:79:12:34:56",
+ "authMode": "AUTO"
+ },
+ "responses": [
+ { "action": "handshake", "body": "{\"js\":{\"token\":\"token-123\"}}" },
+ { "action": "get_profile", "body": "{\"js\":{\"id\":\"77\",\"name\":\"Living Room\",\"status\":\"1\",\"auth_access\":true}}" }
+ ],
+ "expected": {
+ "authMode": "MAC_ONLY",
+ "portalProfile": "MAG_BASIC",
+ "bootstrapEvidence": ["handshake", "get_profile"],
+ "requestOrder": ["handshake", "get_profile"]
+ }
+}
diff --git a/data/src/test/resources/stalker/fixtures/module_gated.json b/data/src/test/resources/stalker/fixtures/module_gated.json
new file mode 100644
index 00000000..102fb480
--- /dev/null
+++ b/data/src/test/resources/stalker/fixtures/module_gated.json
@@ -0,0 +1,20 @@
+{
+ "name": "module_gated",
+ "device": {
+ "portalUrl": "https://portal.example.com/c",
+ "macAddress": "00:1A:79:DE:AD:BE",
+ "authMode": "AUTO"
+ },
+ "responses": [
+ { "action": "handshake", "body": "{\"js\":{\"token\":\"token-abc\"}}" },
+ { "action": "get_profile", "body": "{\"js\":{\"id\":\"12\",\"name\":\"Modules\",\"status\":\"0\",\"auth_access\":false}}" },
+ { "action": "get_main_info", "body": "{\"js\":{\"id\":\"12\",\"name\":\"Modules\",\"status\":\"0\",\"auth_access\":false}}" },
+ { "action": "get_modules", "body": "{\"js\":{\"modules\":{\"itv\":1,\"vod\":1}}}" }
+ ],
+ "expected": {
+ "authMode": "MAC_ONLY",
+ "portalProfile": "MODULE_GATED",
+ "bootstrapEvidence": ["handshake", "get_profile", "get_account_info", "get_modules"],
+ "requestOrder": ["handshake", "get_profile", "get_main_info", "get_modules"]
+ }
+}
diff --git a/data/src/test/resources/stalker/fixtures/nginx_temp_link.json b/data/src/test/resources/stalker/fixtures/nginx_temp_link.json
new file mode 100644
index 00000000..4b231d11
--- /dev/null
+++ b/data/src/test/resources/stalker/fixtures/nginx_temp_link.json
@@ -0,0 +1,22 @@
+{
+ "name": "nginx_temp_link",
+ "device": {
+ "portalUrl": "https://portal.example.com/c",
+ "macAddress": "00:1A:79:12:34:56",
+ "authMode": "AUTO"
+ },
+ "responses": [
+ { "action": "handshake", "body": "{\"js\":{\"token\":\"token-nginx\"}}" },
+ { "action": "get_profile", "body": "{\"js\":{\"id\":\"55\",\"name\":\"TempLink\",\"status\":\"1\",\"auth_access\":true}}" },
+ { "action": "get_all_channels", "body": "{\"js\":{\"data\":[{\"id\":\"100\",\"name\":\"News\",\"tv_genre_id\":\"10\",\"cmd\":\"ffmpeg http://localhost/ch/100_\",\"use_http_tmp_link\":\"1\",\"nginx_secure_link\":\"1\"}]}}" },
+ { "action": "create_link", "body": "{\"js\":{\"cmd\":\"ffmpeg http://edge.example.com/play/live.php?stream=100&play_token=abc\"}}" }
+ ],
+ "expected": {
+ "authMode": "MAC_ONLY",
+ "portalProfile": "MAG_BASIC",
+ "bootstrapEvidence": ["handshake", "get_profile"],
+ "requestOrder": ["handshake", "get_profile", "get_all_channels", "create_link"],
+ "playbackMode": "TEMP_LINK_NGINX",
+ "resolvedPlaybackUrl": "http://edge.example.com/play/live.php?stream=100&play_token=abc"
+ }
+}
diff --git a/domain/src/main/java/com/streamvault/domain/manager/ProviderSetupInputValidator.kt b/domain/src/main/java/com/streamvault/domain/manager/ProviderSetupInputValidator.kt
index acbcd448..82a4aaa0 100644
--- a/domain/src/main/java/com/streamvault/domain/manager/ProviderSetupInputValidator.kt
+++ b/domain/src/main/java/com/streamvault/domain/manager/ProviderSetupInputValidator.kt
@@ -1,6 +1,7 @@
package com.streamvault.domain.manager
import com.streamvault.domain.model.Result
+import com.streamvault.domain.model.StalkerAuthMode
data class ValidatedXtreamProviderInput(
val serverUrl: String,
@@ -22,6 +23,9 @@ data class ValidatedStalkerProviderInput(
val portalUrl: String,
val macAddress: String,
val name: String,
+ val authMode: StalkerAuthMode,
+ val username: String,
+ val password: String,
val deviceProfile: String,
val timezone: String,
val locale: String,
@@ -53,6 +57,10 @@ interface ProviderSetupInputValidator {
portalUrl: String,
macAddress: String,
name: String,
+ authMode: StalkerAuthMode,
+ username: String,
+ password: String,
+ allowBlankPassword: Boolean = false,
deviceProfile: String,
timezone: String,
locale: String,
diff --git a/domain/src/main/java/com/streamvault/domain/model/Provider.kt b/domain/src/main/java/com/streamvault/domain/model/Provider.kt
index 6301bac9..1a6cfa00 100644
--- a/domain/src/main/java/com/streamvault/domain/model/Provider.kt
+++ b/domain/src/main/java/com/streamvault/domain/model/Provider.kt
@@ -19,6 +19,13 @@ data class Provider(
val stalkerDeviceId: String = "",
val stalkerDeviceId2: String = "",
val stalkerSignature: String = "",
+ val stalkerAuthMode: StalkerAuthMode = StalkerAuthMode.AUTO,
+ val stalkerPortalProfile: StalkerPortalProfile = StalkerPortalProfile.MAG_BASIC,
+ val stalkerLastPlaybackMode: String? = null,
+ val stalkerCredentialsRequired: Boolean = false,
+ val stalkerMacRequired: Boolean = true,
+ val stalkerUsesTemporaryLinks: Boolean = false,
+ val stalkerModuleRestricted: Boolean = false,
val isActive: Boolean = true,
val maxConnections: Int = 1,
val expirationDate: Long? = null,
@@ -60,6 +67,21 @@ enum class ProviderXtreamLiveSyncMode {
STREAM_ALL
}
+enum class StalkerAuthMode {
+ AUTO,
+ MAC_ONLY,
+ MAC_PLUS_CREDENTIALS,
+ CREDENTIALS_ONLY
+}
+
+enum class StalkerPortalProfile {
+ MAG_BASIC,
+ MAG_STRICT,
+ AUTH_REQUIRED,
+ AUTH_PLUS_MAG,
+ MODULE_GATED
+}
+
enum class ProviderStatus {
ACTIVE,
PARTIAL,
diff --git a/domain/src/main/java/com/streamvault/domain/repository/ProviderRepository.kt b/domain/src/main/java/com/streamvault/domain/repository/ProviderRepository.kt
index b197afd0..bf322db3 100644
--- a/domain/src/main/java/com/streamvault/domain/repository/ProviderRepository.kt
+++ b/domain/src/main/java/com/streamvault/domain/repository/ProviderRepository.kt
@@ -6,6 +6,7 @@ import com.streamvault.domain.model.Provider
import com.streamvault.domain.model.ProviderEpgSyncMode
import com.streamvault.domain.model.ProviderXtreamLiveSyncMode
import com.streamvault.domain.model.Result
+import com.streamvault.domain.model.StalkerAuthMode
import kotlinx.coroutines.flow.Flow
data class LiveStreamProgramRequest(
@@ -47,6 +48,9 @@ interface ProviderRepository {
portalUrl: String,
macAddress: String,
name: String,
+ authMode: StalkerAuthMode = StalkerAuthMode.AUTO,
+ username: String = "",
+ password: String = "",
deviceProfile: String = "",
timezone: String = "",
locale: String = "",
diff --git a/domain/src/main/java/com/streamvault/domain/usecase/ValidateAndAddProvider.kt b/domain/src/main/java/com/streamvault/domain/usecase/ValidateAndAddProvider.kt
index ba6f51b7..e5d45555 100644
--- a/domain/src/main/java/com/streamvault/domain/usecase/ValidateAndAddProvider.kt
+++ b/domain/src/main/java/com/streamvault/domain/usecase/ValidateAndAddProvider.kt
@@ -6,6 +6,7 @@ import com.streamvault.domain.model.ProviderEpgSyncMode
import com.streamvault.domain.model.ProviderXtreamLiveSyncMode
import com.streamvault.domain.model.ProviderSavedWithSyncErrorException
import com.streamvault.domain.model.Result
+import com.streamvault.domain.model.StalkerAuthMode
import com.streamvault.domain.repository.ProviderRepository
import java.net.URI
import java.net.URLDecoder
@@ -39,6 +40,9 @@ data class StalkerProviderSetupCommand(
val portalUrl: String,
val macAddress: String,
val name: String,
+ val authMode: StalkerAuthMode = StalkerAuthMode.AUTO,
+ val username: String = "",
+ val password: String = "",
val deviceProfile: String = "",
val timezone: String = "",
val locale: String = "",
@@ -118,6 +122,10 @@ class ValidateAndAddProvider @Inject constructor(
portalUrl = command.portalUrl,
macAddress = command.macAddress,
name = command.name,
+ authMode = command.authMode,
+ username = command.username,
+ password = command.password,
+ allowBlankPassword = command.existingProviderId != null,
deviceProfile = command.deviceProfile,
timezone = command.timezone,
locale = command.locale,
@@ -229,6 +237,10 @@ class ValidateAndAddProvider @Inject constructor(
portalUrl = command.portalUrl,
macAddress = command.macAddress,
name = command.name,
+ authMode = command.authMode,
+ username = command.username,
+ password = command.password,
+ allowBlankPassword = command.existingProviderId != null,
deviceProfile = command.deviceProfile,
timezone = command.timezone,
locale = command.locale,
@@ -242,6 +254,9 @@ class ValidateAndAddProvider @Inject constructor(
portalUrl = validated.data.portalUrl,
macAddress = validated.data.macAddress,
name = validated.data.name,
+ authMode = validated.data.authMode,
+ username = validated.data.username,
+ password = validated.data.password,
deviceProfile = validated.data.deviceProfile,
timezone = validated.data.timezone,
locale = validated.data.locale,
diff --git a/domain/src/test/java/com/streamvault/domain/usecase/SyncProviderTest.kt b/domain/src/test/java/com/streamvault/domain/usecase/SyncProviderTest.kt
index bb537c41..7ee90604 100644
--- a/domain/src/test/java/com/streamvault/domain/usecase/SyncProviderTest.kt
+++ b/domain/src/test/java/com/streamvault/domain/usecase/SyncProviderTest.kt
@@ -10,6 +10,7 @@ import com.streamvault.domain.model.ProviderStatus
import com.streamvault.domain.model.ProviderType
import com.streamvault.domain.model.ProviderXtreamLiveSyncMode
import com.streamvault.domain.model.Result
+import com.streamvault.domain.model.StalkerAuthMode
import com.streamvault.domain.model.SyncState
import com.streamvault.domain.repository.ProviderRepository
import kotlinx.coroutines.flow.Flow
@@ -142,6 +143,9 @@ private class FakeSyncProviderRepository(
portalUrl: String,
macAddress: String,
name: String,
+ authMode: StalkerAuthMode,
+ username: String,
+ password: String,
deviceProfile: String,
timezone: String,
locale: String,
diff --git a/domain/src/test/java/com/streamvault/domain/usecase/ValidateAndAddProviderTest.kt b/domain/src/test/java/com/streamvault/domain/usecase/ValidateAndAddProviderTest.kt
index 1c6d4587..088a18db 100644
--- a/domain/src/test/java/com/streamvault/domain/usecase/ValidateAndAddProviderTest.kt
+++ b/domain/src/test/java/com/streamvault/domain/usecase/ValidateAndAddProviderTest.kt
@@ -14,6 +14,7 @@ import com.streamvault.domain.model.ProviderStatus
import com.streamvault.domain.model.ProviderType
import com.streamvault.domain.model.ProviderXtreamLiveSyncMode
import com.streamvault.domain.model.Result
+import com.streamvault.domain.model.StalkerAuthMode
import com.streamvault.domain.repository.ProviderRepository
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
@@ -426,6 +427,9 @@ class ValidateAndAddProviderTest {
ValidatedStalkerProviderInput(
portalUrl = "https://portal.example.com",
macAddress = "00:1A:79:12:34:56",
+ authMode = StalkerAuthMode.AUTO,
+ username = "",
+ password = "",
name = "MAG",
deviceProfile = "MAG250",
timezone = "UTC",
@@ -440,6 +444,9 @@ class ValidateAndAddProviderTest {
StalkerProviderSetupCommand(
portalUrl = " https://portal.example.com ",
macAddress = "00-1a-79-12-34-56",
+ authMode = StalkerAuthMode.AUTO,
+ username = "",
+ password = "",
name = " MAG ",
deviceProfile = " MAG250 ",
timezone = " UTC ",
@@ -454,6 +461,9 @@ class ValidateAndAddProviderTest {
StalkerCall(
portalUrl = "https://portal.example.com",
macAddress = "00:1A:79:12:34:56",
+ authMode = StalkerAuthMode.AUTO,
+ username = "",
+ password = "",
name = "MAG",
deviceProfile = "MAG250",
timezone = "UTC",
@@ -488,6 +498,9 @@ private class FakeProviderSetupInputValidator(
ValidatedStalkerProviderInput(
portalUrl = "https://portal.example.com",
macAddress = "00:1A:79:12:34:56",
+ authMode = StalkerAuthMode.AUTO,
+ username = "",
+ password = "",
name = "Provider",
deviceProfile = "MAG250",
timezone = "UTC",
@@ -516,6 +529,10 @@ private class FakeProviderSetupInputValidator(
portalUrl: String,
macAddress: String,
name: String,
+ authMode: StalkerAuthMode,
+ username: String,
+ password: String,
+ allowBlankPassword: Boolean,
deviceProfile: String,
timezone: String,
locale: String,
@@ -552,6 +569,9 @@ private data class M3uCall(
private data class StalkerCall(
val portalUrl: String,
val macAddress: String,
+ val authMode: StalkerAuthMode,
+ val username: String,
+ val password: String,
val name: String,
val deviceProfile: String,
val timezone: String,
@@ -629,6 +649,9 @@ private class FakeProviderRepository : ProviderRepository {
portalUrl: String,
macAddress: String,
name: String,
+ authMode: StalkerAuthMode,
+ username: String,
+ password: String,
deviceProfile: String,
timezone: String,
locale: String,
@@ -643,6 +666,9 @@ private class FakeProviderRepository : ProviderRepository {
lastStalkerCall = StalkerCall(
portalUrl = portalUrl,
macAddress = macAddress,
+ authMode = authMode,
+ username = username,
+ password = password,
name = name,
deviceProfile = deviceProfile,
timezone = timezone,
@@ -657,7 +683,10 @@ private class FakeProviderRepository : ProviderRepository {
return stalkerResult ?: Result.success(
provider(id = id ?: 3L, name = name, type = ProviderType.STALKER_PORTAL).copy(
serverUrl = portalUrl,
+ username = username,
+ password = password,
stalkerMacAddress = macAddress,
+ stalkerAuthMode = authMode,
stalkerDeviceProfile = deviceProfile,
stalkerDeviceTimezone = timezone,
stalkerDeviceLocale = locale,