Skip to content

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

wp0 and wp1

David Nashash082a94bf11d1
diff --git a/app/src/main/java/com/streamvault/app/StreamVaultApp.kt b/app/src/main/java/com/streamvault/app/StreamVaultApp.kt
index 8d5ecdf4..6be22bff 100644
--- a/app/src/main/java/com/streamvault/app/StreamVaultApp.kt
+++ b/app/src/main/java/com/streamvault/app/StreamVaultApp.kt
@@ -11,9 +11,12 @@ import coil3.request.crossfade
import com.streamvault.app.diagnostics.CrashReportStore
import com.streamvault.app.diagnostics.RuntimeDiagnosticsManager
import com.streamvault.app.update.GitHubReleaseChecker
+import com.streamvault.app.update.AppUpdateCheckPolicy
+import com.streamvault.app.plugins.StreamVaultPluginManager
import com.streamvault.app.ui.accessibility.isReducedMotionEnabled
import com.streamvault.data.remote.jellyfin.JellyfinImageAuthInterceptor
import com.streamvault.data.preferences.PreferencesRepository
+import com.streamvault.domain.repository.DownloadManager
import com.streamvault.domain.model.Result
import dagger.hilt.android.HiltAndroidApp
import kotlinx.coroutines.CoroutineScope
@@ -25,10 +28,10 @@ import okio.Path.Companion.toOkioPath
import androidx.work.Constraints
import androidx.work.ExistingPeriodicWorkPolicy
-import androidx.work.NetworkType
import androidx.work.PeriodicWorkRequestBuilder
import androidx.work.WorkManager
import com.streamvault.data.manager.recording.RecordingReconcileWorker
+import com.streamvault.data.repository.ProviderDeletionCleanupWorker
import com.streamvault.data.sync.ProviderSyncWorker
import com.streamvault.data.sync.XtreamIndexWorker
import com.streamvault.player.timeshift.TimeshiftDiskManager
@@ -52,6 +55,12 @@ class StreamVaultApp : Application(), SingletonImageLoader.Factory {
@Inject
lateinit var jellyfinImageAuthInterceptor: JellyfinImageAuthInterceptor
+ @Inject
+ lateinit var downloadManager: DownloadManager
+
+ @Inject
+ lateinit var streamVaultPluginManager: StreamVaultPluginManager
+
private val imageOkHttpClient: OkHttpClient by lazy {
okHttpClient.newBuilder()
.addInterceptor(jellyfinImageAuthInterceptor)
@@ -70,14 +79,16 @@ class StreamVaultApp : Application(), SingletonImageLoader.Factory {
applicationScope.launch {
refreshCachedAppUpdateIfNeeded()
}
+ applicationScope.launch {
+ downloadManager.recoverInterruptedDownloads()
+ }
+ applicationScope.launch {
+ streamVaultPluginManager.reconcilePluginProviders()
+ }
// Schedule daily data maintenance: EPG pruning, stale-favorite cleanup, and DB compaction checks.
- // BLD-H02: Require network + device idle so the worker doesn't drain battery.
- val gcConstraints = Constraints.Builder()
- .setRequiredNetworkType(NetworkType.CONNECTED)
- .setRequiresBatteryNotLow(true)
- .setRequiresDeviceIdle(true)
- .build()
+ // This work is local-only and must also run for offline/local-playlist devices.
+ val gcConstraints = dataMaintenanceConstraints()
val gcWorkRequest = PeriodicWorkRequestBuilder<com.streamvault.data.sync.SyncWorker>(24, java.util.concurrent.TimeUnit.HOURS)
.setConstraints(gcConstraints)
@@ -95,6 +106,7 @@ class StreamVaultApp : Application(), SingletonImageLoader.Factory {
XtreamIndexWorker.enqueueLaunchStaleCheck(this)
RecordingReconcileWorker.enqueuePeriodic(this)
RecordingReconcileWorker.enqueueOneShot(this)
+ ProviderDeletionCleanupWorker.enqueue(this)
}
override fun onTerminate() {
@@ -108,14 +120,13 @@ class StreamVaultApp : Application(), SingletonImageLoader.Factory {
return
}
- val lastCheckedAt = preferencesRepository.lastAppUpdateCheckTimestamp.first()
+ val lastSuccessfulCheckAt = preferencesRepository.lastAppUpdateCheckTimestamp.first()
+ val lastFailedCheckAt = preferencesRepository.lastAppUpdateFailureTimestamp.first()
val now = System.currentTimeMillis()
- val checkIntervalMs = 24L * 60L * 60L * 1000L
- if (lastCheckedAt != null && now - lastCheckedAt < checkIntervalMs) {
+ if (!AppUpdateCheckPolicy.shouldAutoCheck(now, lastSuccessfulCheckAt, lastFailedCheckAt)) {
return
}
- preferencesRepository.setLastAppUpdateCheckTimestamp(now)
when (val result = gitHubReleaseChecker.fetchLatestRelease()) {
is Result.Success -> {
preferencesRepository.setCachedAppUpdateRelease(
@@ -127,8 +138,10 @@ class StreamVaultApp : Application(), SingletonImageLoader.Factory {
releaseNotes = result.data.releaseNotes,
publishedAt = result.data.publishedAt
)
+ preferencesRepository.setLastAppUpdateCheckTimestamp(now)
+ preferencesRepository.setLastAppUpdateFailureTimestamp(null)
}
- else -> Unit
+ else -> preferencesRepository.setLastAppUpdateFailureTimestamp(now)
}
}
@@ -159,3 +172,8 @@ class StreamVaultApp : Application(), SingletonImageLoader.Factory {
.build()
}
}
+
+internal fun dataMaintenanceConstraints(): Constraints = Constraints.Builder()
+ .setRequiresBatteryNotLow(true)
+ .setRequiresDeviceIdle(true)
+ .build()
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 a4648ccb..2f3fdc41 100644
--- a/app/src/main/java/com/streamvault/app/di/DatabaseModule.kt
+++ b/app/src/main/java/com/streamvault/app/di/DatabaseModule.kt
@@ -102,7 +102,11 @@ object DatabaseModule {
StreamVaultDatabase.MIGRATION_58_59,
StreamVaultDatabase.MIGRATION_59_60,
StreamVaultDatabase.MIGRATION_60_61,
- StreamVaultDatabase.MIGRATION_61_62
+ StreamVaultDatabase.MIGRATION_61_62,
+ StreamVaultDatabase.MIGRATION_62_63,
+ StreamVaultDatabase.MIGRATION_63_64,
+ StreamVaultDatabase.MIGRATION_64_65,
+ StreamVaultDatabase.MIGRATION_65_66
)
// NOTE: fallbackToDestructiveMigration() intentionally removed.
// All future schema changes MUST add a corresponding Migration in StreamVaultDatabase.
@@ -145,4 +149,6 @@ object DatabaseModule {
@Provides fun provideXtreamIndexJobDao(db: StreamVaultDatabase): XtreamIndexJobDao = db.xtreamIndexJobDao()
@Provides fun provideXtreamLiveOnboardingDao(db: StreamVaultDatabase): XtreamLiveOnboardingDao = db.xtreamLiveOnboardingDao()
@Provides fun provideDownloadDao(db: StreamVaultDatabase): DownloadDao = db.downloadDao()
+ @Provides fun provideProviderDeletionCleanupDao(db: StreamVaultDatabase): ProviderDeletionCleanupDao = db.providerDeletionCleanupDao()
+ @Provides fun providePluginProviderOwnershipDao(db: StreamVaultDatabase): PluginProviderOwnershipDao = db.pluginProviderOwnershipDao()
}
diff --git a/app/src/main/java/com/streamvault/app/navigation/ExternalNavigationRequest.kt b/app/src/main/java/com/streamvault/app/navigation/ExternalNavigationRequest.kt
index 80b72e53..d9fb9ede 100644
--- a/app/src/main/java/com/streamvault/app/navigation/ExternalNavigationRequest.kt
+++ b/app/src/main/java/com/streamvault/app/navigation/ExternalNavigationRequest.kt
@@ -2,7 +2,6 @@ package com.streamvault.app.navigation
import java.io.Serializable
import java.net.URLDecoder
-import java.nio.charset.StandardCharsets
sealed class ExternalDestination : Serializable {
data object Home : ExternalDestination()
@@ -85,7 +84,10 @@ private fun String.queryParameters(): Map<String, String> {
val key = entry.substringBefore('=', missingDelimiterValue = "").takeIf { it.isNotBlank() }
?: return@mapNotNull null
val rawValue = entry.substringAfter('=', missingDelimiterValue = "")
- key to URLDecoder.decode(rawValue, StandardCharsets.UTF_8)
+ val value = runCatching { URLDecoder.decode(rawValue, Charsets.UTF_8.name()) }
+ .getOrNull()
+ ?: return@mapNotNull null
+ key to value
}
.toMap()
}
diff --git a/app/src/main/java/com/streamvault/app/plugins/PluginMessengerClient.kt b/app/src/main/java/com/streamvault/app/plugins/PluginMessengerClient.kt
index c958db83..b30d2972 100644
--- a/app/src/main/java/com/streamvault/app/plugins/PluginMessengerClient.kt
+++ b/app/src/main/java/com/streamvault/app/plugins/PluginMessengerClient.kt
@@ -17,9 +17,9 @@ import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.TimeoutCancellationException
+import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.withContext
-import kotlinx.coroutines.withTimeout
+import kotlinx.coroutines.withTimeoutOrNull
@Singleton
class PluginMessengerClient @Inject constructor(
@@ -61,6 +61,9 @@ class PluginMessengerClient @Inject constructor(
if (!serviceDeferred.isCompleted) {
serviceDeferred.completeExceptionally(IllegalStateException("Plugin service disconnected"))
}
+ if (!responseDeferred.isCompleted) {
+ responseDeferred.completeExceptionally(IllegalStateException("Plugin service disconnected"))
+ }
}
}
@@ -75,7 +78,8 @@ class PluginMessengerClient @Inject constructor(
}
}
- val service = withTimeout(timeoutMillis) { serviceDeferred.await() }
+ val service = withTimeoutOrNull(timeoutMillis) { serviceDeferred.await() }
+ ?: throw IllegalStateException("Plugin request timed out")
val request = Message.obtain(null, what).apply {
replyTo = replyMessenger
this.data = Bundle(data).apply {
@@ -88,12 +92,11 @@ class PluginMessengerClient @Inject constructor(
} catch (error: RemoteException) {
throw IllegalStateException("Plugin service did not accept the request", error)
}
- return withTimeout(timeoutMillis) { responseDeferred.await() }
- } catch (error: TimeoutCancellationException) {
- throw IllegalStateException("Plugin request timed out", error)
+ return withTimeoutOrNull(timeoutMillis) { responseDeferred.await() }
+ ?: throw IllegalStateException("Plugin request timed out")
} finally {
if (bound) {
- withContext(Dispatchers.Main.immediate) {
+ withContext(NonCancellable + Dispatchers.Main.immediate) {
runCatching { appContext.unbindService(connection) }
}
}
diff --git a/app/src/main/java/com/streamvault/app/plugins/PluginModels.kt b/app/src/main/java/com/streamvault/app/plugins/PluginModels.kt
index f34d28ba..447d25f0 100644
--- a/app/src/main/java/com/streamvault/app/plugins/PluginModels.kt
+++ b/app/src/main/java/com/streamvault/app/plugins/PluginModels.kt
@@ -14,6 +14,10 @@ data class StreamVaultPluginManifest(
val versionCode: Long = 0L,
val description: String = "",
val capabilities: List<String> = emptyList(),
+ /** Explicit URL ownership for playback and cast hooks. `*` is an intentional catch-all. */
+ val playbackUrlSchemes: List<String> = emptyList(),
+ val playbackUrlHosts: List<String> = emptyList(),
+ val playbackPriority: Int = 0,
val configurationMode: String? = null,
val configurationActivityAction: String? = null,
val providerName: String? = null
@@ -49,6 +53,15 @@ data class InstalledStreamVaultPlugin(
get() = manifest.name.ifBlank { appLabel.ifBlank { packageName } }
}
+data class StreamVaultPluginOwner(
+ val packageName: String,
+ val serviceClassName: String,
+ val manifestId: String
+)
+
+val InstalledStreamVaultPlugin.owner: StreamVaultPluginOwner
+ get() = StreamVaultPluginOwner(packageName, serviceClassName, manifest.id)
+
data class PluginActionResult(
val success: Boolean,
val message: String
diff --git a/app/src/main/java/com/streamvault/app/plugins/PluginPlaybackRouting.kt b/app/src/main/java/com/streamvault/app/plugins/PluginPlaybackRouting.kt
new file mode 100644
index 00000000..d7c54dfc
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/plugins/PluginPlaybackRouting.kt
@@ -0,0 +1,40 @@
+package com.streamvault.app.plugins
+
+import java.net.URI
+import kotlinx.coroutines.withTimeoutOrNull
+
+internal suspend fun <T> withPluginPlaybackDeadline(
+ timeoutMillis: Long,
+ block: suspend () -> T
+): T? = withTimeoutOrNull(timeoutMillis) { block() }
+
+/**
+ * Selects only plugins that explicitly own the URL. Empty routing metadata is
+ * deliberately not a wildcard: old generic handlers must not capture traffic.
+ */
+internal fun playbackCandidates(
+ plugins: List<InstalledStreamVaultPlugin>,
+ url: String,
+ capability: String
+): List<InstalledStreamVaultPlugin> {
+ val parsed = runCatching { URI(url) }.getOrNull() ?: return emptyList()
+ val scheme = parsed.scheme?.lowercase() ?: return emptyList()
+ val host = parsed.host?.lowercase()
+ return plugins.asSequence()
+ .filter { it.enabled && it.manifest.hasCapability(capability) }
+ .filter { plugin -> plugin.manifest.ownsPlaybackUrl(scheme, host) }
+ .sortedWith(
+ compareByDescending<InstalledStreamVaultPlugin> { it.manifest.playbackPriority }
+ .thenBy { it.packageName }
+ .thenBy { it.serviceClassName }
+ .thenBy { it.manifest.id }
+ )
+ .toList()
+}
+
+private fun StreamVaultPluginManifest.ownsPlaybackUrl(scheme: String, host: String?): Boolean {
+ val schemeOwned = playbackUrlSchemes.any { it.equals("*", true) || it.equals(scheme, true) }
+ if (!schemeOwned) return false
+ // Hostless schemes (for example, a custom URI) can be owned by scheme alone.
+ return host == null || playbackUrlHosts.any { it.equals("*", true) || it.equals(host, true) }
+}
diff --git a/app/src/main/java/com/streamvault/app/plugins/StreamVaultPluginManager.kt b/app/src/main/java/com/streamvault/app/plugins/StreamVaultPluginManager.kt
index 59fd55e5..55c7cb24 100644
--- a/app/src/main/java/com/streamvault/app/plugins/StreamVaultPluginManager.kt
+++ b/app/src/main/java/com/streamvault/app/plugins/StreamVaultPluginManager.kt
@@ -1,8 +1,10 @@
package com.streamvault.app.plugins
import android.content.ActivityNotFoundException
+import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
+import android.content.IntentFilter
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
import android.net.Uri
@@ -11,15 +13,18 @@ import android.os.Bundle
import android.os.Environment
import android.provider.Settings
import androidx.core.content.FileProvider
+import androidx.core.content.ContextCompat
import com.streamvault.app.BuildConfig
import com.streamvault.app.cast.CastMediaRequest
import com.streamvault.app.tvinput.TvInputChannelSyncManager
+import com.streamvault.data.local.dao.PluginProviderOwnershipDao
+import com.streamvault.data.local.entity.PluginProviderOwnershipEntity
+import com.streamvault.data.remote.http.useCancellableResponse
import com.streamvault.domain.model.ActiveLiveSource
import com.streamvault.domain.model.DrmInfo
import com.streamvault.domain.model.DrmScheme
import com.streamvault.domain.model.Provider
import com.streamvault.domain.model.ProviderEpgSyncMode
-import com.streamvault.domain.model.ProviderType
import com.streamvault.domain.model.Result
import com.streamvault.domain.model.StreamInfo
import com.streamvault.domain.model.StreamType
@@ -31,6 +36,12 @@ import java.net.URI
import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.CancellationException
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.SupervisorJob
+import kotlinx.coroutines.async
+import kotlinx.coroutines.awaitAll
+import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@@ -45,18 +56,73 @@ class StreamVaultPluginManager @Inject constructor(
@param:ApplicationContext private val context: Context,
private val messengerClient: PluginMessengerClient,
private val providerRepository: ProviderRepository,
+ private val pluginProviderOwnershipDao: PluginProviderOwnershipDao,
private val combinedM3uRepository: CombinedM3uRepository,
private val tvInputChannelSyncManager: TvInputChannelSyncManager,
private val okHttpClient: OkHttpClient,
private val json: Json
) {
private val prefs = context.getSharedPreferences("streamvault_plugins", Context.MODE_PRIVATE)
+ private val discoveryLock = Any()
+ private val backgroundScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
+
+ @Volatile
+ private var cachedDiscovery: List<InstalledStreamVaultPlugin>? = null
+
+ @Volatile
+ private var discoveryExpiresAtMillis = 0L
+
+ private val packageChangeReceiver = object : BroadcastReceiver() {
+ override fun onReceive(context: Context, intent: Intent) = invalidateDiscovery()
+ }
+
+ init {
+ ContextCompat.registerReceiver(
+ context.applicationContext,
+ packageChangeReceiver,
+ IntentFilter().apply {
+ addAction(Intent.ACTION_PACKAGE_ADDED)
+ addAction(Intent.ACTION_PACKAGE_CHANGED)
+ addAction(Intent.ACTION_PACKAGE_REMOVED)
+ addAction(Intent.ACTION_PACKAGE_REPLACED)
+ addDataScheme("package")
+ },
+ ContextCompat.RECEIVER_NOT_EXPORTED
+ )
+ }
suspend fun discoverPlugins(): List<InstalledStreamVaultPlugin> = withContext(Dispatchers.IO) {
- queryPluginServices()
- .mapNotNull { resolveInfo -> resolvePlugin(resolveInfo) }
- .distinctBy { it.manifest.id }
+ cachedDiscovery?.takeIf { System.currentTimeMillis() < discoveryExpiresAtMillis }?.let { return@withContext it }
+ val plugins = queryPluginServices()
+ .map { resolveInfo -> async { resolvePlugin(resolveInfo) } }
+ .awaitAll()
+ .filterNotNull()
.sortedBy { it.displayName.lowercase() }
+ migrateLegacyEnabledStates(plugins)
+ plugins.map { plugin -> plugin.copy(enabled = isEnabled(plugin)) }.also { discovered ->
+ synchronized(discoveryLock) {
+ cachedDiscovery = discovered
+ discoveryExpiresAtMillis = System.currentTimeMillis() + DISCOVERY_CACHE_TTL_MILLIS
+ }
+ }
+ }
+
+ /** Removes only providers with a durable ownership record for an uninstalled plugin service. */
+ suspend fun reconcilePluginProviders() = withContext(Dispatchers.IO) {
+ val installedOwners = queryPluginServices().mapNotNull { resolveInfo ->
+ val serviceInfo = resolveInfo.serviceInfo ?: return@mapNotNull null
+ val packageName = serviceInfo.packageName ?: return@mapNotNull null
+ val serviceName = serviceInfo.name ?: return@mapNotNull null
+ val manifest = readManifestFromService(packageName, serviceName)
+ ?: readManifestFromMetadata(serviceInfo.metaData)
+ ?: StreamVaultPluginManifest(id = packageName, name = packageName)
+ StreamVaultPluginOwner(packageName, serviceName, manifest.id)
+ }.toSet()
+ pluginProviderOwnershipDao.getAll()
+ .filter { ownership ->
+ StreamVaultPluginOwner(ownership.packageName, ownership.serviceClassName, ownership.manifestId) !in installedOwners
+ }
+ .forEach { ownership -> removeOwnedProvider(ownership) }
}
suspend fun setPluginEnabled(
@@ -67,7 +133,7 @@ class StreamVaultPluginManager @Inject constructor(
val command = Bundle().apply {
putBoolean(StreamVaultPluginContract.KEY_ENABLED, enabled)
}
- val response = runCatching {
+ val response = runPluginCatching {
messengerClient.send(
packageName = plugin.packageName,
serviceClassName = plugin.serviceClassName,
@@ -87,7 +153,7 @@ class StreamVaultPluginManager @Inject constructor(
)
}
- prefs.edit().putBoolean(enabledKey(plugin.manifest.id), enabled).apply()
+ prefs.edit().putBoolean(enabledKey(plugin.owner), enabled).apply()
if (enabled && plugin.manifest.hasCapability(StreamVaultPluginContract.CAPABILITY_PROVIDER_M3U)) {
syncPluginProvider(plugin, onProgress)?.let { return@withContext it }
} else if (!enabled) {
@@ -103,7 +169,7 @@ class StreamVaultPluginManager @Inject constructor(
suspend fun installApkFromUri(uri: Uri): Result<Unit> = withContext(Dispatchers.IO) {
val target = pluginApkFile("local-${System.currentTimeMillis()}.apk")
- runCatching {
+ runPluginCatching {
target.parentFile?.mkdirs()
context.contentResolver.openInputStream(uri).use { input ->
requireNotNull(input) { "Cannot open selected APK" }
@@ -122,10 +188,10 @@ class StreamVaultPluginManager @Inject constructor(
}
val target = pluginApkFile("plugin-${System.currentTimeMillis()}.apk")
- runCatching {
+ runPluginCatching {
target.parentFile?.mkdirs()
val request = Request.Builder().url(normalizedUrl).build()
- okHttpClient.newCall(request).execute().use { response ->
+ okHttpClient.newCall(request).useCancellableResponse { response ->
if (!response.isSuccessful) error("HTTP ${response.code}")
val body = response.body ?: error("Empty response")
target.outputStream().use { output -> body.byteStream().copyTo(output) }
@@ -157,7 +223,7 @@ class StreamVaultPluginManager @Inject constructor(
return@withContext Result.error("This plugin does not expose a StreamVault configuration schema")
}
- val schemaResponse = runCatching {
+ val schemaResponse = runPluginCatching {
messengerClient.send(
packageName = plugin.packageName,
serviceClassName = plugin.serviceClassName,
@@ -191,7 +257,7 @@ class StreamVaultPluginManager @Inject constructor(
suspend fun loadPluginConfigurationValues(plugin: InstalledStreamVaultPlugin): Result<JsonObject> =
withContext(Dispatchers.IO) {
- val valuesResponse = runCatching {
+ val valuesResponse = runPluginCatching {
messengerClient.send(
packageName = plugin.packageName,
serviceClassName = plugin.serviceClassName,
@@ -226,7 +292,7 @@ class StreamVaultPluginManager @Inject constructor(
plugin: InstalledStreamVaultPlugin,
valuesJson: String
): PluginActionResult = withContext(Dispatchers.IO) {
- val response = runCatching {
+ val response = runPluginCatching {
messengerClient.send(
packageName = plugin.packageName,
serviceClassName = plugin.serviceClassName,
@@ -246,7 +312,7 @@ class StreamVaultPluginManager @Inject constructor(
plugin: InstalledStreamVaultPlugin,
actionId: String
): PluginActionResult = withContext(Dispatchers.IO) {
- val response = runCatching {
+ val response = runPluginCatching {
messengerClient.send(
packageName = plugin.packageName,
serviceClassName = plugin.serviceClassName,
@@ -268,53 +334,70 @@ class StreamVaultPluginManager @Inject constructor(
suspend fun preparePlaybackStreamInfo(streamInfo: StreamInfo): Result<StreamInfo> = withContext(Dispatchers.IO) {
val url = streamInfo.url
if (url.isBlank()) return@withContext Result.success(streamInfo)
- val plugins = discoverPlugins()
- .filter { it.enabled && it.manifest.hasCapability(StreamVaultPluginContract.CAPABILITY_PLAYBACK_PREPARE) }
- for (plugin in plugins) {
- val response = runCatching {
- messengerClient.send(
- packageName = plugin.packageName,
- serviceClassName = plugin.serviceClassName,
- what = StreamVaultPluginContract.MSG_PREPARE_PLAYBACK,
- data = Bundle().apply { putString(StreamVaultPluginContract.KEY_INPUT_URL, url) },
- timeoutMillis = 120_000L
- )
- }.getOrNull() ?: continue
-
- if (!response.getBoolean(StreamVaultPluginContract.KEY_HANDLED, false)) continue
- if (response.getBoolean(StreamVaultPluginContract.KEY_SUCCESS, false)) {
- return@withContext Result.success(applyPlaybackPreparationResponse(streamInfo, response))
- }
- return@withContext Result.error(
- response.getString(StreamVaultPluginContract.KEY_MESSAGE).orEmpty()
- .ifBlank { "${plugin.displayName} could not prepare playback" }
+ val prepared = withPluginPlaybackDeadline(PLAYBACK_TOTAL_TIMEOUT_MILLIS) {
+ val plugins = playbackCandidates(
+ discoverPlugins(), url, StreamVaultPluginContract.CAPABILITY_PLAYBACK_PREPARE
)
+ coroutineScope {
+ val requests = plugins.associateWith { plugin -> async {
+ runPluginCallOrNull {
+ messengerClient.send(
+ packageName = plugin.packageName,
+ serviceClassName = plugin.serviceClassName,
+ what = StreamVaultPluginContract.MSG_PREPARE_PLAYBACK,
+ data = Bundle().apply { putString(StreamVaultPluginContract.KEY_INPUT_URL, url) },
+ timeoutMillis = PLAYBACK_HANDLER_TIMEOUT_MILLIS
+ )
+ }
+ } }
+ for (plugin in plugins) {
+ val response = requests.getValue(plugin).await() ?: continue
+ if (!response.getBoolean(StreamVaultPluginContract.KEY_HANDLED, false)) continue
+ requests.values.forEach { it.cancel() }
+ return@coroutineScope if (response.getBoolean(StreamVaultPluginContract.KEY_SUCCESS, false)) {
+ Result.success(applyPlaybackPreparationResponse(streamInfo, response))
+ } else {
+ Result.error(response.getString(StreamVaultPluginContract.KEY_MESSAGE).orEmpty()
+ .ifBlank { "${plugin.displayName} could not prepare playback" })
+ }
+ }
+ Result.success(streamInfo)
+ }
}
- Result.success(streamInfo)
+ prepared ?: Result.success(streamInfo)
}
suspend fun rewriteCastUrl(request: CastMediaRequest): String? = withContext(Dispatchers.IO) {
val url = request.url
if (url.isBlank()) return@withContext url
- val plugins = discoverPlugins()
- .filter { it.enabled && it.manifest.hasCapability(StreamVaultPluginContract.CAPABILITY_CAST_REWRITE_URL) }
- for (plugin in plugins) {
- val response = runCatching {
- messengerClient.send(
+ val rewritten = withPluginPlaybackDeadline(PLAYBACK_TOTAL_TIMEOUT_MILLIS) {
+ val plugins = playbackCandidates(
+ discoverPlugins(), url, StreamVaultPluginContract.CAPABILITY_CAST_REWRITE_URL
+ )
+ coroutineScope {
+ val requests = plugins.associateWith { plugin -> async {
+ runPluginCallOrNull {
+ messengerClient.send(
packageName = plugin.packageName,
serviceClassName = plugin.serviceClassName,
what = StreamVaultPluginContract.MSG_REWRITE_CAST_URL,
data = request.toCastRewriteBundle(),
- timeoutMillis = 10_000L
- )
- }.getOrNull() ?: continue
-
- if (!response.getBoolean(StreamVaultPluginContract.KEY_HANDLED, false)) continue
- if (!response.getBoolean(StreamVaultPluginContract.KEY_SUCCESS, false)) return@withContext null
- return@withContext response.getString(StreamVaultPluginContract.KEY_OUTPUT_URL).orEmpty()
- .ifBlank { url }
+ timeoutMillis = PLAYBACK_HANDLER_TIMEOUT_MILLIS
+ )
+ }
+ } }
+ for (plugin in plugins) {
+ val response = requests.getValue(plugin).await() ?: continue
+ if (!response.getBoolean(StreamVaultPluginContract.KEY_HANDLED, false)) continue
+ requests.values.forEach { it.cancel() }
+ return@coroutineScope if (response.getBoolean(StreamVaultPluginContract.KEY_SUCCESS, false)) {
+ response.getString(StreamVaultPluginContract.KEY_OUTPUT_URL).orEmpty().ifBlank { url }
+ } else null
+ }
+ url
+ }
}
- url
+ rewritten ?: url
}
suspend fun rewriteCastUrl(url: String): String? =
@@ -424,7 +507,7 @@ class StreamVaultPluginManager @Inject constructor(
plugin: InstalledStreamVaultPlugin,
onProgress: (String) -> Unit
): PluginActionResult? {
- val providerResponse = runCatching {
+ val providerResponse = runPluginCatching {
messengerClient.send(
packageName = plugin.packageName,
serviceClassName = plugin.serviceClassName,
@@ -493,7 +576,14 @@ class StreamVaultPluginManager @Inject constructor(
}
}
- prefs.edit().putLong(providerKey(plugin.manifest.id), provider.id).apply()
+ pluginProviderOwnershipDao.upsert(
+ PluginProviderOwnershipEntity(
+ packageName = plugin.packageName,
+ serviceClassName = plugin.serviceClassName,
+ manifestId = plugin.manifest.id,
+ providerId = provider.id
+ )
+ )
providerRepository.setActiveProvider(provider.id)
attachProviderToLiveSource(provider.id, activeSource)
refreshTvInputCatalogInBackground()
@@ -501,20 +591,12 @@ class StreamVaultPluginManager @Inject constructor(
}
private suspend fun removePluginProvider(plugin: InstalledStreamVaultPlugin): PluginActionResult? {
- val providerId = prefs.getLong(providerKey(plugin.manifest.id), -1L).takeIf { it > 0L }
- ?: return null
- when (val result = providerRepository.deleteProvider(providerId)) {
- is Result.Error -> return PluginActionResult(false, result.message)
- Result.Loading -> return PluginActionResult(false, "Provider removal is still running")
- is Result.Success -> Unit
- }
- val activeSource = combinedM3uRepository.getActiveLiveSource().first()
- if (activeSource is ActiveLiveSource.ProviderSource && activeSource.providerId == providerId) {
- combinedM3uRepository.setActiveLiveSource(null)
- }
- prefs.edit().remove(providerKey(plugin.manifest.id)).apply()
- refreshTvInputCatalogInBackground()
- return null
+ val ownership = pluginProviderOwnershipDao.get(
+ plugin.packageName,
+ plugin.serviceClassName,
+ plugin.manifest.id
+ ) ?: return null
+ return removeOwnedProvider(ownership)
}
private suspend fun attachProviderToLiveSource(providerId: Long, activeSource: ActiveLiveSource?) {
@@ -529,65 +611,66 @@ class StreamVaultPluginManager @Inject constructor(
}
private suspend fun trackedProvider(plugin: InstalledStreamVaultPlugin): Provider? {
- val providerId = prefs.getLong(providerKey(plugin.manifest.id), -1L).takeIf { it > 0L }
- ?: return providerRepository.getProviders().first().firstOrNull {
- it.type == ProviderType.M3U && it.m3uUrl.isNotBlank() && it.name == plugin.manifest.providerName
- }
- return providerRepository.getProvider(providerId)
+ val ownership = pluginProviderOwnershipDao.get(
+ plugin.packageName,
+ plugin.serviceClassName,
+ plugin.manifest.id
+ ) ?: return null
+ return providerRepository.getProvider(ownership.providerId)
}
private fun refreshTvInputCatalogInBackground() {
- kotlinx.coroutines.CoroutineScope(kotlinx.coroutines.Dispatchers.IO).let { scope ->
- scope.launchCatching { tvInputChannelSyncManager.refreshTvInputCatalog() }
- }
+ backgroundScope.launchCatching { tvInputChannelSyncManager.refreshTvInputCatalog() }
}
- private fun resolvePlugin(resolveInfo: ResolveInfo): InstalledStreamVaultPlugin? {
- val serviceInfo = resolveInfo.serviceInfo ?: return null
- val packageName = serviceInfo.packageName ?: return null
- val serviceName = serviceInfo.name ?: return null
+ private suspend fun resolvePlugin(resolveInfo: ResolveInfo): InstalledStreamVaultPlugin? = coroutineScope {
+ val serviceInfo = resolveInfo.serviceInfo ?: return@coroutineScope null
+ val packageName = serviceInfo.packageName ?: return@coroutineScope null
+ val serviceName = serviceInfo.name ?: return@coroutineScope null
val appLabel = serviceInfo.loadLabel(context.packageManager)?.toString().orEmpty()
- val manifest = readManifestFromService(packageName, serviceName)
- ?: readManifestFromMetadata(serviceInfo.metaData)
- ?: StreamVaultPluginManifest(
- id = packageName,
- name = appLabel.ifBlank { packageName },
- description = "StreamVault plugin"
- )
- val status = runCatching {
- kotlinx.coroutines.runBlocking(Dispatchers.IO) {
+ val metadataManifest = readManifestFromMetadata(serviceInfo.metaData)
+ val manifestResult = async { readManifestFromService(packageName, serviceName) }
+ val statusResult = async {
+ runPluginCallOrNull {
messengerClient.send(
packageName = packageName,
serviceClassName = serviceName,
what = StreamVaultPluginContract.MSG_GET_STATUS,
- timeoutMillis = 2_500L
+ timeoutMillis = DISCOVERY_REQUEST_TIMEOUT_MILLIS
)
}
- }.getOrNull()
- return InstalledStreamVaultPlugin(
+ }
+ val manifest = manifestResult.await()
+ ?: metadataManifest
+ ?: StreamVaultPluginManifest(
+ id = packageName,
+ name = appLabel.ifBlank { packageName },
+ description = "StreamVault plugin"
+ )
+ val status = statusResult.await()
+ InstalledStreamVaultPlugin(
packageName = packageName,
serviceClassName = serviceName,
appLabel = appLabel,
manifest = manifest,
- enabled = prefs.getBoolean(enabledKey(manifest.id), false),
+ enabled = false,
statusLabel = status?.getString(StreamVaultPluginContract.KEY_STATUS_LABEL).orEmpty(),
lastMessage = status?.getString(StreamVaultPluginContract.KEY_MESSAGE).orEmpty()
)
}
- private fun readManifestFromService(packageName: String, serviceName: String): StreamVaultPluginManifest? =
- runCatching {
- val response = kotlinx.coroutines.runBlocking(Dispatchers.IO) {
+ private suspend fun readManifestFromService(packageName: String, serviceName: String): StreamVaultPluginManifest? =
+ runPluginCallOrNull {
+ val response =
messengerClient.send(
packageName = packageName,
serviceClassName = serviceName,
what = StreamVaultPluginContract.MSG_GET_MANIFEST,
- timeoutMillis = 3_000L
+ timeoutMillis = DISCOVERY_REQUEST_TIMEOUT_MILLIS
)
- }
val manifestJson = response.getString(StreamVaultPluginContract.KEY_MANIFEST_JSON).orEmpty()
json.decodeFromString<StreamVaultPluginManifest>(manifestJson)
- }.getOrNull()
+ }
private fun readManifestFromMetadata(metaData: Bundle?): StreamVaultPluginManifest? {
if (metaData == null) return null
@@ -677,12 +760,88 @@ class StreamVaultPluginManager @Inject constructor(
parsed.scheme.equals("https", ignoreCase = true)
}.getOrDefault(false)
- private fun enabledKey(pluginId: String): String = "enabled.$pluginId"
- private fun providerKey(pluginId: String): String = "provider.$pluginId"
+ private fun invalidateDiscovery() {
+ synchronized(discoveryLock) {
+ cachedDiscovery = null
+ discoveryExpiresAtMillis = 0L
+ }
+ }
+
+ private suspend fun <T> runPluginCallOrNull(block: suspend () -> T): T? = try {
+ block()
+ } catch (error: CancellationException) {
+ throw error
+ } catch (_: Exception) {
+ null
+ }
+
+ private suspend inline fun <T> runPluginCatching(
+ block: suspend () -> T
+ ): kotlin.Result<T> = try {
+ kotlin.Result.success(block())
+ } catch (cancelled: CancellationException) {
+ throw cancelled
+ } catch (error: Throwable) {
+ kotlin.Result.failure(error)
+ }
+
+ private suspend fun removeOwnedProvider(ownership: PluginProviderOwnershipEntity): PluginActionResult? {
+ when (val result = providerRepository.deleteProvider(ownership.providerId)) {
+ is Result.Error -> return PluginActionResult(false, result.message)
+ Result.Loading -> return PluginActionResult(false, "Provider removal is still running")
+ is Result.Success -> Unit
+ }
+ val activeSource = combinedM3uRepository.getActiveLiveSource().first()
+ if (activeSource is ActiveLiveSource.ProviderSource && activeSource.providerId == ownership.providerId) {
+ combinedM3uRepository.setActiveLiveSource(null)
+ }
+ pluginProviderOwnershipDao.delete(ownership.packageName, ownership.serviceClassName, ownership.manifestId)
+ refreshTvInputCatalogInBackground()
+ return null
+ }
+
+ private fun isEnabled(plugin: InstalledStreamVaultPlugin): Boolean =
+ prefs.getBoolean(enabledKey(plugin.owner), false)
+
+ /** Legacy state is safe to migrate only when no installed service shares its manifest ID. */
+ private fun migrateLegacyEnabledStates(plugins: List<InstalledStreamVaultPlugin>) {
+ val uniqueManifestIds = plugins.groupingBy { it.manifest.id }.eachCount()
+ .filterValues { it == 1 }
+ .keys
+ val editor = prefs.edit()
+ plugins.filter { it.manifest.id in uniqueManifestIds }.forEach { plugin ->
+ val newKey = enabledKey(plugin.owner)
+ val legacyKey = legacyEnabledKey(plugin.manifest.id)
+ if (!prefs.contains(newKey) && prefs.contains(legacyKey)) {
+ editor.putBoolean(newKey, prefs.getBoolean(legacyKey, false))
+ }
+ }
+ editor.apply()
+ }
+
+ private fun enabledKey(owner: StreamVaultPluginOwner): String =
+ "enabled.${owner.packageName}.${owner.serviceClassName}.${owner.manifestId}"
+
+ private fun legacyEnabledKey(pluginId: String): String = "enabled.$pluginId"
+
+ private companion object {
+ const val DISCOVERY_CACHE_TTL_MILLIS = 30_000L
+ const val DISCOVERY_REQUEST_TIMEOUT_MILLIS = 1_500L
+ const val PLAYBACK_HANDLER_TIMEOUT_MILLIS = 5_000L
+ const val PLAYBACK_TOTAL_TIMEOUT_MILLIS = 5_000L
+ }
}
private fun kotlinx.coroutines.CoroutineScope.launchCatching(block: suspend () -> Unit) {
- launch { runCatching { block() } }
+ launch {
+ try {
+ block()
+ } catch (cancelled: CancellationException) {
+ throw cancelled
+ } catch (_: Exception) {
+ // Best-effort catalog refresh; the next provider/plugin change retries it.
+ }
+ }
}
private fun StreamType.defaultContainerExtension(): String? = when (this) {
diff --git a/app/src/main/java/com/streamvault/app/service/DownloadForegroundService.kt b/app/src/main/java/com/streamvault/app/service/DownloadForegroundService.kt
index 5ba57563..b522517f 100644
--- a/app/src/main/java/com/streamvault/app/service/DownloadForegroundService.kt
+++ b/app/src/main/java/com/streamvault/app/service/DownloadForegroundService.kt
@@ -102,6 +102,21 @@ class DownloadForegroundService : Service() {
super.onDestroy()
}
+ override fun onTimeout(startId: Int, fgsType: Int) {
+ val downloadId = currentDownloadId
+ Log.e(TAG, "Foreground-service time allowance exhausted; pausing download $downloadId")
+ serviceScope.launch {
+ try {
+ if (!downloadId.isNullOrBlank()) {
+ entryPoint().downloadManager().pauseDownloadForForegroundServiceTimeout(downloadId)
+ }
+ } finally {
+ stopForeground(STOP_FOREGROUND_REMOVE)
+ stopSelf(startId)
+ }
+ }
+ }
+
override fun onBind(intent: Intent?): IBinder? = null
private fun buildNotification(
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerLifecycleActions.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerLifecycleActions.kt
index 302faad1..b40cf89a 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerLifecycleActions.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerLifecycleActions.kt
@@ -16,7 +16,7 @@ internal fun PlayerViewModel.startProgressTracking() {
progressTrackingJob = viewModelScope.launch {
while (true) {
- delay(5000)
+ delay(30_000)
if (!isAppInForeground || !playerEngine.isPlaying.value) continue
persistPlaybackProgress()
}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerPreparationSetupActions.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerPreparationSetupActions.kt
index 02563be3..9e0a09eb 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerPreparationSetupActions.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerPreparationSetupActions.kt
@@ -117,7 +117,7 @@ internal fun PlayerViewModel.applyPrepareSessionState(
clearSeriesEpisodeContext()
}
if (currentContentType != ContentType.LIVE) {
- lastRecordedLivePlaybackKey = null
+ livePlaybackRecordTracker.reset()
recentChannelsJob?.cancel()
recentChannelsFlow.value = emptyList()
lastVisitedCategoryJob?.cancel()
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 0cc78ad7..5eb60b9c 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
@@ -265,7 +265,7 @@ class PlayerViewModel @Inject constructor(
internal var hasRetriedXtreamAuthRefresh = false
internal val probePassedPlaybackKeys = mutableSetOf<String>()
private val notifiedRecordingFailureIds = mutableSetOf<String>()
- internal var lastRecordedLivePlaybackKey: Pair<Long, Long>? = null
+ internal val livePlaybackRecordTracker = LivePlaybackRecordTracker()
private var currentStreamClassLabel: String = "Primary"
internal var lastRecordedVariantObservationSignature: String? = null
internal var lastRecordedVodVariantObservationSignature: String? = null
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerZapActions.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerZapActions.kt
index 56809552..c00d0712 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerZapActions.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerZapActions.kt
@@ -28,6 +28,33 @@ internal data class LivePlaybackRecordCandidate(
val history: PlaybackHistory
)
+internal class LivePlaybackRecordTracker {
+ private var latestGeneration = 0L
+ private var lastSuccessfulKey: Pair<Long, Long>? = null
+ private val inFlightGenerations = mutableMapOf<Pair<Long, Long>, Long>()
+
+ fun begin(playbackKey: Pair<Long, Long>): Long? {
+ if (playbackKey == lastSuccessfulKey || playbackKey in inFlightGenerations) return null
+ return (++latestGeneration).also { generation ->
+ inFlightGenerations[playbackKey] = generation
+ }
+ }
+
+ fun complete(playbackKey: Pair<Long, Long>, generation: Long, succeeded: Boolean) {
+ if (inFlightGenerations[playbackKey] != generation) return
+ inFlightGenerations.remove(playbackKey)
+ if (succeeded && generation == latestGeneration) {
+ lastSuccessfulKey = playbackKey
+ }
+ }
+
+ fun reset() {
+ latestGeneration++
+ lastSuccessfulKey = null
+ inFlightGenerations.clear()
+ }
+}
+
internal fun buildLivePlaybackRecordCandidate(
currentProviderId: Long,
currentContentType: ContentType,
@@ -310,14 +337,17 @@ internal fun PlayerViewModel.recordActiveLivePlayback(channel: Channel? = curren
channel = channel
) ?: return
- if (lastRecordedLivePlaybackKey == candidate.playbackKey) return
- lastRecordedLivePlaybackKey = candidate.playbackKey
+ val generation = livePlaybackRecordTracker.begin(candidate.playbackKey) ?: return
viewModelScope.launch {
- logRepositoryFailure(
- operation = "Record live playback",
- result = playbackHistoryRepository.recordPlayback(candidate.history)
- )
+ var succeeded = false
+ try {
+ val result = playbackHistoryRepository.recordPlayback(candidate.history)
+ succeeded = result is com.streamvault.domain.model.Result.Success
+ logRepositoryFailure(operation = "Record live playback", result = result)
+ } finally {
+ livePlaybackRecordTracker.complete(candidate.playbackKey, generation, succeeded)
+ }
}
}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateActions.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateActions.kt
index c2bc3895..4a8f4900 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateActions.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateActions.kt
@@ -8,6 +8,7 @@ import kotlinx.coroutines.launch
import com.streamvault.app.R
import com.streamvault.app.update.AppUpdateActionState
import com.streamvault.app.update.AppUpdateInstaller
+import com.streamvault.app.update.AppUpdateCheckPolicy
import com.streamvault.app.update.GitHubReleaseChecker
import com.streamvault.data.preferences.PreferencesRepository
import com.streamvault.domain.model.Result
@@ -21,11 +22,8 @@ internal class SettingsAppUpdateActions(
) {
private var updateCheckInFlight = false
- fun shouldAutoCheckForUpdates(lastCheckedAt: Long?): Boolean {
- val now = System.currentTimeMillis()
- val checkIntervalMs = 24L * 60L * 60L * 1000L
- return lastCheckedAt == null || now - lastCheckedAt >= checkIntervalMs
- }
+ fun shouldAutoCheckForUpdates(lastSuccessfulCheckAt: Long?, lastFailedCheckAt: Long?): Boolean =
+ AppUpdateCheckPolicy.shouldAutoCheck(System.currentTimeMillis(), lastSuccessfulCheckAt, lastFailedCheckAt)
fun checkForAppUpdates(
scope: CoroutineScope,
@@ -43,9 +41,9 @@ internal class SettingsAppUpdateActions(
appUpdate = it.appUpdate.copy(errorMessage = null)
)
}
- preferencesRepository.setLastAppUpdateCheckTimestamp(checkedAt)
when (val result = gitHubReleaseChecker.fetchLatestRelease()) {
is Result.Error -> {
+ preferencesRepository.setLastAppUpdateFailureTimestamp(checkedAt)
uiState.update {
it.copy(
isCheckingForUpdates = false,
@@ -68,6 +66,8 @@ internal class SettingsAppUpdateActions(
releaseNotes = release.releaseNotes,
publishedAt = release.publishedAt
)
+ preferencesRepository.setLastAppUpdateCheckTimestamp(checkedAt)
+ preferencesRepository.setLastAppUpdateFailureTimestamp(null)
val updateAvailable = isRemoteVersionNewer(
release.versionCode,
release.versionName,
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsObserverRegistrations.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsObserverRegistrations.kt
index 77c2593e..275805d7 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsObserverRegistrations.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsObserverRegistrations.kt
@@ -35,16 +35,20 @@ internal fun registerSettingsAppUpdateObservers(
combine(
preferencesRepository.autoCheckAppUpdates,
preferencesRepository.lastAppUpdateCheckTimestamp,
+ preferencesRepository.lastAppUpdateFailureTimestamp,
preferencesRepository.autoDownloadAppUpdates
- ) { autoCheckEnabled, lastCheckedAt, autoDownload ->
- Triple(autoCheckEnabled, lastCheckedAt, autoDownload)
- }.distinctUntilChanged().collect { (autoCheckEnabled, lastCheckedAt, autoDownload) ->
- if (autoCheckEnabled && appUpdateActions.shouldAutoCheckForUpdates(lastCheckedAt)) {
+ ) { autoCheckEnabled, lastSuccessfulCheckAt, lastFailedCheckAt, autoDownload ->
+ UpdateCheckPreferences(autoCheckEnabled, lastSuccessfulCheckAt, lastFailedCheckAt, autoDownload)
+ }.distinctUntilChanged().collect { preferences ->
+ if (preferences.autoCheckEnabled && appUpdateActions.shouldAutoCheckForUpdates(
+ preferences.lastSuccessfulCheckAt,
+ preferences.lastFailedCheckAt
+ )) {
appUpdateActions.checkForAppUpdates(
scope = scope,
manual = false,
isRemoteVersionNewer = ::isRemoteVersionNewer,
- autoDownload = autoDownload
+ autoDownload = preferences.autoDownload
)
}
}
@@ -63,6 +67,13 @@ internal fun registerSettingsAppUpdateObservers(
}
}
+private data class UpdateCheckPreferences(
+ val autoCheckEnabled: Boolean,
+ val lastSuccessfulCheckAt: Long?,
+ val lastFailedCheckAt: Long?,
+ val autoDownload: Boolean,
+)
+
internal fun registerCombinedProfileObservers(
scope: CoroutineScope,
combinedM3uRepository: CombinedM3uRepository,
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/welcome/WelcomeScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/welcome/WelcomeScreen.kt
index 3ebed40a..4835be9c 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/welcome/WelcomeScreen.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/welcome/WelcomeScreen.kt
@@ -40,9 +40,9 @@ import com.streamvault.app.ui.components.shell.StatusPill
import com.streamvault.app.ui.design.AppColors
import com.streamvault.app.ui.interaction.TvButton
import com.streamvault.data.sync.SyncProgressBus
+import com.streamvault.data.sync.SyncProgressAggregate
import com.streamvault.domain.repository.ProviderRepository
import com.streamvault.domain.sync.Section
-import com.streamvault.domain.sync.SyncProgress
import com.streamvault.domain.usecase.M3uProviderSetupCommand
import com.streamvault.domain.usecase.ValidateAndAddProvider
import com.streamvault.domain.usecase.XtreamProviderSetupCommand
@@ -71,8 +71,8 @@ class WelcomeViewModel @Inject constructor(
private val acceptingProgress = MutableStateFlow(true)
- val syncProgress: StateFlow<SyncProgress?> =
- combine(syncProgressBus.flow, acceptingProgress) { progress, accept ->
+ val syncProgress: StateFlow<SyncProgressAggregate?> =
+ combine(syncProgressBus.aggregate, acceptingProgress) { progress, accept ->
if (accept) progress else null
}.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), null)
@@ -176,7 +176,7 @@ fun WelcomeScreen(
@Composable
private fun WelcomeLoadingCard(
- syncProgress: SyncProgress?,
+ syncProgress: SyncProgressAggregate?,
modifier: Modifier = Modifier
) {
Surface(
@@ -185,16 +185,17 @@ private fun WelcomeLoadingCard(
colors = SurfaceDefaults.colors(containerColor = AppColors.Surface.copy(alpha = 0.9f))
) {
Column(
- modifier = Modifier.padding(horizontal = 36.dp, vertical = 28.dp),
- horizontalAlignment = Alignment.CenterHorizontally
- ) {
- val pillLabel = if (syncProgress != null) {
- stringResource(sectionLabelRes(syncProgress.section))
+ modifier = Modifier.padding(horizontal = 36.dp, vertical = 28.dp),
+ horizontalAlignment = Alignment.CenterHorizontally
+ ) {
+ val representativeProgress = syncProgress?.representative?.progress
+ val pillLabel = if (representativeProgress != null) {
+ stringResource(sectionLabelRes(representativeProgress.section))
} else {
stringResource(R.string.app_name)
}
- val pillColor = if (syncProgress != null) {
- sectionColor(syncProgress.section)
+ val pillColor = if (representativeProgress != null) {
+ sectionColor(representativeProgress.section)
} else {
AppColors.BrandMuted
}
@@ -203,7 +204,7 @@ private fun WelcomeLoadingCard(
containerColor = pillColor
)
Spacer(modifier = Modifier.height(18.dp))
- if (syncProgress == null) {
+ if (representativeProgress == null) {
CircularProgressIndicator(color = AppColors.Brand)
Spacer(modifier = Modifier.height(18.dp))
}
@@ -213,8 +214,8 @@ private fun WelcomeLoadingCard(
color = AppColors.TextPrimary
)
Spacer(modifier = Modifier.height(6.dp))
- val subtitle = if (syncProgress != null && syncProgress.currentLabel.isNotBlank()) {
- syncProgress.currentLabel
+ val subtitle = if (representativeProgress != null && representativeProgress.currentLabel.isNotBlank()) {
+ representativeProgress.currentLabel
} else {
stringResource(R.string.welcome_loading_subtitle)
}
@@ -223,11 +224,11 @@ private fun WelcomeLoadingCard(
style = MaterialTheme.typography.bodyLarge,
color = AppColors.TextSecondary
)
- if (syncProgress != null) {
+ if (representativeProgress != null) {
Spacer(modifier = Modifier.height(14.dp))
- if (syncProgress.total > 0) {
+ if (representativeProgress.total > 0) {
LinearProgressIndicator(
- progress = { syncProgress.current.toFloat() / syncProgress.total.toFloat() },
+ progress = { representativeProgress.current.toFloat() / representativeProgress.total.toFloat() },
modifier = Modifier.width(260.dp),
color = AppColors.Brand,
trackColor = AppColors.BrandMuted
@@ -243,7 +244,7 @@ private fun WelcomeLoadingCard(
Text(
text = stringResource(
R.string.sync_items_indexed_format,
- syncProgress.itemsIndexed
+ representativeProgress.itemsIndexed
),
style = MaterialTheme.typography.labelLarge,
color = AppColors.TextSecondary
diff --git a/app/src/main/java/com/streamvault/app/update/AppUpdateCheckPolicy.kt b/app/src/main/java/com/streamvault/app/update/AppUpdateCheckPolicy.kt
new file mode 100644
index 00000000..4e58f665
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/update/AppUpdateCheckPolicy.kt
@@ -0,0 +1,17 @@
+package com.streamvault.app.update
+
+internal object AppUpdateCheckPolicy {
+ private const val SUCCESS_INTERVAL_MS = 24L * 60L * 60L * 1000L
+ private const val FAILURE_BACKOFF_MS = 15L * 60L * 1000L
+
+ fun shouldAutoCheck(
+ now: Long,
+ lastSuccessfulCheckAt: Long?,
+ lastFailedCheckAt: Long?,
+ ): Boolean {
+ if (lastSuccessfulCheckAt != null && now - lastSuccessfulCheckAt < SUCCESS_INTERVAL_MS) {
+ return false
+ }
+ return lastFailedCheckAt == null || now - lastFailedCheckAt >= FAILURE_BACKOFF_MS
+ }
+}
diff --git a/app/src/test/java/com/streamvault/app/DataMaintenanceSchedulingTest.kt b/app/src/test/java/com/streamvault/app/DataMaintenanceSchedulingTest.kt
new file mode 100644
index 00000000..5e5301ed
--- /dev/null
+++ b/app/src/test/java/com/streamvault/app/DataMaintenanceSchedulingTest.kt
@@ -0,0 +1,17 @@
+package com.streamvault.app
+
+import androidx.work.NetworkType
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+
+class DataMaintenanceSchedulingTest {
+
+ @Test
+ fun `daily local maintenance does not require a network connection`() {
+ val constraints = dataMaintenanceConstraints()
+
+ assertThat(constraints.requiredNetworkType).isEqualTo(NetworkType.NOT_REQUIRED)
+ assertThat(constraints.requiresBatteryNotLow()).isTrue()
+ assertThat(constraints.requiresDeviceIdle()).isTrue()
+ }
+}
diff --git a/app/src/test/java/com/streamvault/app/navigation/ExternalDestinationTest.kt b/app/src/test/java/com/streamvault/app/navigation/ExternalDestinationTest.kt
index f10749d7..aba8515f 100644
--- a/app/src/test/java/com/streamvault/app/navigation/ExternalDestinationTest.kt
+++ b/app/src/test/java/com/streamvault/app/navigation/ExternalDestinationTest.kt
@@ -27,4 +27,18 @@ class ExternalDestinationTest {
assertThat(ExternalDestination.fromLegacyRoute("series_detail/not-a-number"))
.isNull()
}
-}
\ No newline at end of file
+
+ @Test
+ fun fromLegacyRoute_decodesUtf8AndSkipsMalformedQueryValues() {
+ assertThat(
+ ExternalDestination.fromLegacyRoute(
+ "provider_setup?providerId=7&importUri=https%3A%2F%2Fexample.com%2Fguide%3Fname%3DCaf%C3%A9%2BTV&bad=%zz"
+ )
+ ).isEqualTo(
+ ExternalDestination.ProviderSetup(
+ providerId = 7L,
+ importUri = "https://example.com/guide?name=Café+TV"
+ )
+ )
+ }
+}
diff --git a/app/src/test/java/com/streamvault/app/plugins/PluginPlaybackRoutingTest.kt b/app/src/test/java/com/streamvault/app/plugins/PluginPlaybackRoutingTest.kt
new file mode 100644
index 00000000..a234a320
--- /dev/null
+++ b/app/src/test/java/com/streamvault/app/plugins/PluginPlaybackRoutingTest.kt
@@ -0,0 +1,69 @@
+package com.streamvault.app.plugins
+
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.currentCoroutineContext
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.isActive
+import kotlinx.coroutines.test.currentTime
+import kotlinx.coroutines.test.runTest
+import org.junit.Test
+
+class PluginPlaybackRoutingTest {
+
+ @Test
+ fun `only explicitly matching handlers are routed and priority is deterministic`() {
+ val generic = plugin("generic", schemes = listOf("*"), hosts = listOf("*"), priority = 1)
+ val matching = plugin("match", schemes = listOf("https"), hosts = listOf("video.example"), priority = 10)
+ val wrongHost = plugin("wrong", schemes = listOf("https"), hosts = listOf("other.example"), priority = 20)
+ val legacyUnscoped = plugin("legacy")
+
+ val candidates = playbackCandidates(
+ listOf(generic, wrongHost, legacyUnscoped, matching),
+ "https://video.example/live.m3u8",
+ StreamVaultPluginContract.CAPABILITY_PLAYBACK_PREPARE
+ )
+
+ assertThat(candidates.map { it.manifest.id }).containsExactly("match", "generic").inOrder()
+ }
+
+ @Test
+ fun `invalid or unowned URLs have no playback handler`() {
+ val plugin = plugin("scoped", schemes = listOf("https"), hosts = listOf("video.example"))
+
+ assertThat(playbackCandidates(listOf(plugin), "not a url", StreamVaultPluginContract.CAPABILITY_PLAYBACK_PREPARE)).isEmpty()
+ assertThat(playbackCandidates(listOf(plugin), "https://other.example/live", StreamVaultPluginContract.CAPABILITY_PLAYBACK_PREPARE)).isEmpty()
+ }
+
+ @Test
+ fun `playback deadline bounds discovery and handler work together`() = runTest {
+ val result = withPluginPlaybackDeadline(5_000L) {
+ delay(3_000L) // discovery
+ delay(3_000L) // handler
+ "handled"
+ }
+
+ assertThat(result).isNull()
+ assertThat(currentTime).isEqualTo(5_000L)
+ assertThat(currentCoroutineContext().isActive).isTrue()
+ }
+
+ private fun plugin(
+ id: String,
+ schemes: List<String> = emptyList(),
+ hosts: List<String> = emptyList(),
+ priority: Int = 0
+ ) = InstalledStreamVaultPlugin(
+ packageName = "com.example.$id",
+ serviceClassName = "$id.Service",
+ appLabel = id,
+ manifest = StreamVaultPluginManifest(
+ id = id,
+ name = id,
+ capabilities = listOf(StreamVaultPluginContract.CAPABILITY_PLAYBACK_PREPARE),
+ playbackUrlSchemes = schemes,
+ playbackUrlHosts = hosts,
+ playbackPriority = priority
+ ),
+ enabled = true
+ )
+}
diff --git a/app/src/test/java/com/streamvault/app/plugins/StreamVaultPluginOwnerTest.kt b/app/src/test/java/com/streamvault/app/plugins/StreamVaultPluginOwnerTest.kt
new file mode 100644
index 00000000..93a8c035
--- /dev/null
+++ b/app/src/test/java/com/streamvault/app/plugins/StreamVaultPluginOwnerTest.kt
@@ -0,0 +1,23 @@
+package com.streamvault.app.plugins
+
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+
+class StreamVaultPluginOwnerTest {
+
+ @Test
+ fun `plugin owner remains distinct when packages reuse a manifest ID`() {
+ val first = StreamVaultPluginOwner("com.example.first", "FirstService", "shared-id")
+ val second = StreamVaultPluginOwner("com.example.second", "SecondService", "shared-id")
+
+ assertThat(first).isNotEqualTo(second)
+ }
+
+ @Test
+ fun `plugin owner remains distinct for two services in one package`() {
+ val first = StreamVaultPluginOwner("com.example.plugin", "FirstService", "shared-id")
+ val second = StreamVaultPluginOwner("com.example.plugin", "SecondService", "shared-id")
+
+ assertThat(first).isNotEqualTo(second)
+ }
+}
diff --git a/app/src/test/java/com/streamvault/app/ui/screens/player/PlayerZapActionsLivePlaybackTest.kt b/app/src/test/java/com/streamvault/app/ui/screens/player/PlayerZapActionsLivePlaybackTest.kt
index 64ae9a9d..a5688cf3 100644
--- a/app/src/test/java/com/streamvault/app/ui/screens/player/PlayerZapActionsLivePlaybackTest.kt
+++ b/app/src/test/java/com/streamvault/app/ui/screens/player/PlayerZapActionsLivePlaybackTest.kt
@@ -7,6 +7,38 @@ import org.junit.Test
class PlayerZapActionsLivePlaybackTest {
+ @Test
+ fun `live playback tracker retries a failed write and deduplicates a successful one`() {
+ val tracker = LivePlaybackRecordTracker()
+ val key = 9L to 42L
+
+ val firstAttempt = tracker.begin(key)
+ assertThat(firstAttempt).isNotNull()
+ assertThat(tracker.begin(key)).isNull()
+
+ tracker.complete(key, firstAttempt!!, succeeded = false)
+ val retry = tracker.begin(key)
+ assertThat(retry).isNotNull()
+
+ tracker.complete(key, retry!!, succeeded = true)
+ assertThat(tracker.begin(key)).isNull()
+ }
+
+ @Test
+ fun `live playback tracker ignores stale completion when a newer channel started`() {
+ val tracker = LivePlaybackRecordTracker()
+ val firstKey = 9L to 42L
+ val secondKey = 9L to 43L
+
+ val firstAttempt = tracker.begin(firstKey)!!
+ val secondAttempt = tracker.begin(secondKey)!!
+ tracker.complete(firstKey, firstAttempt, succeeded = true)
+ tracker.complete(secondKey, secondAttempt, succeeded = true)
+
+ assertThat(tracker.begin(firstKey)).isNotNull()
+ assertThat(tracker.begin(secondKey)).isNull()
+ }
+
@Test
fun `buildLivePlaybackRecordCandidate uses channel metadata when available`() {
val channel = Channel(
@@ -66,4 +98,4 @@ class PlayerZapActionsLivePlaybackTest {
assertThat(candidate).isNull()
}
-}
\ No newline at end of file
+}
diff --git a/app/src/test/java/com/streamvault/app/update/AppUpdateCheckPolicyTest.kt b/app/src/test/java/com/streamvault/app/update/AppUpdateCheckPolicyTest.kt
new file mode 100644
index 00000000..6f4357b9
--- /dev/null
+++ b/app/src/test/java/com/streamvault/app/update/AppUpdateCheckPolicyTest.kt
@@ -0,0 +1,19 @@
+package com.streamvault.app.update
+
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+
+class AppUpdateCheckPolicyTest {
+
+ @Test
+ fun `success suppresses automatic checks for one day`() {
+ assertThat(AppUpdateCheckPolicy.shouldAutoCheck(1_000L, 1_000L, null)).isFalse()
+ assertThat(AppUpdateCheckPolicy.shouldAutoCheck(86_401_000L, 1_000L, null)).isTrue()
+ }
+
+ @Test
+ fun `failure retries after bounded backoff instead of one day`() {
+ assertThat(AppUpdateCheckPolicy.shouldAutoCheck(1_000L, null, 1_000L)).isFalse()
+ assertThat(AppUpdateCheckPolicy.shouldAutoCheck(901_000L, null, 1_000L)).isTrue()
+ }
+}
diff --git a/data/schemas/com.streamvault.data.local.StreamVaultDatabase/63.json b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/63.json
new file mode 100644
index 00000000..cb108bd6
--- /dev/null
+++ b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/63.json
@@ -0,0 +1,5428 @@
+{
+ "formatVersion": 1,
+ "database": {
+ "version": 63,
+ "identityHash": "0c5ab6634963e36624a0c850adcda7b4",
+ "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_advanced_options_json` TEXT NOT NULL, `stalker_auth_mode` TEXT NOT NULL, `stalker_portal_profile` TEXT NOT NULL, `stalker_portal_fingerprint` TEXT NOT NULL, `stalker_mag_preset` TEXT NOT NULL, `stalker_last_bootstrap_recipe` TEXT NOT NULL, `stalker_endpoint_preference` TEXT NOT NULL, `stalker_cookie_mode` TEXT NOT NULL, `stalker_playback_backend_hint` 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, `stalker_strict_fingerprint_required` INTEGER NOT NULL, `stalker_recipe_fallback_used` INTEGER NOT NULL, `stalker_recipe_rediscovery_attempts` 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, `guide_source_policy` TEXT NOT NULL, `channel_logo_source_policy` 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": "stalkerAdvancedOptionsJson",
+ "columnName": "stalker_advanced_options_json",
+ "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": "stalkerPortalFingerprint",
+ "columnName": "stalker_portal_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerMagPreset",
+ "columnName": "stalker_mag_preset",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerLastBootstrapRecipe",
+ "columnName": "stalker_last_bootstrap_recipe",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerEndpointPreference",
+ "columnName": "stalker_endpoint_preference",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerCookieMode",
+ "columnName": "stalker_cookie_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerPlaybackBackendHint",
+ "columnName": "stalker_playback_backend_hint",
+ "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": "stalkerStrictFingerprintRequired",
+ "columnName": "stalker_strict_fingerprint_required",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerRecipeFallbackUsed",
+ "columnName": "stalker_recipe_fallback_used",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerRecipeRediscoveryAttempts",
+ "columnName": "stalker_recipe_rediscovery_attempts",
+ "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": "guideSourcePolicy",
+ "columnName": "guide_source_policy",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelLogoSourcePolicy",
+ "columnName": "channel_logo_source_policy",
+ "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"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "downloads",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `content_id` INTEGER NOT NULL, `content_name` TEXT NOT NULL, `stream_url` TEXT NOT NULL, `source_stream_url` TEXT, `source_stream_id` INTEGER, `container_extension` TEXT, `poster_url` TEXT, `output_uri` TEXT, `output_display_path` TEXT, `status` TEXT NOT NULL, `bytes_written` INTEGER NOT NULL, `total_bytes` INTEGER, `supports_resume` INTEGER NOT NULL, `retry_count` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `completed_at` INTEGER, `failure_reason` TEXT, `series_id` INTEGER, `season_number` INTEGER, `episode_number` INTEGER, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentId",
+ "columnName": "content_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentName",
+ "columnName": "content_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sourceStreamUrl",
+ "columnName": "source_stream_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "sourceStreamId",
+ "columnName": "source_stream_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputUri",
+ "columnName": "output_uri",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputDisplayPath",
+ "columnName": "output_display_path",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "bytesWritten",
+ "columnName": "bytes_written",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalBytes",
+ "columnName": "total_bytes",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "supportsResume",
+ "columnName": "supports_resume",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryCount",
+ "columnName": "retry_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "completedAt",
+ "columnName": "completed_at",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failure_reason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "seriesId",
+ "columnName": "series_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "seasonNumber",
+ "columnName": "season_number",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "episodeNumber",
+ "columnName": "episode_number",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_downloads_status",
+ "unique": false,
+ "columnNames": [
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_downloads_status` ON `${TABLE_NAME}` (`status`)"
+ },
+ {
+ "name": "index_downloads_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_downloads_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_downloads_content_type_content_id",
+ "unique": false,
+ "columnNames": [
+ "content_type",
+ "content_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_downloads_content_type_content_id` ON `${TABLE_NAME}` (`content_type`, `content_id`)"
+ }
+ ]
+ },
+ {
+ "tableName": "provider_deletion_cleanup",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `action` TEXT NOT NULL, `target_id` TEXT NOT NULL, `created_at` INTEGER NOT NULL, `attempt_count` INTEGER NOT NULL, `last_error` TEXT)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "action",
+ "columnName": "action",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "targetId",
+ "columnName": "target_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "attemptCount",
+ "columnName": "attempt_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_provider_deletion_cleanup_provider_id_action_target_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "action",
+ "target_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_provider_deletion_cleanup_provider_id_action_target_id` ON `${TABLE_NAME}` (`provider_id`, `action`, `target_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, '0c5ab6634963e36624a0c850adcda7b4')"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/data/schemas/com.streamvault.data.local.StreamVaultDatabase/64.json b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/64.json
new file mode 100644
index 00000000..08bd6583
--- /dev/null
+++ b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/64.json
@@ -0,0 +1,5496 @@
+{
+ "formatVersion": 1,
+ "database": {
+ "version": 64,
+ "identityHash": "9a73683fcec109b0299970fd11f1513a",
+ "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_advanced_options_json` TEXT NOT NULL, `stalker_auth_mode` TEXT NOT NULL, `stalker_portal_profile` TEXT NOT NULL, `stalker_portal_fingerprint` TEXT NOT NULL, `stalker_mag_preset` TEXT NOT NULL, `stalker_last_bootstrap_recipe` TEXT NOT NULL, `stalker_endpoint_preference` TEXT NOT NULL, `stalker_cookie_mode` TEXT NOT NULL, `stalker_playback_backend_hint` 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, `stalker_strict_fingerprint_required` INTEGER NOT NULL, `stalker_recipe_fallback_used` INTEGER NOT NULL, `stalker_recipe_rediscovery_attempts` 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, `guide_source_policy` TEXT NOT NULL, `channel_logo_source_policy` 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": "stalkerAdvancedOptionsJson",
+ "columnName": "stalker_advanced_options_json",
+ "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": "stalkerPortalFingerprint",
+ "columnName": "stalker_portal_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerMagPreset",
+ "columnName": "stalker_mag_preset",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerLastBootstrapRecipe",
+ "columnName": "stalker_last_bootstrap_recipe",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerEndpointPreference",
+ "columnName": "stalker_endpoint_preference",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerCookieMode",
+ "columnName": "stalker_cookie_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerPlaybackBackendHint",
+ "columnName": "stalker_playback_backend_hint",
+ "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": "stalkerStrictFingerprintRequired",
+ "columnName": "stalker_strict_fingerprint_required",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerRecipeFallbackUsed",
+ "columnName": "stalker_recipe_fallback_used",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerRecipeRediscoveryAttempts",
+ "columnName": "stalker_recipe_rediscovery_attempts",
+ "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": "guideSourcePolicy",
+ "columnName": "guide_source_policy",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelLogoSourcePolicy",
+ "columnName": "channel_logo_source_policy",
+ "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"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "downloads",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `content_id` INTEGER NOT NULL, `content_name` TEXT NOT NULL, `stream_url` TEXT NOT NULL, `source_stream_url` TEXT, `source_stream_id` INTEGER, `container_extension` TEXT, `poster_url` TEXT, `output_uri` TEXT, `output_display_path` TEXT, `status` TEXT NOT NULL, `bytes_written` INTEGER NOT NULL, `total_bytes` INTEGER, `supports_resume` INTEGER NOT NULL, `retry_count` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `completed_at` INTEGER, `failure_reason` TEXT, `series_id` INTEGER, `season_number` INTEGER, `episode_number` INTEGER, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentId",
+ "columnName": "content_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentName",
+ "columnName": "content_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sourceStreamUrl",
+ "columnName": "source_stream_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "sourceStreamId",
+ "columnName": "source_stream_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputUri",
+ "columnName": "output_uri",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputDisplayPath",
+ "columnName": "output_display_path",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "bytesWritten",
+ "columnName": "bytes_written",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalBytes",
+ "columnName": "total_bytes",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "supportsResume",
+ "columnName": "supports_resume",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryCount",
+ "columnName": "retry_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "completedAt",
+ "columnName": "completed_at",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failure_reason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "seriesId",
+ "columnName": "series_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "seasonNumber",
+ "columnName": "season_number",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "episodeNumber",
+ "columnName": "episode_number",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_downloads_status",
+ "unique": false,
+ "columnNames": [
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_downloads_status` ON `${TABLE_NAME}` (`status`)"
+ },
+ {
+ "name": "index_downloads_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_downloads_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_downloads_content_type_content_id",
+ "unique": false,
+ "columnNames": [
+ "content_type",
+ "content_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_downloads_content_type_content_id` ON `${TABLE_NAME}` (`content_type`, `content_id`)"
+ }
+ ]
+ },
+ {
+ "tableName": "provider_deletion_cleanup",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `action` TEXT NOT NULL, `target_id` TEXT NOT NULL, `created_at` INTEGER NOT NULL, `attempt_count` INTEGER NOT NULL, `last_error` TEXT)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "action",
+ "columnName": "action",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "targetId",
+ "columnName": "target_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "attemptCount",
+ "columnName": "attempt_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_provider_deletion_cleanup_provider_id_action_target_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "action",
+ "target_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_provider_deletion_cleanup_provider_id_action_target_id` ON `${TABLE_NAME}` (`provider_id`, `action`, `target_id`)"
+ }
+ ]
+ },
+ {
+ "tableName": "plugin_provider_ownership",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`package_name` TEXT NOT NULL, `service_class_name` TEXT NOT NULL, `manifest_id` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, PRIMARY KEY(`package_name`, `service_class_name`, `manifest_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "packageName",
+ "columnName": "package_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "serviceClassName",
+ "columnName": "service_class_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "manifestId",
+ "columnName": "manifest_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "package_name",
+ "service_class_name",
+ "manifest_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_plugin_provider_ownership_provider_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_plugin_provider_ownership_provider_id` ON `${TABLE_NAME}` (`provider_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, '9a73683fcec109b0299970fd11f1513a')"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/data/schemas/com.streamvault.data.local.StreamVaultDatabase/65.json b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/65.json
new file mode 100644
index 00000000..3088a3f2
--- /dev/null
+++ b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/65.json
@@ -0,0 +1,5496 @@
+{
+ "formatVersion": 1,
+ "database": {
+ "version": 65,
+ "identityHash": "9a73683fcec109b0299970fd11f1513a",
+ "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_advanced_options_json` TEXT NOT NULL, `stalker_auth_mode` TEXT NOT NULL, `stalker_portal_profile` TEXT NOT NULL, `stalker_portal_fingerprint` TEXT NOT NULL, `stalker_mag_preset` TEXT NOT NULL, `stalker_last_bootstrap_recipe` TEXT NOT NULL, `stalker_endpoint_preference` TEXT NOT NULL, `stalker_cookie_mode` TEXT NOT NULL, `stalker_playback_backend_hint` 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, `stalker_strict_fingerprint_required` INTEGER NOT NULL, `stalker_recipe_fallback_used` INTEGER NOT NULL, `stalker_recipe_rediscovery_attempts` 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, `guide_source_policy` TEXT NOT NULL, `channel_logo_source_policy` 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": "stalkerAdvancedOptionsJson",
+ "columnName": "stalker_advanced_options_json",
+ "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": "stalkerPortalFingerprint",
+ "columnName": "stalker_portal_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerMagPreset",
+ "columnName": "stalker_mag_preset",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerLastBootstrapRecipe",
+ "columnName": "stalker_last_bootstrap_recipe",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerEndpointPreference",
+ "columnName": "stalker_endpoint_preference",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerCookieMode",
+ "columnName": "stalker_cookie_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerPlaybackBackendHint",
+ "columnName": "stalker_playback_backend_hint",
+ "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": "stalkerStrictFingerprintRequired",
+ "columnName": "stalker_strict_fingerprint_required",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerRecipeFallbackUsed",
+ "columnName": "stalker_recipe_fallback_used",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerRecipeRediscoveryAttempts",
+ "columnName": "stalker_recipe_rediscovery_attempts",
+ "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": "guideSourcePolicy",
+ "columnName": "guide_source_policy",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelLogoSourcePolicy",
+ "columnName": "channel_logo_source_policy",
+ "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"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "downloads",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `content_id` INTEGER NOT NULL, `content_name` TEXT NOT NULL, `stream_url` TEXT NOT NULL, `source_stream_url` TEXT, `source_stream_id` INTEGER, `container_extension` TEXT, `poster_url` TEXT, `output_uri` TEXT, `output_display_path` TEXT, `status` TEXT NOT NULL, `bytes_written` INTEGER NOT NULL, `total_bytes` INTEGER, `supports_resume` INTEGER NOT NULL, `retry_count` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `completed_at` INTEGER, `failure_reason` TEXT, `series_id` INTEGER, `season_number` INTEGER, `episode_number` INTEGER, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentId",
+ "columnName": "content_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentName",
+ "columnName": "content_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sourceStreamUrl",
+ "columnName": "source_stream_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "sourceStreamId",
+ "columnName": "source_stream_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputUri",
+ "columnName": "output_uri",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputDisplayPath",
+ "columnName": "output_display_path",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "bytesWritten",
+ "columnName": "bytes_written",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalBytes",
+ "columnName": "total_bytes",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "supportsResume",
+ "columnName": "supports_resume",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryCount",
+ "columnName": "retry_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "completedAt",
+ "columnName": "completed_at",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failure_reason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "seriesId",
+ "columnName": "series_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "seasonNumber",
+ "columnName": "season_number",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "episodeNumber",
+ "columnName": "episode_number",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_downloads_status",
+ "unique": false,
+ "columnNames": [
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_downloads_status` ON `${TABLE_NAME}` (`status`)"
+ },
+ {
+ "name": "index_downloads_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_downloads_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_downloads_content_type_content_id",
+ "unique": false,
+ "columnNames": [
+ "content_type",
+ "content_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_downloads_content_type_content_id` ON `${TABLE_NAME}` (`content_type`, `content_id`)"
+ }
+ ]
+ },
+ {
+ "tableName": "provider_deletion_cleanup",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `action` TEXT NOT NULL, `target_id` TEXT NOT NULL, `created_at` INTEGER NOT NULL, `attempt_count` INTEGER NOT NULL, `last_error` TEXT)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "action",
+ "columnName": "action",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "targetId",
+ "columnName": "target_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "attemptCount",
+ "columnName": "attempt_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_provider_deletion_cleanup_provider_id_action_target_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "action",
+ "target_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_provider_deletion_cleanup_provider_id_action_target_id` ON `${TABLE_NAME}` (`provider_id`, `action`, `target_id`)"
+ }
+ ]
+ },
+ {
+ "tableName": "plugin_provider_ownership",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`package_name` TEXT NOT NULL, `service_class_name` TEXT NOT NULL, `manifest_id` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, PRIMARY KEY(`package_name`, `service_class_name`, `manifest_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "packageName",
+ "columnName": "package_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "serviceClassName",
+ "columnName": "service_class_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "manifestId",
+ "columnName": "manifest_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "package_name",
+ "service_class_name",
+ "manifest_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_plugin_provider_ownership_provider_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_plugin_provider_ownership_provider_id` ON `${TABLE_NAME}` (`provider_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, '9a73683fcec109b0299970fd11f1513a')"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/data/schemas/com.streamvault.data.local.StreamVaultDatabase/66.json b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/66.json
new file mode 100644
index 00000000..99078cb7
--- /dev/null
+++ b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/66.json
@@ -0,0 +1,5508 @@
+{
+ "formatVersion": 1,
+ "database": {
+ "version": 66,
+ "identityHash": "a1a8e2917703a774f2410d792180091f",
+ "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_advanced_options_json` TEXT NOT NULL, `stalker_auth_mode` TEXT NOT NULL, `stalker_portal_profile` TEXT NOT NULL, `stalker_portal_fingerprint` TEXT NOT NULL, `stalker_mag_preset` TEXT NOT NULL, `stalker_last_bootstrap_recipe` TEXT NOT NULL, `stalker_endpoint_preference` TEXT NOT NULL, `stalker_cookie_mode` TEXT NOT NULL, `stalker_playback_backend_hint` 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, `stalker_strict_fingerprint_required` INTEGER NOT NULL, `stalker_recipe_fallback_used` INTEGER NOT NULL, `stalker_recipe_rediscovery_attempts` 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, `guide_source_policy` TEXT NOT NULL, `channel_logo_source_policy` 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": "stalkerAdvancedOptionsJson",
+ "columnName": "stalker_advanced_options_json",
+ "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": "stalkerPortalFingerprint",
+ "columnName": "stalker_portal_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerMagPreset",
+ "columnName": "stalker_mag_preset",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerLastBootstrapRecipe",
+ "columnName": "stalker_last_bootstrap_recipe",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerEndpointPreference",
+ "columnName": "stalker_endpoint_preference",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerCookieMode",
+ "columnName": "stalker_cookie_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerPlaybackBackendHint",
+ "columnName": "stalker_playback_backend_hint",
+ "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": "stalkerStrictFingerprintRequired",
+ "columnName": "stalker_strict_fingerprint_required",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerRecipeFallbackUsed",
+ "columnName": "stalker_recipe_fallback_used",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerRecipeRediscoveryAttempts",
+ "columnName": "stalker_recipe_rediscovery_attempts",
+ "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": "guideSourcePolicy",
+ "columnName": "guide_source_policy",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelLogoSourcePolicy",
+ "columnName": "channel_logo_source_policy",
+ "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, `exact_alarm_armed` INTEGER NOT NULL, `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": "exactAlarmArmed",
+ "columnName": "exact_alarm_armed",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "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, `exact_alarm_armed` INTEGER NOT NULL, `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": "exactAlarmArmed",
+ "columnName": "exact_alarm_armed",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "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"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "downloads",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `content_id` INTEGER NOT NULL, `content_name` TEXT NOT NULL, `stream_url` TEXT NOT NULL, `source_stream_url` TEXT, `source_stream_id` INTEGER, `container_extension` TEXT, `poster_url` TEXT, `output_uri` TEXT, `output_display_path` TEXT, `status` TEXT NOT NULL, `bytes_written` INTEGER NOT NULL, `total_bytes` INTEGER, `supports_resume` INTEGER NOT NULL, `retry_count` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `completed_at` INTEGER, `failure_reason` TEXT, `series_id` INTEGER, `season_number` INTEGER, `episode_number` INTEGER, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentId",
+ "columnName": "content_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentName",
+ "columnName": "content_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sourceStreamUrl",
+ "columnName": "source_stream_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "sourceStreamId",
+ "columnName": "source_stream_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputUri",
+ "columnName": "output_uri",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputDisplayPath",
+ "columnName": "output_display_path",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "bytesWritten",
+ "columnName": "bytes_written",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalBytes",
+ "columnName": "total_bytes",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "supportsResume",
+ "columnName": "supports_resume",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryCount",
+ "columnName": "retry_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "completedAt",
+ "columnName": "completed_at",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failure_reason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "seriesId",
+ "columnName": "series_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "seasonNumber",
+ "columnName": "season_number",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "episodeNumber",
+ "columnName": "episode_number",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_downloads_status",
+ "unique": false,
+ "columnNames": [
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_downloads_status` ON `${TABLE_NAME}` (`status`)"
+ },
+ {
+ "name": "index_downloads_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_downloads_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_downloads_content_type_content_id",
+ "unique": false,
+ "columnNames": [
+ "content_type",
+ "content_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_downloads_content_type_content_id` ON `${TABLE_NAME}` (`content_type`, `content_id`)"
+ }
+ ]
+ },
+ {
+ "tableName": "provider_deletion_cleanup",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `action` TEXT NOT NULL, `target_id` TEXT NOT NULL, `created_at` INTEGER NOT NULL, `attempt_count` INTEGER NOT NULL, `last_error` TEXT)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "action",
+ "columnName": "action",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "targetId",
+ "columnName": "target_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "attemptCount",
+ "columnName": "attempt_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_provider_deletion_cleanup_provider_id_action_target_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "action",
+ "target_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_provider_deletion_cleanup_provider_id_action_target_id` ON `${TABLE_NAME}` (`provider_id`, `action`, `target_id`)"
+ }
+ ]
+ },
+ {
+ "tableName": "plugin_provider_ownership",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`package_name` TEXT NOT NULL, `service_class_name` TEXT NOT NULL, `manifest_id` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, PRIMARY KEY(`package_name`, `service_class_name`, `manifest_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "packageName",
+ "columnName": "package_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "serviceClassName",
+ "columnName": "service_class_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "manifestId",
+ "columnName": "manifest_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "package_name",
+ "service_class_name",
+ "manifest_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_plugin_provider_ownership_provider_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_plugin_provider_ownership_provider_id` ON `${TABLE_NAME}` (`provider_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, 'a1a8e2917703a774f2410d792180091f')"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/data/src/androidTest/java/com/streamvault/data/local/StreamVaultDatabaseMigrationTest.kt b/data/src/androidTest/java/com/streamvault/data/local/StreamVaultDatabaseMigrationTest.kt
index 24f18635..27d7e8e2 100644
--- a/data/src/androidTest/java/com/streamvault/data/local/StreamVaultDatabaseMigrationTest.kt
+++ b/data/src/androidTest/java/com/streamvault/data/local/StreamVaultDatabaseMigrationTest.kt
@@ -1216,7 +1216,7 @@ class StreamVaultDatabaseMigrationTest {
}
@Test
- fun migrate60To61_release114To115UpgradePreservesProviders() {
+ fun migrate60To66_release114UpgradePreservesProvidersThroughCurrentSchema() {
migrationTestHelper.createDatabase("streamvault-release-114-115-test", 60).apply {
execSQL(
"""
@@ -1254,9 +1254,14 @@ class StreamVaultDatabaseMigrationTest {
val migratedDb = migrationTestHelper.runMigrationsAndValidate(
"streamvault-release-114-115-test",
- 61,
+ 66,
true,
- StreamVaultDatabase.MIGRATION_60_61
+ StreamVaultDatabase.MIGRATION_60_61,
+ StreamVaultDatabase.MIGRATION_61_62,
+ StreamVaultDatabase.MIGRATION_62_63,
+ StreamVaultDatabase.MIGRATION_63_64,
+ StreamVaultDatabase.MIGRATION_64_65,
+ StreamVaultDatabase.MIGRATION_65_66
)
assertEquals(1, countRows(migratedDb, "SELECT COUNT(*) FROM pragma_table_info('providers') WHERE name = 'stalker_advanced_options_json'"))
@@ -1267,6 +1272,7 @@ class StreamVaultDatabaseMigrationTest {
"SELECT COUNT(*) FROM providers WHERE id = 1 AND name = 'Release 1.0.14 Provider' AND stalker_advanced_options_json = ''"
)
)
+ assertEquals(1, countRows(migratedDb, "SELECT COUNT(*) FROM providers WHERE id = 1 AND guide_source_policy = 'AUTO' AND channel_logo_source_policy = 'SUPPLIER_PREFERRED'"))
migratedDb.close()
}
@@ -1286,6 +1292,66 @@ class StreamVaultDatabaseMigrationTest {
migratedDb.close()
}
+ @Test
+ fun migrate61To62_addsGuideAndChannelLogoPolicies() {
+ migrationTestHelper.createDatabase("streamvault-61-62-test", 61).close()
+
+ val migratedDb = migrationTestHelper.runMigrationsAndValidate(
+ "streamvault-61-62-test",
+ 62,
+ true,
+ StreamVaultDatabase.MIGRATION_61_62
+ )
+
+ assertEquals(1, countRows(migratedDb, "SELECT COUNT(*) FROM pragma_table_info('providers') WHERE name = 'guide_source_policy'"))
+ assertEquals(1, countRows(migratedDb, "SELECT COUNT(*) FROM pragma_table_info('providers') WHERE name = 'channel_logo_source_policy'"))
+ migratedDb.close()
+ }
+
+ @Test
+ fun migrate63To64_addsPluginProviderOwnershipTable() {
+ migrationTestHelper.createDatabase("streamvault-63-64-test", 63).close()
+
+ val migratedDb = migrationTestHelper.runMigrationsAndValidate(
+ "streamvault-63-64-test",
+ 64,
+ true,
+ StreamVaultDatabase.MIGRATION_63_64
+ )
+
+ assertEquals(
+ 1,
+ countRows(
+ migratedDb,
+ "SELECT COUNT(*) FROM sqlite_master WHERE type = 'table' AND name = 'plugin_provider_ownership'"
+ )
+ )
+ assertEquals(
+ 1,
+ countRows(
+ migratedDb,
+ "SELECT COUNT(*) FROM sqlite_master WHERE type = 'index' AND name = 'index_plugin_provider_ownership_provider_id'"
+ )
+ )
+ migratedDb.close()
+ }
+
+ @Test
+ fun migrate65To66_addsExactAlarmArmedColumns() {
+ migrationTestHelper.createDatabase("streamvault-65-66-test", 65).close()
+
+ val migratedDb = migrationTestHelper.runMigrationsAndValidate(
+ "streamvault-65-66-test",
+ 66,
+ true,
+ StreamVaultDatabase.MIGRATION_65_66
+ )
+
+ assertEquals(1, countRows(migratedDb, "SELECT COUNT(*) FROM pragma_table_info('recording_runs') WHERE name = 'exact_alarm_armed'"))
+ assertEquals(1, countRows(migratedDb, "SELECT COUNT(*) FROM pragma_table_info('program_reminders') WHERE name = 'exact_alarm_armed'"))
+ migratedDb.close()
+ }
+
private fun countRows(db: androidx.sqlite.db.SupportSQLiteDatabase, sql: String): Int {
db.query(sql).use { cursor ->
if (!cursor.moveToFirst()) return 0
diff --git a/data/src/main/AndroidManifest.xml b/data/src/main/AndroidManifest.xml
index e0a7c31b..3fc583e0 100644
--- a/data/src/main/AndroidManifest.xml
+++ b/data/src/main/AndroidManifest.xml
@@ -21,6 +21,7 @@
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
+ <action android:name="android.app.action.SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED" />
</intent-filter>
</receiver>
@@ -31,6 +32,7 @@
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
+ <action android:name="android.app.action.SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED" />
</intent-filter>
</receiver>
</application>
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 9dacbd6f..48ea6ce6 100644
--- a/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt
+++ b/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt
@@ -48,9 +48,11 @@ import com.streamvault.data.local.entity.*
XtreamContentIndexEntity::class,
XtreamIndexJobEntity::class,
XtreamLiveOnboardingStateEntity::class,
- DownloadEntity::class
+ DownloadEntity::class,
+ ProviderDeletionCleanupEntity::class,
+ PluginProviderOwnershipEntity::class
],
- version = 62,
+ version = 66,
exportSchema = true // ← was false; schema JSON now tracked in version control
)
@TypeConverters(RoomEnumConverters::class)
@@ -89,6 +91,8 @@ abstract class StreamVaultDatabase : RoomDatabase() {
abstract fun xtreamIndexJobDao(): XtreamIndexJobDao
abstract fun xtreamLiveOnboardingDao(): XtreamLiveOnboardingDao
abstract fun downloadDao(): DownloadDao
+ abstract fun providerDeletionCleanupDao(): ProviderDeletionCleanupDao
+ abstract fun pluginProviderOwnershipDao(): PluginProviderOwnershipDao
companion object {
/**
@@ -2702,6 +2706,78 @@ abstract class StreamVaultDatabase : RoomDatabase() {
}
}
+ val MIGRATION_62_63 = object : Migration(62, 63) {
+ override fun migrate(database: SupportSQLiteDatabase) {
+ database.execSQL("""CREATE TABLE IF NOT EXISTS provider_deletion_cleanup (
+ id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
+ provider_id INTEGER NOT NULL,
+ action TEXT NOT NULL,
+ target_id TEXT NOT NULL DEFAULT '',
+ created_at INTEGER NOT NULL,
+ attempt_count INTEGER NOT NULL DEFAULT 0,
+ last_error TEXT
+ )""")
+ database.execSQL("CREATE UNIQUE INDEX IF NOT EXISTS index_provider_deletion_cleanup_provider_id_action_target_id ON provider_deletion_cleanup(provider_id, action, target_id)")
+ }
+ }
+
+ /** Migration 63 -> 64: records immutable ownership for plugin-created M3U providers. */
+ val MIGRATION_63_64 = object : Migration(63, 64) {
+ override fun migrate(database: SupportSQLiteDatabase) {
+ database.execSQL("""CREATE TABLE IF NOT EXISTS plugin_provider_ownership (
+ package_name TEXT NOT NULL,
+ service_class_name TEXT NOT NULL,
+ manifest_id TEXT NOT NULL,
+ provider_id INTEGER NOT NULL,
+ created_at INTEGER NOT NULL,
+ PRIMARY KEY(package_name, service_class_name, manifest_id),
+ FOREIGN KEY(provider_id) REFERENCES providers(id) ON UPDATE NO ACTION ON DELETE CASCADE
+ )""")
+ database.execSQL("CREATE UNIQUE INDEX IF NOT EXISTS index_plugin_provider_ownership_provider_id ON plugin_provider_ownership(provider_id)")
+ validateForeignKeys(database, "plugin_provider_ownership")
+ }
+ }
+
+ /** Migration 64 -> 65: make already-persisted Jellyfin image URLs account scoped. */
+ val MIGRATION_64_65 = object : Migration(64, 65) {
+ override fun migrate(database: SupportSQLiteDatabase) {
+ listOf(
+ imageUrlMigrationSql("movies", "poster_url"),
+ imageUrlMigrationSql("movies", "backdrop_url"),
+ imageUrlMigrationSql("series", "poster_url"),
+ imageUrlMigrationSql("series", "backdrop_url"),
+ imageUrlMigrationSql("episodes", "cover_url")
+ ).forEach(database::execSQL)
+ }
+ }
+
+ /** Migration 65 -> 66: distinguish schedules that exist from schedules armed in AlarmManager. */
+ val MIGRATION_65_66 = object : Migration(65, 66) {
+ override fun migrate(database: SupportSQLiteDatabase) {
+ addColumnIfMissing(
+ database,
+ tableName = "recording_runs",
+ columnName = "exact_alarm_armed",
+ columnDefinition = "INTEGER NOT NULL DEFAULT 1"
+ )
+ addColumnIfMissing(
+ database,
+ tableName = "program_reminders",
+ columnName = "exact_alarm_armed",
+ columnDefinition = "INTEGER NOT NULL DEFAULT 1"
+ )
+ }
+ }
+
+ private fun imageUrlMigrationSql(table: String, column: String): String = """
+ UPDATE $table SET $column = CASE
+ WHEN instr($column, 'streamvault_provider_id=') > 0 THEN $column
+ ELSE $column || CASE WHEN instr($column, '?') = 0 THEN '?streamvault_provider_id=' ELSE '&streamvault_provider_id=' END || provider_id
+ END
+ WHERE $column IS NOT NULL
+ AND provider_id IN (SELECT id FROM providers WHERE type = 'JELLYFIN')
+ """.trimIndent()
+
val MIGRATION_52_53 = object : Migration(52, 53) {
override fun migrate(database: SupportSQLiteDatabase) {
addStalkerHardeningColumns(database, "movie_category_hydration")
diff --git a/data/src/main/java/com/streamvault/data/local/dao/DownloadDao.kt b/data/src/main/java/com/streamvault/data/local/dao/DownloadDao.kt
index d2256e79..9861d8de 100644
--- a/data/src/main/java/com/streamvault/data/local/dao/DownloadDao.kt
+++ b/data/src/main/java/com/streamvault/data/local/dao/DownloadDao.kt
@@ -29,6 +29,10 @@ interface DownloadDao {
@Query("SELECT * FROM downloads WHERE status = 'PAUSED' AND retry_count < :maxRetries ORDER BY created_at ASC")
suspend fun getRetryablePausedOnce(maxRetries: Int): List<DownloadEntity>
+ /** A DOWNLOADING row is valid only while an in-process job owns it. */
+ @Query("UPDATE downloads SET status = 'PENDING', failure_reason = :reason WHERE status = 'DOWNLOADING'")
+ suspend fun recoverOrphanedDownloading(reason: String): Int
+
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(entity: DownloadEntity)
diff --git a/data/src/main/java/com/streamvault/data/local/dao/PluginProviderOwnershipDao.kt b/data/src/main/java/com/streamvault/data/local/dao/PluginProviderOwnershipDao.kt
new file mode 100644
index 00000000..b6937b00
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/local/dao/PluginProviderOwnershipDao.kt
@@ -0,0 +1,37 @@
+package com.streamvault.data.local.dao
+
+import androidx.room.Dao
+import androidx.room.Insert
+import androidx.room.OnConflictStrategy
+import androidx.room.Query
+import com.streamvault.data.local.entity.PluginProviderOwnershipEntity
+
+@Dao
+interface PluginProviderOwnershipDao {
+ @Query("""
+ SELECT * FROM plugin_provider_ownership
+ WHERE package_name = :packageName
+ AND service_class_name = :serviceClassName
+ AND manifest_id = :manifestId
+ LIMIT 1
+ """)
+ suspend fun get(
+ packageName: String,
+ serviceClassName: String,
+ manifestId: String
+ ): PluginProviderOwnershipEntity?
+
+ @Query("SELECT * FROM plugin_provider_ownership")
+ suspend fun getAll(): List<PluginProviderOwnershipEntity>
+
+ @Insert(onConflict = OnConflictStrategy.REPLACE)
+ suspend fun upsert(ownership: PluginProviderOwnershipEntity)
+
+ @Query("""
+ DELETE FROM plugin_provider_ownership
+ WHERE package_name = :packageName
+ AND service_class_name = :serviceClassName
+ AND manifest_id = :manifestId
+ """)
+ suspend fun delete(packageName: String, serviceClassName: String, manifestId: String)
+}
diff --git a/data/src/main/java/com/streamvault/data/local/dao/ProviderDeletionCleanupDao.kt b/data/src/main/java/com/streamvault/data/local/dao/ProviderDeletionCleanupDao.kt
new file mode 100644
index 00000000..3c59e0c1
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/local/dao/ProviderDeletionCleanupDao.kt
@@ -0,0 +1,22 @@
+package com.streamvault.data.local.dao
+
+import androidx.room.Dao
+import androidx.room.Insert
+import androidx.room.OnConflictStrategy
+import androidx.room.Query
+import com.streamvault.data.local.entity.ProviderDeletionCleanupEntity
+
+@Dao
+interface ProviderDeletionCleanupDao {
+ @Insert(onConflict = OnConflictStrategy.IGNORE)
+ suspend fun insertAll(items: List<ProviderDeletionCleanupEntity>)
+
+ @Query("SELECT * FROM provider_deletion_cleanup ORDER BY id")
+ suspend fun getAll(): List<ProviderDeletionCleanupEntity>
+
+ @Query("DELETE FROM provider_deletion_cleanup WHERE id = :id")
+ suspend fun delete(id: Long)
+
+ @Query("UPDATE provider_deletion_cleanup SET attempt_count = attempt_count + 1, last_error = :error WHERE id = :id")
+ suspend fun recordFailure(id: Long, error: String)
+}
diff --git a/data/src/main/java/com/streamvault/data/local/dao/RecordingDaos.kt b/data/src/main/java/com/streamvault/data/local/dao/RecordingDaos.kt
index 8c29715e..93dc200b 100644
--- a/data/src/main/java/com/streamvault/data/local/dao/RecordingDaos.kt
+++ b/data/src/main/java/com/streamvault/data/local/dao/RecordingDaos.kt
@@ -59,6 +59,7 @@ interface RecordingRunDao {
rr.failure_reason,
rr.terminal_at_ms,
rr.schedule_enabled,
+ rr.exact_alarm_armed,
rr.priority
FROM recording_runs rr
ORDER BY rr.scheduled_start_ms DESC, rr.created_at DESC
@@ -78,6 +79,9 @@ interface RecordingRunDao {
@Update
suspend fun update(run: RecordingRunEntity)
+ @Query("UPDATE recording_runs SET exact_alarm_armed = :armed, updated_at = :updatedAt WHERE id = :id")
+ suspend fun setExactAlarmArmed(id: String, armed: Boolean, updatedAt: Long = System.currentTimeMillis())
+
@Query("DELETE FROM recording_runs WHERE id = :id")
suspend fun delete(id: String)
@@ -208,6 +212,9 @@ interface ProgramReminderDao {
@Update
suspend fun update(reminder: ProgramReminderEntity)
+ @Query("UPDATE program_reminders SET exact_alarm_armed = :armed WHERE id = :id")
+ suspend fun setExactAlarmArmed(id: Long, armed: Boolean)
+
@Query(
"""
DELETE FROM program_reminders
diff --git a/data/src/main/java/com/streamvault/data/local/entity/PluginProviderOwnershipEntity.kt b/data/src/main/java/com/streamvault/data/local/entity/PluginProviderOwnershipEntity.kt
new file mode 100644
index 00000000..fe93625e
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/local/entity/PluginProviderOwnershipEntity.kt
@@ -0,0 +1,31 @@
+package com.streamvault.data.local.entity
+
+import androidx.room.ColumnInfo
+import androidx.room.Entity
+import androidx.room.ForeignKey
+import androidx.room.Index
+
+/**
+ * Durable proof that a provider was created by one exact plugin service.
+ *
+ * This deliberately does not use a display name or playlist URL: neither is an ownership
+ * identifier and both may be shared with user-created providers.
+ */
+@Entity(
+ tableName = "plugin_provider_ownership",
+ primaryKeys = ["package_name", "service_class_name", "manifest_id"],
+ foreignKeys = [ForeignKey(
+ entity = ProviderEntity::class,
+ parentColumns = ["id"],
+ childColumns = ["provider_id"],
+ onDelete = ForeignKey.CASCADE
+ )],
+ indices = [Index(value = ["provider_id"], unique = true)]
+)
+data class PluginProviderOwnershipEntity(
+ @ColumnInfo(name = "package_name") val packageName: String,
+ @ColumnInfo(name = "service_class_name") val serviceClassName: String,
+ @ColumnInfo(name = "manifest_id") val manifestId: String,
+ @ColumnInfo(name = "provider_id") val providerId: Long,
+ @ColumnInfo(name = "created_at") val createdAt: Long = System.currentTimeMillis()
+)
diff --git a/data/src/main/java/com/streamvault/data/local/entity/ProviderDeletionCleanupEntity.kt b/data/src/main/java/com/streamvault/data/local/entity/ProviderDeletionCleanupEntity.kt
new file mode 100644
index 00000000..04b7a424
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/local/entity/ProviderDeletionCleanupEntity.kt
@@ -0,0 +1,20 @@
+package com.streamvault.data.local.entity
+
+import androidx.room.ColumnInfo
+import androidx.room.Entity
+import androidx.room.Index
+import androidx.room.PrimaryKey
+
+@Entity(
+ tableName = "provider_deletion_cleanup",
+ indices = [Index(value = ["provider_id", "action", "target_id"], unique = true)]
+)
+data class ProviderDeletionCleanupEntity(
+ @PrimaryKey(autoGenerate = true) val id: Long = 0,
+ @ColumnInfo(name = "provider_id") val providerId: Long,
+ val action: String,
+ @ColumnInfo(name = "target_id") val targetId: String = "",
+ @ColumnInfo(name = "created_at") val createdAt: Long = System.currentTimeMillis(),
+ @ColumnInfo(name = "attempt_count") val attemptCount: Int = 0,
+ @ColumnInfo(name = "last_error") val lastError: String? = null
+)
diff --git a/data/src/main/java/com/streamvault/data/local/entity/RecordingEntities.kt b/data/src/main/java/com/streamvault/data/local/entity/RecordingEntities.kt
index cd942243..fe4ac999 100644
--- a/data/src/main/java/com/streamvault/data/local/entity/RecordingEntities.kt
+++ b/data/src/main/java/com/streamvault/data/local/entity/RecordingEntities.kt
@@ -104,6 +104,7 @@ data class RecordingRunEntity(
val priority: Int = 0,
@ColumnInfo(name = "alarm_start_at_ms") val alarmStartAtMs: Long? = null,
@ColumnInfo(name = "alarm_stop_at_ms") val alarmStopAtMs: Long? = null,
+ @ColumnInfo(name = "exact_alarm_armed") val exactAlarmArmed: Boolean = true,
@ColumnInfo(name = "created_at") val createdAt: Long = System.currentTimeMillis(),
@ColumnInfo(name = "updated_at") val updatedAt: Long = System.currentTimeMillis()
)
@@ -155,6 +156,7 @@ data class ProgramReminderEntity(
@ColumnInfo(name = "lead_time_minutes") val leadTimeMinutes: Int = 5,
@ColumnInfo(name = "is_dismissed") val isDismissed: Boolean = false,
@ColumnInfo(name = "notified_at") val notifiedAt: Long? = null,
+ @ColumnInfo(name = "exact_alarm_armed") val exactAlarmArmed: Boolean = true,
@ColumnInfo(name = "created_at") val createdAt: Long = System.currentTimeMillis()
)
@@ -182,5 +184,6 @@ data class RecordingRunWithSchedule(
@ColumnInfo(name = "failure_reason") val failureReason: String? = null,
@ColumnInfo(name = "terminal_at_ms") val terminalAtMs: Long? = null,
@ColumnInfo(name = "schedule_enabled") val scheduleEnabled: Boolean,
+ @ColumnInfo(name = "exact_alarm_armed") val exactAlarmArmed: Boolean,
val priority: Int
)
diff --git a/data/src/main/java/com/streamvault/data/manager/BackupManagerImpl.kt b/data/src/main/java/com/streamvault/data/manager/BackupManagerImpl.kt
index fac5c50f..44e786dd 100644
--- a/data/src/main/java/com/streamvault/data/manager/BackupManagerImpl.kt
+++ b/data/src/main/java/com/streamvault/data/manager/BackupManagerImpl.kt
@@ -48,6 +48,8 @@ import java.io.OutputStream
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
+import java.io.FilterInputStream
+import java.io.IOException
import java.io.InputStreamReader
import java.io.OutputStreamWriter
import java.io.Writer
@@ -268,52 +270,33 @@ class BackupManagerImpl @Inject constructor(
val existingScheduledRecordings = recordingManager.observeRecordingItems().first()
.filter { it.status == RecordingStatus.SCHEDULED }
- val providerConflicts = backupData.providers.orEmpty().count { incoming ->
- existingProviders.findMatchingProvider(
- serverUrl = incoming.serverUrl,
- username = incoming.username,
- stalkerMacAddress = incoming.stalkerMacAddress
- ) != null
+ val providersByIdentity = existingProviders.associateBy { it.backupIdentity() }
+ val groupKeys = existingGroups.mapTo(hashSetOf()) { it.name.lowercase() to it.contentType }
+ val favoriteKeys = existingFavorites.mapTo(hashSetOf()) { Triple(it.contentId, it.contentType, it.groupId) }
+ val historyKeys = existingHistory.mapTo(hashSetOf()) { Triple(it.contentId, it.contentType, it.providerId) }
+ val protectedCategoryKeys = existingProtectedCategories.mapTo(hashSetOf()) { (provider, name, type) ->
+ Triple(provider.id, name, type)
}
- val groupConflicts = backupData.virtualGroups.orEmpty().count { incoming ->
- existingGroups.any { it.name.equals(incoming.name, ignoreCase = true) && it.contentType == incoming.contentType }
+ val recordingKeys = existingScheduledRecordings.mapTo(hashSetOf()) {
+ RecordingConflictKey(it.providerId, it.scheduledStartMs, it.channelId, it.streamUrl)
}
- val favoriteConflicts = backupData.favorites.orEmpty().count { incoming ->
- existingFavorites.any {
- it.contentId == incoming.contentId &&
- it.contentType == incoming.contentType &&
- it.groupId == incoming.groupId
- }
+ val providerConflicts = backupData.providers.orEmpty().count { it.backupIdentity() in providersByIdentity }
+ val groupConflicts = backupData.virtualGroups.orEmpty().count { (it.name.lowercase() to it.contentType) in groupKeys }
+ val favoriteConflicts = backupData.favorites.orEmpty().count {
+ Triple(it.contentId, it.contentType, it.groupId) in favoriteKeys
}
- val historyConflicts = backupData.playbackHistory.orEmpty().count { incoming ->
- existingHistory.any {
- it.contentId == incoming.contentId &&
- it.contentType == incoming.contentType &&
- it.providerId == incoming.providerId
- }
+ val historyConflicts = backupData.playbackHistory.orEmpty().count {
+ Triple(it.contentId, it.contentType, it.providerId) in historyKeys
}
val protectedCategoryConflicts = backupData.protectedCategories.orEmpty().count { incoming ->
- val provider = existingProviders.findMatchingProvider(
- serverUrl = incoming.providerServerUrl,
- username = incoming.providerUsername,
- stalkerMacAddress = incoming.providerStalkerMacAddress
- ) ?: return@count false
- existingProtectedCategories.any { (existingProvider, categoryName, type) ->
- existingProvider.id == provider.id &&
- categoryName == incoming.categoryName.lowercase() &&
- type == incoming.type
- }
+ val provider = providersByIdentity[incoming.backupIdentity()] ?: return@count false
+ Triple(provider.id, incoming.categoryName.lowercase(), incoming.type) in protectedCategoryKeys
}
val recordingConflicts = backupData.scheduledRecordings.orEmpty().normalizedRecurringBackups().count { incoming ->
- val provider = existingProviders.findMatchingProvider(
- serverUrl = incoming.providerServerUrl,
- username = incoming.providerUsername,
- stalkerMacAddress = incoming.providerStalkerMacAddress
- ) ?: return@count false
- existingScheduledRecordings.any {
- it.providerId == provider.id &&
- it.scheduledStartMs == incoming.scheduledStartMs &&
- (it.channelId == incoming.channelId || it.streamUrl == incoming.streamUrl)
+ val provider = providersByIdentity[incoming.backupIdentity()] ?: return@count false
+ recordingKeys.any { key ->
+ key.providerId == provider.id && key.startMs == incoming.scheduledStartMs &&
+ (key.channelId == incoming.channelId || key.streamUrl == incoming.streamUrl)
}
}
@@ -512,12 +495,28 @@ class BackupManagerImpl @Inject constructor(
private fun readBackupData(uriString: String): BackupData? {
return openBackupInputStream(uriString)?.use { inputStream ->
- InputStreamReader(inputStream).use { reader ->
- gson.fromJson(reader, BackupData::class.java)
+ BoundedInputStream(inputStream, MAX_BACKUP_BYTES).use { boundedInput ->
+ InputStreamReader(boundedInput).use { reader ->
+ gson.fromJson(reader, BackupData::class.java).also(::validateBackupDataLimits)
+ }
}
}
}
+ private fun validateBackupDataLimits(data: BackupData) {
+ require(data.preferences.orEmpty().size <= MAX_PREFERENCES) { "Backup has too many preferences" }
+ require(data.providers.orEmpty().size <= MAX_PROVIDERS) { "Backup has too many providers" }
+ require(data.favorites.orEmpty().size <= MAX_SECTION_ITEMS) { "Backup has too many favorites" }
+ require(data.virtualGroups.orEmpty().size <= MAX_SECTION_ITEMS) { "Backup has too many groups" }
+ require(data.playbackHistory.orEmpty().size <= MAX_SECTION_ITEMS) { "Backup has too much playback history" }
+ require(data.protectedCategories.orEmpty().size <= MAX_SECTION_ITEMS) { "Backup has too many protected categories" }
+ require(data.scheduledRecordings.orEmpty().size <= MAX_SECTION_ITEMS) { "Backup has too many recording schedules" }
+ require(data.multiViewPresets.orEmpty().values.sumOf { it.size } <= MAX_SECTION_ITEMS) { "Backup has too many preset entries" }
+ data.preferences.orEmpty().forEach { (key, value) ->
+ require(key.length <= MAX_FIELD_CHARS && value.length <= MAX_FIELD_CHARS) { "Backup contains an overlong preference" }
+ }
+ }
+
private fun openBackupOutputStream(uriString: String): OutputStream? {
return if (uriString.isFileUriString()) {
val target = uriString.toFileUriTarget() ?: return null
@@ -925,8 +924,49 @@ class BackupManagerImpl @Inject constructor(
val importedSections: List<String>,
val skippedSections: List<String>
)
+
+ private data class RecordingConflictKey(
+ val providerId: Long,
+ val startMs: Long,
+ val channelId: Long,
+ val streamUrl: String
+ )
+
+ private class BoundedInputStream(input: java.io.InputStream, private val maxBytes: Long) : FilterInputStream(input) {
+ private var bytesRead = 0L
+
+ override fun read(): Int = super.read().also { if (it >= 0) consume(1) }
+
+ override fun read(buffer: ByteArray, offset: Int, length: Int): Int =
+ super.read(buffer, offset, length).also { if (it > 0) consume(it.toLong()) }
+
+ private fun consume(count: Long) {
+ bytesRead += count
+ if (bytesRead > maxBytes) throw IOException("Backup exceeds the ${maxBytes / (1024 * 1024)} MiB import limit")
+ }
+ }
+
+ private companion object {
+ const val MAX_BACKUP_BYTES = 16L * 1024 * 1024
+ const val MAX_PREFERENCES = 5_000
+ const val MAX_PROVIDERS = 1_000
+ const val MAX_SECTION_ITEMS = 100_000
+ const val MAX_FIELD_CHARS = 8_192
+ }
}
+private fun ProviderEntity.backupIdentity(): Triple<String, String, String> =
+ Triple(serverUrl, username, stalkerMacAddress)
+
+private fun com.streamvault.domain.model.Provider.backupIdentity(): Triple<String, String, String> =
+ Triple(serverUrl, username, stalkerMacAddress)
+
+private fun ProtectedCategoryBackup.backupIdentity(): Triple<String, String, String> =
+ Triple(providerServerUrl, providerUsername, providerStalkerMacAddress.orEmpty())
+
+private fun ScheduledRecordingBackup.backupIdentity(): Triple<String, String, String> =
+ Triple(providerServerUrl, providerUsername, providerStalkerMacAddress.orEmpty())
+
internal fun com.streamvault.domain.model.RecordingItem.toScheduledRecordingBackup(
provider: com.streamvault.domain.model.Provider,
schedule: RecordingScheduleEntity?
@@ -1035,28 +1075,31 @@ internal suspend fun importScheduledRecordingBackups(
)
return@forEach
}
- if (conflict != null && conflictStrategy == BackupConflictStrategy.REPLACE_EXISTING) {
- when (val cancelResult = recordingManager.cancelRecording(conflict.id)) {
- is Result.Success -> existingSchedules.remove(conflict)
- is Result.Error -> {
- outcomes += scheduled.toImportOutcome(
- disposition = RecordingScheduleImportDisposition.FAILED,
- reason = cancelResult.message
- )
- return@forEach
- }
- Result.Loading -> {
- outcomes += scheduled.toImportOutcome(
- disposition = RecordingScheduleImportDisposition.FAILED,
- reason = "Cancellation did not complete."
- )
- return@forEach
- }
- }
- }
-
when (val result = recordingManager.scheduleRecording(scheduled.toRecordingRequest(provider.id))) {
is Result.Success -> {
+ if (conflict != null && conflictStrategy == BackupConflictStrategy.REPLACE_EXISTING) {
+ when (val cancelResult = recordingManager.cancelRecording(conflict.id)) {
+ is Result.Success -> existingSchedules.remove(conflict)
+ is Result.Error -> {
+ // The replacement is already armed; remove it again so a failed
+ // promotion leaves the prior schedule intact.
+ recordingManager.cancelRecording(result.data.id)
+ outcomes += scheduled.toImportOutcome(
+ disposition = RecordingScheduleImportDisposition.FAILED,
+ reason = "Could not replace existing schedule: ${cancelResult.message}"
+ )
+ return@forEach
+ }
+ Result.Loading -> {
+ recordingManager.cancelRecording(result.data.id)
+ outcomes += scheduled.toImportOutcome(
+ disposition = RecordingScheduleImportDisposition.FAILED,
+ reason = "Could not replace existing schedule because cancellation did not complete."
+ )
+ return@forEach
+ }
+ }
+ }
existingSchedules += result.data
outcomes += scheduled.toImportOutcome(
disposition = if (conflict != null) {
diff --git a/data/src/main/java/com/streamvault/data/manager/DownloadManagerImpl.kt b/data/src/main/java/com/streamvault/data/manager/DownloadManagerImpl.kt
index 6f1245ae..f2e15153 100644
--- a/data/src/main/java/com/streamvault/data/manager/DownloadManagerImpl.kt
+++ b/data/src/main/java/com/streamvault/data/manager/DownloadManagerImpl.kt
@@ -13,8 +13,10 @@ import androidx.documentfile.provider.DocumentFile
import com.streamvault.data.local.dao.DownloadDao
import com.streamvault.data.local.entity.DownloadEntity
import com.streamvault.data.preferences.PreferencesRepository
+import com.streamvault.data.remote.http.useCancellableResponse
import com.streamvault.data.remote.xtream.ResolvedStreamUrl
import com.streamvault.data.remote.xtream.XtreamStreamUrlResolver
+import com.streamvault.data.util.runSuspendCatching
import com.streamvault.domain.model.ContentType
import com.streamvault.domain.model.DownloadContentType
import com.streamvault.domain.model.DownloadItem
@@ -108,7 +110,7 @@ class DownloadManagerImpl @Inject constructor(
}
override suspend fun enqueueDownload(request: DownloadRequest): Result<DownloadItem> {
- return runCatching {
+ return runSuspendCatching {
val entity = DownloadEntity.fromRequest(
request = request,
outputUri = null,
@@ -124,7 +126,7 @@ class DownloadManagerImpl @Inject constructor(
}
override suspend fun resumeDownload(id: String): Result<Unit> {
- return runCatching {
+ return runSuspendCatching {
downloadDao.getByIdOnce(id)?.let { entity ->
if (entity.status != DownloadStatus.COMPLETED && entity.status != DownloadStatus.CANCELLED) {
deleteOutput(entity)
@@ -150,7 +152,7 @@ class DownloadManagerImpl @Inject constructor(
}
override suspend fun cancelDownload(id: String): Result<Unit> {
- return runCatching {
+ return runSuspendCatching {
activeCalls.remove(id)?.cancel()
activeJobs.remove(id)?.cancelAndJoin()
downloadDao.getByIdOnce(id)?.let { entity ->
@@ -164,16 +166,16 @@ class DownloadManagerImpl @Inject constructor(
override fun onPlaybackStarted() {
playbackActive = true
- applicationScope.launch(Dispatchers.IO) { runCatching { pauseActiveDownloadsForPlayback() } }
+ applicationScope.launch(Dispatchers.IO) { runSuspendCatching { pauseActiveDownloadsForPlayback() } }
}
override fun onPlaybackStopped() {
playbackActive = false
- applicationScope.launch(Dispatchers.IO) { runCatching { startNextQueued() } }
+ applicationScope.launch(Dispatchers.IO) { runSuspendCatching { startNextQueued() } }
}
override suspend fun deleteDownload(id: String): Result<Unit> {
- return runCatching {
+ return runSuspendCatching {
activeCalls.remove(id)?.cancel()
activeJobs.remove(id)?.cancelAndJoin()
downloadDao.getByIdOnce(id)?.let { deleteOutput(it) }
@@ -189,7 +191,7 @@ class DownloadManagerImpl @Inject constructor(
treeUri: String?,
displayName: String?
): Result<DownloadStorageConfig> {
- return runCatching {
+ return runSuspendCatching {
preferencesRepository.setDownloadTreeUri(treeUri)
DownloadStorageConfig(
treeUri = treeUri,
@@ -239,6 +241,27 @@ class DownloadManagerImpl @Inject constructor(
}
}
+ override suspend fun recoverInterruptedDownloads(): Result<Int> = runSuspendCatching {
+ val recovered = schedulerMutex.withLock {
+ // This method runs only at process startup, before this manager owns any job.
+ // Reconnect callbacks deliberately do not call it, so live work is never reclaimed.
+ check(activeJobs.isEmpty()) { "Cannot recover downloads while this process owns active jobs" }
+ downloadDao.recoverOrphanedDownloading(
+ "Interrupted after app process stopped; queued to resume"
+ )
+ }
+ startNextQueued()
+ recovered
+ }.fold(
+ onSuccess = { Result.success(it) },
+ onFailure = { Result.error("Failed to recover interrupted downloads", it) }
+ )
+
+ /**
+ * A process death destroys active jobs and HTTP calls. Persisted DOWNLOADING rows therefore
+ * have no owner on the next manager instance and must be made schedulable again.
+ */
+
private suspend fun pauseActiveDownloadsForPlayback() {
activeJobs.entries.toList().forEach { (id, job) ->
playbackPausedIds.add(id)
@@ -248,6 +271,20 @@ class DownloadManagerImpl @Inject constructor(
}
}
+ override suspend fun pauseDownloadForForegroundServiceTimeout(id: String): Result<Unit> = runSuspendCatching {
+ activeCalls.remove(id)?.cancel()
+ activeJobs.remove(id)?.let { job ->
+ job.cancel(ForegroundServiceTimeoutCancellation())
+ job.join()
+ }
+ downloadDao.getByIdOnce(id)
+ ?.takeIf { it.status == DownloadStatus.DOWNLOADING }
+ ?.let { pauseForForegroundServiceTimeout(it) }
+ }.fold(
+ onSuccess = { Result.success(Unit) },
+ onFailure = { Result.error("Failed to pause download after foreground-service timeout", it) }
+ )
+
private suspend fun captureDownload(initial: DownloadEntity) {
var current = downloadDao.getByIdOnce(initial.id) ?: initial
current = current.copy(status = DownloadStatus.DOWNLOADING, failureReason = null)
@@ -273,7 +310,7 @@ class DownloadManagerImpl @Inject constructor(
if (resumeFrom > 0L) requestBuilder.header("Range", "bytes=$resumeFrom-")
val call = okHttpClient.newCall(requestBuilder.build())
activeCalls[initial.id] = call
- call.execute().use { response ->
+ call.useCancellableResponse { response ->
if (!response.isSuccessful) throw HttpDownloadException(response.code)
val body = response.body ?: error("Empty response body")
val rangeAccepted = resumeFrom > 0L && response.code == HttpURLConnection.HTTP_PARTIAL
@@ -290,7 +327,7 @@ class DownloadManagerImpl @Inject constructor(
}
val supportsResume = response.header("Accept-Ranges")
?.contains("bytes", ignoreCase = true) == true || rangeAccepted
- val target = runCatching { createOutputTarget(current, response.header("Content-Type"), append) }
+ val target = runSuspendCatching { createOutputTarget(current, response.header("Content-Type"), append) }
.getOrElse { error ->
if (!append) throw error
throw RestartFromZeroException(error)
@@ -352,6 +389,8 @@ class DownloadManagerImpl @Inject constructor(
downloadDao.getByIdOnce(initial.id)?.let { entity ->
if (cancelled is PlaybackStartedCancellation || playbackPausedIds.contains(initial.id)) {
resetInterruptedDownload(current, DownloadStatus.PAUSED, "Waiting for playback to stop")
+ } else if (cancelled is ForegroundServiceTimeoutCancellation) {
+ pauseForForegroundServiceTimeout(current)
} else {
downloadDao.update(entity.copy(status = DownloadStatus.CANCELLED))
}
@@ -423,6 +462,16 @@ class DownloadManagerImpl @Inject constructor(
)
}
+ private suspend fun pauseForForegroundServiceTimeout(entity: DownloadEntity) {
+ downloadDao.update(
+ entity.copy(
+ status = DownloadStatus.PAUSED,
+ completedAt = null,
+ failureReason = FOREGROUND_SERVICE_TIMEOUT_REASON
+ )
+ )
+ }
+
private fun hasAppendTarget(entity: DownloadEntity): Boolean {
val path = entity.outputDisplayPath
return !entity.outputUri.isNullOrBlank() || (!path.isNullOrBlank() && File(path).exists())
@@ -445,7 +494,7 @@ class DownloadManagerImpl @Inject constructor(
private suspend fun resolveFreshDownloadStream(entity: DownloadEntity): ResolvedStreamUrl? {
val logicalUrl = entity.sourceStreamUrl?.takeIf { it.isNotBlank() } ?: entity.streamUrl
- return runCatching {
+ return runSuspendCatching {
xtreamStreamUrlResolver.resolveWithMetadata(
url = logicalUrl,
fallbackProviderId = entity.providerId,
@@ -597,6 +646,8 @@ class DownloadManagerImpl @Inject constructor(
const val DEFAULT_BUFFER_SIZE = 64 * 1024
const val PROGRESS_UPDATE_BYTES = 512 * 1024
const val MAX_RETRIES = 5
+ const val FOREGROUND_SERVICE_TIMEOUT_REASON =
+ "Download paused because Android exhausted the foreground-service time allowance."
}
private class HttpDownloadException(val code: Int) : Exception("HTTP $code")
@@ -604,4 +655,7 @@ class DownloadManagerImpl @Inject constructor(
private class RestartFromZeroException(cause: Throwable) : Exception(cause)
private class PlaybackStartedCancellation : CancellationException("Playback started")
+
+ private class ForegroundServiceTimeoutCancellation :
+ CancellationException("Android exhausted the foreground-service time allowance")
}
diff --git a/data/src/main/java/com/streamvault/data/manager/GoogleDriveBackupSyncManager.kt b/data/src/main/java/com/streamvault/data/manager/GoogleDriveBackupSyncManager.kt
index 7306cb98..e8d0955d 100644
--- a/data/src/main/java/com/streamvault/data/manager/GoogleDriveBackupSyncManager.kt
+++ b/data/src/main/java/com/streamvault/data/manager/GoogleDriveBackupSyncManager.kt
@@ -13,6 +13,7 @@ import com.google.android.gms.common.GoogleApiAvailability
import com.google.android.gms.common.api.ApiException
import com.google.android.gms.common.api.Scope
import com.google.android.gms.tasks.Task
+import com.streamvault.data.remote.http.useCancellableResponse
import com.streamvault.domain.manager.BackupManager
import com.streamvault.domain.manager.DriveAccount
import com.streamvault.domain.manager.DriveAuthState
@@ -358,7 +359,7 @@ class GoogleDriveBackupSyncManager @Inject constructor(
null
}
- private fun findRemoteFileId(authToken: String, fileName: String): String? {
+ private suspend fun findRemoteFileId(authToken: String, fileName: String): String? {
val url = "https://www.googleapis.com/drive/v3/files" +
"?spaces=appDataFolder" +
"&q=" + uriEncode("name='$fileName'") +
@@ -368,7 +369,7 @@ class GoogleDriveBackupSyncManager @Inject constructor(
.addHeader("Authorization", "Bearer $authToken")
.get()
.build()
- httpClient.newCall(request).execute().use { response ->
+ httpClient.newCall(request).useCancellableResponse { response ->
if (!response.isSuccessful) return null
val body = response.body?.string().orEmpty()
val files = JSONObject(body).optJSONArray("files") ?: return null
@@ -377,7 +378,7 @@ class GoogleDriveBackupSyncManager @Inject constructor(
}
}
- private fun uploadAppDataFile(authToken: String, payload: File, fileName: String): Boolean {
+ private suspend fun uploadAppDataFile(authToken: String, payload: File, fileName: String): Boolean {
val existingId = findRemoteFileId(authToken, fileName)
val boundary = "streamvault-${System.nanoTime()}"
val (httpMethod, endpoint) = if (existingId != null) {
@@ -400,18 +401,18 @@ class GoogleDriveBackupSyncManager @Inject constructor(
.method(httpMethod, body)
.build()
- httpClient.newCall(request).execute().use { response ->
+ httpClient.newCall(request).useCancellableResponse { response ->
return response.isSuccessful
}
}
- private fun downloadAppDataFile(authToken: String, fileId: String, target: File): Boolean {
+ private suspend fun downloadAppDataFile(authToken: String, fileId: String, target: File): Boolean {
val request = Request.Builder()
.url("https://www.googleapis.com/drive/v3/files/$fileId?alt=media")
.addHeader("Authorization", "Bearer $authToken")
.get()
.build()
- httpClient.newCall(request).execute().use { response ->
+ httpClient.newCall(request).useCancellableResponse { response ->
if (!response.isSuccessful) return false
val source = response.body?.byteStream() ?: return false
target.outputStream().use { sink -> source.copyTo(sink) }
diff --git a/data/src/main/java/com/streamvault/data/manager/ProgramReminderManagerImpl.kt b/data/src/main/java/com/streamvault/data/manager/ProgramReminderManagerImpl.kt
index b65a9016..25fcbe65 100644
--- a/data/src/main/java/com/streamvault/data/manager/ProgramReminderManagerImpl.kt
+++ b/data/src/main/java/com/streamvault/data/manager/ProgramReminderManagerImpl.kt
@@ -109,17 +109,19 @@ class ProgramReminderManagerImpl private constructor(
notifiedAt = null,
createdAt = existing?.createdAt ?: now
)
- val reminderId = if (existing == null) {
- programReminderDao.insert(reminder)
- } else {
- programReminderDao.update(reminder)
- existing.id
- }
+ val reminderId = existing?.id ?: programReminderDao.insert(reminder)
return when (val result = alarmScheduler.schedule(reminderId, remindAt)) {
- is Result.Success -> Result.success(Unit)
+ is Result.Success -> {
+ if (existing != null) {
+ programReminderDao.update(reminder)
+ }
+ Result.success(Unit)
+ }
is Result.Error -> {
if (existing == null) {
programReminderDao.deleteById(reminderId)
+ } else {
+ alarmScheduler.schedule(existing.id, existing.remindAt)
}
Result.error(result.message, result.exception)
}
@@ -142,10 +144,19 @@ class ProgramReminderManagerImpl private constructor(
override suspend fun restoreScheduledReminders() {
val now = System.currentTimeMillis()
+ if (!alarmScheduler.canScheduleExactAlarms()) {
+ programReminderDao.getPendingActive(now).forEach { reminder ->
+ programReminderDao.setExactAlarmArmed(reminder.id, false)
+ }
+ return
+ }
programReminderDao.getPendingActive(now).forEach { reminder ->
when (val result = alarmScheduler.schedule(reminder.id, reminder.remindAt.coerceAtLeast(now + 1_000L))) {
- is Result.Error -> android.util.Log.w("ProgramReminderManager", "Unable to restore reminder ${reminder.id}: ${result.message}")
- else -> Unit
+ is Result.Error -> {
+ programReminderDao.setExactAlarmArmed(reminder.id, false)
+ android.util.Log.w("ProgramReminderManager", "Unable to restore reminder ${reminder.id}: ${result.message}")
+ }
+ else -> programReminderDao.setExactAlarmArmed(reminder.id, true)
}
}
}
@@ -158,8 +169,9 @@ class ProgramReminderManagerImpl private constructor(
programReminderDao.update(reminder.copy(isDismissed = true))
return
}
- notifier.showReminder(reminder)
- programReminderDao.update(reminder.copy(notifiedAt = now))
+ if (notifier.showReminder(reminder) is Result.Success) {
+ programReminderDao.update(reminder.copy(notifiedAt = now))
+ }
}
private fun ProgramReminderEntity.asDomain(): ProgramReminder = ProgramReminder(
@@ -173,6 +185,7 @@ class ProgramReminderManagerImpl private constructor(
leadTimeMinutes = leadTimeMinutes,
isDismissed = isDismissed,
notifiedAt = notifiedAt,
+ exactAlarmArmed = exactAlarmArmed,
createdAt = createdAt
)
}
diff --git a/data/src/main/java/com/streamvault/data/manager/RecordingManagerImpl.kt b/data/src/main/java/com/streamvault/data/manager/RecordingManagerImpl.kt
index f14f77a2..3e0c257d 100644
--- a/data/src/main/java/com/streamvault/data/manager/RecordingManagerImpl.kt
+++ b/data/src/main/java/com/streamvault/data/manager/RecordingManagerImpl.kt
@@ -25,6 +25,7 @@ import com.streamvault.data.manager.recording.ResolvedRecordingSource
import com.streamvault.data.manager.recording.TsPassThroughCaptureEngine
import com.streamvault.data.manager.recording.UnsupportedRecordingException
import com.streamvault.data.preferences.PreferencesRepository
+import com.streamvault.data.util.runSuspendCatching
import com.streamvault.data.manager.recording.asPersistenceValues
import com.streamvault.data.manager.recording.createOutputTarget
import com.streamvault.data.manager.recording.deleteOutputTarget
@@ -52,10 +53,13 @@ import java.time.Duration
import java.time.Instant
import java.time.ZoneId
import java.util.UUID
+import java.util.concurrent.ConcurrentHashMap
+import java.util.concurrent.atomic.AtomicBoolean
import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.SupervisorJob
@@ -71,6 +75,22 @@ private const val TAG = "RecordingManager"
private const val MIN_FREE_SPACE_BYTES = 512L * 1024L * 1024L // 512 MB
private const val FAILURE_NOTIFICATION_CHANNEL_ID = "streamvault_recording_failure"
private const val FAILURE_NOTIFICATION_ID_BASE = 5000
+private const val FOREGROUND_SERVICE_TIMEOUT_REASON =
+ "Recording stopped because Android exhausted the foreground-service time allowance."
+
+internal class ActiveCapture(private val job: Job) {
+ private val cancellationRequested = AtomicBoolean(false)
+
+ val isActive: Boolean
+ get() = job.isActive
+
+ suspend fun cancelAndJoin() {
+ if (cancellationRequested.compareAndSet(false, true)) {
+ job.cancel()
+ }
+ job.join()
+ }
+}
@Singleton
class RecordingManagerImpl @Inject constructor(
@@ -90,8 +110,9 @@ class RecordingManagerImpl @Inject constructor(
) : RecordingManager {
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
- private val activeJobs = mutableMapOf<String, Job>()
+ private val activeJobs = mutableMapOf<String, ActiveCapture>()
private val activeJobsMutex = Mutex()
+ private val foregroundServiceTimeoutRecordingIds = ConcurrentHashMap.newKeySet<String>()
private val recordingMutex = Mutex()
private val legacyStateFile by lazy { File(File(context.filesDir, "recordings"), "recordings_state.json") }
@@ -132,7 +153,7 @@ class RecordingManagerImpl @Inject constructor(
}
override suspend fun startManualRecording(request: RecordingRequest): Result<RecordingItem> = withContext(Dispatchers.IO) {
- runCatching {
+ runSuspendCatching {
val storage = ensureStorageStateSync()
if (!storage.isWritable) {
return@withContext Result.error("Recording storage is not writable.")
@@ -152,6 +173,8 @@ class RecordingManagerImpl @Inject constructor(
)
val run = try {
persistManualRun(request, source, outputTarget)
+ } catch (cancelled: CancellationException) {
+ throw cancelled
} catch (error: Throwable) {
val (outputUri, outputDisplayPath) = outputTarget.asPersistenceValues()
deleteOutputTarget(context, outputUri, outputDisplayPath)
@@ -161,6 +184,8 @@ class RecordingManagerImpl @Inject constructor(
scheduleStopAlarmOrFail(run.id, request.scheduledEndMs)
try {
recordingServiceLauncher.startCapture(context, run.id)
+ } catch (cancelled: CancellationException) {
+ throw cancelled
} catch (error: Throwable) {
markRunFailed(run.id, error.message ?: "Capture failed to start.", inferFailureCategory(error))
throw IllegalStateException(error.message ?: "Capture failed to start.", error)
@@ -173,7 +198,7 @@ class RecordingManagerImpl @Inject constructor(
}
override suspend fun scheduleRecording(request: RecordingRequest): Result<RecordingItem> = withContext(Dispatchers.IO) {
- runCatching {
+ runSuspendCatching {
val storage = ensureStorageStateSync()
if (!storage.isWritable) {
return@withContext Result.error("Recording storage is not writable.")
@@ -213,6 +238,29 @@ class RecordingManagerImpl @Inject constructor(
Result.success(Unit)
}
+ override suspend fun stopRecordingForForegroundServiceTimeout(recordingId: String): Result<Unit> = withContext(Dispatchers.IO) {
+ val run = recordingRunDao.getById(recordingId) ?: return@withContext Result.error("Recording not found")
+ foregroundServiceTimeoutRecordingIds.add(recordingId)
+ try {
+ cancelActiveJob(recordingId)
+ alarmScheduler.cancel(recordingId)
+ val now = System.currentTimeMillis()
+ recordingRunDao.update(
+ run.copy(
+ status = RecordingStatus.FAILED,
+ failureCategory = RecordingFailureCategory.UNKNOWN,
+ failureReason = FOREGROUND_SERVICE_TIMEOUT_REASON,
+ endedAtMs = now,
+ terminalAtMs = now,
+ updatedAt = now
+ )
+ )
+ } finally {
+ foregroundServiceTimeoutRecordingIds.remove(recordingId)
+ }
+ Result.success(Unit)
+ }
+
override suspend fun cancelRecording(recordingId: String): Result<Unit> = withContext(Dispatchers.IO) {
val run = recordingRunDao.getById(recordingId) ?: return@withContext Result.error("Recording not found")
cancelActiveJob(recordingId)
@@ -277,7 +325,7 @@ class RecordingManagerImpl @Inject constructor(
}
override suspend fun forceScheduleRecording(request: RecordingRequest): Result<RecordingItem> = withContext(Dispatchers.IO) {
- runCatching {
+ runSuspendCatching {
val storage = ensureStorageStateSync()
if (!storage.isWritable) {
return@withContext Result.error("Recording storage is not writable.")
@@ -347,7 +395,7 @@ class RecordingManagerImpl @Inject constructor(
}
override suspend fun retryRecording(recordingId: String): Result<Unit> = withContext(Dispatchers.IO) {
- runCatching {
+ runSuspendCatching {
ensureExactRecordingAlarmsAvailableOrThrow()
val run = recordingRunDao.getById(recordingId) ?: return@withContext Result.error("Recording not found")
val schedule = recordingScheduleDao.getById(run.scheduleId) ?: return@withContext Result.error("Recording schedule not found")
@@ -431,7 +479,7 @@ class RecordingManagerImpl @Inject constructor(
}
override suspend fun updateStorageConfig(config: RecordingStorageConfig): Result<RecordingStorageState> = withContext(Dispatchers.IO) {
- runCatching {
+ runSuspendCatching {
val existing = recordingStorageDao.get()
val (outputDirectory, availableBytes, isWritable) =
resolveStorageDetails(context, config.treeUri, config.localDirectory)
@@ -449,18 +497,20 @@ class RecordingManagerImpl @Inject constructor(
runCatching<Unit> {
ensureStorageState()
pruneExpiredRecordings()
- recordingRunDao.getAlarmManagedScheduledRuns()
+ val scheduledRuns = recordingRunDao.getAlarmManagedScheduledRuns()
.filter { it.scheduleEnabled && it.status == RecordingStatus.SCHEDULED }
- .forEach { run ->
+ if (!alarmScheduler.canScheduleExactAlarms()) {
+ scheduledRuns.forEach { run -> recordingRunDao.setExactAlarmArmed(run.id, false) }
+ } else scheduledRuns.forEach { run ->
if (run.scheduledEndMs <= System.currentTimeMillis()) {
markRunFailed(run.id, "Recording window expired before capture started.", RecordingFailureCategory.UNKNOWN)
} else {
when (val result = alarmScheduler.scheduleStart(run.id, run.scheduledStartMs)) {
is Result.Error -> markRunFailed(run.id, result.message, RecordingFailureCategory.UNKNOWN)
- else -> Unit
+ else -> recordingRunDao.setExactAlarmArmed(run.id, true)
}
}
- }
+ }
recordingRunDao.getRecordingRuns().forEach { run ->
if (run.scheduledEndMs <= System.currentTimeMillis()) {
stopRecording(run.id)
@@ -538,7 +588,7 @@ class RecordingManagerImpl @Inject constructor(
internal suspend fun onCaptureFinished(recordingId: String) {
val remaining = observeActiveRecordingCountSync().coerceAtLeast(0)
- if (remaining == 0) {
+ if (remaining == 0 && recordingId !in foregroundServiceTimeoutRecordingIds) {
recordingServiceLauncher.stopIfIdle(context)
}
}
@@ -561,7 +611,8 @@ class RecordingManagerImpl @Inject constructor(
RecordingSourceType.DASH -> return Result.error("DASH live recording is not supported yet.")
}
val maxVideoHeight = resolveMaxVideoHeightForCurrentNetwork()
- val job = scope.launch {
+ lateinit var activeCapture: ActiveCapture
+ val job = scope.launch(start = CoroutineStart.LAZY) {
try {
engine.capture(
source = source,
@@ -574,22 +625,25 @@ class RecordingManagerImpl @Inject constructor(
completeRun(run.id)
} catch (cancelled: CancellationException) {
Log.i("RecordingManager", "Capture cancelled for ${run.id}")
+ throw cancelled
} catch (unsupported: UnsupportedRecordingException) {
markRunFailed(run.id, unsupported.message ?: "Recording format is unsupported.", unsupported.category)
} catch (error: Throwable) {
markRunFailed(run.id, error.message ?: "Recording failed.", inferFailureCategory(error))
} finally {
- removeActiveJob(run.id)
+ removeActiveJob(run.id, activeCapture)
onCaptureFinished(run.id)
}
}
- registerActiveJob(run.id, job)
+ activeCapture = ActiveCapture(job)
+ registerActiveJob(run.id, activeCapture)
+ job.start()
return Result.success(Unit)
}
private suspend fun migrateLegacyStateIfNeeded() {
if (!legacyStateFile.exists()) return
- val hasExistingRuns = runCatching {
+ val hasExistingRuns = runSuspendCatching {
recordingRunDao.getByStatus(RecordingStatus.SCHEDULED).isNotEmpty() || recordingRunDao.getRecordingRuns().isNotEmpty()
}.getOrDefault(false)
if (hasExistingRuns) return
@@ -1070,15 +1124,23 @@ class RecordingManagerImpl @Inject constructor(
}
}
- private suspend fun registerActiveJob(id: String, job: Job) {
- activeJobsMutex.withLock { activeJobs[id] = job }
+ private suspend fun registerActiveJob(id: String, capture: ActiveCapture) {
+ activeJobsMutex.withLock { activeJobs[id] = capture }
}
- private suspend fun removeActiveJob(id: String): Job? =
- activeJobsMutex.withLock { activeJobs.remove(id) }
+ private suspend fun removeActiveJob(id: String, expected: ActiveCapture? = null): ActiveCapture? =
+ activeJobsMutex.withLock {
+ val current = activeJobs[id] ?: return@withLock null
+ if (expected != null && current !== expected) return@withLock null
+ activeJobs.remove(id)
+ }
private suspend fun cancelActiveJob(id: String) {
- removeActiveJob(id)?.cancel()
+ val capture = activeJobsMutex.withLock { activeJobs[id] }
+ capture?.let {
+ it.cancelAndJoin()
+ removeActiveJob(id, it)
+ }
}
private suspend fun isActiveJob(id: String): Boolean =
@@ -1122,7 +1184,8 @@ class RecordingManagerImpl @Inject constructor(
scheduleEnabled = scheduleEnabled,
priority = priority,
failureReason = failureReason,
- terminalAtMs = terminalAtMs
+ terminalAtMs = terminalAtMs,
+ exactAlarmArmed = exactAlarmArmed
)
}
diff --git a/data/src/main/java/com/streamvault/data/manager/recording/RecordingCaptureEngine.kt b/data/src/main/java/com/streamvault/data/manager/recording/RecordingCaptureEngine.kt
index 7d51a475..bae30b29 100644
--- a/data/src/main/java/com/streamvault/data/manager/recording/RecordingCaptureEngine.kt
+++ b/data/src/main/java/com/streamvault/data/manager/recording/RecordingCaptureEngine.kt
@@ -1,6 +1,7 @@
package com.streamvault.data.manager.recording
import android.content.ContentResolver
+import com.streamvault.data.remote.http.useCancellableResponse
import com.streamvault.domain.model.RecordingFailureCategory
import com.streamvault.domain.model.RecordingSourceType
import java.io.ByteArrayOutputStream
@@ -77,7 +78,7 @@ class TsPassThroughCaptureEngine @Inject constructor(
source.userAgent?.takeIf { it.isNotBlank() }?.let { header("User-Agent", it) }
source.headers.forEach { (key, value) -> header(key, value) }
}.build()
- okHttpClient.newCall(request).execute().use { response ->
+ okHttpClient.newCall(request).useCancellableResponse { response ->
if (!response.isSuccessful) throw IOException("Recording stream failed with HTTP ${response.code}")
val body = response.body ?: throw IOException("Recording stream returned an empty body")
body.byteStream().use { input ->
@@ -200,7 +201,9 @@ class HlsLiveCaptureEngine @Inject constructor(
}
val segKey = segment.key?.takeIf { it.method.equals("AES-128", ignoreCase = true) }
val payload = if (segKey != null) {
- val keyBytes = keyCache.getOrPut(segKey.uri) { fetchBytes(segKey.uri, headers) }
+ val keyBytes = keyCache[segKey.uri] ?: fetchBytes(segKey.uri, headers).also {
+ keyCache[segKey.uri] = it
+ }
decryptAes128(bytes, keyBytes, segKey.iv, segment.mediaSequenceNumber)
} else {
bytes
@@ -231,21 +234,21 @@ class HlsLiveCaptureEngine @Inject constructor(
}
}
- private fun fetchText(url: String, headers: Map<String, String>): String {
+ private suspend fun fetchText(url: String, headers: Map<String, String>): String {
val request = Request.Builder().url(url).apply {
headers.forEach { (key, value) -> header(key, value) }
}.build()
- okHttpClient.newCall(request).execute().use { response ->
+ okHttpClient.newCall(request).useCancellableResponse { response ->
if (!response.isSuccessful) throw IOException("Recording stream failed with HTTP ${response.code}")
return response.body?.string().orEmpty()
}
}
- private fun fetchBytes(url: String, headers: Map<String, String>): ByteArray {
+ private suspend fun fetchBytes(url: String, headers: Map<String, String>): ByteArray {
val request = Request.Builder().url(url).apply {
headers.forEach { (key, value) -> header(key, value) }
}.build()
- okHttpClient.newCall(request).execute().use { response ->
+ okHttpClient.newCall(request).useCancellableResponse { response ->
if (!response.isSuccessful) throw IOException("Recording stream failed with HTTP ${response.code}")
return response.body?.bytes() ?: ByteArray(0)
}
diff --git a/data/src/main/java/com/streamvault/data/manager/recording/RecordingForegroundService.kt b/data/src/main/java/com/streamvault/data/manager/recording/RecordingForegroundService.kt
index 9a9a74e2..c79ed29f 100644
--- a/data/src/main/java/com/streamvault/data/manager/recording/RecordingForegroundService.kt
+++ b/data/src/main/java/com/streamvault/data/manager/recording/RecordingForegroundService.kt
@@ -14,6 +14,7 @@ import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import com.streamvault.data.R
import com.streamvault.domain.manager.RecordingManager
+import com.streamvault.domain.model.RecordingStatus
import dagger.hilt.EntryPoint
import dagger.hilt.InstallIn
import dagger.hilt.android.EntryPointAccessors
@@ -25,6 +26,7 @@ import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.collectLatest
+import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
class RecordingForegroundService : Service() {
@@ -107,6 +109,29 @@ class RecordingForegroundService : Service() {
super.onDestroy()
}
+ override fun onTimeout(startId: Int, fgsType: Int) {
+ Log.e(TAG, "Foreground-service time allowance exhausted; stopping active recordings")
+ idleStopJob?.cancel()
+ serviceScope.launch {
+ try {
+ val manager = entryPoint().recordingManager()
+ manager.observeRecordingItems().first()
+ .asSequence()
+ .filter { it.status == RecordingStatus.RECORDING }
+ .forEach { recording ->
+ runCatching {
+ manager.stopRecordingForForegroundServiceTimeout(recording.id)
+ }.onFailure { error ->
+ Log.e(TAG, "Failed to stop recording ${recording.id} after service timeout", error)
+ }
+ }
+ } finally {
+ stopForeground(STOP_FOREGROUND_REMOVE)
+ stopSelf(startId)
+ }
+ }
+ }
+
override fun onBind(intent: Intent?): IBinder? = null
private fun ensureNotificationObserver() {
@@ -207,6 +232,7 @@ class RecordingForegroundService : Service() {
}
companion object {
+ private const val TAG = "RecordingFgService"
private const val CHANNEL_ID = "streamvault_recording"
private const val NOTIFICATION_ID = 4102
private const val IDLE_GRACE_MS = 3_000L
diff --git a/data/src/main/java/com/streamvault/data/manager/recording/RecordingReconcileWorker.kt b/data/src/main/java/com/streamvault/data/manager/recording/RecordingReconcileWorker.kt
index 4e33446b..f36dffc3 100644
--- a/data/src/main/java/com/streamvault/data/manager/recording/RecordingReconcileWorker.kt
+++ b/data/src/main/java/com/streamvault/data/manager/recording/RecordingReconcileWorker.kt
@@ -2,6 +2,7 @@ package com.streamvault.data.manager.recording
import android.content.Context
import androidx.work.CoroutineWorker
+import androidx.work.BackoffPolicy
import androidx.work.ExistingPeriodicWorkPolicy
import androidx.work.ExistingWorkPolicy
import androidx.work.OneTimeWorkRequestBuilder
@@ -30,16 +31,13 @@ class RecordingReconcileWorker(
applicationContext,
RecordingWorkerEntryPoint::class.java
).recordingManager()
- return when (manager.reconcileRecordingState()) {
- is com.streamvault.domain.model.Result.Success -> Result.success()
- is com.streamvault.domain.model.Result.Error -> Result.retry()
- com.streamvault.domain.model.Result.Loading -> Result.retry()
- }
+ return reconciliationWorkResult(manager.reconcileRecordingState(), runAttemptCount)
}
companion object {
private const val PERIODIC_WORK_NAME = "RecordingReconcileWorker"
private const val ONE_SHOT_WORK_NAME = "RecordingReconcileWorkerOneShot"
+ private const val MAX_ONE_SHOT_ATTEMPTS = 3
fun enqueuePeriodic(context: Context) {
val request = PeriodicWorkRequestBuilder<RecordingReconcileWorker>(6, TimeUnit.HOURS)
@@ -52,7 +50,9 @@ class RecordingReconcileWorker(
}
fun enqueueOneShot(context: Context) {
- val request = OneTimeWorkRequestBuilder<RecordingReconcileWorker>().build()
+ val request = OneTimeWorkRequestBuilder<RecordingReconcileWorker>()
+ .setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 30, TimeUnit.SECONDS)
+ .build()
WorkManager.getInstance(context).enqueueUniqueWork(
ONE_SHOT_WORK_NAME,
ExistingWorkPolicy.REPLACE,
@@ -61,3 +61,15 @@ class RecordingReconcileWorker(
}
}
}
+
+internal fun reconciliationWorkResult(
+ result: com.streamvault.domain.model.Result<Unit>,
+ runAttemptCount: Int,
+): androidx.work.ListenableWorker.Result = when (result) {
+ is com.streamvault.domain.model.Result.Success -> androidx.work.ListenableWorker.Result.success()
+ is com.streamvault.domain.model.Result.Error -> {
+ if (runAttemptCount >= 2) androidx.work.ListenableWorker.Result.failure()
+ else androidx.work.ListenableWorker.Result.retry()
+ }
+ com.streamvault.domain.model.Result.Loading -> androidx.work.ListenableWorker.Result.failure()
+}
diff --git a/data/src/main/java/com/streamvault/data/manager/recording/RecordingRestoreReceiver.kt b/data/src/main/java/com/streamvault/data/manager/recording/RecordingRestoreReceiver.kt
index 7341683a..76243b7c 100644
--- a/data/src/main/java/com/streamvault/data/manager/recording/RecordingRestoreReceiver.kt
+++ b/data/src/main/java/com/streamvault/data/manager/recording/RecordingRestoreReceiver.kt
@@ -1,5 +1,6 @@
package com.streamvault.data.manager.recording
+import android.app.AlarmManager
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
@@ -9,8 +10,8 @@ class RecordingRestoreReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
when (intent.action) {
Intent.ACTION_BOOT_COMPLETED,
- Intent.ACTION_MY_PACKAGE_REPLACED -> {
- RecordingForegroundService.requestReconcile(context)
+ Intent.ACTION_MY_PACKAGE_REPLACED,
+ AlarmManager.ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED -> {
RecordingReconcileWorker.enqueueOneShot(context)
}
}
diff --git a/data/src/main/java/com/streamvault/data/manager/recording/RecordingSourceResolver.kt b/data/src/main/java/com/streamvault/data/manager/recording/RecordingSourceResolver.kt
index b0c21246..c40418c3 100644
--- a/data/src/main/java/com/streamvault/data/manager/recording/RecordingSourceResolver.kt
+++ b/data/src/main/java/com/streamvault/data/manager/recording/RecordingSourceResolver.kt
@@ -1,6 +1,7 @@
package com.streamvault.data.manager.recording
import com.streamvault.data.local.dao.ProviderDao
+import com.streamvault.data.remote.http.useCancellableResponse
import com.streamvault.data.remote.xtream.ResolvedStreamUrl
import com.streamvault.data.remote.xtream.XtreamStreamUrlResolver
import com.streamvault.domain.model.ContentType
@@ -10,6 +11,7 @@ import java.io.IOException
import java.util.Locale
import javax.inject.Inject
import javax.inject.Singleton
+import kotlinx.coroutines.CancellationException
import okhttp3.OkHttpClient
import okhttp3.Request
@@ -66,7 +68,7 @@ class RecordingSourceResolver @Inject constructor(
)
}
- private fun sniffSourceType(resolved: ResolvedStreamUrl): RecordingSourceType {
+ private suspend fun sniffSourceType(resolved: ResolvedStreamUrl): RecordingSourceType {
// Prefer the container extension reported by the URL resolver (e.g. from the
// Xtream internal token) — this avoids a network probe that many IPTV servers
// reject with 404/416 when a Range header is present.
@@ -87,12 +89,12 @@ class RecordingSourceResolver @Inject constructor(
}
}
- private fun probeAdaptiveType(resolved: ResolvedStreamUrl): RecordingSourceType {
+ private suspend fun probeAdaptiveType(resolved: ResolvedStreamUrl): RecordingSourceType {
// Try HEAD first — lighter and avoids Range-header rejections.
- val headResult = runCatching {
+ val headResult = try {
val headRequest = buildRequest(resolved, isHead = true)
- okHttpClient.newCall(headRequest).execute().use { response ->
- if (!response.isSuccessful) return@use null
+ okHttpClient.newCall(headRequest).useCancellableResponse { response ->
+ if (!response.isSuccessful) return@useCancellableResponse null
val contentType = response.header("Content-Type").orEmpty().lowercase(Locale.ROOT)
when {
"application/vnd.apple.mpegurl" in contentType || "application/x-mpegurl" in contentType -> RecordingSourceType.HLS
@@ -101,15 +103,19 @@ class RecordingSourceResolver @Inject constructor(
else -> null
}
}
- }.getOrNull()
+ } catch (e: CancellationException) {
+ throw e
+ } catch (_: IOException) {
+ null
+ }
if (headResult != null) return headResult
// Fall back to a small GET to inspect the body prefix.
val request = buildRequest(resolved, isHead = false)
- val bodyPrefix = runCatching {
- okHttpClient.newCall(request).execute().use { response ->
- if (!response.isSuccessful) return@use ""
+ val bodyPrefix = try {
+ okHttpClient.newCall(request).useCancellableResponse { response ->
+ if (!response.isSuccessful) return@useCancellableResponse ""
val contentType = response.header("Content-Type").orEmpty().lowercase(Locale.ROOT)
when {
"application/vnd.apple.mpegurl" in contentType || "application/x-mpegurl" in contentType -> return RecordingSourceType.HLS
@@ -117,7 +123,11 @@ class RecordingSourceResolver @Inject constructor(
}
response.body?.string().orEmpty().take(1024)
}
- }.getOrDefault("")
+ } catch (e: CancellationException) {
+ throw e
+ } catch (_: IOException) {
+ ""
+ }
return when {
bodyPrefix.contains("#EXTM3U", ignoreCase = true) -> RecordingSourceType.HLS
diff --git a/data/src/main/java/com/streamvault/data/manager/recording/RecordingSupport.kt b/data/src/main/java/com/streamvault/data/manager/recording/RecordingSupport.kt
index 34c5c6af..344d9c90 100644
--- a/data/src/main/java/com/streamvault/data/manager/recording/RecordingSupport.kt
+++ b/data/src/main/java/com/streamvault/data/manager/recording/RecordingSupport.kt
@@ -45,6 +45,7 @@ internal fun RecordingRunWithSchedule.toDomain(): RecordingItem = RecordingItem(
lastProgressAtMs = lastProgressAtMs,
failureCategory = failureCategory,
scheduleEnabled = scheduleEnabled,
+ exactAlarmArmed = exactAlarmArmed,
priority = priority,
failureReason = failureReason,
terminalAtMs = terminalAtMs
diff --git a/data/src/main/java/com/streamvault/data/manager/reminder/ProgramReminderNotifier.kt b/data/src/main/java/com/streamvault/data/manager/reminder/ProgramReminderNotifier.kt
index 804120b5..a81ea62e 100644
--- a/data/src/main/java/com/streamvault/data/manager/reminder/ProgramReminderNotifier.kt
+++ b/data/src/main/java/com/streamvault/data/manager/reminder/ProgramReminderNotifier.kt
@@ -8,6 +8,7 @@ import android.os.Build
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import com.streamvault.data.local.entity.ProgramReminderEntity
+import com.streamvault.domain.model.Result
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
import javax.inject.Singleton
@@ -17,7 +18,11 @@ class ProgramReminderNotifier @Inject constructor(
@ApplicationContext private val context: Context
) {
- fun showReminder(reminder: ProgramReminderEntity) {
+ fun showReminder(reminder: ProgramReminderEntity): Result<Unit> {
+ val notificationManager = NotificationManagerCompat.from(context)
+ if (!notificationManager.areNotificationsEnabled()) {
+ return Result.error("Notifications are disabled for program reminders.")
+ }
createChannelIfNeeded()
val now = System.currentTimeMillis()
val minutesUntilStart = ((reminder.programStartTime - now) / 60000L).coerceAtLeast(0L)
@@ -36,9 +41,10 @@ class ProgramReminderNotifier @Inject constructor(
.setAutoCancel(true)
.setContentIntent(buildLaunchPendingIntent())
.build()
- runCatching {
- NotificationManagerCompat.from(context).notify(reminderNotificationTag(reminder.id), 0, notification)
- }
+ return runCatching {
+ notificationManager.notify(reminderNotificationTag(reminder.id), 0, notification)
+ Result.success(Unit)
+ }.getOrElse { error -> Result.error("Unable to show program reminder.", error) }
}
private fun reminderNotificationTag(reminderId: Long): String = "program-reminder:$reminderId"
diff --git a/data/src/main/java/com/streamvault/data/manager/reminder/ProgramReminderRestoreReceiver.kt b/data/src/main/java/com/streamvault/data/manager/reminder/ProgramReminderRestoreReceiver.kt
index fe3386e2..2ceb3f8d 100644
--- a/data/src/main/java/com/streamvault/data/manager/reminder/ProgramReminderRestoreReceiver.kt
+++ b/data/src/main/java/com/streamvault/data/manager/reminder/ProgramReminderRestoreReceiver.kt
@@ -3,6 +3,7 @@ package com.streamvault.data.manager.reminder
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
+import android.app.AlarmManager
import com.streamvault.data.manager.ProgramReminderManagerImpl
import dagger.hilt.EntryPoint
import dagger.hilt.InstallIn
@@ -24,7 +25,8 @@ class ProgramReminderRestoreReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
when (intent.action) {
Intent.ACTION_BOOT_COMPLETED,
- Intent.ACTION_MY_PACKAGE_REPLACED -> {
+ Intent.ACTION_MY_PACKAGE_REPLACED,
+ AlarmManager.ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED -> {
val pendingResult = goAsync()
val appContext = context.applicationContext
CoroutineScope(SupervisorJob() + Dispatchers.IO).launch {
diff --git a/data/src/main/java/com/streamvault/data/parser/M3uParser.kt b/data/src/main/java/com/streamvault/data/parser/M3uParser.kt
index 43295964..40d72ab0 100644
--- a/data/src/main/java/com/streamvault/data/parser/M3uParser.kt
+++ b/data/src/main/java/com/streamvault/data/parser/M3uParser.kt
@@ -4,9 +4,11 @@ import com.streamvault.domain.model.Channel
import com.streamvault.domain.model.Movie
import com.streamvault.domain.util.ChannelNormalizer
import com.streamvault.domain.util.StreamEntryUrlPolicy
+import java.io.BufferedInputStream
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
+import java.net.URI
/**
* Robust M3U parser that handles real-world malformed playlists.
@@ -23,9 +25,11 @@ import java.io.InputStreamReader
class M3uParser {
data class M3uHeader(
- val tvgUrl: String? = null,
+ val tvgUrls: List<String> = emptyList(),
val userAgent: String? = null
- )
+ ) {
+ val tvgUrl: String? get() = tvgUrls.firstOrNull()
+ }
data class M3uEntry(
val name: String,
@@ -54,7 +58,7 @@ class M3uParser {
)
fun parse(inputStream: InputStream): ParseResult {
- val reader = BufferedReader(InputStreamReader(inputStream, Charsets.UTF_8))
+ val reader = playlistReader(inputStream)
val entries = mutableListOf<M3uEntry>()
var header = M3uHeader()
var pendingExtinf: ParsedExtinf? = null
@@ -94,9 +98,10 @@ class M3uParser {
suspend fun parseStreaming(
inputStream: InputStream,
onHeader: suspend (M3uHeader) -> Unit = {},
- onEntry: suspend (M3uEntry) -> Unit
+ onEntry: suspend (M3uEntry) -> Unit,
+ onInvalidEntry: suspend () -> Unit = {}
) {
- val reader = BufferedReader(InputStreamReader(inputStream, Charsets.UTF_8))
+ val reader = playlistReader(inputStream)
var header = M3uHeader()
var pendingExtinf: ParsedExtinf? = null
@@ -122,7 +127,9 @@ class M3uParser {
pendingExtinf = pendingExtinf?.let { applyPendingDirective(it, line) }
}
pendingExtinf != null -> {
- parseEntry(pendingExtinf!!, line, header.userAgent)?.let { onEntry(it) }
+ parseEntry(pendingExtinf!!, line, header.userAgent)
+ ?.let { onEntry(it) }
+ ?: onInvalidEntry()
pendingExtinf = null
}
else -> {
@@ -212,21 +219,41 @@ class M3uParser {
private fun parseHeader(line: String): M3uHeader {
val attributes = parseAttributes(line, line.indexOf(' '))
return M3uHeader(
- tvgUrl = extractHeaderEpgUrl(attributes),
+ tvgUrls = extractHeaderEpgUrls(attributes),
userAgent = attributes["user-agent"]
)
}
- private fun extractHeaderEpgUrl(attributes: Map<String, String>): String? {
+ private fun extractHeaderEpgUrls(attributes: Map<String, String>): List<String> {
val rawValue = headerEpgAttributes
.firstNotNullOfOrNull { key -> attributes[key]?.takeIf { it.isNotBlank() } }
- ?: return null
+ ?: return emptyList()
return rawValue
.split(',')
.asSequence()
.map { it.trim() }
- .firstOrNull { it.isNotEmpty() }
+ .filter { it.isNotEmpty() }
+ .distinct()
+ .take(MAX_HEADER_EPG_URLS)
+ .toList()
+ }
+
+ private fun playlistReader(inputStream: InputStream): BufferedReader {
+ val buffered = inputStream as? BufferedInputStream ?: BufferedInputStream(inputStream, 64 * 1024)
+ buffered.mark(3)
+ val first = buffered.read()
+ val second = buffered.read()
+ val third = buffered.read()
+ buffered.reset()
+ val (bomLength, charset) = when {
+ first == 0xEF && second == 0xBB && third == 0xBF -> 3 to Charsets.UTF_8
+ first == 0xFF && second == 0xFE -> 2 to Charsets.UTF_16LE
+ first == 0xFE && second == 0xFF -> 2 to Charsets.UTF_16BE
+ else -> 0 to Charsets.UTF_8
+ }
+ repeat(bomLength) { buffered.read() }
+ return BufferedReader(InputStreamReader(buffered, charset))
}
private fun parseStandaloneGroupTitle(line: String): String? {
@@ -428,15 +455,20 @@ class M3uParser {
"tvg-url",
"url-xml"
)
+ private const val MAX_HEADER_EPG_URLS = 8
/** Exposed for callers outside M3uParser (e.g. SyncManager) to avoid duplicate logic. */
fun isVodEntry(entry: M3uEntry): Boolean {
val url = entry.url.lowercase()
+ val path = runCatching { URI(entry.url).path }
+ .getOrNull()
+ ?.lowercase()
+ ?: entry.url.substringBefore('#').substringBefore('?').lowercase()
val group = entry.groupTitle.lowercase()
- return url.endsWith(".mp4") ||
- url.endsWith(".mkv") ||
- url.endsWith(".avi") ||
+ return path.endsWith(".mp4") ||
+ path.endsWith(".mkv") ||
+ path.endsWith(".avi") ||
url.contains("/movie/") ||
group.contains("movie") ||
group.contains("vod") ||
diff --git a/data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt b/data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt
index a1564577..37088761 100644
--- a/data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt
+++ b/data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt
@@ -210,6 +210,7 @@ class PreferencesRepository @Inject constructor(
val DOWNLOAD_TREE_URI = stringPreferencesKey("download_tree_uri")
val MAX_CONCURRENT_STREAMS = intPreferencesKey("max_concurrent_streams")
val LAST_APP_UPDATE_CHECK_TIMESTAMP = longPreferencesKey("last_app_update_check_timestamp")
+ val LAST_APP_UPDATE_FAILURE_TIMESTAMP = longPreferencesKey("last_app_update_failure_timestamp")
val APP_UPDATE_DOWNLOAD_ID = longPreferencesKey("app_update_download_id")
val APP_UPDATE_DOWNLOAD_VERSION_NAME = stringPreferencesKey("app_update_download_version_name")
val APP_UPDATE_DOWNLOADED_VERSION_NAME = stringPreferencesKey("app_update_downloaded_version_name")
@@ -616,6 +617,10 @@ class PreferencesRepository @Inject constructor(
preferences[PreferencesKeys.LAST_APP_UPDATE_CHECK_TIMESTAMP]?.takeIf { it > 0L }
}
+ val lastAppUpdateFailureTimestamp: Flow<Long?> = context.dataStore.data.map { preferences ->
+ preferences[PreferencesKeys.LAST_APP_UPDATE_FAILURE_TIMESTAMP]?.takeIf { it > 0L }
+ }
+
val appUpdateDownloadId: Flow<Long?> = context.dataStore.data.map { preferences ->
preferences[PreferencesKeys.APP_UPDATE_DOWNLOAD_ID]?.takeIf { it > 0L }
}
@@ -780,6 +785,16 @@ class PreferencesRepository @Inject constructor(
}
}
+ suspend fun setLastAppUpdateFailureTimestamp(timestampMs: Long?) {
+ context.dataStore.edit { preferences ->
+ if (timestampMs == null || timestampMs <= 0L) {
+ preferences.remove(PreferencesKeys.LAST_APP_UPDATE_FAILURE_TIMESTAMP)
+ } else {
+ preferences[PreferencesKeys.LAST_APP_UPDATE_FAILURE_TIMESTAMP] = timestampMs
+ }
+ }
+ }
+
suspend fun setAppUpdateDownloadId(downloadId: Long?) {
context.dataStore.edit { preferences ->
if (downloadId == null || downloadId <= 0L) {
diff --git a/data/src/main/java/com/streamvault/data/remote/http/CancellableOkHttp.kt b/data/src/main/java/com/streamvault/data/remote/http/CancellableOkHttp.kt
new file mode 100644
index 00000000..48faddb0
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/remote/http/CancellableOkHttp.kt
@@ -0,0 +1,84 @@
+package com.streamvault.data.remote.http
+
+import java.io.IOException
+import kotlin.coroutines.resume
+import kotlin.coroutines.resumeWithException
+import kotlinx.coroutines.CoroutineStart
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.Job
+import kotlinx.coroutines.awaitCancellation
+import kotlinx.coroutines.cancelAndJoin
+import kotlinx.coroutines.currentCoroutineContext
+import kotlinx.coroutines.ensureActive
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.suspendCancellableCoroutine
+import okhttp3.Call
+import okhttp3.Callback
+import okhttp3.Response
+
+/**
+ * Owns an OkHttp response for the complete lifetime of [block].
+ *
+ * The cancellation watcher remains installed after response headers arrive, so cancellation
+ * also interrupts a thread blocked while reading the response body.
+ */
+suspend inline fun <T> Call.useCancellableResponse(
+ block: suspend (Response) -> T
+): T {
+ val owned = openCancellableResponse()
+ try {
+ return block(owned.response)
+ } catch (error: Throwable) {
+ currentCoroutineContext().ensureActive()
+ throw error
+ } finally {
+ owned.close()
+ }
+}
+
+@PublishedApi
+internal class CancellableHttpResponse internal constructor(
+ val response: Response,
+ private val cancellationWatcher: Job
+) : AutoCloseable {
+ override fun close() {
+ response.close()
+ cancellationWatcher.cancel()
+ }
+}
+
+@PublishedApi
+internal suspend fun Call.openCancellableResponse(): CancellableHttpResponse {
+ val call = this
+ val parentJob = currentCoroutineContext()[Job]
+ ?: error("Cancellable HTTP calls require a coroutine Job")
+ val cancellationWatcher = CoroutineScope(parentJob + Dispatchers.Unconfined).launch(
+ start = CoroutineStart.UNDISPATCHED
+ ) {
+ try {
+ awaitCancellation()
+ } finally {
+ call.cancel()
+ }
+ }
+ return try {
+ CancellableHttpResponse(call.awaitResponseHeaders(), cancellationWatcher)
+ } catch (error: Throwable) {
+ cancellationWatcher.cancelAndJoin()
+ throw error
+ }
+}
+
+private suspend fun Call.awaitResponseHeaders(): Response = suspendCancellableCoroutine { continuation ->
+ continuation.invokeOnCancellation { cancel() }
+ enqueue(object : Callback {
+ override fun onFailure(call: Call, e: IOException) {
+ if (continuation.isActive) continuation.resumeWithException(e)
+ }
+
+ override fun onResponse(call: Call, response: Response) {
+ if (continuation.isActive) continuation.resume(response) else response.close()
+ }
+ })
+}
diff --git a/data/src/main/java/com/streamvault/data/remote/jellyfin/JellyfinImageAuthInterceptor.kt b/data/src/main/java/com/streamvault/data/remote/jellyfin/JellyfinImageAuthInterceptor.kt
index 6a6e2302..f1fb0446 100644
--- a/data/src/main/java/com/streamvault/data/remote/jellyfin/JellyfinImageAuthInterceptor.kt
+++ b/data/src/main/java/com/streamvault/data/remote/jellyfin/JellyfinImageAuthInterceptor.kt
@@ -31,8 +31,13 @@ class JellyfinImageAuthInterceptor @Inject constructor(
return chain.proceed(request)
}
- val provider = jellyfinProviders().firstOrNull { candidate -> candidate.matches(request.url) }
+ // Image credentials are account-scoped. A URL without this marker is
+ // deliberately not guessed from its host: two accounts may share it.
+ val providerId = request.url.queryParameter("streamvault_provider_id")?.toLongOrNull()
?: return chain.proceed(request)
+ val provider = jellyfinProviders().firstOrNull { it.id == providerId }
+ ?: return chain.proceed(request)
+ if (!provider.matches(request.url)) return chain.proceed(request)
val accessToken = runCatching { credentialCrypto.decryptIfNeeded(provider.password) }
.getOrNull()
?.takeIf { it.isNotBlank() }
@@ -40,6 +45,7 @@ class JellyfinImageAuthInterceptor @Inject constructor(
return chain.proceed(
request.newBuilder()
+ .url(request.url.newBuilder().removeAllQueryParameters("streamvault_provider_id").build())
.header(
"Authorization",
buildJellyfinAuthorizationHeader(provider.serverUrl, provider.username, accessToken)
@@ -74,4 +80,4 @@ class JellyfinImageAuthInterceptor @Inject constructor(
return baseSegments.indices.all { index -> requestSegments[index] == baseSegments[index] }
}
-}
\ No newline at end of file
+}
diff --git a/data/src/main/java/com/streamvault/data/remote/jellyfin/JellyfinProvider.kt b/data/src/main/java/com/streamvault/data/remote/jellyfin/JellyfinProvider.kt
index 8669b812..5118b9ef 100644
--- a/data/src/main/java/com/streamvault/data/remote/jellyfin/JellyfinProvider.kt
+++ b/data/src/main/java/com/streamvault/data/remote/jellyfin/JellyfinProvider.kt
@@ -6,16 +6,22 @@ import com.google.gson.reflect.TypeToken
import com.streamvault.data.local.entity.EpisodeEntity
import com.streamvault.data.local.entity.MovieEntity
import com.streamvault.data.local.entity.SeriesEntity
+import com.streamvault.data.remote.http.useCancellableResponse
import com.streamvault.domain.model.Provider
import com.streamvault.domain.model.Result
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
+import java.io.FilterInputStream
+import java.io.IOException
+import java.io.InputStream
+import java.io.InputStreamReader
import java.util.concurrent.TimeUnit
import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.delay
+import kotlinx.coroutines.CancellationException
import java.net.URLEncoder
@Singleton
@@ -29,6 +35,10 @@ class JellyfinProvider @Inject constructor(
private const val REQUEST_TIMEOUT_SECONDS = 60L
private const val QUICK_CONNECT_TIMEOUT_MILLIS = 120_000L
private const val QUICK_CONNECT_POLL_INTERVAL_MILLIS = 2_000L
+ /** Kept deliberately small: catalog endpoints are explicitly paged. */
+ const val PAGE_SIZE = 100
+ const val MAX_PAGE_BYTES = 4L * 1024L * 1024L
+ const val MAX_EPISODES_PER_SERIES = 10_000
}
private val itemsResponseType = object : TypeToken<JellyfinItemsResponseDto>() {}.type
@@ -42,6 +52,7 @@ class JellyfinProvider @Inject constructor(
}
Result.success(session.accessToken)
} catch (e: Exception) {
+ if (e is CancellationException) throw e
Result.error("Jellyfin authentication failed: ${e.message}", e)
}
}
@@ -75,13 +86,14 @@ class JellyfinProvider @Inject constructor(
}
Result.error("Quick Connect timed out waiting for approval")
} catch (e: Exception) {
+ if (e is CancellationException) throw e
Result.error("Jellyfin Quick Connect failed: ${e.message}", e)
}
}
- suspend fun fetchMovies(provider: Provider): Result<List<MovieEntity>> = try {
- val items = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) {
- fetchItems(provider, "/Items", mapOf(
+ suspend fun fetchMoviesPage(provider: Provider, startIndex: Int): Result<JellyfinPage<MovieEntity>> = try {
+ val page = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) {
+ fetchItemsPage(provider, "/Items", startIndex, mapOf(
"IncludeItemTypes" to "Movie",
"Recursive" to "true",
"EnableImages" to "false",
@@ -89,14 +101,15 @@ class JellyfinProvider @Inject constructor(
"Fields" to "Overview,ProviderIds,ProductionYear,PremiereDate,RunTimeTicks,Genres,CommunityRating,ImageTags,BackdropImageTags,MediaSources,DateCreated,Path"
))
}
- Result.success(items.map { item -> buildMovieEntity(item, provider) })
+ Result.success(page.map { item -> buildMovieEntity(item, provider) })
} catch (e: Exception) {
+ if (e is CancellationException) throw e
Result.error("Failed to load Jellyfin movies: ${e.message}", e)
}
- suspend fun fetchSeries(provider: Provider): Result<List<SeriesEntity>> = try {
- val items = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) {
- fetchItems(provider, "/Items", mapOf(
+ suspend fun fetchSeriesPage(provider: Provider, startIndex: Int): Result<JellyfinPage<SeriesEntity>> = try {
+ val page = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) {
+ fetchItemsPage(provider, "/Items", startIndex, mapOf(
"IncludeItemTypes" to "Series",
"Recursive" to "true",
"EnableImages" to "false",
@@ -104,21 +117,37 @@ class JellyfinProvider @Inject constructor(
"Fields" to "Overview,ProviderIds,ProductionYear,PremiereDate,RunTimeTicks,Genres,CommunityRating,ImageTags,BackdropImageTags,DateCreated,DateLastMediaAdded,Path"
))
}
- Result.success(items.map { item -> buildSeriesEntity(item, provider) })
+ Result.success(page.map { item -> buildSeriesEntity(item, provider) })
} catch (e: Exception) {
+ if (e is CancellationException) throw e
Result.error("Failed to load Jellyfin series: ${e.message}", e)
}
suspend fun fetchEpisodes(provider: Provider, seriesRemoteId: String, seriesLocalId: Long): Result<List<EpisodeEntity>> = try {
- val response = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) {
- fetchSeriesEpisodes(provider, seriesRemoteId)
- }
- Result.success(response.map { item -> buildEpisodeEntity(item, provider, seriesLocalId) })
+ val episodes = ArrayList<EpisodeEntity>()
+ var startIndex = 0
+ var expectedTotal: Int? = null
+ do {
+ val page = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) {
+ fetchSeriesEpisodesPage(provider, seriesRemoteId, startIndex)
+ }
+ expectedTotal = expectedTotal ?: page.totalRecordCount
+ if (page.totalRecordCount != expectedTotal || page.items.isEmpty() && startIndex < expectedTotal) {
+ throw JellyfinPaginationException("Jellyfin episode catalog changed or ended early")
+ }
+ episodes += page.items.map { item -> buildEpisodeEntity(item, provider, seriesLocalId) }
+ if (episodes.size > MAX_EPISODES_PER_SERIES) {
+ throw JellyfinCatalogLimitException("Jellyfin series exceeds $MAX_EPISODES_PER_SERIES episodes")
+ }
+ startIndex = page.nextStartIndex
+ } while (startIndex < (expectedTotal ?: 0))
+ Result.success(episodes)
} catch (e: Exception) {
+ if (e is CancellationException) throw e
Result.error("Failed to load Jellyfin episodes: ${e.message}", e)
}
- private fun authenticateSession(serverUrl: String, username: String, password: String): JellyfinAuthenticatedSession {
+ private suspend fun authenticateSession(serverUrl: String, username: String, password: String): JellyfinAuthenticatedSession {
val url = "${serverUrl.trimEnd('/')}/Users/AuthenticateByName"
val payload = gson.toJson(JellyfinAuthenticateRequestDto(username = username, password = password))
val request = Request.Builder()
@@ -138,7 +167,7 @@ class JellyfinProvider @Inject constructor(
return JellyfinAuthenticatedSession(accessToken = token, userId = userId, userName = parsed.user?.name ?: username)
}
- private fun initiateQuickConnect(serverUrl: String): JellyfinQuickConnectInitiateResponseDto {
+ private suspend fun initiateQuickConnect(serverUrl: String): JellyfinQuickConnectInitiateResponseDto {
val url = buildUrl(serverUrl, "/QuickConnect/Initiate", emptyMap())
val request = Request.Builder()
.url(url)
@@ -149,7 +178,7 @@ class JellyfinProvider @Inject constructor(
return executeJsonRequest(request, object : TypeToken<JellyfinQuickConnectInitiateResponseDto>() {}.type, "Quick Connect initiation failed")
}
- private fun pollQuickConnectState(serverUrl: String, secret: String): JellyfinQuickConnectStatusResponseDto {
+ private suspend fun pollQuickConnectState(serverUrl: String, secret: String): JellyfinQuickConnectStatusResponseDto {
val url = buildUrl(serverUrl, "/QuickConnect/Connect", mapOf("Secret" to secret))
val request = Request.Builder()
.url(url)
@@ -160,7 +189,7 @@ class JellyfinProvider @Inject constructor(
return executeJsonRequest(request, object : TypeToken<JellyfinQuickConnectStatusResponseDto>() {}.type, "Quick Connect status failed")
}
- private fun authenticateWithQuickConnect(serverUrl: String, secret: String): Result<JellyfinQuickConnectAuthenticationResult> {
+ private suspend fun authenticateWithQuickConnect(serverUrl: String, secret: String): Result<JellyfinQuickConnectAuthenticationResult> {
return try {
val url = buildUrl(serverUrl, "/Users/AuthenticateWithQuickConnect", emptyMap())
val request = Request.Builder()
@@ -179,30 +208,30 @@ class JellyfinProvider @Inject constructor(
?: throw IllegalStateException("Quick Connect did not return a user id")
Result.success(JellyfinQuickConnectAuthenticationResult(accessToken, userId, auth.user?.name ?: ""))
} catch (e: Exception) {
+ if (e is CancellationException) throw e
Result.error("Quick Connect authentication failed: ${e.message}", e)
}
}
- private fun fetchItems(provider: Provider, path: String, query: Map<String, String>): List<JellyfinItemDto> {
- val url = buildUrl(provider.serverUrl, path, query)
+ private suspend fun fetchItemsPage(provider: Provider, path: String, startIndex: Int, query: Map<String, String>): JellyfinPage<JellyfinItemDto> {
+ val url = buildUrl(provider.serverUrl, path, query + mapOf("StartIndex" to startIndex.toString(), "Limit" to PAGE_SIZE.toString()))
val request = Request.Builder()
.url(url)
.header("Authorization", buildJellyfinAuthorizationHeader(provider.serverUrl, provider.username, provider.password))
.header("Accept", "application/json")
.get()
.build()
- val body = executeRequest(request, "Jellyfin request failed")
- if (body.isBlank()) return emptyList()
- val parsed = gson.fromJson<JellyfinItemsResponseDto>(body, itemsResponseType)
- return parsed.items.orEmpty().filter { !it.id.isNullOrBlank() }
+ return executeItemsPage(request, "Jellyfin request failed", startIndex)
}
- private fun fetchSeriesEpisodes(provider: Provider, seriesRemoteId: String): List<JellyfinItemDto> {
+ private suspend fun fetchSeriesEpisodesPage(provider: Provider, seriesRemoteId: String, startIndex: Int): JellyfinPage<JellyfinItemDto> {
try {
val url = buildUrl(provider.serverUrl, "/Shows/$seriesRemoteId/Episodes", mapOf(
"Fields" to "Overview,ProviderIds,PremiereDate,RunTimeTicks,Genres,CommunityRating,ImageTags,MediaSources,ParentIndexNumber,IndexNumber",
"EnableImages" to "false",
- "EnableUserData" to "false"
+ "EnableUserData" to "false",
+ "StartIndex" to startIndex.toString(),
+ "Limit" to PAGE_SIZE.toString()
))
val request = Request.Builder()
.url(url)
@@ -210,10 +239,7 @@ class JellyfinProvider @Inject constructor(
.header("Accept", "application/json")
.get()
.build()
- val body = executeRequest(request, "Jellyfin episodes request failed")
- if (body.isBlank()) return emptyList()
- val parsed = gson.fromJson<JellyfinSeriesEpisodesResponseDto>(body, seriesResponseType)
- return parsed.items.orEmpty().filter { !it.id.isNullOrBlank() }
+ return executeItemsPage(request, "Jellyfin episodes request failed", startIndex)
} catch (e: Exception) {
android.util.Log.e("JellyfinEps", "fetchSeriesEpisodes error for seriesRemoteId=$seriesRemoteId url=${provider.serverUrl}: ${e::class.java.simpleName} msg='${e.message}'", e)
throw e
@@ -225,9 +251,9 @@ class JellyfinProvider @Inject constructor(
return MovieEntity(
streamId = stableRemoteId(remoteId),
name = item.name.orEmpty(),
- posterUrl = buildImageUrl(provider.serverUrl, remoteId, "Primary", item.imageTags?.get("Primary")),
+ posterUrl = buildImageUrl(provider.serverUrl, provider.id, remoteId, "Primary", item.imageTags?.get("Primary")),
backdropUrl = item.backdropImageTags?.firstOrNull()?.let { tag ->
- buildImageUrl(provider.serverUrl, remoteId, "Backdrop", tag, imageIndex = 0)
+ buildImageUrl(provider.serverUrl, provider.id, remoteId, "Backdrop", tag, imageIndex = 0)
},
categoryId = MOVIE_CATEGORY_ID,
categoryName = "Movies",
@@ -253,9 +279,9 @@ class JellyfinProvider @Inject constructor(
seriesId = stableRemoteId(remoteId),
providerSeriesId = remoteId,
name = item.name.orEmpty(),
- posterUrl = buildImageUrl(provider.serverUrl, remoteId, "Primary", item.imageTags?.get("Primary")),
+ posterUrl = buildImageUrl(provider.serverUrl, provider.id, remoteId, "Primary", item.imageTags?.get("Primary")),
backdropUrl = item.backdropImageTags?.firstOrNull()?.let { tag ->
- buildImageUrl(provider.serverUrl, remoteId, "Backdrop", tag, imageIndex = 0)
+ buildImageUrl(provider.serverUrl, provider.id, remoteId, "Backdrop", tag, imageIndex = 0)
},
categoryId = SERIES_CATEGORY_ID,
categoryName = "Series",
@@ -282,7 +308,7 @@ class JellyfinProvider @Inject constructor(
seasonNumber = item.parentIndexNumber ?: 0,
streamUrl = buildStreamUrl(provider.serverUrl, remoteId),
containerExtension = item.primaryMediaSource?.container?.takeIf { it.isNotBlank() },
- coverUrl = buildImageUrl(provider.serverUrl, remoteId, "Primary", item.imageTags?.get("Primary")),
+ coverUrl = buildImageUrl(provider.serverUrl, provider.id, remoteId, "Primary", item.imageTags?.get("Primary")),
plot = item.overview,
duration = item.runTimeTicks?.let(::ticksToDurationString),
durationSeconds = item.runTimeTicks?.let(::ticksToSeconds)?.toInt() ?: 0,
@@ -294,19 +320,18 @@ class JellyfinProvider @Inject constructor(
)
}
- private fun <T> executeJsonRequest(request: Request, responseType: java.lang.reflect.Type, errorPrefix: String): T {
+ private suspend fun <T> executeJsonRequest(request: Request, responseType: java.lang.reflect.Type, errorPrefix: String): T {
val body = executeRequest(request, errorPrefix)
@Suppress("UNCHECKED_CAST")
return gson.fromJson<T>(body, responseType)
}
- private fun executeRequest(request: Request, errorPrefix: String): String {
+ private suspend fun executeRequest(request: Request, errorPrefix: String): String {
okHttpClient.newBuilder()
.callTimeout(REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS)
.build()
.newCall(request)
- .execute()
- .use { response ->
+ .useCancellableResponse { response ->
if (!response.isSuccessful) {
throw IllegalStateException("$errorPrefix with HTTP ${response.code}")
}
@@ -314,6 +339,30 @@ class JellyfinProvider @Inject constructor(
}
}
+ /** Decodes the response envelope incrementally; neither a String nor a whole JSON tree is retained. */
+ private suspend fun executeItemsPage(request: Request, errorPrefix: String, startIndex: Int): JellyfinPage<JellyfinItemDto> {
+ okHttpClient.newBuilder().callTimeout(REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS).build().newCall(request).useCancellableResponse { response ->
+ if (!response.isSuccessful) throw IllegalStateException("$errorPrefix with HTTP ${response.code}")
+ val body = response.body ?: throw IllegalStateException("$errorPrefix with an empty body")
+ if (body.contentLength() > MAX_PAGE_BYTES) throw JellyfinResponseTooLargeException(body.contentLength(), MAX_PAGE_BYTES)
+ val reader = com.google.gson.stream.JsonReader(InputStreamReader(BoundedInputStream(body.byteStream(), MAX_PAGE_BYTES), body.contentType()?.charset(Charsets.UTF_8) ?: Charsets.UTF_8))
+ var total: Int? = null
+ val items = ArrayList<JellyfinItemDto>(PAGE_SIZE)
+ reader.use {
+ it.beginObject()
+ while (it.hasNext()) when (it.nextName()) {
+ "TotalRecordCount" -> total = it.nextInt()
+ "Items" -> { it.beginArray(); while (it.hasNext()) { if (items.size >= PAGE_SIZE) throw JellyfinPaginationException("Jellyfin ignored requested page limit $PAGE_SIZE"); gson.fromJson<JellyfinItemDto>(it, JellyfinItemDto::class.java)?.takeIf { dto -> !dto.id.isNullOrBlank() }?.let(items::add) }; it.endArray() }
+ else -> it.skipValue()
+ }
+ it.endObject()
+ }
+ val count = total ?: throw JellyfinPaginationException("Jellyfin response omitted TotalRecordCount")
+ if (count < 0 || startIndex > count || items.isEmpty() && startIndex < count) throw JellyfinPaginationException("Invalid Jellyfin pagination response")
+ return JellyfinPage(startIndex, count, items)
+ }
+ }
+
private fun buildUrl(baseUrl: String, path: String, query: Map<String, String>): String {
val normalized = baseUrl.trimEnd('/')
val qs = query.entries.joinToString("&") { (k, v) -> "${enc(k)}=${enc(v)}" }
@@ -323,12 +372,13 @@ class JellyfinProvider @Inject constructor(
private fun buildStreamUrl(baseUrl: String, itemId: String): String =
"${baseUrl.trimEnd('/')}/Videos/$itemId/stream"
- private fun buildImageUrl(baseUrl: String, itemId: String, imageType: String, tag: String?, imageIndex: Int? = null): String {
+ private fun buildImageUrl(baseUrl: String, providerId: Long, itemId: String, imageType: String, tag: String?, imageIndex: Int? = null): String {
val qs = buildList {
tag?.takeIf { it.isNotBlank() }?.let { add("tag=${enc(it)}") }
}.joinToString("&")
val path = if (imageIndex != null) "/Items/$itemId/Images/$imageType/$imageIndex" else "/Items/$itemId/Images/$imageType"
- return "${baseUrl.trimEnd('/')}$path${if (qs.isNotBlank()) "?$qs" else ""}"
+ val providerQuery = "streamvault_provider_id=$providerId"
+ return "${baseUrl.trimEnd('/')}$path?${listOf(qs, providerQuery).filter { it.isNotBlank() }.joinToString("&")}"
}
private fun stableRemoteId(value: String): Long {
@@ -364,6 +414,23 @@ private data class JellyfinItemsResponseDto(
@SerializedName("Items") val items: List<JellyfinItemDto>? = emptyList()
)
+data class JellyfinPage<T>(val startIndex: Int, val totalRecordCount: Int, val items: List<T>) {
+ val nextStartIndex: Int get() = startIndex + items.size
+ fun <R> map(transform: (T) -> R): JellyfinPage<R> =
+ JellyfinPage(startIndex, totalRecordCount, items.map(transform))
+}
+
+class JellyfinResponseTooLargeException(val observedBytes: Long, val maxAllowedBytes: Long) : IOException("Jellyfin response exceeded safe page budget ($observedBytes B > $maxAllowedBytes B)")
+class JellyfinPaginationException(message: String) : IOException(message)
+class JellyfinCatalogLimitException(message: String) : IOException(message)
+
+private class BoundedInputStream(delegate: InputStream, private val limit: Long) : FilterInputStream(delegate) {
+ private var count = 0L
+ override fun read(): Int = super.read().also { if (it >= 0) record(1) }
+ override fun read(buffer: ByteArray, offset: Int, length: Int): Int = super.read(buffer, offset, length).also { if (it > 0) record(it.toLong()) }
+ private fun record(read: Long) { count += read; if (count > limit) throw JellyfinResponseTooLargeException(count, limit) }
+}
+
private data class JellyfinSeriesEpisodesResponseDto(
@SerializedName("Items") val items: List<JellyfinItemDto>? = emptyList()
)
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 ee53b98c..c69682b9 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
@@ -5,6 +5,8 @@ import com.google.gson.JsonObject as GsonJsonObject
import com.google.gson.JsonParser
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonToken
+import com.streamvault.data.remote.http.useCancellableResponse
+import com.streamvault.data.util.runSuspendCatching
import com.streamvault.domain.model.Result
import com.streamvault.domain.model.StalkerAuthMode
import com.streamvault.domain.model.StalkerBootstrapRecipe
@@ -34,10 +36,17 @@ import java.time.format.ResolverStyle
import java.util.Base64
import java.util.Locale
import java.util.concurrent.ConcurrentHashMap
+import java.util.concurrent.atomic.AtomicInteger
import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.CancellationException
+import kotlinx.coroutines.currentCoroutineContext
+import kotlinx.coroutines.ensureActive
import kotlinx.coroutines.withContext
+import kotlinx.coroutines.withTimeoutOrNull
+import kotlin.coroutines.AbstractCoroutineContextElement
+import kotlin.coroutines.CoroutineContext
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonElement
@@ -60,15 +69,61 @@ import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
+class StalkerDiscoveryBudget @Inject constructor() {
+ var timeoutMillis: Long = 45_000L
+ private set
+ var maxRequests: Int = 24
+ private set
+
+ internal constructor(timeoutMillis: Long, maxRequests: Int) : this() {
+ require(timeoutMillis > 0)
+ require(maxRequests > 0)
+ this.timeoutMillis = timeoutMillis
+ this.maxRequests = maxRequests
+ }
+}
+
+private class StalkerDiscoveryContext(
+ maxRequests: Int
+) : AbstractCoroutineContextElement(Key) {
+ private val remainingRequests = AtomicInteger(maxRequests)
+
+ fun consumeRequest() {
+ if (remainingRequests.getAndDecrement() <= 0) {
+ throw IOException("Portal discovery exceeded its request budget.")
+ }
+ }
+
+ companion object Key : CoroutineContext.Key<StalkerDiscoveryContext>
+}
+
+private class StalkerCompatibilityException(
+ message: String,
+ cause: Throwable? = null
+) : IOException(message, cause)
+
@Singleton
class OkHttpStalkerApiService @Inject constructor(
private val okHttpClient: OkHttpClient,
- private val json: Json
+ private val json: Json,
+ private val discoveryBudget: StalkerDiscoveryBudget = StalkerDiscoveryBudget()
) : StalkerApiService {
private val cookieJar = InMemoryStalkerCookieJar()
private val stalkerHttpClients = ConcurrentHashMap<String, OkHttpClient>()
override suspend fun authenticate(profile: StalkerDeviceProfile): Result<Pair<StalkerSession, StalkerProviderProfile>> {
+ return withContext(Dispatchers.IO) {
+ withTimeoutOrNull(discoveryBudget.timeoutMillis) {
+ withContext(StalkerDiscoveryContext(discoveryBudget.maxRequests)) {
+ authenticateWithinBudget(profile)
+ }
+ }
+ } ?: Result.error("Portal discovery exceeded ${discoveryBudget.timeoutMillis / 1000} seconds.")
+ }
+
+ private suspend fun authenticateWithinBudget(
+ profile: StalkerDeviceProfile
+ ): Result<Pair<StalkerSession, StalkerProviderProfile>> {
var lastError: Throwable? = null
var lockedLoadUrl: String? = null
val failedHandshakeLoadUrls = mutableSetOf<String>()
@@ -93,7 +148,7 @@ class OkHttpStalkerApiService @Inject constructor(
val bootstrapSessionKey = "${effectiveAuthMode.name}|$loadUrl"
var bootstrapSession = bootstrapSessions[bootstrapSessionKey]
val token = bootstrapSession?.token ?: run {
- val handshakePayload = runCatching {
+ val handshakePayload = runSuspendCatching {
requestJson(
url = loadUrl,
profile = attemptProfile,
@@ -106,6 +161,9 @@ class OkHttpStalkerApiService @Inject constructor(
)
)
}.getOrElse { error ->
+ if (error !is StalkerCompatibilityException) {
+ return Result.error(error.message ?: "Portal handshake failed.", error)
+ }
failedHandshakeLoadUrls += loadUrl
lastError = error
continue
@@ -113,8 +171,8 @@ class OkHttpStalkerApiService @Inject constructor(
handshakePayload.findString("token")
?.takeIf { it.isNotBlank() }
?: run {
- lastError = IOException("Portal handshake did not return a token.")
- continue
+ val error = IOException("Portal handshake did not return a token.")
+ return Result.error(error.message ?: "Portal handshake failed.", error)
}
}
evidence += "handshake"
@@ -130,7 +188,7 @@ class OkHttpStalkerApiService @Inject constructor(
lastError = IOException("Portal requires account credentials for this connection.")
continue
}
- val authPayload = runCatching {
+ val authPayload = runSuspendCatching {
requestCredentialAuth(
url = loadUrl,
profile = attemptProfile,
@@ -139,6 +197,9 @@ class OkHttpStalkerApiService @Inject constructor(
allowAlternateEndpointRetry = false
)
}.getOrElse { error ->
+ if (error !is StalkerCompatibilityException) {
+ return Result.error(error.message ?: "Portal authentication failed.", error)
+ }
lastError = error
continue
}
@@ -154,7 +215,7 @@ class OkHttpStalkerApiService @Inject constructor(
token = token
)
if (recipe.preferLocalizationBeforeProfile) {
- runCatching {
+ runSuspendCatching {
requestJson(
url = loadUrl,
profile = attemptProfile,
@@ -170,7 +231,7 @@ class OkHttpStalkerApiService @Inject constructor(
evidence += "get_localization"
}
}
- val profilePayload = runCatching {
+ val profilePayload = runSuspendCatching {
requestJson(
url = loadUrl,
profile = attemptProfile,
@@ -179,6 +240,9 @@ class OkHttpStalkerApiService @Inject constructor(
query = buildProfileQuery(attemptProfile)
)
}.getOrElse { error ->
+ if (error !is StalkerCompatibilityException) {
+ return Result.error(error.message ?: "Portal profile request failed.", error)
+ }
lastError = error
continue
}
@@ -197,7 +261,7 @@ class OkHttpStalkerApiService @Inject constructor(
StalkerBootstrapRecipe.MODULE_GATED -> StalkerBootstrapStrategy.MAC_WITH_MODULES
}
if (recipe.requestAccountInfo || providerProfile.shouldRequestAccountInfo()) {
- runCatching {
+ runSuspendCatching {
requestJson(
url = loadUrl,
profile = attemptProfile,
@@ -216,7 +280,7 @@ class OkHttpStalkerApiService @Inject constructor(
}
}
if (recipe.requestLocalization && "get_localization" !in evidence) {
- runCatching {
+ runSuspendCatching {
requestJson(
url = loadUrl,
profile = attemptProfile,
@@ -233,7 +297,7 @@ class OkHttpStalkerApiService @Inject constructor(
}
}
if (recipe.requestModules || providerProfile.shouldRequestModules()) {
- runCatching {
+ runSuspendCatching {
requestJson(
url = loadUrl,
profile = attemptProfile,
@@ -257,7 +321,7 @@ class OkHttpStalkerApiService @Inject constructor(
if ((recipe.strictIdentityRequired || recipe.playbackBackendHint == StalkerPlaybackBackendHint.TEMP_LINK_STRICT) &&
"get_events" !in evidence
) {
- runCatching {
+ runSuspendCatching {
requestJson(
url = loadUrl,
profile = attemptProfile,
@@ -897,7 +961,7 @@ class OkHttpStalkerApiService @Inject constructor(
session: StalkerSession,
profile: StalkerDeviceProfile
): List<StalkerItemRecord>? {
- return runCatching {
+ return runSuspendCatching {
requestJson(
url = session.loadUrl,
profile = profile,
@@ -924,6 +988,7 @@ class OkHttpStalkerApiService @Inject constructor(
method: String = "GET",
body: String? = null
): JsonElement = withContext(Dispatchers.IO) {
+ currentCoroutineContext()[StalkerDiscoveryContext]?.consumeRequest()
val effectiveQuery = prepareQuery(profile, query)
val action = effectiveQuery["action"]
val fullUrl = buildUrl(url, effectiveQuery)
@@ -946,7 +1011,7 @@ class OkHttpStalkerApiService @Inject constructor(
.method(method, requestBody)
.build()
- runCatching {
+ runSuspendCatching {
executeJsonRequest(request, action, profile)
}.recoverCatching { error ->
if (!allowAlternateEndpointRetry) throw error
@@ -971,11 +1036,19 @@ class OkHttpStalkerApiService @Inject constructor(
}.getOrElse { throw it }
}
- private fun executeJsonRequest(request: Request, action: String?, profile: StalkerDeviceProfile): JsonElement {
- return stalkerHttpClientFor(profile).newCall(request).execute().use { response ->
+ private suspend fun executeJsonRequest(request: Request, action: String?, profile: StalkerDeviceProfile): JsonElement {
+ return stalkerHttpClientFor(profile).newCall(request).useCancellableResponse { response ->
+ currentCoroutineContext().ensureActive()
captureResponseCookies(response)
if (!response.isSuccessful) {
response.body?.close()
+ if (action in DISCOVERY_COMPATIBILITY_ACTIONS &&
+ response.code in DISCOVERY_COMPATIBILITY_HTTP_CODES
+ ) {
+ throw StalkerCompatibilityException(
+ "Portal endpoint is incompatible with '$action' (HTTP ${response.code})."
+ )
+ }
throw IOException("Portal request failed with HTTP ${response.code}.")
}
val responseBody = response.body
@@ -988,6 +1061,11 @@ class OkHttpStalkerApiService @Inject constructor(
action = action
)
if (raw.isBlank()) {
+ if (action == "get_profile") {
+ throw StalkerCompatibilityException(
+ "Portal profile recipe returned an empty compatibility response."
+ )
+ }
throw IOException("Portal returned an empty response${actionSuffix(action)}.")
}
val parsed = parsePortalJson(raw, action)
@@ -1079,7 +1157,8 @@ class OkHttpStalkerApiService @Inject constructor(
profile: StalkerDeviceProfile,
onItem: suspend (StalkerItemRecord) -> Unit
): Int {
- return stalkerHttpClientFor(profile).newCall(request).execute().use { response ->
+ return stalkerHttpClientFor(profile).newCall(request).useCancellableResponse { response ->
+ currentCoroutineContext().ensureActive()
captureResponseCookies(response)
if (!response.isSuccessful) {
throw IOException("Portal request failed with HTTP ${response.code}.")
@@ -1218,7 +1297,8 @@ class OkHttpStalkerApiService @Inject constructor(
channelIdOverride: String?,
onProgram: suspend (StalkerProgramRecord) -> Unit
): Int {
- return stalkerHttpClientFor(profile).newCall(request).execute().use { response ->
+ return stalkerHttpClientFor(profile).newCall(request).useCancellableResponse { response ->
+ currentCoroutineContext().ensureActive()
captureResponseCookies(response)
if (!response.isSuccessful) {
throw IOException("Portal request failed with HTTP ${response.code}.")
@@ -1410,6 +1490,8 @@ class OkHttpStalkerApiService @Inject constructor(
crossinline block: suspend () -> T
): Result<T> = try {
Result.success(block())
+ } catch (cancelled: CancellationException) {
+ throw cancelled
} catch (error: Exception) {
Result.error(error.message ?: message, error)
}
@@ -1533,7 +1615,7 @@ class OkHttpStalkerApiService @Inject constructor(
"action" to "do_auth",
"JsHttpRequest" to "1-xml"
)
- return runCatching {
+ return runSuspendCatching {
requestJson(
url = url,
profile = profile,
@@ -1544,7 +1626,8 @@ class OkHttpStalkerApiService @Inject constructor(
method = "POST",
body = formBody
)
- }.getOrElse {
+ }.getOrElse { error ->
+ if (error !is StalkerCompatibilityException) throw error
requestJson(
url = url,
profile = profile,
@@ -2452,6 +2535,16 @@ class OkHttpStalkerApiService @Inject constructor(
companion object {
private const val TAG = "OkHttpStalkerApi"
+ private val DISCOVERY_COMPATIBILITY_ACTIONS = setOf(
+ "handshake",
+ "do_auth",
+ "get_profile",
+ "get_localization",
+ "get_modules",
+ "get_main_info",
+ "get_events"
+ )
+ private val DISCOVERY_COMPATIBILITY_HTTP_CODES = setOf(400, 404, 405, 415, 501)
private const val MAX_PAGE_COUNT = 200
private const val DEFAULT_PROGRAM_DURATION_MILLIS = 30 * 60_000L
/** Hard ceiling for the streamed `get_epg_info` body; anything larger is treated as a portal fault. */
diff --git a/data/src/main/java/com/streamvault/data/remote/xtream/XtreamProvider.kt b/data/src/main/java/com/streamvault/data/remote/xtream/XtreamProvider.kt
index c88a2bf4..0abaaf4f 100644
--- a/data/src/main/java/com/streamvault/data/remote/xtream/XtreamProvider.kt
+++ b/data/src/main/java/com/streamvault/data/remote/xtream/XtreamProvider.kt
@@ -4,6 +4,7 @@ import android.util.Log
import com.streamvault.data.remote.http.HttpRequestProfile
import com.streamvault.data.remote.dto.*
import com.streamvault.data.util.AdultContentClassifier
+import com.streamvault.data.util.runSuspendCatching
import com.streamvault.domain.model.*
import com.streamvault.domain.provider.IptvProvider
import com.streamvault.domain.util.ChannelNormalizer
@@ -128,6 +129,8 @@ class XtreamProvider(
)
)
}
+ } catch (e: CancellationException) {
+ throw e
} catch (e: Exception) {
Result.error(XtreamErrorFormatter.message("Authentication failed", e), e)
}
@@ -141,6 +144,8 @@ class XtreamProvider(
)
cacheAdultCategoryIds(ContentType.LIVE, categories)
Result.success(categories.map { it.toDomain(ContentType.LIVE) })
+ } catch (e: CancellationException) {
+ throw e
} catch (e: Exception) {
Result.error(XtreamErrorFormatter.message("Failed to load live categories", e), e)
}
@@ -170,6 +175,8 @@ class XtreamProvider(
.getOrNull()
}
)
+ } catch (e: CancellationException) {
+ throw e
} catch (e: Exception) {
Result.error(XtreamErrorFormatter.message("Failed to load live streams", e), e)
}
@@ -183,6 +190,8 @@ class XtreamProvider(
)
cacheAdultCategoryIds(ContentType.MOVIE, categories)
Result.success(categories.map { it.toDomain(ContentType.MOVIE) })
+ } catch (e: CancellationException) {
+ throw e
} catch (e: Exception) {
Result.error(XtreamErrorFormatter.message("Failed to load VOD categories", e), e)
}
@@ -212,6 +221,8 @@ class XtreamProvider(
.getOrNull()
}
)
+ } catch (e: CancellationException) {
+ throw e
} catch (e: Exception) {
Result.error(XtreamErrorFormatter.message("Failed to load VOD", e), e)
}
@@ -248,6 +259,8 @@ class XtreamProvider(
onBatch(buffer.toList())
}
Result.success(acceptedCount)
+ } catch (e: CancellationException) {
+ throw e
} catch (e: Exception) {
Result.error(XtreamErrorFormatter.message("Failed to stream VOD index", e), e)
}
@@ -312,6 +325,8 @@ class XtreamProvider(
)
)
}
+ } catch (e: CancellationException) {
+ throw e
} catch (e: Exception) {
Result.error(XtreamErrorFormatter.message("Failed to load movie details", e), e)
}
@@ -325,6 +340,8 @@ class XtreamProvider(
)
cacheAdultCategoryIds(ContentType.SERIES, categories)
Result.success(categories.map { it.toDomain(ContentType.SERIES) })
+ } catch (e: CancellationException) {
+ throw e
} catch (e: Exception) {
Result.error(XtreamErrorFormatter.message("Failed to load series categories", e), e)
}
@@ -354,6 +371,8 @@ class XtreamProvider(
.getOrNull()
}
)
+ } catch (e: CancellationException) {
+ throw e
} catch (e: Exception) {
Result.error(XtreamErrorFormatter.message("Failed to load series", e), e)
}
@@ -390,6 +409,8 @@ class XtreamProvider(
onBatch(buffer.toList())
}
Result.success(acceptedCount)
+ } catch (e: CancellationException) {
+ throw e
} catch (e: Exception) {
Result.error(XtreamErrorFormatter.message("Failed to stream series index", e), e)
}
@@ -505,6 +526,8 @@ class XtreamProvider(
requestProfile
)
Result.success(response.epgListings.mapNotNull { it.toDomainOrNull() })
+ } catch (e: CancellationException) {
+ throw e
} catch (e: Exception) {
Result.error(XtreamErrorFormatter.message("Failed to load EPG", e), e)
}
@@ -525,6 +548,8 @@ class XtreamProvider(
requestProfile
)
Result.success(response.epgListings.mapNotNull { it.toDomainOrNull() })
+ } catch (e: CancellationException) {
+ throw e
} catch (e: Exception) {
Result.error(XtreamErrorFormatter.message("Failed to load EPG", e), e)
}
@@ -665,7 +690,7 @@ class XtreamProvider(
private suspend fun loadAdultCategoryIds(type: ContentType): Set<Long> {
adultCategoryCacheMutex.withLock {
adultCategoryCache[type]?.let { return it }
- val categories = runCatching {
+ val categories = try {
when (type) {
ContentType.LIVE -> api.getLiveCategories(
XtreamUrlFactory.buildPlayerApiUrl(serverUrl, username, password, action = "get_live_categories"),
@@ -681,13 +706,15 @@ class XtreamProvider(
)
ContentType.SERIES_EPISODE -> emptyList()
}
- }.getOrElse {
+ } catch (e: CancellationException) {
+ throw e
+ } catch (e: Exception) {
Log.w(
TAG,
"Failed to prefetch $type categories for adult tagging: " +
- XtreamUrlFactory.sanitizeLogMessage(it.message ?: "unknown error")
+ XtreamUrlFactory.sanitizeLogMessage(e.message ?: "unknown error")
)
- emptyList()
+ return emptySet()
}
return categories
.filter { it.isAdult == true || (useTextClassification && AdultContentClassifier.isAdultCategoryName(it.categoryName)) }
@@ -1020,7 +1047,7 @@ class XtreamProvider(
}
private suspend fun requestSeriesInfoWithCompatibilityFallback(seriesId: Long): XtreamSeriesInfoResponse {
- val primaryAttempt = runCatching { requestSeriesInfo(seriesId, "series_id") }
+ val primaryAttempt = runSuspendCatching { requestSeriesInfo(seriesId, "series_id") }
val primaryResponse = primaryAttempt.getOrNull()
if (primaryResponse.hasUsableSeriesDetailPayload()) {
return requireNotNull(primaryResponse)
@@ -1034,7 +1061,7 @@ class XtreamProvider(
primaryResponse?.let { return it }
primaryFailure?.let { throw it }
}
- val legacyAttempt = runCatching { requestSeriesInfo(seriesId, "series") }
+ val legacyAttempt = runSuspendCatching { requestSeriesInfo(seriesId, "series") }
val legacyResponse = legacyAttempt.getOrNull()
if (legacyResponse.hasUsableSeriesDetailPayload()) {
return requireNotNull(legacyResponse)
diff --git a/data/src/main/java/com/streamvault/data/repository/EpgRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/EpgRepositoryImpl.kt
index de26bd0e..f3e0fc51 100644
--- a/data/src/main/java/com/streamvault/data/repository/EpgRepositoryImpl.kt
+++ b/data/src/main/java/com/streamvault/data/repository/EpgRepositoryImpl.kt
@@ -11,6 +11,7 @@ import com.streamvault.data.mapper.toDomain
import com.streamvault.data.mapper.toEntity
import com.streamvault.data.parser.XmltvParser
import com.streamvault.data.remote.http.HttpRequestProfile
+import com.streamvault.data.remote.http.useCancellableResponse
import com.streamvault.data.remote.http.safeRequestIdentitySummary
import com.streamvault.data.remote.http.toGenericRequestProfile
import com.streamvault.data.remote.http.withRequestProfile
@@ -20,6 +21,7 @@ import com.streamvault.domain.model.Result
import com.streamvault.domain.repository.EpgRepository
import com.streamvault.domain.repository.EpgSourceRepository
import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.SupervisorJob
@@ -285,7 +287,7 @@ class EpgRepositoryImpl @Inject constructor(
.url(epgUrl)
.build()
.withRequestProfile(providerRequestProfile)
- epgHttpClient.newCall(request).execute().use { response ->
+ epgHttpClient.newCall(request).useCancellableResponse { response ->
if (!response.isSuccessful) {
Log.w(
"EpgRepository",
@@ -340,6 +342,7 @@ class EpgRepositoryImpl @Inject constructor(
Result.success(Unit)
} catch (e: Exception) {
+ if (e is CancellationException) throw e
programDao.deleteByProvider(stagingProviderId)
if (e is IOException && e.message?.contains("too large", ignoreCase = true) == true) {
Result.error("EPG response exceeded 200 MB limit", e)
diff --git a/data/src/main/java/com/streamvault/data/repository/EpgSourceRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/EpgSourceRepositoryImpl.kt
index 96a44e33..6083a1fc 100644
--- a/data/src/main/java/com/streamvault/data/repository/EpgSourceRepositoryImpl.kt
+++ b/data/src/main/java/com/streamvault/data/repository/EpgSourceRepositoryImpl.kt
@@ -24,8 +24,10 @@ import com.streamvault.domain.model.EpgOverrideCandidate
import com.streamvault.domain.model.EpgSourceType
import com.streamvault.data.parser.XmltvParser
import com.streamvault.data.util.ProviderInputSanitizer
+import com.streamvault.data.util.runSuspendCatching
import com.streamvault.data.util.UrlSecurityPolicy
import com.streamvault.data.remote.http.HttpRequestProfile
+import com.streamvault.data.remote.http.openCancellableResponse
import com.streamvault.data.remote.http.safeRequestIdentitySummary
import com.streamvault.data.remote.http.withRequestProfile
import com.streamvault.domain.model.ChannelEpgMapping
@@ -37,6 +39,7 @@ import com.streamvault.domain.model.ProviderEpgSourceAssignment
import com.streamvault.domain.model.Result
import com.streamvault.domain.repository.EpgSourceRepository
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
@@ -47,6 +50,7 @@ import okhttp3.OkHttpClient
import okhttp3.Request
import java.io.FilterInputStream
import java.io.IOException
+import java.io.InputStream
import java.util.concurrent.TimeUnit
import com.streamvault.data.remote.NetworkTimeoutConfig
import dagger.hilt.android.qualifiers.ApplicationContext
@@ -54,6 +58,24 @@ import java.util.concurrent.ConcurrentHashMap
import javax.inject.Inject
import javax.inject.Singleton
+internal fun limitEpgInput(
+ input: InputStream,
+ maxBytes: Long = NetworkTimeoutConfig.EPG_MAX_SIZE_BYTES,
+): InputStream = object : FilterInputStream(input) {
+ private var bytesRead = 0L
+
+ override fun read(): Int {
+ if (bytesRead >= maxBytes) throw IOException("EPG response too large (>200 MB)")
+ return super.read().also { if (it >= 0) bytesRead++ }
+ }
+
+ override fun read(bytes: ByteArray, off: Int, len: Int): Int {
+ if (bytesRead >= maxBytes) throw IOException("EPG response too large (>200 MB)")
+ val remaining = (maxBytes - bytesRead).coerceAtMost(len.toLong()).toInt()
+ return super.read(bytes, off, remaining).also { if (it > 0) bytesRead += it }
+ }
+}
+
@Singleton
class EpgSourceRepositoryImpl @Inject constructor(
@ApplicationContext private val context: Context,
@@ -253,10 +275,11 @@ class EpgSourceRepositoryImpl @Inject constructor(
}
.build()
.withRequestProfile(requestProfile)
- val response = epgHttpClient.newCall(request).execute()
+ val ownedResponse = epgHttpClient.newCall(request).openCancellableResponse()
+ val response = ownedResponse.response
if (response.code == 304) {
- response.close()
+ ownedResponse.close()
val now = System.currentTimeMillis()
epgSourceDao.updateRefreshSuccess(sourceId, now)
if (resolveAffectedProviders) {
@@ -271,21 +294,21 @@ class EpgSourceRepositoryImpl @Inject constructor(
"EPG request failed for source $sourceId (${response.request.safeRequestIdentitySummary(requestProfile)}): HTTP ${response.code}"
)
val err = "HTTP ${response.code}"
- response.close()
+ ownedResponse.close()
epgSourceDao.updateRefreshError(sourceId, err)
return@withLock Result.error("Failed to download EPG: $err")
}
val contentLength = response.header("Content-Length")?.toLongOrNull() ?: -1L
if (contentLength > MAX_EPG_SIZE_BYTES) {
- response.close()
+ ownedResponse.close()
val err = "File too large (${contentLength / 1_048_576}MB)"
epgSourceDao.updateRefreshError(sourceId, err)
return@withLock Result.error(err)
}
val bodyStream = response.body?.byteStream() ?: run {
- response.close()
+ ownedResponse.close()
epgSourceDao.updateRefreshError(sourceId, "Empty response")
return@withLock Result.error("Empty EPG response")
}
@@ -296,7 +319,7 @@ class EpgSourceRepositoryImpl @Inject constructor(
try {
super.close()
} finally {
- response.close()
+ ownedResponse.close()
}
}
}
@@ -314,20 +337,10 @@ class EpgSourceRepositoryImpl @Inject constructor(
prepareStagingSource(source, stagingId)
rawInputStream.use { raw ->
- val limited = object : FilterInputStream(raw) {
- private var bytesRead = 0L
- override fun read(): Int {
- if (bytesRead >= MAX_EPG_SIZE_BYTES) throw IOException("EPG response too large (>200 MB)")
- return super.read().also { if (it >= 0) bytesRead++ }
- }
- override fun read(b: ByteArray, off: Int, len: Int): Int {
- if (bytesRead >= MAX_EPG_SIZE_BYTES) throw IOException("EPG response too large (>200 MB)")
- return super.read(b, off, len).also { if (it > 0) bytesRead += it }
- }
- }
- xmltvParser.maybeDecompressGzip(source.url, limited).use { decompressed ->
+ val rawLimited = limitEpgInput(raw)
+ xmltvParser.maybeDecompressGzip(source.url, rawLimited).use { decompressed ->
xmltvParser.parseStreamingWithChannels(
- inputStream = decompressed,
+ inputStream = limitEpgInput(decompressed),
timezoneId = sourceTimezoneId,
onChannel = { xmltvChannel ->
channelBatch.add(
@@ -397,10 +410,11 @@ class EpgSourceRepositoryImpl @Inject constructor(
Log.d(TAG, "Refreshed source $sourceId: $channelCount channels, $programmeCount programmes")
Result.success(Unit)
} catch (e: Exception) {
+ if (e is CancellationException) throw e
Log.e(TAG, "Failed to refresh source $sourceId", e)
// Clean up any staged rows on failure
val stagingId = -sourceId
- runCatching {
+ runSuspendCatching {
transactionRunner.inTransaction {
epgProgrammeDao.deleteBySource(stagingId)
epgChannelDao.deleteBySource(stagingId)
diff --git a/data/src/main/java/com/streamvault/data/repository/ProviderDeletionCleanupWorker.kt b/data/src/main/java/com/streamvault/data/repository/ProviderDeletionCleanupWorker.kt
new file mode 100644
index 00000000..78115905
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/repository/ProviderDeletionCleanupWorker.kt
@@ -0,0 +1,58 @@
+package com.streamvault.data.repository
+
+import android.content.Context
+import androidx.work.CoroutineWorker
+import androidx.work.ExistingWorkPolicy
+import androidx.work.OneTimeWorkRequestBuilder
+import androidx.work.WorkManager
+import androidx.work.WorkerParameters
+import com.streamvault.data.local.dao.ProviderDeletionCleanupDao
+import com.streamvault.data.manager.recording.RecordingAlarmScheduler
+import com.streamvault.data.manager.reminder.ProgramReminderAlarmScheduler
+import com.streamvault.data.sync.SyncManager
+import dagger.hilt.EntryPoint
+import dagger.hilt.InstallIn
+import dagger.hilt.android.EntryPointAccessors
+import dagger.hilt.components.SingletonComponent
+import kotlinx.coroutines.CancellationException
+
+class ProviderDeletionCleanupWorker(appContext: Context, params: WorkerParameters) : CoroutineWorker(appContext, params) {
+ @EntryPoint @InstallIn(SingletonComponent::class)
+ interface Entry {
+ fun providerDeletionCleanupDao(): ProviderDeletionCleanupDao
+ fun recordingAlarmScheduler(): RecordingAlarmScheduler
+ fun programReminderAlarmScheduler(): ProgramReminderAlarmScheduler
+ fun syncManager(): SyncManager
+ }
+
+ override suspend fun doWork(): Result {
+ val entry = EntryPointAccessors.fromApplication(applicationContext, Entry::class.java)
+ val dao = entry.providerDeletionCleanupDao()
+ var failed = false
+ dao.getAll().forEach { item ->
+ try {
+ when (item.action) {
+ RECORDING_ALARM -> entry.recordingAlarmScheduler().cancel(item.targetId)
+ REMINDER_ALARM -> entry.programReminderAlarmScheduler().cancel(item.targetId.toLong())
+ SYNC_RUNTIME -> entry.syncManager().onProviderDeleted(item.providerId)
+ }
+ dao.delete(item.id)
+ } catch (t: Throwable) {
+ if (t is CancellationException) throw t
+ dao.recordFailure(item.id, t.message ?: t.javaClass.simpleName)
+ failed = true
+ }
+ }
+ return if (failed) Result.retry() else Result.success()
+ }
+
+ companion object {
+ const val RECORDING_ALARM = "RECORDING_ALARM"
+ const val REMINDER_ALARM = "REMINDER_ALARM"
+ const val SYNC_RUNTIME = "SYNC_RUNTIME"
+ private const val WORK_NAME = "ProviderDeletionCleanup"
+ fun enqueue(context: Context) = WorkManager.getInstance(context).enqueueUniqueWork(
+ WORK_NAME, ExistingWorkPolicy.KEEP, OneTimeWorkRequestBuilder<ProviderDeletionCleanupWorker>().build()
+ )
+ }
+}
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 b434d173..c4a0fcf7 100644
--- a/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt
+++ b/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt
@@ -1,5 +1,8 @@
package com.streamvault.data.repository
+import android.content.Context
+import com.streamvault.data.local.dao.ProviderDeletionCleanupDao
+import com.streamvault.data.local.entity.ProviderDeletionCleanupEntity
import com.streamvault.data.local.DatabaseTransactionRunner
import com.streamvault.data.local.dao.*
import com.streamvault.data.local.entity.ProviderEntity
@@ -41,6 +44,7 @@ import kotlinx.coroutines.launch
import java.util.logging.Logger
import javax.inject.Inject
import javax.inject.Singleton
+import dagger.hilt.android.qualifiers.ApplicationContext
@Singleton
class ProviderRepositoryImpl @Inject constructor(
@@ -61,7 +65,9 @@ class ProviderRepositoryImpl @Inject constructor(
private val transactionRunner: DatabaseTransactionRunner,
private val recordingAlarmScheduler: RecordingAlarmScheduler,
private val programReminderAlarmScheduler: ProgramReminderAlarmScheduler,
- private val jellyfinProvider: JellyfinProvider
+ private val jellyfinProvider: JellyfinProvider,
+ private val providerDeletionCleanupDao: ProviderDeletionCleanupDao,
+ @ApplicationContext private val appContext: Context
) : ProviderRepository {
private companion object {
const val XTREAM_GUIDE_BATCH_CONCURRENCY = 4
@@ -160,6 +166,11 @@ class ProviderRepositoryImpl @Inject constructor(
reportProgress("Preparing to remove provider...")
transactionRunner.inTransaction {
+ providerDeletionCleanupDao.insertAll(
+ recordingRunIds.map { ProviderDeletionCleanupEntity(id = 0, providerId = id, action = ProviderDeletionCleanupWorker.RECORDING_ALARM, targetId = it) } +
+ reminderIds.map { ProviderDeletionCleanupEntity(id = 0, providerId = id, action = ProviderDeletionCleanupWorker.REMINDER_ALARM, targetId = it.toString()) } +
+ ProviderDeletionCleanupEntity(id = 0, providerId = id, action = ProviderDeletionCleanupWorker.SYNC_RUNTIME)
+ )
// ProgramEntity still has no provider FK, so it requires explicit cleanup.
if (programCount > 0) reportProgress("Removing $programCount guide entries...")
programDao.deleteByProvider(id)
@@ -182,37 +193,16 @@ class ProviderRepositoryImpl @Inject constructor(
completedWeight += PROVIDER_ROW_STEP_WEIGHT
}
reportProgress("Provider library removed.")
- recordingRunIds.forEach { runId ->
- reportProgress("Cleaning recording alarms...")
- runPostDeleteCleanup("recording alarm $runId") {
- recordingAlarmScheduler.cancel(runId)
- }
- completedWeight += ALARM_STEP_WEIGHT
- }
- reminderIds.forEach { reminderId ->
- reportProgress("Cleaning reminders...")
- runPostDeleteCleanup("reminder alarm $reminderId") {
- programReminderAlarmScheduler.cancel(reminderId)
- }
- completedWeight += ALARM_STEP_WEIGHT
- }
reportProgress("Finalizing provider cleanup...")
- runPostDeleteCleanup("provider sync cleanup $id") {
- syncManager.onProviderDeleted(id)
- }
- completedWeight += FINALIZE_STEP_WEIGHT
- reportProgress("Provider deleted.")
+ runCatching { ProviderDeletionCleanupWorker.enqueue(appContext) }
+ .onFailure { logger.warning("Provider cleanup was queued but WorkManager enqueue failed: ${it.message}") }
+ completedWeight = totalWeight
+ reportProgress("Provider deleted; final cleanup continues.")
Result.success(Unit)
} catch (e: Exception) {
Result.error("Failed to delete provider: ${e.message}", e)
}
- private inline fun runPostDeleteCleanup(step: String, block: () -> Unit) {
- runCatching(block).onFailure { throwable ->
- logger.warning("Provider delete committed but post-delete cleanup failed for $step: ${throwable.message}")
- }
- }
-
override suspend fun setActiveProvider(id: Long): Result<Unit> {
return try {
val provider = providerDao.getById(id)
diff --git a/data/src/main/java/com/streamvault/data/sync/BackgroundEpgSyncWorker.kt b/data/src/main/java/com/streamvault/data/sync/BackgroundEpgSyncWorker.kt
index bcaf6924..5bb20b11 100644
--- a/data/src/main/java/com/streamvault/data/sync/BackgroundEpgSyncWorker.kt
+++ b/data/src/main/java/com/streamvault/data/sync/BackgroundEpgSyncWorker.kt
@@ -78,6 +78,8 @@ class BackgroundEpgSyncWorker(
}
com.streamvault.domain.model.Result.Loading -> Result.retry()
}
+ } catch (cancelled: kotlinx.coroutines.CancellationException) {
+ throw cancelled
} catch (e: Exception) {
Log.e(TAG, "Background EPG work failed for provider $providerId", e)
if (shouldRetry(e)) Result.retry() else Result.failure()
diff --git a/data/src/main/java/com/streamvault/data/sync/CatalogSizeLimits.kt b/data/src/main/java/com/streamvault/data/sync/CatalogSizeLimits.kt
index a9dc111d..4fec36b8 100644
--- a/data/src/main/java/com/streamvault/data/sync/CatalogSizeLimits.kt
+++ b/data/src/main/java/com/streamvault/data/sync/CatalogSizeLimits.kt
@@ -3,5 +3,11 @@ package com.streamvault.data.sync
data class CatalogSizeLimits(
val maxChannelsPerProvider: Int = 100_000,
val maxMoviesPerProvider: Int = 200_000,
- val maxSeriesPerProvider: Int = 100_000
+ val maxSeriesPerProvider: Int = 100_000,
+ val maxM3uDecompressedBytes: Long = 100L * 1024L * 1024L,
+ val maxM3uLineBytes: Int = 16 * 1024,
+ val maxM3uEntries: Int = 300_000,
+ val maxM3uCategoriesPerType: Int = 10_000,
+ val maxM3uFieldLength: Int = 8_192,
+ val maxM3uInvalidEntryRatioPercent: Int = 50
)
diff --git a/data/src/main/java/com/streamvault/data/sync/ProviderSyncWorker.kt b/data/src/main/java/com/streamvault/data/sync/ProviderSyncWorker.kt
index 94f4e556..02531af0 100644
--- a/data/src/main/java/com/streamvault/data/sync/ProviderSyncWorker.kt
+++ b/data/src/main/java/com/streamvault/data/sync/ProviderSyncWorker.kt
@@ -82,6 +82,12 @@ internal suspend fun reconcileTargetedProviderStatus(
}
}
+internal fun isFreshRunningIndexJob(
+ updatedAt: Long,
+ now: Long,
+ staleAfterMillis: Long
+): Boolean = updatedAt <= now && now - updatedAt < staleAfterMillis
+
internal suspend fun shouldTrackInitialLiveOnboarding(
provider: com.streamvault.data.local.entity.ProviderEntity,
onboardingDao: XtreamLiveOnboardingDao
@@ -155,6 +161,8 @@ class ProviderSyncWorker(
}
if (sawRetryableFailure) Result.retry() else Result.success()
+ } catch (cancelled: kotlinx.coroutines.CancellationException) {
+ throw cancelled
} catch (e: Exception) {
Log.e(TAG, "Provider sync worker failed", e)
if (shouldRetry(e)) Result.retry() else Result.failure()
@@ -312,7 +320,7 @@ class ProviderSyncWorker(
): Boolean {
val job = entryPoint.xtreamIndexJobDao().get(providerId, section.name) ?: return true
if (job.state in setOf("QUEUED", "PARTIAL", "STALE", "FAILED_RETRYABLE")) return true
- if (job.state == "RUNNING" && (now - job.updatedAt) < STALE_RUNNING_JOB_MILLIS) return false
+ if (job.state == "RUNNING" && isFreshRunningIndexJob(job.updatedAt, now, STALE_RUNNING_JOB_MILLIS)) return false
return ContentCachePolicy.shouldRefresh(job.lastSuccessAt, ContentCachePolicy.CATALOG_TTL_MILLIS, now)
}
diff --git a/data/src/main/java/com/streamvault/data/sync/StalkerIndexWorker.kt b/data/src/main/java/com/streamvault/data/sync/StalkerIndexWorker.kt
index 9bb07cb5..2d049be3 100644
--- a/data/src/main/java/com/streamvault/data/sync/StalkerIndexWorker.kt
+++ b/data/src/main/java/com/streamvault/data/sync/StalkerIndexWorker.kt
@@ -78,6 +78,8 @@ class StalkerIndexWorker(
}
if (sawRetryableFailure) Result.retry() else Result.success()
+ } catch (cancelled: kotlinx.coroutines.CancellationException) {
+ throw cancelled
} catch (error: Exception) {
Log.e(TAG, "Stalker index worker failed", error)
if (shouldRetry(error)) Result.retry() else Result.failure()
diff --git a/data/src/main/java/com/streamvault/data/sync/SyncCatalogStore.kt b/data/src/main/java/com/streamvault/data/sync/SyncCatalogStore.kt
index b0855616..62b08287 100644
--- a/data/src/main/java/com/streamvault/data/sync/SyncCatalogStore.kt
+++ b/data/src/main/java/com/streamvault/data/sync/SyncCatalogStore.kt
@@ -329,10 +329,22 @@ internal class SyncCatalogStore(
}
suspend fun stageChannelBatch(providerId: Long, sessionId: Long, channels: List<ChannelEntity>) {
+ requireStageCapacity(
+ currentCount = catalogSyncDao.countChannelStages(providerId, sessionId),
+ incomingCount = channels.distinctBy { it.streamId }.size,
+ maximum = sizeLimits.maxChannelsPerProvider,
+ label = "channel"
+ )
insertStageRows(buildChannelStages(providerId, sessionId, channels), catalogSyncDao::insertChannelStages)
}
suspend fun stageMovieBatch(providerId: Long, sessionId: Long, movies: List<MovieEntity>) {
+ requireStageCapacity(
+ currentCount = catalogSyncDao.countMovieStages(providerId, sessionId),
+ incomingCount = movies.distinctBy { it.streamId }.size,
+ maximum = sizeLimits.maxMoviesPerProvider,
+ label = "movie"
+ )
insertStageRows(buildMovieStages(providerId, sessionId, movies), catalogSyncDao::insertMovieStages)
}
@@ -389,6 +401,12 @@ internal class SyncCatalogStore(
clearSession(providerId, sessionId)
}
+ private fun requireStageCapacity(currentCount: Int, incomingCount: Int, maximum: Int, label: String) {
+ if (incomingCount > maximum - currentCount) {
+ throw CatalogAdmissionExceeded("Staged $label limit exceeded")
+ }
+ }
+
suspend fun stagedLiveImportState(providerId: Long, sessionId: Long): StagedLiveImportState {
val stagedCategories = catalogSyncDao.getCategoryStages(providerId, sessionId, "LIVE")
val categorySummaries = catalogSyncDao.getChannelStageCategorySummaries(providerId, sessionId)
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 b9ed9a4b..00643644 100644
--- a/data/src/main/java/com/streamvault/data/sync/SyncManager.kt
+++ b/data/src/main/java/com/streamvault/data/sync/SyncManager.kt
@@ -50,6 +50,7 @@ import com.streamvault.data.remote.xtream.XtreamProvider
import com.streamvault.data.remote.xtream.XtreamUrlFactory
import com.streamvault.data.security.CredentialCrypto
import com.streamvault.data.util.AdultContentClassifier
+import com.streamvault.data.util.runSuspendCatching
import com.streamvault.data.util.UrlSecurityPolicy
import com.streamvault.domain.model.Channel
import com.streamvault.domain.model.GuideSourcePolicy
@@ -214,7 +215,7 @@ class SyncManager @Inject constructor(
syncCatalogStore = syncCatalogStore,
retryTransient = { block -> retryTransient(block = block) },
progress = ::progress,
- syncProgressBus = syncProgressBus
+ emitProgress = ::emitProviderProgress
)
private val xtreamSupport = SyncManagerXtreamSupport(
adaptiveSyncPolicy = xtreamAdaptiveSyncPolicy,
@@ -276,7 +277,7 @@ class SyncManager @Inject constructor(
liveCategorySequentialModeWarning = LIVE_CATEGORY_SEQUENTIAL_MODE_WARNING,
isCurrentlyLowOnMemory = applicationContext::isCurrentlyLowOnMemoryForSync,
stageChannelItems = catalogStager::stageChannelItems,
- syncProgressBus = syncProgressBus
+ emitProgress = ::emitProviderProgress
)
}
@@ -664,6 +665,7 @@ class SyncManager @Inject constructor(
onProgress: ((String) -> Unit)? = null,
trackInitialLiveOnboarding: Boolean = false
): com.streamvault.domain.model.Result<Unit> = withProviderLock(providerId) lock@{
+ var progressSession: SyncProgressSession? = null
try {
val providerEntity = providerDao.getById(providerId)
?: return@lock com.streamvault.domain.model.Result.error("Provider $providerId not found")
@@ -677,6 +679,7 @@ class SyncManager @Inject constructor(
epgSyncMode = epgSyncModeOverride ?: resolvedProvider.epgSyncMode
)
}
+ progressSession = beginProgressSession(providerId)
publishSyncState(providerId, SyncState.Syncing("Starting..."))
try {
@@ -727,9 +730,7 @@ class SyncManager @Inject constructor(
com.streamvault.domain.model.Result.error(safeMessage, e)
}
} finally {
- // D7 — reset systematique du bus a la fin du cycle (succes, exception, abort low-memory)
- // pour eviter qu'un ecran ulterieur n'herite d'un etat de progression obsolete.
- syncProgressBus.reset()
+ progressSession?.let(::finishProgressSession)
}
}
@@ -755,6 +756,7 @@ class SyncManager @Inject constructor(
val now = System.currentTimeMillis()
val warnings = mutableListOf<String>()
+ val progressSession = beginProgressSession(providerId)
try {
withContext(Dispatchers.IO) {
progress(providerId, onProgress, "Marking existing index rows stale...")
@@ -838,6 +840,8 @@ class SyncManager @Inject constructor(
updateSyncStatusMetadata(providerId = providerId, status = "ERROR")
publishSyncState(providerId, SyncState.Error(safeMessage, e))
com.streamvault.domain.model.Result.error(safeMessage, e)
+ } finally {
+ finishProgressSession(progressSession)
}
}
@@ -860,6 +864,7 @@ class SyncManager @Inject constructor(
} ?: resolvedProvider
}
+ val progressSession = beginProgressSession(providerId)
try {
val outcome = withContext(Dispatchers.IO) {
when (section) {
@@ -895,7 +900,7 @@ class SyncManager @Inject constructor(
publishSyncState(providerId, SyncState.Error(safeMessage, e))
com.streamvault.domain.model.Result.error(safeMessage, e)
} finally {
- syncProgressBus.reset()
+ finishProgressSession(progressSession)
}
}
@@ -937,7 +942,7 @@ class SyncManager @Inject constructor(
now = now,
lastAttemptAt = now
)
- val liveOutcome = runCatching {
+ val liveOutcome = runSuspendCatching {
val recoveredLiveCommit = if (trackInitialLiveOnboarding) {
recoverXtreamLiveOnboardingSession(
provider = provider,
@@ -967,7 +972,7 @@ class SyncManager @Inject constructor(
liveCount = acceptedCount
)
syncMetadataRepository.updateMetadata(metadata)
- return@runCatching acceptedCount
+ return@runSuspendCatching acceptedCount
}
if (trackInitialLiveOnboarding) {
@@ -1143,7 +1148,7 @@ class SyncManager @Inject constructor(
// Transition VOD : signale a l'UI qu'on passe a la section Movies. Le total
// reel des categories VOD n'est connu qu'a l'interieur de `syncXtreamCategoryShell`,
// donc on emet en indetermine (total = 0). `itemsIndexed` cumule le LIVE deja importe.
- syncProgressBus.emit(
+ emitProviderProgress(provider.id,
com.streamvault.domain.sync.SyncProgress(
section = com.streamvault.domain.sync.Section.VOD,
current = 0,
@@ -1177,7 +1182,7 @@ class SyncManager @Inject constructor(
// Transition SERIES : meme principe que VOD ci-dessus. `itemsIndexed` reste a
// `liveCount` car VOD ne stage pas d'items dans la base au moment du shell
// (le contenu detaille est rempli ulterieurement par XtreamIndexWorker).
- syncProgressBus.emit(
+ emitProviderProgress(provider.id,
com.streamvault.domain.sync.SyncProgress(
section = com.streamvault.domain.sync.Section.SERIES,
current = 0,
@@ -1420,7 +1425,7 @@ class SyncManager @Inject constructor(
label: String,
now: Long,
onProgress: ((String) -> Unit)?
- ): kotlin.Result<Int> = runCatching {
+ ): kotlin.Result<Int> = runSuspendCatching {
progress(provider.id, onProgress, "Loading $label categories...")
upsertXtreamIndexJob(
providerId = provider.id,
@@ -1491,7 +1496,7 @@ class SyncManager @Inject constructor(
if (!force && !shouldRunXtreamSummaryIndex(job)) {
return@forEach
}
- val failure = runCatching {
+ val failure = runSuspendCatching {
when (contentType) {
ContentType.LIVE -> processXtreamLiveIndexBackfillSection(providerId, onProgress)
ContentType.MOVIE,
@@ -1594,7 +1599,7 @@ class SyncManager @Inject constructor(
val failures = mutableListOf<Throwable>()
var sawRetryableFailure = false
val categoryLimit = maxCategoriesPerSection?.coerceAtLeast(1) ?: STALKER_INDEX_CATEGORY_SLICE_SIZE
- val failure = runCatching {
+ val failure = runSuspendCatching {
processStalkerSummaryIndexSection(
provider = provider,
api = api,
@@ -3753,8 +3758,31 @@ class SyncManager @Inject constructor(
throw IllegalStateException("Playlist is empty or contains no supported entries")
}
warnings += stats.warnings
- if (provider.epgUrl.isBlank() && !stats.header.tvgUrl.isNullOrBlank()) {
- providerDao.updateEpgUrl(provider.id, stats.header.tvgUrl)
+ val playlistEpgUrl = stats.header.tvgUrl
+ if (provider.epgUrl.isBlank() && !playlistEpgUrl.isNullOrBlank()) {
+ providerDao.updateEpgUrl(provider.id, playlistEpgUrl)
+ val existingSourcesByUrl = epgSourceRepository.getAllSources().first().associateBy { it.url }
+ val assignedSourceIds = epgSourceRepository.getAssignmentsForProvider(provider.id)
+ .first()
+ .mapTo(mutableSetOf()) { it.epgSourceId }
+ stats.header.tvgUrls.forEachIndexed { priority, url ->
+ val source = existingSourcesByUrl[url] ?: when (
+ val addResult = epgSourceRepository.addSource("Playlist EPG ${priority + 1}", url)
+ ) {
+ is Result.Success -> addResult.data
+ is Result.Error -> {
+ warnings += "Could not add playlist EPG source: ${addResult.message}"
+ null
+ }
+ Result.Loading -> null
+ }
+ if (source != null && assignedSourceIds.add(source.id)) {
+ when (val assignment = epgSourceRepository.assignSourceToProvider(provider.id, source.id, priority)) {
+ is Result.Error -> warnings += "Could not assign playlist EPG source: ${assignment.message}"
+ else -> Unit
+ }
+ }
+ }
}
metadata = metadata.copy(
lastLiveSync = now,
@@ -3865,7 +3893,7 @@ class SyncManager @Inject constructor(
UrlSecurityPolicy.validateStalkerPortalUrl(provider.serverUrl)?.let { message ->
throw IllegalStateException(message)
}
- emitCatalogSyncProgress(section = Section.LIVE)
+ emitCatalogSyncProgress(provider.id, section = Section.LIVE)
progress(provider.id, onProgress, "Connecting to portal...")
val api = createStalkerSyncProvider(provider)
requireResult(api.authenticate(), "Failed to authenticate with portal")
@@ -3899,7 +3927,7 @@ class SyncManager @Inject constructor(
)
liveCount = liveCatalogResult.acceptedCount
syncMetadataRepository.updateMetadata(metadata)
- emitCatalogSyncProgress(
+ emitCatalogSyncProgress(provider.id,
section = Section.LIVE,
itemsIndexed = liveCatalogResult.acceptedCount
)
@@ -3945,7 +3973,7 @@ class SyncManager @Inject constructor(
}
is com.streamvault.domain.model.Result.Loading -> throw IllegalStateException("Unexpected loading state")
}
- emitCatalogSyncProgress(
+ emitCatalogSyncProgress(provider.id,
section = Section.VOD,
total = categories.size,
itemsIndexed = metadata.liveCount
@@ -4012,7 +4040,7 @@ class SyncManager @Inject constructor(
}
is com.streamvault.domain.model.Result.Loading -> throw IllegalStateException("Unexpected loading state")
}
- emitCatalogSyncProgress(
+ emitCatalogSyncProgress(provider.id,
section = Section.SERIES,
total = categories.size,
itemsIndexed = metadata.liveCount
@@ -4096,66 +4124,62 @@ class SyncManager @Inject constructor(
val decryptedPassword = credentialCrypto.decryptIfNeeded(provider.password)
val decryptedProvider = provider.copy(password = decryptedPassword)
android.util.Log.d("JellyfinSync", "Starting Jellyfin sync for provider=${provider.id}")
- progress(provider.id, onProgress, "Loading Jellyfin library...")
- val (resolvedMovies, resolvedSeries) = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) {
- val movieResult = jellyfinProvider.fetchMovies(decryptedProvider)
- val seriesResult = jellyfinProvider.fetchSeries(decryptedProvider)
- movieResult to seriesResult
- }
- if (resolvedMovies is com.streamvault.domain.model.Result.Error) android.util.Log.e("JellyfinSync", "Movies error: ${resolvedMovies.message}")
- if (resolvedSeries is com.streamvault.domain.model.Result.Error) android.util.Log.e("JellyfinSync", "Series error: ${resolvedSeries.message}")
-
- if (resolvedMovies is com.streamvault.domain.model.Result.Error && resolvedSeries is com.streamvault.domain.model.Result.Error) {
- warnings.add("Failed to load Jellyfin catalog: ${resolvedMovies.message}; ${resolvedSeries.message}")
- return SyncOutcome(partial = true, warnings = warnings)
- }
-
- val movieEntities = (resolvedMovies as? com.streamvault.domain.model.Result.Success)?.data.orEmpty()
- val seriesEntities = (resolvedSeries as? com.streamvault.domain.model.Result.Success)?.data.orEmpty()
-
- if (movieEntities.isNotEmpty()) {
- progress(provider.id, onProgress, "Importing Jellyfin movies...")
- movieEntities.chunked(50).forEach { chunk ->
- transactionRunner.inTransaction {
- movieDao.upsertCategoryPage(provider.id, chunk)
+ progress(provider.id, onProgress, "Loading Jellyfin movies...")
+ val movieSession = syncCatalogStore.newSessionId()
+ val seriesSession = syncCatalogStore.newSessionId()
+ syncCatalogStore.clearProviderStaging(provider.id)
+ try {
+ var movieStart = 0
+ var movieTotal: Int? = null
+ do {
+ when (val result = jellyfinProvider.fetchMoviesPage(decryptedProvider, movieStart)) {
+ is com.streamvault.domain.model.Result.Error -> throw result.exception ?: IllegalStateException(result.message)
+ is com.streamvault.domain.model.Result.Success -> {
+ val page = result.data
+ movieTotal = movieTotal ?: page.totalRecordCount
+ if (page.totalRecordCount != movieTotal || page.totalRecordCount > 200_000) throw IllegalStateException("Jellyfin movie catalog is unstable or exceeds the supported limit")
+ syncCatalogStore.stageMovieBatch(provider.id, movieSession, page.items)
+ movieStart = page.nextStartIndex
+ }
+ is com.streamvault.domain.model.Result.Loading -> Unit
}
+ } while (movieStart < (movieTotal ?: 0))
+ if (catalogSyncDao.countMovieStages(provider.id, movieSession) != (movieTotal ?: 0)) {
+ throw IllegalStateException("Jellyfin movie pagination returned duplicate or invalid items")
}
- transactionRunner.inTransaction {
- categoryDao.replaceAll(provider.id, com.streamvault.domain.model.ContentType.MOVIE.name, listOf(
- com.streamvault.data.local.entity.CategoryEntity(
- providerId = provider.id, categoryId = 1L, name = "Movies",
- type = com.streamvault.domain.model.ContentType.MOVIE
- )
- ))
- }
- }
- if (seriesEntities.isNotEmpty()) {
- progress(provider.id, onProgress, "Importing Jellyfin series...")
- seriesEntities.forEach { seriesEntity ->
- val remoteId = seriesEntity.providerSeriesId
- if (!remoteId.isNullOrBlank()) {
- transactionRunner.inTransaction {
- seriesDao.insertAll(listOf(seriesEntity))
+ progress(provider.id, onProgress, "Loading Jellyfin series...")
+ var seriesStart = 0
+ var seriesTotal: Int? = null
+ do {
+ when (val result = jellyfinProvider.fetchSeriesPage(decryptedProvider, seriesStart)) {
+ is com.streamvault.domain.model.Result.Error -> throw result.exception ?: IllegalStateException(result.message)
+ is com.streamvault.domain.model.Result.Success -> {
+ val page = result.data
+ seriesTotal = seriesTotal ?: page.totalRecordCount
+ if (page.totalRecordCount != seriesTotal || page.totalRecordCount > 100_000) throw IllegalStateException("Jellyfin series catalog is unstable or exceeds the supported limit")
+ syncCatalogStore.stageSeriesBatch(provider.id, seriesSession, page.items)
+ seriesStart = page.nextStartIndex
}
+ is com.streamvault.domain.model.Result.Loading -> Unit
}
+ } while (seriesStart < (seriesTotal ?: 0))
+ if (catalogSyncDao.countSeriesStages(provider.id, seriesSession) != (seriesTotal ?: 0)) {
+ throw IllegalStateException("Jellyfin series pagination returned duplicate or invalid items")
}
- transactionRunner.inTransaction {
- categoryDao.replaceAll(provider.id, com.streamvault.domain.model.ContentType.SERIES.name, listOf(
- com.streamvault.data.local.entity.CategoryEntity(
- providerId = provider.id, categoryId = 2L, name = "Series",
- type = com.streamvault.domain.model.ContentType.SERIES
- )
- ))
- }
- }
- if (movieEntities.isEmpty() && seriesEntities.isEmpty()) {
- warnings.add("Jellyfin library is empty or contains no supported movies or series.")
- return SyncOutcome(partial = true, warnings = warnings)
+ progress(provider.id, onProgress, "Importing Jellyfin library...")
+ syncCatalogStore.applyStagedMovieCatalog(provider.id, movieSession, listOf(
+ com.streamvault.data.local.entity.CategoryEntity(providerId = provider.id, categoryId = 1L, name = "Movies", type = com.streamvault.domain.model.ContentType.MOVIE)
+ ))
+ syncCatalogStore.applyStagedSeriesCatalog(provider.id, seriesSession, listOf(
+ com.streamvault.data.local.entity.CategoryEntity(providerId = provider.id, categoryId = 2L, name = "Series", type = com.streamvault.domain.model.ContentType.SERIES)
+ ))
+ return SyncOutcome(warnings = warnings)
+ } catch (error: Exception) {
+ syncCatalogStore.clearProviderStaging(provider.id)
+ throw error
}
-
- return SyncOutcome(warnings = warnings)
} catch (e: Exception) {
warnings.add("Jellyfin sync failed: ${e.message.orEmpty()}")
return SyncOutcome(partial = true, warnings = warnings)
@@ -4530,7 +4554,7 @@ class SyncManager @Inject constructor(
}
}
- runCatching {
+ runSuspendCatching {
// Stream the bulk EPG payload program-by-program; the previous buffered API
// could materialise >30 MB JSON trees on certain Stalker portals which led to
// OOM crashes when re-entering content screens.
@@ -4565,7 +4589,7 @@ class SyncManager @Inject constructor(
fallbackGuideRequests.forEachIndexed { index, request ->
if (ignorePerChannelGuide) return@forEachIndexed
progress(provider.id, onProgress, "Downloading portal EPG... ${index + 1} of ${fallbackGuideRequests.size}")
- runCatching {
+ runSuspendCatching {
var perChannelRecordCount = 0
val foreignChannelIds = HashSet<String>()
val streamResult = api.streamEpg(request.channelKey) { program ->
@@ -4821,7 +4845,7 @@ class SyncManager @Inject constructor(
syncMetadataRepository.updateMetadata(metadata)
}
ProviderType.STALKER_PORTAL -> {
- emitCatalogSyncProgress(section = Section.LIVE)
+ emitCatalogSyncProgress(provider.id, section = Section.LIVE)
progress(provider.id, onProgress, "Retrying Live TV...")
upsertXtreamIndexJob(
providerId = provider.id,
@@ -4843,7 +4867,7 @@ class SyncManager @Inject constructor(
liveCount = liveCatalogResult.acceptedCount
)
syncMetadataRepository.updateMetadata(metadata)
- emitCatalogSyncProgress(
+ emitCatalogSyncProgress(provider.id,
section = Section.LIVE,
itemsIndexed = liveCatalogResult.acceptedCount
)
@@ -4937,7 +4961,7 @@ class SyncManager @Inject constructor(
progress(provider.id, onProgress, "Queueing Movies index...")
val api = createStalkerSyncProvider(provider)
val categories = requireResult(api.getVodCategories(), "Failed to load movie categories")
- emitCatalogSyncProgress(
+ emitCatalogSyncProgress(provider.id,
section = Section.VOD,
total = categories.size,
itemsIndexed = movieDao.getCount(provider.id).first()
@@ -5026,7 +5050,7 @@ class SyncManager @Inject constructor(
progress(provider.id, onProgress, "Queueing Series index...")
val api = createStalkerSyncProvider(provider)
val categories = requireResult(api.getSeriesCategories(), "Failed to load series categories")
- emitCatalogSyncProgress(
+ emitCatalogSyncProgress(provider.id,
section = Section.SERIES,
total = categories.size,
itemsIndexed = seriesDao.getCount(provider.id).first()
@@ -5082,7 +5106,7 @@ class SyncManager @Inject constructor(
// Emission d'entree LIVE : signale tot a l'UI que la section LIVE demarre,
// avant meme la requete `get_live_categories`. `total = 0` = indetermine ;
// la premiere fin de fenetre (T5) viendra raffiner avec le vrai denominateur.
- syncProgressBus.emit(
+ emitProviderProgress(provider.id,
com.streamvault.domain.sync.SyncProgress(
section = com.streamvault.domain.sync.Section.LIVE,
current = 0,
@@ -5353,13 +5377,14 @@ class SyncManager @Inject constructor(
}
private fun emitCatalogSyncProgress(
+ providerId: Long,
section: Section,
current: Int = 0,
total: Int = 0,
currentLabel: String = "",
itemsIndexed: Int = 0
) {
- syncProgressBus.emit(
+ emitProviderProgress(providerId,
SyncProgress(
section = section,
current = current,
@@ -5374,6 +5399,20 @@ class SyncManager @Inject constructor(
syncStateTracker.publish(providerId, state)
}
+ private val progressSessions = ConcurrentHashMap<Long, SyncProgressSession>()
+
+ private fun beginProgressSession(providerId: Long): SyncProgressSession =
+ syncProgressBus.begin(providerId).also { progressSessions[providerId] = it }
+
+ private fun finishProgressSession(session: SyncProgressSession) {
+ progressSessions.remove(session.providerId, session)
+ syncProgressBus.finish(session)
+ }
+
+ private fun emitProviderProgress(providerId: Long, progress: SyncProgress) {
+ progressSessions[providerId]?.let { session -> syncProgressBus.emit(session, progress) }
+ }
+
private fun redactUrlForLogs(url: String?): String {
if (url.isNullOrBlank()) return "<empty>"
return runCatching {
diff --git a/data/src/main/java/com/streamvault/data/sync/SyncManagerM3uImporter.kt b/data/src/main/java/com/streamvault/data/sync/SyncManagerM3uImporter.kt
index 809886f0..75aecfaf 100644
--- a/data/src/main/java/com/streamvault/data/sync/SyncManagerM3uImporter.kt
+++ b/data/src/main/java/com/streamvault/data/sync/SyncManagerM3uImporter.kt
@@ -5,6 +5,7 @@ import com.streamvault.data.local.entity.ChannelEntity
import com.streamvault.data.local.entity.MovieEntity
import com.streamvault.data.parser.M3uParser
import com.streamvault.data.remote.http.HttpRequestProfile
+import com.streamvault.data.remote.http.useCancellableResponse
import com.streamvault.data.remote.http.safeRequestIdentitySummary
import com.streamvault.data.remote.http.toGenericRequestProfile
import com.streamvault.data.remote.http.withRequestProfile
@@ -32,7 +33,8 @@ internal class SyncManagerM3uImporter(
private val syncCatalogStore: SyncCatalogStore,
private val retryTransient: suspend (suspend () -> Unit) -> Unit,
private val progress: (Long, ((String) -> Unit)?, String) -> Unit,
- private val syncProgressBus: SyncProgressBus
+ private val emitProgress: (Long, SyncProgress) -> Unit,
+ private val sizeLimits: CatalogSizeLimits = CatalogSizeLimits()
) {
suspend fun importPlaylist(
provider: Provider,
@@ -48,7 +50,7 @@ internal class SyncManagerM3uImporter(
// D14 — emission M3U etape Downloading : Section.LIVE par convention (le M3U
// peut contenir un melange Live/VOD, mais l'UI ne distingue pas). Mode
// indetermine (total = 0) puisqu'on ne connait pas encore la taille du flux.
- syncProgressBus.emit(
+ emitProgress(provider.id,
SyncProgress(
section = Section.LIVE,
current = 0,
@@ -70,15 +72,19 @@ internal class SyncManagerM3uImporter(
var liveCount = 0
var movieCount = 0
var parsedCount = 0
+ var invalidEntryCount = 0
var nextMilestone = M3U_PROGRESS_INTERVAL
val warnings = mutableListOf<String>()
var insecureStreamCount = 0
try {
openPlaylistStream(provider) { streamed ->
+ streamed.contentLength
+ ?.takeIf { it > sizeLimits.maxM3uDecompressedBytes }
+ ?.let { throw CatalogAdmissionExceeded("M3U response length limit exceeded") }
progress(provider.id, onProgress, "Parsing Playlist...")
// D14 — emission M3U etape Parsing : meme section / mode indetermine.
- syncProgressBus.emit(
+ emitProgress(provider.id,
SyncProgress(
section = Section.LIVE,
current = 0,
@@ -87,24 +93,32 @@ internal class SyncManagerM3uImporter(
itemsIndexed = 0
)
)
- maybeDecompressPlaylist(streamed).use { input ->
+ BoundedInputStream(
+ input = maybeDecompressPlaylist(streamed),
+ maximumBytes = sizeLimits.maxM3uDecompressedBytes,
+ maximumLineBytes = sizeLimits.maxM3uLineBytes
+ ).use { input ->
m3uParser.parseStreaming(
inputStream = input,
onHeader = { parsedHeader ->
- val validEpgUrl = parsedHeader.tvgUrl?.takeIf { UrlSecurityPolicy.validateOptionalEpgUrl(it) == null }
- if (parsedHeader.tvgUrl != null && validEpgUrl == null) {
+ val validEpgUrls = parsedHeader.tvgUrls.filter { UrlSecurityPolicy.validateOptionalEpgUrl(it) == null }
+ if (validEpgUrls.size != parsedHeader.tvgUrls.size) {
warnings += "Ignored unsupported EPG URL from playlist header."
}
- header = parsedHeader.copy(tvgUrl = validEpgUrl)
- }
- ) { entry ->
+ header = parsedHeader.copy(tvgUrls = validEpgUrls)
+ },
+ onEntry = { entry ->
parsedCount++
+ if (parsedCount > sizeLimits.maxM3uEntries) {
+ throw CatalogAdmissionExceeded("M3U entry limit exceeded")
+ }
+ requireM3uFieldBounds(entry.name, entry.url, entry.groupTitle)
if (parsedCount >= nextMilestone) {
progress(provider.id, onProgress, "Imported $parsedCount playlist entries...")
// D14 — emission M3U etape Imported : current = nombre d'entrees
// parsees jusqu'ici (palier de M3U_PROGRESS_INTERVAL), `itemsIndexed`
// refletera la meme valeur (compteur cumulatif local).
- syncProgressBus.emit(
+ emitProgress(provider.id,
SyncProgress(
section = Section.LIVE,
current = parsedCount,
@@ -136,7 +150,9 @@ internal class SyncManagerM3uImporter(
hasher = stableLongHasher
)
if (seenMovieStreamIds?.add(stableStreamId) != true) return@parseStreaming
+ if (movieCount >= sizeLimits.maxMoviesPerProvider) throw CatalogAdmissionExceeded("M3U movie limit exceeded")
val categoryId = movieCategories.idFor(groupTitle)
+ if (movieCategories.count > sizeLimits.maxM3uCategoriesPerType) throw CatalogAdmissionExceeded("M3U movie category limit exceeded")
val isAdult = AdultContentClassifier.isAdultCategoryName(groupTitle)
movieBatch.add(
MovieEntity(
@@ -170,7 +186,9 @@ internal class SyncManagerM3uImporter(
hasher = stableLongHasher
)
if (seenLiveStreamIds?.add(stableStreamId) != true) return@parseStreaming
+ if (liveCount >= sizeLimits.maxChannelsPerProvider) throw CatalogAdmissionExceeded("M3U live-channel limit exceeded")
val categoryId = liveCategories.idFor(groupTitle)
+ if (liveCategories.count > sizeLimits.maxM3uCategoriesPerType) throw CatalogAdmissionExceeded("M3U live category limit exceeded")
val isAdult = AdultContentClassifier.isAdultCategoryName(groupTitle)
channelBatch.add(
ChannelEntity(
@@ -197,7 +215,17 @@ internal class SyncManagerM3uImporter(
flushChannelBatch(provider.id, sessionId, channelBatch)
}
}
- }
+ },
+ onInvalidEntry = {
+ invalidEntryCount++
+ val candidateCount = parsedCount + invalidEntryCount
+ if (candidateCount >= 100 &&
+ invalidEntryCount * 100 > candidateCount * sizeLimits.maxM3uInvalidEntryRatioPercent
+ ) {
+ throw CatalogAdmissionExceeded("M3U invalid-entry ratio limit exceeded")
+ }
+ }
+ )
}
}
@@ -240,7 +268,7 @@ internal class SyncManagerM3uImporter(
val urlStr = provider.m3uUrl.ifBlank { provider.serverUrl }
if (urlStr.startsWith("file:")) {
java.io.File(java.net.URI(urlStr)).inputStream().use { input ->
- block(StreamedPlaylist(inputStream = input, sourceName = urlStr))
+ block(StreamedPlaylist(inputStream = input, contentLength = java.io.File(java.net.URI(urlStr)).length(), sourceName = urlStr))
}
return
}
@@ -251,7 +279,7 @@ internal class SyncManagerM3uImporter(
.url(urlStr)
.build()
.withRequestProfile(requestProfile)
- okHttpClient.newCall(request).execute().use { response ->
+ okHttpClient.newCall(request).useCancellableResponse { response ->
ensureSuccessfulPlaylistResponse(response, requestProfile)
val body = response.body ?: throw IllegalStateException("Empty M3U response")
body.byteStream().use { input ->
@@ -259,6 +287,7 @@ internal class SyncManagerM3uImporter(
StreamedPlaylist(
inputStream = input,
contentEncoding = response.header("Content-Encoding"),
+ contentLength = body.contentLength().takeIf { it >= 0L },
sourceName = urlStr
)
)
@@ -368,4 +397,40 @@ internal class SyncManagerM3uImporter(
private fun normalizeTextForIdentity(value: String?): String {
return value.orEmpty().lowercase().replace(Regex("\\s+"), " ").trim()
}
+
+ private fun requireM3uFieldBounds(vararg fields: String?) {
+ if (fields.any { it != null && it.length > sizeLimits.maxM3uFieldLength }) {
+ throw CatalogAdmissionExceeded("M3U field length limit exceeded")
+ }
+ }
+
+ private class BoundedInputStream(
+ input: InputStream,
+ private val maximumBytes: Long,
+ private val maximumLineBytes: Int
+ ) : java.io.FilterInputStream(input) {
+ private var readBytes = 0L
+ private var lineBytes = 0
+
+ override fun read(): Int = super.read().also { if (it >= 0) count(byteArrayOf(it.toByte())) }
+
+ override fun read(buffer: ByteArray, offset: Int, length: Int): Int = super.read(buffer, offset, length).also {
+ if (it > 0) count(buffer, offset, it)
+ }
+
+ private fun count(bytes: ByteArray, offset: Int = 0, length: Int = bytes.size) {
+ readBytes += length
+ if (readBytes > maximumBytes) throw CatalogAdmissionExceeded("M3U decompressed byte limit exceeded")
+ for (index in offset until offset + length) {
+ if (bytes[index].toInt().toChar() == '\n') {
+ lineBytes = 0
+ } else {
+ lineBytes++
+ if (lineBytes > maximumLineBytes) throw CatalogAdmissionExceeded("M3U line length limit exceeded")
+ }
+ }
+ }
+ }
}
+
+internal class CatalogAdmissionExceeded(message: String) : IllegalStateException(message)
diff --git a/data/src/main/java/com/streamvault/data/sync/SyncManagerSupport.kt b/data/src/main/java/com/streamvault/data/sync/SyncManagerSupport.kt
index 3903b3d9..99761557 100644
--- a/data/src/main/java/com/streamvault/data/sync/SyncManagerSupport.kt
+++ b/data/src/main/java/com/streamvault/data/sync/SyncManagerSupport.kt
@@ -103,6 +103,7 @@ internal data class M3uImportStats(
internal data class StreamedPlaylist(
val inputStream: InputStream,
val contentEncoding: String? = null,
+ val contentLength: Long? = null,
val sourceName: String? = null
)
diff --git a/data/src/main/java/com/streamvault/data/sync/SyncManagerXtreamFetcher.kt b/data/src/main/java/com/streamvault/data/sync/SyncManagerXtreamFetcher.kt
index 21bbc74e..4cd2809d 100644
--- a/data/src/main/java/com/streamvault/data/sync/SyncManagerXtreamFetcher.kt
+++ b/data/src/main/java/com/streamvault/data/sync/SyncManagerXtreamFetcher.kt
@@ -9,6 +9,7 @@ import com.streamvault.data.remote.xtream.OkHttpXtreamApiService
import com.streamvault.data.remote.xtream.XtreamApiService
import com.streamvault.data.remote.xtream.XtreamProvider
import com.streamvault.data.remote.xtream.XtreamUrlFactory
+import com.streamvault.data.util.runSuspendCatching
import com.streamvault.domain.model.Channel
import com.streamvault.domain.model.Movie
import com.streamvault.domain.model.Provider
@@ -82,7 +83,7 @@ internal class SyncManagerXtreamFetcher(
when (val attempt = xtreamSupport.attemptNonCancellation {
xtreamSupport.retryXtreamCatalogTransient(provider.id) {
xtreamSupport.executeXtreamRequest(provider.id, XtreamAdaptiveSyncPolicy.Stage.CATEGORY) {
- val thinResult = runCatching {
+ val thinResult = runSuspendCatching {
streamThinRowsInBatches()
}
val thinCount = thinResult.getOrNull()?.first ?: 0
diff --git a/data/src/main/java/com/streamvault/data/sync/SyncManagerXtreamLiveStrategy.kt b/data/src/main/java/com/streamvault/data/sync/SyncManagerXtreamLiveStrategy.kt
index d2837ec3..849a8c41 100644
--- a/data/src/main/java/com/streamvault/data/sync/SyncManagerXtreamLiveStrategy.kt
+++ b/data/src/main/java/com/streamvault/data/sync/SyncManagerXtreamLiveStrategy.kt
@@ -43,7 +43,7 @@ internal class SyncManagerXtreamLiveStrategy(
private val liveCategorySequentialModeWarning: String,
private val isCurrentlyLowOnMemory: () -> Boolean = { false },
private val stageChannelItems: suspend (Long, List<Channel>, MutableSet<Long>, FallbackCategoryCollector, Long?) -> StagedCatalogSnapshot,
- private val syncProgressBus: SyncProgressBus
+ private val emitProgress: (Long, SyncProgress) -> Unit
) {
suspend fun syncXtreamLiveCatalog(
provider: Provider,
@@ -247,7 +247,7 @@ internal class SyncManagerXtreamLiveStrategy(
// deja acceptes). Le `reset()` du finally cote SyncManager (T3) viendra
// ensuite ramener le flow a null — c'est volontaire (D7) pour eviter que
// l'ecran suivant n'herite d'un etat partiel.
- syncProgressBus.emit(
+ emitProgress(provider.id,
SyncProgress(
section = Section.LIVE,
current = 0,
@@ -286,7 +286,7 @@ internal class SyncManagerXtreamLiveStrategy(
// on emet en indetermine (`total = 0`) une fois par flush de batch (cadence
// <= 1/s en pratique, jamais par item). Le label reste vide car aucune
// categorie ne correspond a la fenetre courante.
- syncProgressBus.emit(
+ emitProgress(provider.id,
SyncProgress(
section = Section.LIVE,
current = 0,
@@ -464,7 +464,7 @@ internal class SyncManagerXtreamLiveStrategy(
// `stagedAcceptedCount` est mis a jour de maniere thread-safe sous le
// `stageMutex` (cf `stageMappedBatch`), la lecture ici est best-effort
// (snapshot UX, pas une metrique business).
- syncProgressBus.emit(
+ emitProgress(provider.id,
SyncProgress(
section = Section.LIVE,
current = completed,
diff --git a/data/src/main/java/com/streamvault/data/sync/SyncProgressBus.kt b/data/src/main/java/com/streamvault/data/sync/SyncProgressBus.kt
index f4f580d3..594cce95 100644
--- a/data/src/main/java/com/streamvault/data/sync/SyncProgressBus.kt
+++ b/data/src/main/java/com/streamvault/data/sync/SyncProgressBus.kt
@@ -1,35 +1,81 @@
package com.streamvault.data.sync
import com.streamvault.domain.sync.SyncProgress
+import java.util.concurrent.atomic.AtomicLong
import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
+/** Identifies one run of a provider sync. */
+data class SyncProgressSession(val providerId: Long, val epoch: Long)
+
+data class ProviderSyncProgress(
+ val session: SyncProgressSession,
+ val progress: SyncProgress,
+ val updatedAt: Long = System.currentTimeMillis()
+)
+
+/** A presentation-oriented summary; it is deliberately derived from keyed state. */
+data class SyncProgressAggregate(
+ val activeProviderCount: Int,
+ val representative: ProviderSyncProgress
+)
+
/**
- * Bus singleton de progression du sync catalogue.
- *
- * Publie le dernier [SyncProgress] émis par `SyncManager` et ses stratégies, consommé
- * par `WelcomeViewModel` côté `:app`. Pattern miroir de `SyncStateTracker` (StateFlow
- * privé mutable + façade publique read-only).
- *
- * Valeur initiale `null` = aucun sync en cours / écran fallback. `reset()` ramène
- * explicitement le flow à `null` à la fin de chaque cycle (succès, échec ou abort
- * low-memory) pour éviter qu'un écran ultérieur n'hérite d'un état obsolète.
+ * Process-local catalog-sync progress keyed by provider and monotonically increasing session epoch.
+ * A completion or late update only affects the session that created it; it cannot clear progress
+ * published by another provider.
*/
@Singleton
class SyncProgressBus @Inject constructor() {
+ private val nextEpoch = AtomicLong(0)
+ private val lock = Any()
+ private val activeSessions = mutableMapOf<Long, SyncProgressSession>()
+ private val _progressByProvider = MutableStateFlow<Map<Long, ProviderSyncProgress>>(emptyMap())
+ private val _aggregate = MutableStateFlow<SyncProgressAggregate?>(null)
+
+ val progressByProvider: StateFlow<Map<Long, ProviderSyncProgress>> = _progressByProvider.asStateFlow()
- private val _flow = MutableStateFlow<SyncProgress?>(null)
+ val aggregate: StateFlow<SyncProgressAggregate?> = _aggregate.asStateFlow()
- val flow: StateFlow<SyncProgress?> = _flow.asStateFlow()
+ fun begin(providerId: Long): SyncProgressSession {
+ val session = SyncProgressSession(providerId, nextEpoch.incrementAndGet())
+ synchronized(lock) {
+ activeSessions[providerId] = session
+ // A new session replaces only this provider's prior presentation state.
+ _progressByProvider.value = _progressByProvider.value - providerId
+ publishAggregate()
+ }
+ return session
+ }
+
+ fun emit(session: SyncProgressSession, progress: SyncProgress) {
+ synchronized(lock) {
+ if (activeSessions[session.providerId] != session) return
+ _progressByProvider.value = _progressByProvider.value + (
+ session.providerId to ProviderSyncProgress(session, progress)
+ )
+ publishAggregate()
+ }
+ }
- fun emit(progress: SyncProgress) {
- _flow.value = progress
+ fun finish(session: SyncProgressSession) {
+ synchronized(lock) {
+ if (activeSessions[session.providerId] != session) return
+ activeSessions.remove(session.providerId)
+ _progressByProvider.value = _progressByProvider.value - session.providerId
+ publishAggregate()
+ }
}
- fun reset() {
- _flow.value = null
+ private fun publishAggregate() {
+ val active = _progressByProvider.value
+ _aggregate.value = active.values.maxWithOrNull(
+ compareBy<ProviderSyncProgress> { it.updatedAt }.thenBy { it.session.epoch }
+ )?.let { representative ->
+ SyncProgressAggregate(active.size, representative)
+ }
}
}
diff --git a/data/src/main/java/com/streamvault/data/sync/SyncWorker.kt b/data/src/main/java/com/streamvault/data/sync/SyncWorker.kt
index 35680df4..0f68d340 100644
--- a/data/src/main/java/com/streamvault/data/sync/SyncWorker.kt
+++ b/data/src/main/java/com/streamvault/data/sync/SyncWorker.kt
@@ -58,6 +58,8 @@ class SyncWorker(
"reclaimableBytes=${report.statsAfterVacuum.reclaimableBytes}"
)
Result.success()
+ } catch (cancelled: kotlinx.coroutines.CancellationException) {
+ throw cancelled
} catch (e: Exception) {
Log.e("SyncWorker", "Failed to run data maintenance", e)
if (shouldRetry(e)) Result.retry() else Result.failure()
diff --git a/data/src/main/java/com/streamvault/data/sync/XtreamIndexWorker.kt b/data/src/main/java/com/streamvault/data/sync/XtreamIndexWorker.kt
index 3c9f9e09..9d49732e 100644
--- a/data/src/main/java/com/streamvault/data/sync/XtreamIndexWorker.kt
+++ b/data/src/main/java/com/streamvault/data/sync/XtreamIndexWorker.kt
@@ -80,6 +80,8 @@ class XtreamIndexWorker(
}
if (sawRetryableFailure) Result.retry() else Result.success()
+ } catch (cancelled: kotlinx.coroutines.CancellationException) {
+ throw cancelled
} catch (error: Exception) {
Log.e(TAG, "Xtream index worker failed", error)
if (shouldRetry(error)) Result.retry() else Result.failure()
diff --git a/data/src/main/java/com/streamvault/data/util/CoroutineCancellation.kt b/data/src/main/java/com/streamvault/data/util/CoroutineCancellation.kt
new file mode 100644
index 00000000..7a1b8d0d
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/util/CoroutineCancellation.kt
@@ -0,0 +1,18 @@
+package com.streamvault.data.util
+
+import kotlinx.coroutines.CancellationException
+
+/** Kotlin's standard runCatching catches coroutine cancellation; suspend owners must not. */
+internal suspend inline fun <T> runSuspendCatching(
+ block: suspend () -> T
+): kotlin.Result<T> = try {
+ kotlin.Result.success(block())
+} catch (cancelled: CancellationException) {
+ throw cancelled
+} catch (error: Throwable) {
+ kotlin.Result.failure(error)
+}
+
+internal fun Throwable.rethrowIfCancellation() {
+ if (this is CancellationException) throw this
+}
diff --git a/data/src/test/java/com/streamvault/data/Wp1CancellationPolicyTest.kt b/data/src/test/java/com/streamvault/data/Wp1CancellationPolicyTest.kt
new file mode 100644
index 00000000..4be6a124
--- /dev/null
+++ b/data/src/test/java/com/streamvault/data/Wp1CancellationPolicyTest.kt
@@ -0,0 +1,49 @@
+package com.streamvault.data
+
+import com.google.common.truth.Truth.assertWithMessage
+import java.io.File
+import org.junit.Test
+
+class Wp1CancellationPolicyTest {
+
+ private val root = generateSequence(File(System.getProperty("user.dir")).absoluteFile) { it.parentFile }
+ .first { File(it, "settings.gradle.kts").isFile }
+
+ @Test
+ fun `WP1 owners do not regress to blocking or cancellation-swallowing calls`() {
+ val workers = listOf(
+ "SyncWorker.kt",
+ "BackgroundEpgSyncWorker.kt",
+ "ProviderSyncWorker.kt",
+ "StalkerIndexWorker.kt",
+ "XtreamIndexWorker.kt"
+ ).map { root.resolve("data/src/main/java/com/streamvault/data/sync/$it") }
+ workers.forEach { file ->
+ val source = file.readText()
+ assertWithMessage("${file.name} must rethrow cancellation before broad worker catches")
+ .that(source.indexOf("catch (cancelled: kotlinx.coroutines.CancellationException)"))
+ .isLessThan(source.indexOf("catch (e: Exception)").takeIf { it >= 0 }
+ ?: source.indexOf("catch (error: Exception)"))
+ }
+
+ val stalker = root.resolve(
+ "data/src/main/java/com/streamvault/data/remote/stalker/OkHttpStalkerApiService.kt"
+ ).readText()
+ assertWithMessage("Stalker suspend transport must not use blocking execute()")
+ .that(stalker).doesNotContain(".execute()")
+ assertWithMessage("Stalker network fallbacks must use runSuspendCatching")
+ .that(stalker).doesNotContain("runCatching {\n requestJson(")
+
+ val xtream = root.resolve(
+ "data/src/main/java/com/streamvault/data/remote/xtream/XtreamProvider.kt"
+ ).readText()
+ assertWithMessage("Xtream compatibility fallback must preserve cancellation")
+ .that(xtream).doesNotContain("runCatching { requestSeriesInfo(")
+
+ val plugins = root.resolve(
+ "app/src/main/java/com/streamvault/app/plugins/StreamVaultPluginManager.kt"
+ ).readText()
+ assertWithMessage("Plugin IPC must not use raw runCatching")
+ .that(plugins).doesNotContain("runCatching {\n messengerClient.send(")
+ }
+}
diff --git a/data/src/test/java/com/streamvault/data/manager/ActiveCaptureTest.kt b/data/src/test/java/com/streamvault/data/manager/ActiveCaptureTest.kt
new file mode 100644
index 00000000..2fb6c47e
--- /dev/null
+++ b/data/src/test/java/com/streamvault/data/manager/ActiveCaptureTest.kt
@@ -0,0 +1,38 @@
+package com.streamvault.data.manager
+
+import com.google.common.truth.Truth.assertThat
+import java.util.concurrent.atomic.AtomicBoolean
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.CoroutineStart
+import kotlinx.coroutines.NonCancellable
+import kotlinx.coroutines.awaitCancellation
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.runBlocking
+import kotlinx.coroutines.withContext
+import org.junit.Test
+
+class ActiveCaptureTest {
+
+ @Test
+ fun `cancelAndJoin returns only after capture cleanup completes`() = runBlocking {
+ val cleanedUp = AtomicBoolean(false)
+ val job = launch(Dispatchers.IO, start = CoroutineStart.UNDISPATCHED) {
+ try {
+ awaitCancellation()
+ } finally {
+ withContext(NonCancellable) {
+ delay(25)
+ cleanedUp.set(true)
+ }
+ }
+ }
+ val capture = ActiveCapture(job)
+
+ capture.cancelAndJoin()
+ capture.cancelAndJoin()
+
+ assertThat(cleanedUp.get()).isTrue()
+ assertThat(capture.isActive).isFalse()
+ }
+}
diff --git a/data/src/test/java/com/streamvault/data/manager/ProgramReminderManagerImplTest.kt b/data/src/test/java/com/streamvault/data/manager/ProgramReminderManagerImplTest.kt
index fdfeacc3..66d66bb6 100644
--- a/data/src/test/java/com/streamvault/data/manager/ProgramReminderManagerImplTest.kt
+++ b/data/src/test/java/com/streamvault/data/manager/ProgramReminderManagerImplTest.kt
@@ -35,6 +35,7 @@ class ProgramReminderManagerImplTest {
init {
whenever(alarmScheduler.canScheduleExactAlarms()).thenReturn(true)
whenever(alarmScheduler.schedule(org.mockito.kotlin.any(), org.mockito.kotlin.any())).thenReturn(Result.success(Unit))
+ whenever(notifier.showReminder(org.mockito.kotlin.any())).thenReturn(Result.success(Unit))
}
@Test
@@ -86,6 +87,42 @@ class ProgramReminderManagerImplTest {
verify(alarmScheduler, never()).schedule(org.mockito.kotlin.any(), org.mockito.kotlin.any())
}
+ @Test
+ fun `scheduleReminder keeps existing reminder when replacement alarm fails`() = runTest {
+ val now = System.currentTimeMillis()
+ val program = Program(
+ channelId = "bbc1",
+ title = "World News",
+ startTime = now + 30 * 60_000L,
+ endTime = now + 60 * 60_000L,
+ providerId = 7L
+ )
+ val existing = ProgramReminderEntity(
+ id = 42L,
+ providerId = 7L,
+ channelId = "bbc1",
+ channelName = "BBC One",
+ programTitle = program.title,
+ programStartTime = program.startTime,
+ remindAt = now + 10 * 60_000L,
+ leadTimeMinutes = 20
+ )
+ whenever(dao.getByProgram(7L, "bbc1", "World News", program.startTime)).thenReturn(existing)
+ whenever(alarmScheduler.schedule(eq(42L), org.mockito.kotlin.any())).thenReturn(Result.error("denied"))
+
+ val result = manager.scheduleReminder(
+ providerId = 7L,
+ channelId = "bbc1",
+ channelName = "BBC One",
+ program = program,
+ leadTimeMinutes = 5
+ )
+
+ assertThat(result).isInstanceOf(Result.Error::class.java)
+ verify(dao, never()).update(org.mockito.kotlin.any())
+ verify(alarmScheduler).schedule(42L, existing.remindAt)
+ }
+
@Test
fun `cancelReminder deletes reminder and cancels alarm`() = runTest {
val reminder = ProgramReminderEntity(
@@ -128,9 +165,30 @@ class ProgramReminderManagerImplTest {
val remindAtCaptor = argumentCaptor<Long>()
verify(alarmScheduler).schedule(eq(42L), remindAtCaptor.capture())
+ verify(dao).setExactAlarmArmed(42L, true)
assertThat(remindAtCaptor.firstValue).isAtLeast(nowBeforeRestore + 1_000L)
}
+ @Test
+ fun `restoreScheduledReminders persists unarmed state when permission is unavailable`() = runTest {
+ val reminder = ProgramReminderEntity(
+ id = 42L,
+ providerId = 7L,
+ channelId = "bbc1",
+ channelName = "BBC One",
+ programTitle = "World News",
+ programStartTime = System.currentTimeMillis() + 5 * 60_000L,
+ remindAt = System.currentTimeMillis() + 60_000L
+ )
+ whenever(alarmScheduler.canScheduleExactAlarms()).thenReturn(false)
+ whenever(dao.getPendingActive(org.mockito.kotlin.any())).thenReturn(listOf(reminder))
+
+ manager.restoreScheduledReminders()
+
+ verify(dao).setExactAlarmArmed(42L, false)
+ verify(alarmScheduler, never()).schedule(org.mockito.kotlin.any(), org.mockito.kotlin.any())
+ }
+
@Test
fun `restoreScheduledReminders continues after one reminder fails to reschedule`() = runTest {
val now = System.currentTimeMillis()
@@ -182,6 +240,25 @@ class ProgramReminderManagerImplTest {
assertThat(updatedCaptor.firstValue.notifiedAt).isNotNull()
}
+ @Test
+ fun `deliverReminder keeps reminder pending when notification fails`() = runTest {
+ val reminder = ProgramReminderEntity(
+ id = 42L,
+ providerId = 7L,
+ channelId = "bbc1",
+ channelName = "BBC One",
+ programTitle = "World News",
+ programStartTime = System.currentTimeMillis() + 5 * 60_000L,
+ remindAt = System.currentTimeMillis()
+ )
+ whenever(dao.getById(42L)).thenReturn(reminder)
+ whenever(notifier.showReminder(reminder)).thenReturn(Result.error("disabled"))
+
+ manager.deliverReminder(42L)
+
+ verify(dao, never()).update(org.mockito.kotlin.any())
+ }
+
@Test
fun `deliverReminder skips stale reminders and dismisses them`() = runTest {
val reminder = ProgramReminderEntity(
@@ -241,6 +318,8 @@ class ProgramReminderManagerImplTest {
override suspend fun update(reminder: ProgramReminderEntity) = error("unused")
+ override suspend fun setExactAlarmArmed(id: Long, armed: Boolean) = error("unused")
+
override suspend fun deleteByProgram(
providerId: Long,
channelId: String,
diff --git a/data/src/test/java/com/streamvault/data/manager/RecordingManagerImplTest.kt b/data/src/test/java/com/streamvault/data/manager/RecordingManagerImplTest.kt
index 750114aa..c34ac818 100644
--- a/data/src/test/java/com/streamvault/data/manager/RecordingManagerImplTest.kt
+++ b/data/src/test/java/com/streamvault/data/manager/RecordingManagerImplTest.kt
@@ -195,6 +195,39 @@ class RecordingManagerImplTest {
verify(recordingServiceLauncher, never()).startCapture(any(), any())
}
+ @Test
+ fun `reconcileRecordingState persists unarmed schedules while exact alarms are unavailable`(): Unit = runBlocking {
+ val scheduled = scheduledRun(id = "unarmed")
+ whenever(alarmScheduler.canScheduleExactAlarms()).thenReturn(false)
+ whenever(recordingRunDao.getAlarmManagedScheduledRuns()).thenReturn(listOf(scheduled))
+
+ val result = createManager().reconcileRecordingState()
+
+ assertThat(result).isInstanceOf(Result.Success::class.java)
+ verify(recordingRunDao).setExactAlarmArmed(eq(scheduled.id), eq(false), any())
+ verify(alarmScheduler, never()).scheduleStart(any(), any())
+ }
+
+ @Test
+ fun `foreground service timeout joins capture and persists a terminal reason`() = runBlocking {
+ val activeRun = scheduledRun(id = "quota-timeout", status = RecordingStatus.RECORDING)
+ whenever(recordingRunDao.getById(activeRun.id)).thenReturn(activeRun)
+
+ val manager = createManager()
+ val result = manager.stopRecordingForForegroundServiceTimeout(activeRun.id)
+
+ assertThat(result).isInstanceOf(Result.Success::class.java)
+ verify(alarmScheduler).cancel(activeRun.id)
+ verify(recordingRunDao).update(
+ argThat {
+ id == activeRun.id &&
+ status == RecordingStatus.FAILED &&
+ failureReason?.contains("foreground-service time allowance") == true &&
+ terminalAtMs != null
+ }
+ )
+ }
+
private fun createManager() = RecordingManagerImpl(
context = context,
gson = Gson(),
@@ -271,4 +304,4 @@ class RecordingManagerImplTest {
password = "pass",
maxConnections = 3
)
-}
\ No newline at end of file
+}
diff --git a/data/src/test/java/com/streamvault/data/manager/recording/RecordingReconcileWorkerTest.kt b/data/src/test/java/com/streamvault/data/manager/recording/RecordingReconcileWorkerTest.kt
new file mode 100644
index 00000000..f7584ff3
--- /dev/null
+++ b/data/src/test/java/com/streamvault/data/manager/recording/RecordingReconcileWorkerTest.kt
@@ -0,0 +1,15 @@
+package com.streamvault.data.manager.recording
+
+import androidx.work.ListenableWorker
+import com.google.common.truth.Truth.assertThat
+import com.streamvault.domain.model.Result
+import org.junit.Test
+
+class RecordingReconcileWorkerTest {
+ @Test
+ fun `permanent reconciliation failures stop after bounded retries`() {
+ assertThat(reconciliationWorkResult(Result.error("bad row"), 0)).isEqualTo(ListenableWorker.Result.retry())
+ assertThat(reconciliationWorkResult(Result.error("bad row"), 2)).isEqualTo(ListenableWorker.Result.failure())
+ assertThat(reconciliationWorkResult(Result.Loading, 0)).isEqualTo(ListenableWorker.Result.failure())
+ }
+}
diff --git a/data/src/test/java/com/streamvault/data/parser/M3uParserTest.kt b/data/src/test/java/com/streamvault/data/parser/M3uParserTest.kt
index 8ae08e2c..751c0886 100644
--- a/data/src/test/java/com/streamvault/data/parser/M3uParserTest.kt
+++ b/data/src/test/java/com/streamvault/data/parser/M3uParserTest.kt
@@ -1,6 +1,7 @@
package com.streamvault.data.parser
import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.runBlocking
import org.junit.Before
import org.junit.Test
import java.io.ByteArrayOutputStream
@@ -197,7 +198,7 @@ class M3uParserTest {
}
@Test
- fun `parse_headerWithMultipleEpgUrls_usesFirstUrl`() {
+ fun `parse_headerWithMultipleEpgUrls_retainsDistinctUrlsInOrder`() {
val result = parser.parse(
"""
#EXTM3U x-tvg-url="https://epg.example.com/guide.xml.gz, https://backup.example.com/guide.xml"
@@ -206,7 +207,38 @@ class M3uParserTest {
""".trimIndent().byteInputStream()
)
- assertThat(result.header.tvgUrl).isEqualTo("https://epg.example.com/guide.xml.gz")
+ assertThat(result.header.tvgUrls).containsExactly(
+ "https://epg.example.com/guide.xml.gz",
+ "https://backup.example.com/guide.xml"
+ ).inOrder()
+ }
+
+ @Test
+ fun `parseStreaming_reportsMalformedCandidate`() = runBlocking {
+ var invalidEntries = 0
+
+ parser.parseStreaming(
+ inputStream = """
+ #EXTM3U
+ #EXTINF:-1,Missing URL
+ not-a-stream-url
+ """.trimIndent().byteInputStream(),
+ onEntry = { error("Expected malformed entry to be rejected") },
+ onInvalidEntry = { invalidEntries++ }
+ )
+
+ assertThat(invalidEntries).isEqualTo(1)
+ }
+
+ @Test
+ fun `parse_utf16Bom_decodesPlaylist`() {
+ val playlist = "#EXTM3U\n#EXTINF:-1 tvg-id=\"cafe\" group-title=\"Café\",Café\nhttps://stream.example.com/cafe.m3u8\n"
+ val utf16 = byteArrayOf(0xFF.toByte(), 0xFE.toByte()) + playlist.toByteArray(Charsets.UTF_16LE)
+
+ val result = parser.parse(utf16.inputStream())
+
+ assertThat(result.entries.single().name).isEqualTo("Café")
+ assertThat(result.entries.single().groupTitle).isEqualTo("Café")
}
@Test
diff --git a/data/src/test/java/com/streamvault/data/remote/http/CancellableOkHttpTest.kt b/data/src/test/java/com/streamvault/data/remote/http/CancellableOkHttpTest.kt
new file mode 100644
index 00000000..9c7fcea3
--- /dev/null
+++ b/data/src/test/java/com/streamvault/data/remote/http/CancellableOkHttpTest.kt
@@ -0,0 +1,137 @@
+package com.streamvault.data.remote.http
+
+import com.google.common.truth.Truth.assertThat
+import java.io.IOException
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.TimeUnit
+import java.util.concurrent.atomic.AtomicBoolean
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.cancelAndJoin
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.runBlocking
+import kotlinx.coroutines.withTimeout
+import okhttp3.Interceptor
+import okhttp3.MediaType
+import okhttp3.OkHttpClient
+import okhttp3.Protocol
+import okhttp3.Request
+import okhttp3.Response
+import okhttp3.ResponseBody
+import okio.Buffer
+import okio.BufferedSource
+import okio.Source
+import okio.Timeout
+import okio.buffer
+import org.junit.Test
+
+class CancellableOkHttpTest {
+
+ @Test
+ fun `cancellation before headers cancels the call promptly`() = runBlocking {
+ val started = CountDownLatch(1)
+ val cancelled = CountDownLatch(1)
+ val client = OkHttpClient.Builder().addInterceptor { chain ->
+ started.countDown()
+ while (!chain.call().isCanceled()) Thread.sleep(5)
+ cancelled.countDown()
+ throw IOException("cancelled")
+ }.build()
+ val job = launch(Dispatchers.IO) {
+ client.newCall(request()).useCancellableResponse { Unit }
+ }
+
+ assertThat(started.await(5, TimeUnit.SECONDS)).isTrue()
+ job.cancelAndJoin()
+
+ assertThat(cancelled.await(5, TimeUnit.SECONDS)).isTrue()
+ }
+
+ @Test
+ fun `cancellation during a blocked body read cancels call and closes body`() = runBlocking {
+ val cancelled = CountDownLatch(1)
+ val readStarted = CountDownLatch(1)
+ val bodyClosed = AtomicBoolean(false)
+ val client = OkHttpClient.Builder().addInterceptor(Interceptor { chain ->
+ Response.Builder()
+ .request(chain.request())
+ .protocol(Protocol.HTTP_1_1)
+ .code(200)
+ .message("OK")
+ .body(blockingBody(chain, readStarted, cancelled, bodyClosed))
+ .build()
+ }).build()
+ val job = launch(Dispatchers.IO) {
+ client.newCall(request()).useCancellableResponse { response ->
+ response.body!!.source().read(Buffer(), 1)
+ }
+ }
+
+ assertThat(readStarted.await(5, TimeUnit.SECONDS)).isTrue()
+ withTimeout(5_000) {
+ job.cancelAndJoin()
+ }
+
+ assertThat(cancelled.await(5, TimeUnit.SECONDS)).isTrue()
+ assertThat(bodyClosed.get()).isTrue()
+ }
+
+ @Test
+ fun `response closes when consumer throws`() = runBlocking {
+ val bodyClosed = AtomicBoolean(false)
+ val client = OkHttpClient.Builder().addInterceptor { chain ->
+ Response.Builder()
+ .request(chain.request())
+ .protocol(Protocol.HTTP_1_1)
+ .code(200)
+ .message("OK")
+ .body(finiteBody(bodyClosed))
+ .build()
+ }.build()
+
+ val result = runCatching {
+ client.newCall(request()).useCancellableResponse {
+ throw IllegalStateException("parser failed")
+ }
+ }
+
+ assertThat(result.exceptionOrNull()).isInstanceOf(IllegalStateException::class.java)
+ assertThat(bodyClosed.get()).isTrue()
+ }
+
+ private fun request() = Request.Builder().url("https://example.test/stream").build()
+
+ private fun blockingBody(
+ chain: Interceptor.Chain,
+ readStarted: CountDownLatch,
+ cancelled: CountDownLatch,
+ closed: AtomicBoolean
+ ): ResponseBody = object : ResponseBody() {
+ override fun contentType(): MediaType? = null
+ override fun contentLength(): Long = -1L
+ override fun source(): BufferedSource = object : Source {
+ override fun read(sink: Buffer, byteCount: Long): Long {
+ readStarted.countDown()
+ while (!chain.call().isCanceled()) Thread.sleep(5)
+ cancelled.countDown()
+ throw IOException("cancelled")
+ }
+
+ override fun timeout(): Timeout = Timeout.NONE
+ override fun close() {
+ closed.set(true)
+ }
+ }.buffer()
+ }
+
+ private fun finiteBody(closed: AtomicBoolean): ResponseBody = object : ResponseBody() {
+ override fun contentType(): MediaType? = null
+ override fun contentLength(): Long = 0L
+ override fun source(): BufferedSource = object : Source {
+ override fun read(sink: Buffer, byteCount: Long): Long = -1L
+ override fun timeout(): Timeout = Timeout.NONE
+ override fun close() {
+ closed.set(true)
+ }
+ }.buffer()
+ }
+}
diff --git a/data/src/test/java/com/streamvault/data/remote/jellyfin/JellyfinProviderTest.kt b/data/src/test/java/com/streamvault/data/remote/jellyfin/JellyfinProviderTest.kt
index 5156725e..bd6bf42a 100644
--- a/data/src/test/java/com/streamvault/data/remote/jellyfin/JellyfinProviderTest.kt
+++ b/data/src/test/java/com/streamvault/data/remote/jellyfin/JellyfinProviderTest.kt
@@ -15,15 +15,54 @@ import org.junit.Test
class JellyfinProviderTest {
+ @Test
+ fun `movie pages retain continuation metadata`() = runTest {
+ val client = OkHttpClient.Builder().addInterceptor { chain ->
+ val request = chain.request()
+ val start = request.url.queryParameter("StartIndex")
+ val body = when (start) {
+ "0" -> """{"TotalRecordCount":2,"Items":[{"Id":"movie-1","Name":"One"}]}"""
+ "1" -> """{"TotalRecordCount":2,"Items":[{"Id":"movie-2","Name":"Two"}]}"""
+ else -> error("Unexpected continuation: $start")
+ }
+ Response.Builder().request(request).protocol(Protocol.HTTP_1_1).code(200).message("OK")
+ .body(body.toResponseBody("application/json".toMediaType())).build()
+ }.build()
+ val provider = JellyfinProvider(client, Gson())
+ val account = Provider(name = "Jellyfin", type = ProviderType.JELLYFIN, serverUrl = "https://demo.example", username = "alice", password = "token")
+
+ val first = provider.fetchMoviesPage(account, 0) as Result.Success
+ assertThat(first.data.totalRecordCount).isEqualTo(2)
+ assertThat(first.data.nextStartIndex).isEqualTo(1)
+ val second = provider.fetchMoviesPage(account, first.data.nextStartIndex) as Result.Success
+ assertThat(second.data.items.single().name).isEqualTo("Two")
+ }
+
+ @Test
+ fun `movie page rejects server that ignores requested limit`() = runTest {
+ val items = (1..101).joinToString(",") { "{\"Id\":\"movie-$it\"}" }
+ val client = OkHttpClient.Builder().addInterceptor { chain ->
+ Response.Builder().request(chain.request()).protocol(Protocol.HTTP_1_1).code(200).message("OK")
+ .body("{\"TotalRecordCount\":101,\"Items\":[$items]}".toResponseBody("application/json".toMediaType())).build()
+ }.build()
+ val provider = JellyfinProvider(client, Gson())
+ val result = provider.fetchMoviesPage(Provider(name = "Jellyfin", type = ProviderType.JELLYFIN, serverUrl = "https://demo.example", username = "alice", password = "token"), 0)
+ assertThat(result).isInstanceOf(Result.Error::class.java)
+ assertThat((result as Result.Error).exception).isInstanceOf(JellyfinPaginationException::class.java)
+ }
+
@Test
fun `fetchMovies does not embed access token in artwork urls`() = runTest {
val client = OkHttpClient.Builder()
.addInterceptor { chain ->
val request = chain.request()
+ assertThat(request.url.queryParameter("StartIndex")).isEqualTo("0")
+ assertThat(request.url.queryParameter("Limit")).isEqualTo("100")
val body = when (request.url.encodedPath) {
"/Items" -> {
"""
{
+ "TotalRecordCount": 1,
"Items": [
{
"Id": "movie-1",
@@ -53,21 +92,22 @@ class JellyfinProviderTest {
gson = Gson()
)
- val result = provider.fetchMovies(
+ val result = provider.fetchMoviesPage(
Provider(
name = "Jellyfin",
type = ProviderType.JELLYFIN,
serverUrl = "https://demo.example",
username = "alice",
password = "secret-token"
- )
+ ),
+ startIndex = 0
)
assertThat(result).isInstanceOf(Result.Success::class.java)
- val movie = (result as Result.Success).data.single()
- assertThat(movie.posterUrl).isEqualTo("https://demo.example/Items/movie-1/Images/Primary?tag=poster-tag")
- assertThat(movie.backdropUrl).isEqualTo("https://demo.example/Items/movie-1/Images/Backdrop/0?tag=backdrop-tag")
+ val movie = (result as Result.Success).data.items.single()
+ assertThat(movie.posterUrl).isEqualTo("https://demo.example/Items/movie-1/Images/Primary?tag=poster-tag&streamvault_provider_id=0")
+ assertThat(movie.backdropUrl).isEqualTo("https://demo.example/Items/movie-1/Images/Backdrop/0?tag=backdrop-tag&streamvault_provider_id=0")
assertThat(movie.posterUrl).doesNotContain("api_key")
assertThat(movie.backdropUrl).doesNotContain("api_key")
}
-}
\ No newline at end of file
+}
diff --git a/data/src/test/java/com/streamvault/data/remote/stalker/OkHttpStalkerCancellationTest.kt b/data/src/test/java/com/streamvault/data/remote/stalker/OkHttpStalkerCancellationTest.kt
new file mode 100644
index 00000000..bec9cee7
--- /dev/null
+++ b/data/src/test/java/com/streamvault/data/remote/stalker/OkHttpStalkerCancellationTest.kt
@@ -0,0 +1,98 @@
+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 java.io.IOException
+import java.util.concurrent.CopyOnWriteArrayList
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.TimeUnit
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.cancelAndJoin
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.runBlocking
+import kotlinx.serialization.json.Json
+import kotlin.system.measureTimeMillis
+import okhttp3.MediaType.Companion.toMediaType
+import okhttp3.OkHttpClient
+import okhttp3.Protocol
+import okhttp3.Response
+import okhttp3.ResponseBody.Companion.toResponseBody
+import org.junit.Test
+
+class OkHttpStalkerCancellationTest {
+
+ @Test
+ fun `cancelling handshake prevents later recipe requests`(): Unit = runBlocking {
+ val started = CountDownLatch(1)
+ val actions = CopyOnWriteArrayList<String>()
+ val client = OkHttpClient.Builder().addInterceptor { chain ->
+ actions += chain.request().url.queryParameter("action").orEmpty()
+ started.countDown()
+ while (!chain.call().isCanceled()) Thread.sleep(5)
+ throw IOException("cancelled")
+ }.build()
+ val service = service(client, StalkerDiscoveryBudget(10_000, 24))
+ val job = launch(Dispatchers.IO) {
+ service.authenticate(profile())
+ }
+
+ assertThat(started.await(5, TimeUnit.SECONDS)).isTrue()
+ job.cancelAndJoin()
+
+ assertThat(actions).containsExactly("handshake")
+ }
+
+ @Test
+ fun `request budget prevents an additional outbound request`(): Unit = runBlocking {
+ val actions = CopyOnWriteArrayList<String>()
+ val client = OkHttpClient.Builder().addInterceptor { chain ->
+ val action = chain.request().url.queryParameter("action").orEmpty()
+ actions += action
+ Response.Builder()
+ .request(chain.request())
+ .protocol(Protocol.HTTP_1_1)
+ .code(200)
+ .message("OK")
+ .body("""{"js":{"token":"token-123"}}""".toResponseBody("application/json".toMediaType()))
+ .build()
+ }.build()
+
+ val result = service(client, StalkerDiscoveryBudget(10_000, 1)).authenticate(profile())
+
+ assertThat(result).isInstanceOf(Result.Error::class.java)
+ assertThat(actions).containsExactly("handshake")
+ }
+
+ @Test
+ fun `overall discovery deadline cancels the active request`(): Unit = runBlocking {
+ val cancelled = CountDownLatch(1)
+ val client = OkHttpClient.Builder().addInterceptor { chain ->
+ while (!chain.call().isCanceled()) Thread.sleep(5)
+ cancelled.countDown()
+ throw IOException("cancelled")
+ }.build()
+ lateinit var result: Result<Pair<StalkerSession, StalkerProviderProfile>>
+
+ val elapsedMillis = measureTimeMillis {
+ result = service(client, StalkerDiscoveryBudget(100, 24)).authenticate(profile())
+ }
+
+ assertThat(result).isInstanceOf(Result.Error::class.java)
+ assertThat((result as Result.Error).message).contains("exceeded")
+ assertThat(cancelled.await(5, TimeUnit.SECONDS)).isTrue()
+ assertThat(elapsedMillis).isLessThan(5_000L)
+ }
+
+ private fun service(client: OkHttpClient, budget: StalkerDiscoveryBudget) =
+ OkHttpStalkerApiService(client, Json { ignoreUnknownKeys = true }, budget)
+
+ private fun profile() = buildStalkerDeviceProfile(
+ portalUrl = "https://portal.example.com/c",
+ macAddress = "00:1A:79:12:34:56",
+ authMode = StalkerAuthMode.AUTO,
+ deviceProfile = "MAG250",
+ timezone = "UTC",
+ locale = "en"
+ )
+}
diff --git a/data/src/test/java/com/streamvault/data/remote/xtream/XtreamProviderTest.kt b/data/src/test/java/com/streamvault/data/remote/xtream/XtreamProviderTest.kt
index e7c148c0..a08bdd63 100644
--- a/data/src/test/java/com/streamvault/data/remote/xtream/XtreamProviderTest.kt
+++ b/data/src/test/java/com/streamvault/data/remote/xtream/XtreamProviderTest.kt
@@ -448,6 +448,38 @@ class XtreamProviderTest {
assertThat(movies.first().categoryId).isNotNull()
}
+ @Test
+ fun `getVodStreams retries adult category prefetch after a transient failure`() = runBlocking {
+ var categoryRequests = 0
+ val provider = XtreamProvider(
+ providerId = 42,
+ api = FakeXtreamApiService(
+ vodCategoriesLoader = {
+ if (categoryRequests++ == 0) {
+ throw XtreamNetworkException("category prefetch failed")
+ }
+ listOf(XtreamCategory(categoryId = "28", categoryName = "Adults", isAdult = true))
+ },
+ vodStreams = listOf(
+ XtreamStream(
+ name = "Movie",
+ streamId = 321,
+ categoryId = "28",
+ categoryName = "Movies",
+ containerExtension = "mp4"
+ )
+ )
+ ),
+ serverUrl = "https://example.com",
+ username = "user",
+ password = "pass"
+ )
+
+ assertThat(provider.getVodStreams().getOrNull().orEmpty().single().isAdult).isFalse()
+ assertThat(provider.getVodStreams().getOrNull().orEmpty().single().isAdult).isTrue()
+ assertThat(categoryRequests).isEqualTo(2)
+ }
+
@Test
fun `getVodStreams honors explicit adult flag from xtream payload`() = runBlocking {
val provider = XtreamProvider(
@@ -744,6 +776,7 @@ class XtreamProviderTest {
private val liveCategories: List<XtreamCategory> = emptyList(),
private val liveStreams: List<XtreamStream> = emptyList(),
private val vodCategories: List<XtreamCategory> = emptyList(),
+ private val vodCategoriesLoader: (suspend () -> List<XtreamCategory>)? = null,
private val vodStreams: List<XtreamStream> = emptyList(),
private val vodInfo: XtreamVodInfoResponse = XtreamVodInfoResponse(),
private val seriesCategories: List<XtreamCategory> = emptyList(),
@@ -760,7 +793,8 @@ class XtreamProviderTest {
override suspend fun getLiveStreams(endpoint: String, requestProfile: HttpRequestProfile): List<XtreamStream> = liveStreams
- override suspend fun getVodCategories(endpoint: String, requestProfile: HttpRequestProfile): List<XtreamCategory> = vodCategories
+ override suspend fun getVodCategories(endpoint: String, requestProfile: HttpRequestProfile): List<XtreamCategory> =
+ vodCategoriesLoader?.invoke() ?: vodCategories
override suspend fun getVodStreams(endpoint: String, requestProfile: HttpRequestProfile): List<XtreamStream> = vodStreams
diff --git a/data/src/test/java/com/streamvault/data/repository/EpgSourceRepositoryImplTest.kt b/data/src/test/java/com/streamvault/data/repository/EpgSourceRepositoryImplTest.kt
index 5f538189..85bbb1ff 100644
--- a/data/src/test/java/com/streamvault/data/repository/EpgSourceRepositoryImplTest.kt
+++ b/data/src/test/java/com/streamvault/data/repository/EpgSourceRepositoryImplTest.kt
@@ -33,6 +33,7 @@ import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.test.runTest
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.Call
+import okhttp3.Callback
import okhttp3.OkHttpClient
import okhttp3.Protocol
import okhttp3.Request
@@ -40,6 +41,7 @@ import okhttp3.Response
import okhttp3.ResponseBody.Companion.toResponseBody
import org.junit.Before
import org.junit.Test
+import org.junit.Assert.assertThrows
import org.mockito.kotlin.any
import org.mockito.kotlin.anyOrNull
import org.mockito.kotlin.argThat
@@ -57,6 +59,14 @@ import java.util.zip.GZIPOutputStream
class EpgSourceRepositoryImplTest {
+ @Test
+ fun `limitEpgInput rejects bytes after the configured decompressed limit`() {
+ val input = limitEpgInput(ByteArrayInputStream(byteArrayOf(1, 2, 3, 4)), maxBytes = 3)
+
+ assertThat(input.read(ByteArray(3))).isEqualTo(3)
+ assertThrows(IOException::class.java) { input.read() }
+ }
+
private val context: Context = mock()
private val contentResolver: ContentResolver = mock()
private val epgSourceDao: EpgSourceDao = mock()
@@ -309,7 +319,7 @@ class EpgSourceRepositoryImplTest {
whenever(epgSourceDao.getById(10L)).thenReturn(source)
whenever(okHttpClient.newCall(any())).thenReturn(call)
- whenever(call.execute()).thenReturn(response)
+ enqueueResponse(call, response)
whenever(providerEpgSourceDao.getProviderIdsForSourceSync(10L)).thenReturn(emptyList())
val result = repositoryWithRealParser.refreshSource(10L)
@@ -367,7 +377,7 @@ class EpgSourceRepositoryImplTest {
whenever(epgSourceDao.getById(10L)).thenReturn(source)
whenever(okHttpClient.newCall(requestCaptor.capture())).thenReturn(call)
- whenever(call.execute()).thenReturn(response)
+ enqueueResponse(call, response)
whenever(providerEpgSourceDao.getProviderIdsForSourceSync(10L)).thenReturn(emptyList())
whenever(xmltvParser.maybeDecompressGzip(eq(source.url), any())).thenAnswer { it.arguments[1] }
@@ -398,7 +408,7 @@ class EpgSourceRepositoryImplTest {
whenever(epgSourceDao.getById(10L)).thenReturn(source)
whenever(okHttpClient.newCall(any())).thenReturn(call)
- whenever(call.execute()).thenReturn(response)
+ enqueueResponse(call, response)
whenever(providerEpgSourceDao.getProviderIdsForSourceSync(10L)).thenReturn(listOf(7L, 8L))
val result = repository.refreshSource(10L)
@@ -428,7 +438,7 @@ class EpgSourceRepositoryImplTest {
whenever(epgSourceDao.getById(10L)).thenReturn(source)
whenever(okHttpClient.newCall(any())).thenReturn(call)
- whenever(call.execute()).thenReturn(response)
+ enqueueResponse(call, response)
whenever(xmltvParser.maybeDecompressGzip(eq(source.url), any())).thenAnswer { it.arguments[1] }
whenever(providerEpgSourceDao.getProviderIdsForSourceSync(10L)).thenReturn(listOf(7L, 8L))
whenever(providerDao.getById(7L)).thenReturn(
@@ -475,7 +485,7 @@ class EpgSourceRepositoryImplTest {
whenever(epgSourceDao.getById(10L)).thenReturn(source)
whenever(okHttpClient.newCall(any())).thenReturn(call)
- whenever(call.execute()).thenReturn(response)
+ enqueueResponse(call, response)
whenever(xmltvParser.maybeDecompressGzip(eq(source.url), any())).thenAnswer { it.arguments[1] }
whenever(providerEpgSourceDao.getProviderIdsForSourceSync(10L)).thenReturn(listOf(7L, 8L))
whenever(providerDao.getById(7L)).thenReturn(
@@ -513,6 +523,13 @@ class EpgSourceRepositoryImplTest {
}
}
+ private fun enqueueResponse(call: Call, response: Response) {
+ doAnswer { invocation ->
+ (invocation.arguments[0] as Callback).onResponse(call, response)
+ null
+ }.whenever(call).enqueue(any())
+ }
+
private fun gzip(bytes: ByteArray): ByteArray {
val output = ByteArrayOutputStream()
GZIPOutputStream(output).use { it.write(bytes) }
diff --git a/data/src/test/java/com/streamvault/data/repository/ProviderRepositoryImplTest.kt b/data/src/test/java/com/streamvault/data/repository/ProviderRepositoryImplTest.kt
index 2657bd9d..75f4f8a9 100644
--- a/data/src/test/java/com/streamvault/data/repository/ProviderRepositoryImplTest.kt
+++ b/data/src/test/java/com/streamvault/data/repository/ProviderRepositoryImplTest.kt
@@ -1,5 +1,6 @@
package com.streamvault.data.repository
+import android.content.Context
import com.google.common.truth.Truth.assertThat
import com.streamvault.data.local.DatabaseTransactionRunner
import com.streamvault.data.local.dao.CategoryDao
@@ -10,6 +11,7 @@ import com.streamvault.data.local.dao.ProgramReminderDao
import com.streamvault.data.local.dao.ProviderDao
import com.streamvault.data.local.dao.RecordingRunDao
import com.streamvault.data.local.dao.SeriesDao
+import com.streamvault.data.local.dao.ProviderDeletionCleanupDao
import com.streamvault.data.local.entity.ProviderEntity
import com.streamvault.data.local.entity.CategoryEntity
import com.streamvault.data.manager.recording.RecordingAlarmScheduler
@@ -49,6 +51,7 @@ import org.mockito.kotlin.whenever
class ProviderRepositoryImplTest {
+
private val providerDao: ProviderDao = mock()
private val categoryDao: CategoryDao = mock()
private val channelDao: ChannelDao = mock()
@@ -66,6 +69,8 @@ class ProviderRepositoryImplTest {
private val recordingAlarmScheduler: RecordingAlarmScheduler = mock()
private val programReminderAlarmScheduler: ProgramReminderAlarmScheduler = mock()
private val jellyfinProvider: JellyfinProvider = mock()
+ private val providerDeletionCleanupDao: ProviderDeletionCleanupDao = mock()
+ private val appContext: Context = mock()
private val transactionRunner = object : DatabaseTransactionRunner {
override suspend fun <T> inTransaction(block: suspend () -> T): T = block()
}
@@ -90,7 +95,9 @@ class ProviderRepositoryImplTest {
transactionRunner = transactionRunner,
recordingAlarmScheduler = recordingAlarmScheduler,
programReminderAlarmScheduler = programReminderAlarmScheduler,
- jellyfinProvider = jellyfinProvider
+ jellyfinProvider = jellyfinProvider,
+ providerDeletionCleanupDao = providerDeletionCleanupDao,
+ appContext = appContext
)
private val repository = createRepository()
@@ -114,14 +121,10 @@ class ProviderRepositoryImplTest {
val result = repository.deleteProvider(7L)
assertThat(result.isSuccess).isTrue()
- val inOrder = inOrder(recordingAlarmScheduler, programReminderAlarmScheduler, programDao, providerDao, syncManager)
+ val inOrder = inOrder(programDao, providerDao)
inOrder.verify(programDao).deleteByProvider(7L)
inOrder.verify(providerDao).delete(7L)
- inOrder.verify(recordingAlarmScheduler).cancel("run-1")
- inOrder.verify(recordingAlarmScheduler).cancel("run-2")
- inOrder.verify(programReminderAlarmScheduler).cancel(11L)
- inOrder.verify(programReminderAlarmScheduler).cancel(12L)
- inOrder.verify(syncManager).onProviderDeleted(7L)
+ verify(providerDeletionCleanupDao).insertAll(any())
verify(recordingRunDao).getIdsByProvider(7L)
verify(programReminderDao).getIdsByProvider(7L)
}
@@ -163,8 +166,7 @@ class ProviderRepositoryImplTest {
"transaction:start",
"programs:delete",
"provider:delete",
- "transaction:end",
- "sync:cleanup"
+ "transaction:end"
).inOrder()
}
@@ -180,9 +182,7 @@ class ProviderRepositoryImplTest {
assertThat(result.isSuccess).isTrue()
verify(programDao).deleteByProvider(7L)
verify(providerDao).delete(7L)
- verify(recordingAlarmScheduler).cancel("run-1")
- verify(programReminderAlarmScheduler).cancel(11L)
- verify(syncManager).onProviderDeleted(7L)
+ verify(providerDeletionCleanupDao).insertAll(any())
}
@Test
diff --git a/data/src/test/java/com/streamvault/data/sync/ProviderSyncWorkerTest.kt b/data/src/test/java/com/streamvault/data/sync/ProviderSyncWorkerTest.kt
index 3e3ff856..a42ef4b9 100644
--- a/data/src/test/java/com/streamvault/data/sync/ProviderSyncWorkerTest.kt
+++ b/data/src/test/java/com/streamvault/data/sync/ProviderSyncWorkerTest.kt
@@ -40,6 +40,28 @@ class ProviderSyncWorkerTest {
}
}
+ @Test
+ fun `future running index job timestamp is not fresh`() {
+ assertThat(
+ isFreshRunningIndexJob(
+ updatedAt = 1_001L,
+ now = 1_000L,
+ staleAfterMillis = 15 * 60 * 1_000L
+ )
+ ).isFalse()
+ }
+
+ @Test
+ fun `recent running index job timestamp is fresh`() {
+ assertThat(
+ isFreshRunningIndexJob(
+ updatedAt = 1_000L,
+ now = 1_001L,
+ staleAfterMillis = 15 * 60 * 1_000L
+ )
+ ).isTrue()
+ }
+
@Test
fun `xtream provider with incomplete onboarding state is tracked for initial live resume`() = runTest {
val provider = ProviderEntity(
diff --git a/data/src/test/java/com/streamvault/data/sync/SyncManagerTest.kt b/data/src/test/java/com/streamvault/data/sync/SyncManagerTest.kt
index 73810ec8..7e913983 100644
--- a/data/src/test/java/com/streamvault/data/sync/SyncManagerTest.kt
+++ b/data/src/test/java/com/streamvault/data/sync/SyncManagerTest.kt
@@ -3524,6 +3524,13 @@ class SyncManagerTest {
assertThat(M3uParser.isVodEntry(entry(url = "http://vod.example.com/show.mkv"))).isTrue()
}
+ @Test
+ fun `isVodEntry_fileExtensionWithQueryOrFragment_returnsTrue`() {
+ assertThat(M3uParser.isVodEntry(entry(url = "https://vod.example.com/film.MP4?token=abc"))).isTrue()
+ assertThat(M3uParser.isVodEntry(entry(url = "https://vod.example.com/show.mkv#preview"))).isTrue()
+ assertThat(M3uParser.isVodEntry(entry(url = "https://vod.example.com/archive.avi?token=abc#preview"))).isTrue()
+ }
+
@Test
fun `isVodEntry_movieGroupTitle_returnsTrue`() {
assertThat(M3uParser.isVodEntry(entry(group = "Movies HD"))).isTrue()
diff --git a/data/src/test/java/com/streamvault/data/sync/SyncManagerXtreamLiveStrategyTest.kt b/data/src/test/java/com/streamvault/data/sync/SyncManagerXtreamLiveStrategyTest.kt
index a474cbf7..eb8655b1 100644
--- a/data/src/test/java/com/streamvault/data/sync/SyncManagerXtreamLiveStrategyTest.kt
+++ b/data/src/test/java/com/streamvault/data/sync/SyncManagerXtreamLiveStrategyTest.kt
@@ -1025,7 +1025,7 @@ class SyncManagerXtreamLiveStrategyTest {
liveCategorySequentialModeWarning = "Live category sync used sequential mode.",
isCurrentlyLowOnMemory = isCurrentlyLowOnMemory,
stageChannelItems = stageChannelItems,
- syncProgressBus = SyncProgressBus()
+ emitProgress = { _, _ -> }
)
}
diff --git a/data/src/test/java/com/streamvault/data/sync/SyncProgressBusTest.kt b/data/src/test/java/com/streamvault/data/sync/SyncProgressBusTest.kt
index 736c34ed..904b85fc 100644
--- a/data/src/test/java/com/streamvault/data/sync/SyncProgressBusTest.kt
+++ b/data/src/test/java/com/streamvault/data/sync/SyncProgressBusTest.kt
@@ -3,99 +3,52 @@ package com.streamvault.data.sync
import com.google.common.truth.Truth.assertThat
import com.streamvault.domain.sync.Section
import com.streamvault.domain.sync.SyncProgress
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.flow.toList
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.test.UnconfinedTestDispatcher
-import kotlinx.coroutines.test.runTest
import org.junit.Test
-/**
- * Tests unitaires de [SyncProgressBus].
- *
- * Couvre les 4 cas du test plan §7 du SCOPE M1 :
- * 1. `emit` met à jour la valeur courante du flow.
- * 2. `reset` remet le flow à `null`.
- * 3. Deux collectors observent la même séquence d'émissions.
- * 4. Un collector qui souscrit tardivement reçoit la dernière valeur (contrat StateFlow).
- */
-@OptIn(ExperimentalCoroutinesApi::class)
class SyncProgressBusTest {
+ private fun progress(section: Section = Section.LIVE) = SyncProgress(section, 3, 10, "Sport", 42)
@Test
- fun emit_updatesFlowValue() = runTest {
+ fun finishingOneProvider_doesNotClearAnotherProvidersProgress() {
val bus = SyncProgressBus()
- val progress = SyncProgress(
- section = Section.LIVE,
- current = 3,
- total = 10,
- currentLabel = "Sport",
- itemsIndexed = 42
- )
+ val providerA = bus.begin(1L)
+ val providerB = bus.begin(2L)
+ bus.emit(providerA, progress())
+ val providerBProgress = progress(Section.VOD)
+ bus.emit(providerB, providerBProgress)
- bus.emit(progress)
+ bus.finish(providerA)
- assertThat(bus.flow.value).isEqualTo(progress)
+ assertThat(bus.progressByProvider.value).containsKey(2L)
+ assertThat(bus.progressByProvider.value[2L]?.progress).isEqualTo(providerBProgress)
+ assertThat(bus.aggregate.value?.activeProviderCount).isEqualTo(1)
}
@Test
- fun reset_setsFlowToNull() = runTest {
+ fun staleSession_cannotClearOrPublishOverReplacementSession() {
val bus = SyncProgressBus()
- bus.emit(
- SyncProgress(
- section = Section.VOD,
- current = 1,
- total = 5,
- currentLabel = "Movies",
- itemsIndexed = 100
- )
- )
- assertThat(bus.flow.value).isNotNull()
+ val stale = bus.begin(1L)
+ bus.emit(stale, progress())
+ val replacement = bus.begin(1L)
+ val replacementProgress = progress(Section.SERIES)
+ bus.emit(replacement, replacementProgress)
- bus.reset()
+ bus.emit(stale, progress(Section.VOD))
+ bus.finish(stale)
- assertThat(bus.flow.value).isNull()
+ assertThat(bus.progressByProvider.value[1L]?.session).isEqualTo(replacement)
+ assertThat(bus.progressByProvider.value[1L]?.progress).isEqualTo(replacementProgress)
}
@Test
- fun twoCollectors_receiveSameSequence() = runTest(UnconfinedTestDispatcher()) {
+ fun aggregate_isDerivedFromAllActiveProviders() {
val bus = SyncProgressBus()
- val first = mutableListOf<SyncProgress?>()
- val second = mutableListOf<SyncProgress?>()
+ val providerA = bus.begin(1L)
+ val providerB = bus.begin(2L)
+ bus.emit(providerA, progress())
+ bus.emit(providerB, progress(Section.VOD))
- val firstJob = launch { bus.flow.toList(first) }
- val secondJob = launch { bus.flow.toList(second) }
-
- val progressLive = SyncProgress(Section.LIVE, 1, 4, "Live", 10)
- val progressVod = SyncProgress(Section.VOD, 2, 4, "VOD", 20)
- bus.emit(progressLive)
- bus.emit(progressVod)
- bus.reset()
-
- firstJob.cancel()
- secondJob.cancel()
-
- assertThat(first).containsExactly(null, progressLive, progressVod, null).inOrder()
- assertThat(second).containsExactly(null, progressLive, progressVod, null).inOrder()
- }
-
- @Test
- fun lateCollector_receivesReplayValue() = runTest(UnconfinedTestDispatcher()) {
- val bus = SyncProgressBus()
- val progress = SyncProgress(
- section = Section.SERIES,
- current = 7,
- total = 12,
- currentLabel = "Drama",
- itemsIndexed = 350
- )
-
- bus.emit(progress)
-
- val received = mutableListOf<SyncProgress?>()
- val job = launch { bus.flow.toList(received) }
- job.cancel()
-
- assertThat(received).containsExactly(progress)
+ assertThat(bus.aggregate.value?.activeProviderCount).isEqualTo(2)
+ assertThat(bus.aggregate.value?.representative?.session).isEqualTo(providerB)
}
}
diff --git a/docs/IPTV_CODE_REVIEW.md b/docs/IPTV_CODE_REVIEW.md
new file mode 100644
index 00000000..b9fd7241
--- /dev/null
+++ b/docs/IPTV_CODE_REVIEW.md
@@ -0,0 +1,1396 @@
+# StreamVault IPTV Player Technical Review
+
+## Review status
+
+| Phase | Status | Last updated |
+|---|---|---|
+| 1. Architecture and flow mapping | **Complete** | 2026-07-11 |
+| 2. Shared infrastructure review | **Complete** | 2026-07-11 |
+| 3. Provider reviews | **Complete** | 2026-07-11 |
+| 4. Feature flow reviews | **Complete** | 2026-07-11 |
+| 5. Edge cases and failure scenarios | **Complete** | 2026-07-12 |
+| 6. Consolidated remediation plan | **Complete** | 2026-07-12 |
+
+This is a living report. Findings are added and refined in this file as each phase is completed. A finding marked **Confirmed defect** is directly demonstrated by the source or a focused build/test. **Highly likely defect** has a concrete failing path but still needs a runtime/provider fixture to reproduce. **Suspected risk** needs further verification. **Architectural concern** describes a structural condition that makes correctness or maintenance materially harder. **Simplification opportunity** identifies unnecessary complexity without asserting a current failure.
+
+## Table of contents
+
+- [Scope and method](#scope-and-method)
+- [Phase 1 — Architecture and flow mapping](#phase-1--architecture-and-flow-mapping)
+ - [System map](#system-map)
+ - [Provider boundaries](#provider-boundaries)
+ - [Application and feature flows](#application-and-feature-flows)
+ - [Phase 1 findings summary](#phase-1-findings-summary)
+ - [Detailed Phase 1 findings](#detailed-phase-1-findings)
+ - [Phase 1 open questions](#phase-1-open-questions)
+ - [Next review targets](#next-review-targets)
+- [Phase 2 — Shared infrastructure review](#phase-2--shared-infrastructure-review)
+- [Phase 3 — Provider reviews](#phase-3--provider-reviews)
+- [Phase 4 — Feature flow reviews](#phase-4--feature-flow-reviews)
+- [Phase 5 — Edge cases and failure scenarios](#phase-5--edge-cases-and-failure-scenarios)
+- [Phase 6 — Consolidated remediation plan](#phase-6--consolidated-remediation-plan)
+
+## Scope and method
+
+The review covers all four Gradle modules (`app`, `data`, `domain`, and `player`) and all provider/feature families visible in the application. It intentionally excludes a security/privacy assessment. Authentication, tokens, cookies, credentials, and device identity are in scope only where they affect correctness, reliability, networking, persistence, or playback.
+
+Phase 1 used the repository's existing graphify graph and wiki, then verified the graph against startup, DI, provider setup, synchronization, persistence, playback, EPG, recording, backup, and plugin entry points. The graph contains thousands of nodes and identifies `PreferencesRepository`, `SettingsViewModel`, `OkHttpStalkerApiService`, `StalkerProvider`, `Media3PlayerEngine`, and `XtreamProvider` as load-bearing abstractions. The graph's community labels are generic and its cohesion is low, so graph relationships were treated as navigation hints, not proof.
+
+Focused verification performed in this phase:
+
+- `./gradlew.bat :data:compileDebugKotlin --rerun-tasks --no-daemon` — passed on 2026-07-11. This confirms the inspected data-module source compiles, while also producing a large warning set that will be triaged in Phase 2/4.
+- Static size/coupling measurements: `SyncManager` is 6,048 lines/169 functions; `OkHttpStalkerApiService` 2,767/124; `Media3PlayerEngine` 2,482/122; `PreferencesRepository` 2,324/169; `PlayerViewModel` 1,776 lines; `StalkerProvider` 1,611/88; `ProviderRepositoryImpl` 1,308 lines.
+
+# Phase 1 — Architecture and flow mapping
+
+**Status: Complete.** This phase maps responsibilities and control/data flow. It identifies architectural faults and directly visible correctness problems; it does not yet claim a line-by-line infrastructure or provider audit.
+
+## System map
+
+### Module boundaries
+
+| Module | Intended responsibility | Observed responsibility and dependencies |
+|---|---|---|
+| `domain` | Platform-neutral models, repository/manager contracts, use cases | Pure Kotlin/JVM and depends only on coroutines/injection. It defines repositories, recording/backup contracts, provider setup use cases, and `IptvProvider`. However, its central `Provider` model contains extensive Stalker persistence/runtime-learning state (ARCH-002). |
+| `data` | Room, DataStore, networking, provider clients, parsers, sync, backup/recording implementations | Android library depending on `domain`. It owns the Room database and DAOs, Xtream/Stalker/Jellyfin clients, M3U/XMLTV parsing, synchronization workers, repositories, backup/Drive, downloads, recordings, reminders, and URL resolution. `SyncManager` centralizes much of the application's provider policy (ARCH-003). |
+| `player` | Reusable playback engine and timeshift | Android library depending on `domain`. It wraps Media3/ExoPlayer, networking/data sources, decoder policy, media session, timeshift, and diagnostics. Provider URL resolution occurs outside this module in `data`/`app`, so the engine receives a resolved URL plus request metadata. |
+| `app` | Android entry points, Compose UI/navigation, DI, TV integration, plugins, cast, updates | Depends on all other modules and is the composition root. Several ViewModels directly depend on `data` implementation types (`SyncManager`, `PreferencesRepository`, `XtreamStreamUrlResolver`, Stalker URL helpers), weakening the domain boundary (ARCH-005). |
+
+### Runtime composition
+
+Hilt modules under `app/.../di` bind domain repository/manager interfaces to `data` implementations and construct the shared networking, database, and player objects. `StreamVaultDatabase` is the durable catalog/state store. `PreferencesRepository` is the DataStore-backed global preference/session facade. UI consumes Room/DataStore flows through repositories and directly through a few implementation services.
+
+The primary runtime path is:
+
+```text
+Android components / Compose UI
+ |
+ v
+ViewModels + domain use cases
+ |
+ +------> domain repository/manager contracts ------> data implementations
+ | |
+ | +--> Room / DataStore
+ | +--> provider HTTP/parsers
+ | +--> WorkManager / alarms/services
+ |
+ +------> direct data implementation dependencies (architectural leak)
+ |
+ +------> PlayerEngine contract ------> Media3PlayerEngine
+```
+
+### Persistence
+
+`StreamVaultDatabase` declares the provider/catalog, EPG, favorites, history, recording, download, sync staging/index, and compatibility tables and exposes their DAOs. It also contains a long in-file migration chain. Provider catalog sync uses staging and transaction helpers (`SyncCatalogStore`, `DatabaseTransactionRunner`) before committing normalized entities. Preferences and cross-feature flags live in `PreferencesRepository`, while plugin enablement/mappings use a separate `SharedPreferences` store in `StreamVaultPluginManager`.
+
+This is a hybrid state system: Room owns durable relational content and job metadata; DataStore owns global/user settings and some generation/session markers; WorkManager owns background job state; services/alarms own recording execution; in-memory maps/mutexes own active provider and playback state. Phase 2 must verify consistency and recovery across these stores.
+
+## Provider boundaries
+
+### Declared boundary
+
+`domain/provider/IptvProvider.kt` declares a uniform interface for authentication, live/VOD/series catalogs, EPG, stream URL building, and catch-up. Only `XtreamProvider` and `StalkerProvider` implement it.
+
+### Actual boundaries
+
+| Provider/source | Setup and validation | Catalog/sync path | Playback resolution | EPG path |
+|---|---|---|---|---|
+| Xtream Codes | `ValidateAndAddProvider` → `ProviderRepositoryImpl` → Xtream API | `SyncManager` branches into Xtream onboarding, live sync, staged index jobs, and `XtreamIndexWorker`; `XtreamProvider` implements `IptvProvider` | `XtreamStreamUrlResolver` parses internal tokens/direct URLs and rebuilds credentialed URLs | Provider API short/full EPG plus optional XMLTV/external sources |
+| Stalker Portal | `ValidateAndAddProvider` → `ProviderRepositoryImpl` → `StalkerProvider`/`StalkerApiService` bootstrap | `SyncManager` branches into Stalker catalog staging/index jobs; `StalkerIndexWorker`; `StalkerProvider` implements `IptvProvider` | The Xtream-named resolver constructs/caches `StalkerProvider`, calls `resolvePlaybackInfo`, and persists learned playback behavior | Portal EPG bulk/per-channel strategies plus optional XMLTV/external sources |
+| M3U/M3U8 | `ValidateAndAddProvider.addM3u` → `ProviderRepositoryImpl.validateM3u` | `SyncManagerM3uImporter` and `M3uParser`; no `IptvProvider` implementation | Pass-through URL with provider request profile | Playlist/provider URL and manually assigned XMLTV sources |
+| Jellyfin/local media | Jellyfin login/quick-connect paths in setup/repository | Dedicated `JellyfinProvider`, but dispatched directly by `SyncManager`; no `IptvProvider` implementation | Direct Jellyfin URL plus authorization header assembled by the shared resolver | No provider guide lookup; catalog metadata is server-derived |
+| Plugin-based | Android service discovery and Messenger protocol in `StreamVaultPluginManager` | Plugin catalogs are imported/mapped into an M3U provider record rather than represented as a provider capability | Playback delegates through the plugin manager or the mapped M3U path depending on manifest action | No first-class provider EPG contract identified |
+| Recordings/local output | `RecordingManagerImpl`, Room recording entities, alarms, foreground service/capture engine | Local database/files/document URIs, reconciled on launch and periodically | Local `RecordingItem` enters player/navigation as content | EPG is used to schedule/name recordings; recordings do not supply EPG |
+
+The table exposes the core provider problem: the documented shared abstraction is not the boundary used by the main synchronization or playback systems.
+
+## Application and feature flows
+
+### Startup
+
+1. Android creates `StreamVaultApp` (`AndroidManifest.xml`, `StreamVaultApp.onCreate`).
+2. Crash/runtime diagnostics start; stale timeshift directories and cached app-update checks are launched in an application-scoped coroutine.
+3. WorkManager schedules daily maintenance, periodic/launch provider sync, periodic/launch Xtream indexing, and periodic/one-shot recording reconciliation.
+4. `MainActivity` installs Compose and enters `AppNavigation`, whose start destination is always `WELCOME`.
+5. `WelcomeViewModel` observes whether providers exist. Existing providers proceed to the configured landing route; an empty database shows setup. Deep links, search, playback-history navigation, and imported M3U/backup intents are coordinated by `MainActivity`/`AppNavigation`.
+
+### Provider setup and first synchronization
+
+1. Welcome/setup UI builds a provider-specific command (`XtreamProviderSetupCommand`, `M3uProviderSetupCommand`, `StalkerProviderSetupCommand`, or Jellyfin command).
+2. `ValidateAndAddProvider` calls `ProviderSetupInputValidator`, then delegates provider-specific login/add behavior to `ProviderRepository`.
+3. `ProviderRepositoryImpl` validates/authenticates, encrypts/persists provider data, and calls `SyncManager` for the initial catalog. A provider can be persisted even when sync fails, represented by `ProviderSavedWithSyncErrorException`/`SavedWithWarning`.
+4. `SyncManager.sync` acquires a provider lock, decrypts the entity, dispatches on `ProviderType`, stages/commits catalog data, updates sync metadata/status, publishes a `SyncState`, and may queue follow-up provider-specific workers.
+5. UI observes Room catalog flows and the separate sync state/progress facilities.
+
+### Refresh and incremental synchronization
+
+Manual refresh flows through `SyncProvider` or UI classes that call `ProviderRepository.refreshProviderData`/`SyncManager` directly. Background refresh is split across `ProviderSyncWorker`, `XtreamIndexWorker`, `StalkerIndexWorker`, and `BackgroundEpgSyncWorker`. Each uses its own unique-work naming, policies, retries, and stale-job rules; per-provider mutexes in `SyncManager` are the in-process serialization mechanism. Process death relies on Room job/staging metadata and WorkManager re-entry.
+
+### Live TV playback
+
+1. UI selects a normalized `Channel`; navigation constructs a player request.
+2. `PlayerViewModel` loads content/EPG/context and calls `XtreamStreamUrlResolver` even though the content may be Xtream, Stalker, M3U, or Jellyfin.
+3. The resolver reads/decrypts the provider entity, resolves internal tokens or direct URLs, attaches headers/user agent/proxy data, and for Stalker may authenticate/create a link and persist learned playback settings.
+4. `PlayerViewModel` prepares the `PlayerEngine`; `Media3PlayerEngine` constructs Media3 sources/renderers, media session, retry/recovery, token renewal, and optional timeshift.
+5. Recovery, alternate streams, catch-up variants, cast, recording, history, watch-next, plugin actions, and UI messages are coordinated across `PlayerViewModel` plus many extension/support files.
+
+### VOD, series, and resume
+
+Movie/series repositories expose Room-backed catalog flows. Xtream and Stalker can lazily hydrate details/categories through provider-specific branches embedded in `MovieRepositoryImpl` and `SeriesRepositoryImpl`; M3U/Jellyfin mostly use persisted records. Player preparation resolves movie/episode URLs, reads history, and periodically persists progress. Completion updates watched state, recommendations, and optional next-episode behavior.
+
+### EPG and manual XMLTV
+
+Provider EPG can be fetched during provider sync, in `BackgroundEpgSyncWorker`, or on demand. External/manual XMLTV sources and provider assignments are managed by `EpgSourceRepositoryImpl`; provider-owned refresh is also exposed by `EpgRepositoryImpl`. Channel-to-guide resolution and priorities are stored in separate EPG source/program/mapping tables. UI guide composition combines cached provider data and assigned sources through `EpgViewModel` and repository helpers.
+
+### Recording and scheduled recording
+
+UI uses `ScheduleRecording`/`RecordingManager`. `RecordingManagerImpl` persists schedule/run entities, schedules exact start/stop alarms, and starts `RecordingForegroundService`, which invokes the capture engine and updates run status/output. A boot/package restore receiver and `RecordingReconcileWorker` re-establish or reconcile schedules; startup also triggers an immediate reconciliation. Manual recording is initiated from `PlayerViewModel` but uses the same manager/service pipeline.
+
+### Backup and restore
+
+`BackupManagerImpl` serializes preferences, providers, mappings, user state, and scheduled recordings through the domain backup contract. File/document bridging happens in `app`; optional Google Drive orchestration is in `GoogleDriveBackupSyncManager`. Restore recreates provider and feature records and delegates recording re-scheduling to `RecordingManager`. Migration/identity matching behavior requires full Phase 4 review.
+
+### Plugins
+
+`StreamVaultPluginManager` discovers Android services implementing the plugin action, reads a manifest over Messenger or service metadata, enables/disables plugins in its own preferences, invokes plugin operations, imports plugin-provided catalog data into an M3U provider mapping, and refreshes TV input/catalog state. Discovery currently performs synchronous `runBlocking(Dispatchers.IO)` Messenger calls (ARCH-006).
+
+### App upgrades and database migrations
+
+App update checking starts from `StreamVaultApp` and stores cached release metadata in `PreferencesRepository`; install UI/service logic lives under `app/update`. Room database upgrades are handled by the large explicit migration chain in `StreamVaultDatabase`, with schema JSON emitted by the Room Gradle plugin. Migration correctness is deferred to Phase 4, but its concentration is recorded in ARCH-007.
+
+## Phase 1 findings summary
+
+| ID | Classification | Severity | Summary | Fix scope |
+|---|---|---:|---|---|
+| ARCH-001 | Architectural concern | High | The advertised shared provider interface is only implemented by Xtream and Stalker and is bypassed by synchronization. | Architectural |
+| ARCH-002 | Architectural concern | High | The domain `Provider` model is a provider-union record dominated by Stalker learned/runtime state. | Architectural |
+| ARCH-003 | Architectural concern | High | `SyncManager` is a 6,048-line policy, networking, persistence, recovery, and scheduling god object. | Architectural |
+| ARCH-004 | Confirmed defect + architectural concern | Medium | The all-provider playback resolver contains contradictory dispatch and mixes URL resolution with Stalker session construction and persistence. | Local first; architectural follow-up |
+| ARCH-005 | Architectural concern | High | `PlayerViewModel` is a 25+ dependency feature orchestrator that crosses domain/data/player boundaries. | Architectural |
+| ARCH-006 | Highly likely defect | High | Plugin discovery performs multiple blocking IPC calls and maps plugin providers into M3U records. | Local + architectural |
+| ARCH-007 | Architectural concern | Medium | Database schema and the full migration history are concentrated in one multi-thousand-line class. | Architectural |
+| ARCH-008 | Suspected risk | Medium | Startup launches several overlapping background pipelines with independent work identities and state stores. | Architectural |
+
+## Detailed Phase 1 findings
+
+### ARCH-001 — Shared provider abstraction is partial and not used by the main sync pipeline
+
+- **Classification:** Architectural concern
+- **Severity:** High
+- **Where:** `domain/.../provider/IptvProvider.kt`; `data/.../remote/xtream/XtreamProvider.kt`; `data/.../remote/stalker/StalkerProvider.kt`; `data/.../remote/jellyfin/JellyfinProvider.kt`; `data/.../sync/SyncManager.kt`, especially `sync`, `syncLiveOnly`, `syncMoviesOnly`, and `syncSeriesOnly`.
+- **Current behavior:** `IptvProvider` claims to be the shared interface for all providers and includes authentication, every catalog type, EPG, playback, and catch-up. Only Xtream and Stalker implement it. M3U and Jellyfin bypass it. More importantly, `SyncManager` does not dispatch through this interface; it repeatedly switches on `ProviderType` and constructs/calls provider-specific helpers.
+- **Why this is wrong/fragile:** There are two competing provider architectures: a polymorphic domain contract and a central type switch. Adding or correcting a capability requires edits to multiple switches, repositories, URL resolution, setup, workers, and UI. The oversized interface also assumes every source supports authentication, live, VOD, series, EPG, and catch-up, which is false for M3U, Jellyfin, plugins, and recordings. This encourages dummy behavior and exceptions rather than explicit capabilities.
+- **Concrete failure scenario:** A new provider or a Jellyfin live-TV capability is added to one path (for example catalog sync) but omitted from one of `retrySection`, guide lookup, playback resolution, or background-worker dispatch. It compiles because `ProviderType` switches are distributed, then fails only in the omitted feature. Existing code already throws “retry unavailable” for Jellyfin in section-specific paths and handles Jellyfin separately in playback.
+- **Recommended correction:** Replace the monolithic interface with explicit capabilities (`ProviderAuthenticator`, `LiveCatalogSource`, `VodCatalogSource`, `SeriesCatalogSource`, `GuideSource`, `PlaybackResolver`, `CatchUpSource`) and a registry/factory keyed by provider type. Make `SyncManager` orchestrate capability results rather than provider types. M3U, Jellyfin, plugins, and local sources should implement only supported capabilities.
+- **Fix scope:** Architectural; can be introduced incrementally behind adapters.
+- **Required tests:** A provider capability contract test suite; registry completeness test for every `ProviderType`; unsupported-capability tests returning typed results rather than exceptions; end-to-end sync/playback tests using one fake per capability combination.
+
+### ARCH-002 — Core domain model is polluted by Stalker transport, fingerprint, and learned state
+
+- **Classification:** Architectural concern
+- **Severity:** High
+- **Where:** `domain/.../model/Provider.kt:3-52` and corresponding provider entity/mappers/backup/setup code.
+- **Current behavior:** One `Provider` data class stores generic identity plus Stalker MAC, device profile, timezone/locale, serial/device IDs/signature, advanced JSON, auth mode, portal profile/fingerprint/MAG preset/bootstrap recipe, endpoint/cookie/playback preferences, learned playback mode, requirement flags, fallback use, and rediscovery attempts. Xtream and M3U flags are mixed into the same record.
+- **Why this is wrong/fragile:** Transport configuration, durable user configuration, portal-learning output, and cross-provider identity are conflated. Every layer and backup/migration must understand fields irrelevant to most providers. Defaults silently create plausible Stalker state, making “unset”, “learned”, and “user-selected” hard to distinguish. It also causes provider-specific policy to leak into UI and shared data paths.
+- **Concrete failure scenario:** A Stalker bootstrap attempt updates a learned recipe/fingerprint but a concurrent provider edit saves an older copied `Provider`, reverting learned state or overwriting user configuration. Alternatively, a new Stalker strategy requires more fields and forces domain model, Room schema, backup format, UI commands, and every mapper to change together.
+- **Recommended correction:** Keep `Provider` as stable identity/status. Store typed provider configurations (`XtreamConfig`, `M3uConfig`, `StalkerDeviceIdentity`, `StalkerPortalLearning`, `JellyfinConfig`) behind a sealed configuration model or dedicated tables. Separate user intent from observed/learned portal state with version/timestamp/source metadata.
+- **Fix scope:** Architectural and migration-sensitive.
+- **Required tests:** Mapping round trips for each provider subtype; migrations from the union record; concurrent edit-vs-learning update tests; backup compatibility tests; explicit unset/default/learned state tests.
+
+### ARCH-003 — `SyncManager` is the application's provider-policy and persistence god object
+
+- **Classification:** Architectural concern
+- **Severity:** High
+- **Where:** `data/.../sync/SyncManager.kt` (6,048 lines, 169 functions, 27 constructor dependencies/created collaborators), plus `ProviderSyncWorker`, `XtreamIndexWorker`, `StalkerIndexWorker`, `ProviderRepositoryImpl`, `MovieRepositoryImpl`, and `SeriesRepositoryImpl`.
+- **Current behavior:** The class owns provider locking/state publication, M3U downloading/parsing, Xtream and Stalker authentication/catalog logic, category staging, transaction commits, EPG decisions, retries/timeouts, incremental index job state, worker scheduling, error sanitization, metadata/status updates, and repair flows. It creates additional support objects internally while also exposing provider-specific public methods used by workers and UI/repositories.
+- **Why this is wrong/fragile:** Correctness depends on many implicit invariants across one class: which lock is held, which staging rows exist, which status is published, whether a worker was queued, and whether provider-specific partial success is safe to commit. Repeated `ProviderType` branches create divergent full-sync and repair behavior. Unit tests must mock a huge dependency graph and cannot isolate protocol policy from transaction policy.
+- **Concrete failure scenario:** A fix to Stalker full sync commits a new staging invariant but `syncStalkerLiveCatalogStaged` or section repair uses the old invariant. A repair reports success and updates sync time while leaving a stale/partial catalog that the normal path would reject. Similar divergence can occur between Xtream initial onboarding and periodic index workers.
+- **Recommended correction:** Extract a provider-neutral `SyncCoordinator`, per-provider `CatalogSyncPlan` implementations, section-level transactional importers, and a separate durable job scheduler. Each plan should return a typed result containing staged mutations, warnings, continuation work, and activation criteria. Centralize status transitions in one state machine.
+- **Fix scope:** Architectural, high risk; refactor by seams and preserve fixtures before behavior changes.
+- **Required tests:** State-machine transition tests; full-sync vs repair equivalence tests; cancellation before/during/after commit; process-death recovery from each persisted job state; concurrent manual/background sync serialization; partial-result activation rules for every provider.
+
+### ARCH-004 — Playback resolver has contradictory provider dispatch and hidden side effects
+
+- **Classification:** Confirmed defect and architectural concern
+- **Severity:** Medium
+- **Where:** `data/.../remote/xtream/XtreamStreamUrlResolver.kt:45-227`, especially `resolveWithMetadata`; Stalker provider cache and learning helpers in the same class.
+- **Current behavior:** A class named `XtreamStreamUrlResolver` resolves Xtream, Stalker, M3U, and Jellyfin. In its exhaustive provider `when`, `ProviderType.M3U` is handled at lines 217-224 and then listed again with Jellyfin at lines 225-226. Kotlin accepts this, and the forced data-module compile passed, but the second M3U label contradicts the preceding pass-through behavior. The resolver also decrypts provider state, constructs/caches a full `StalkerProvider`, authenticates/resolves a link, and persists learned Stalker playback behavior.
+- **Why this is wrong/fragile:** A URL resolver is expected to be a mostly deterministic transformation. Here it is a provider session factory and state-mutating learning component. The duplicate branch is direct evidence that provider routing has become difficult to reason about. The cached provider configuration can also diverge from persisted edits unless every relevant field participates in cache replacement correctly.
+- **Concrete failure scenario:** A future edit changes the combined M3U/Jellyfin branch believing it handles both, while runtime M3U continues taking the earlier branch. More seriously, a playback retry can mutate learned Stalker settings, and a later retry/provider edit observes a cached session built from a different configuration, producing inconsistent headers, cookies, or endpoint choice.
+- **Recommended correction:** Immediately remove the duplicate M3U label and add exhaustive provider-routing tests. Rename/split this into a provider-neutral `PlaybackResolverRegistry` with independent Xtream, Stalker, M3U, and Jellyfin resolvers. Return explicit `PlaybackResolution` plus optional observations; persist observations in a separate coordinator with compare/version semantics rather than inside resolution.
+- **Fix scope:** Duplicate-label fix is local; side-effect/cache correction is architectural.
+- **Required tests:** One routing test per provider for internal and direct URLs; blank/missing provider cases; Stalker cache invalidation after every configuration field changes; concurrent resolve/edit; temporary-link expiry/renewal; observation persistence conflict tests.
+
+### ARCH-005 — `PlayerViewModel` crosses every layer and is a feature-level god object
+
+- **Classification:** Architectural concern
+- **Severity:** High
+- **Where:** `app/.../ui/screens/player/PlayerViewModel.kt:88-118` and the many `Player*Actions.kt`/`Player*Support.kt` extensions; direct imports of `SyncManager`, `StalkerUrlFactory`, `XtreamStreamUrlResolver`, `PreferencesRepository`, `OkHttpClient`, and concrete Media3 types.
+- **Current behavior:** The ViewModel has more than 25 constructor dependencies spanning repositories, recording, TV recommendations, cast, plugins, URL resolution, synchronization, raw HTTP, preferences, and playback. Its behavior is distributed across dozens of extension files that share `internal` mutable state. It coordinates live/VOD/series resolution, EPG, history, autoplay, token renewal, alternate streams, recovery, timeshift, cast, recording, downloads, plugins, diagnostics, and UI notices.
+- **Why this is wrong/fragile:** Splitting methods into files reduces file size but does not create ownership boundaries; all extensions still operate on one mutable object. UI lifetime becomes the owner of network/session policy and background sync. Testing one playback behavior requires a broad fixture and can inadvertently exercise unrelated collectors or timers. Concrete data imports bypass domain contracts and prevent isolated player-feature tests.
+- **Concrete failure scenario:** Channel zapping cancels/replaces a preparation job while a token-renewal, EPG refresh, alternate-stream recovery, or plugin callback from the prior item completes and mutates shared current state. The code may pass unit tests for each helper but fail under the combined event ordering.
+- **Recommended correction:** Introduce a `PlaybackSessionCoordinator` with an immutable session ID/state machine and scoped child jobs. Separate content resolution, provider playback resolution, player control/recovery, guide timeline, history, cast, and recording into explicit collaborators. ViewModel should translate coordinator state to UI and dispatch user intents. Depend on domain/app contracts rather than `data` concrete classes.
+- **Fix scope:** Architectural; migrate one session concern at a time.
+- **Required tests:** Stale-event/session-ID tests; rapid zap and content-switch tests; cancellation at every preparation stage; token renewal racing stop/release; recovery/cast/recording interactions; ViewModel lifecycle destruction while work is active.
+
+### ARCH-006 — Plugin discovery blocks callers and plugins are not first-class providers
+
+- **Classification:** Highly likely defect
+- **Severity:** High
+- **Where:** `app/.../plugins/StreamVaultPluginManager.kt`, especially `resolvePlugin`, `readManifestFromService`, `refreshTvInputCatalogInBackground`, and provider mapping/import methods.
+- **Current behavior:** Discovery resolves each service and uses `runBlocking(Dispatchers.IO)` for status and manifest Messenger calls with 2.5s and 3s timeouts. These calls are sequential per plugin and are invoked from non-suspending discovery helpers. Background TV refresh creates an unowned `CoroutineScope(Dispatchers.IO)`. Plugin catalog identity is persisted as a mapping to an M3U provider, so plugin lifecycle and provider lifecycle are coupled indirectly by names/IDs and preferences.
+- **Why this is wrong/fragile:** `runBlocking` blocks the calling thread even though work runs on IO; if discovery runs from the main thread, one unresponsive plugin can freeze UI for up to 5.5 seconds, multiplied by installed plugins. The unowned refresh scope cannot be cancelled or observed. Treating a plugin as M3U erases its runtime/capability boundary and risks orphaned or colliding provider records.
+- **Concrete failure scenario:** Three installed but unresponsive plugins make opening the plugin screen block for roughly 16.5 seconds. The user disables/uninstalls a plugin while its fire-and-forget TV refresh or catalog import is running, leaving an enabled mapping or M3U catalog that no longer has a source service.
+- **Recommended correction:** Make discovery/status loading suspending and concurrent with a bounded global timeout, expose per-plugin loading/error state, and run it in a lifecycle-owned scope. Model plugins as a provider/source capability with stable package/service/manifest identity and explicit uninstall/disable cleanup. Replace the ad-hoc scope with injected application work coordination or WorkManager if durable.
+- **Fix scope:** Local for blocking calls/scope; architectural for provider modeling.
+- **Required tests:** Main-thread discovery test; multiple slow/dead plugin services; timeout/cancellation; uninstall during import; duplicate manifest IDs; mapping cleanup and TV catalog consistency; process death during catalog import.
+
+### ARCH-007 — Database definition and migration history are too concentrated to audit safely
+
+- **Classification:** Architectural concern
+- **Severity:** Medium
+- **Where:** `data/.../local/StreamVaultDatabase.kt` and generated `data/schemas`.
+- **Current behavior:** One multi-thousand-line Room database class declares a large entity set and a long sequence of handwritten migrations. The forced compile emitted dozens of migration override warnings and two warnings about inferred intersection types in migration code, in addition to schema-related warning noise.
+- **Why this is wrong/fragile:** Schema declaration, migration SQL, data backfills, and compatibility helpers in one file make it difficult to review whether every historical upgrade path preserves invariants. Warning volume hides newly introduced warnings. Large provider-union entities and feature tables amplify migration coupling.
+- **Concrete failure scenario:** An upgrade from an older production version takes a different migration chain than tests normally cover; a backfill infers/coerces the wrong type or omits a newly required provider state column, producing a database that opens but later fails catalog/playback logic.
+- **Recommended correction:** Split migrations into versioned files grouped by feature, introduce reusable migration assertions/backfill helpers, and maintain an explicit schema-invariant checklist. Treat warnings as errors after cleaning the current baseline. Keep Room schema exports under version control and test every supported historical start version.
+- **Fix scope:** Architectural organization; individual warning fixes are local.
+- **Required tests:** Room MigrationTestHelper coverage from every shipped schema to current; multi-hop and direct-chain equivalence; data-preservation fixtures for every provider, EPG assignment, recording, history, and plugin mapping; downgrade/restore incompatibility messaging.
+
+### ARCH-008 — Background work is fragmented across independently scheduled pipelines
+
+- **Classification:** Suspected risk requiring further verification
+- **Severity:** Medium
+- **Where:** `StreamVaultApp.onCreate:74-97`; `ProviderSyncWorker`; `XtreamIndexWorker`; `StalkerIndexWorker`; `BackgroundEpgSyncWorker`; `RecordingReconcileWorker`; scheduling methods inside `SyncManager`.
+- **Current behavior:** Every process start enqueues maintenance, provider stale-check, Xtream index stale-check, and recording reconciliation, while periodic equivalents also exist. Provider sync can queue provider-specific index and EPG workers. Each class has separate unique names, `KEEP`/`REPLACE`/`APPEND_OR_REPLACE` policy, retry classification, delays, and persisted job metadata. In-process provider mutexes serialize some `SyncManager` calls but do not by themselves define a durable cross-worker state machine.
+- **Why this is wrong/fragile:** WorkManager uniqueness prevents duplicates only within an identical unique name. Different worker types can target the same provider and network/database concurrently. Status is distributed across WorkManager, Room job tables, provider status, sync metadata, and in-memory `SyncStateTracker`, so cancellation/process death may leave contradictory state.
+- **Concrete failure scenario:** Shortly after launch, `ProviderSyncWorker` refreshes an Xtream provider while `XtreamIndexWorker` processes queued categories and `BackgroundEpgSyncWorker` writes guide data. A manual refresh replaces one unique work chain but not the others; UI sees success from one state source while another worker later marks the provider partial or overwrites staging data.
+- **Recommended correction:** Define a durable per-provider work coordinator/state machine with named phases and one serialized chain. Worker entry points should claim persisted leases/epochs and reject stale work. Manual refresh should explicitly supersede or join background work. Consolidate retry/error/status publication rules.
+- **Fix scope:** Architectural.
+- **Required tests:** Simultaneous launch workers; manual refresh during each worker phase; process death and restart; stale WorkManager input after provider edit/delete; network loss and retry across phases; verify one authoritative user-visible status.
+
+## Phase 1 open questions
+
+1. Which historical app/database versions are actually in the supported upgrade window? Phase 4 migration coverage depends on this.
+2. Is Jellyfin intended as a permanent first-class provider? It appears throughout setup/catalog/playback but is omitted from the requested provider-review list and the shared provider contract.
+3. Are plugins intended to supply only M3U-compatible catalogs, or arbitrary provider operations and playback resolution? The current Messenger contract and M3U mapping suggest both models.
+4. Which Stalker fields are user configuration versus learned observations, and which must survive edits/backups? The current union record does not make this distinction explicit.
+5. What is the intended source of truth for a sync's visible state after process death: provider status, sync metadata, job tables, WorkManager, or `SyncStateTracker`?
+6. Should provider sync and index work be allowed during playback/recording on low-powered TV devices, or should a resource coordinator throttle them?
+7. Is the app expected to support multiple Jellyfin providers? `JellyfinImageAuthInterceptor` performs provider lookup by type, which may imply a singleton assumption requiring Phase 3 verification.
+8. Are direct M3U/Jellyfin playback URLs expected to be renewable, or only Xtream/Stalker URLs? Expiring signed M3U/Jellyfin URLs need an owner-specific renewal contract.
+
+## Next review targets
+
+Phase 2 should review these files/modules first, in this order:
+
+1. Networking profiles, clients, limits, cookies, timeouts, retries, and logging:
+ - `app/.../di/NetworkModule.kt`
+ - `data/.../remote/http/*`
+ - `OkHttpXtreamApiService.kt`
+ - `OkHttpStalkerApiService.kt`
+ - `JellyfinProvider.kt`
+2. Coroutine/lifecycle ownership and concurrency:
+ - `SyncManager.kt`, `SyncStateTracker.kt`, all sync workers
+ - repository-owned scopes in movie/series/provider/history/EPG repositories
+ - `Media3PlayerEngine.kt`, `LiveTimeshiftManager.kt`
+ - plugin, recording, receiver, and application scopes
+3. Persistence and transaction boundaries:
+ - `StreamVaultDatabase.kt`, all migrations and schema exports
+ - `SyncCatalogStore.kt`, staging/index DAOs, provider deletion
+ - preference/DataStore and plugin preference stores
+4. Shared playback infrastructure:
+ - `PlayerEngine`, `Media3PlayerEngine`, data source factories, retry/recovery, URL renewal, session release
+ - `XtreamStreamUrlResolver` (to be renamed/split later)
+5. Error/result/logging semantics and observability across repositories, workers, player, recording, and plugins.
+
+# Phase 2 — Shared infrastructure review
+
+**Status: Complete.** This phase reviewed shared networking, coroutine/cancellation ownership, WorkManager policy, catalog staging, Room/DataStore use, playback/recording lifecycle, cache bounds, application update checks, and error/result propagation. Provider-specific protocol behavior remains for Phase 3; end-to-end feature behavior and migrations remain for Phase 4.
+
+## Phase 2 findings summary
+
+| ID | Finding | Classification | Severity |
+|---|---|---|---|
+| INFRA-001 | Cancellation is broadly converted into normal failure/retry results | Implemented; adverse-case verification pending (2026-07-27) | High |
+| NET-001 | Suspend call paths use blocking, non-cancellable OkHttp `execute()` | Implemented; MockWebServer race matrix pending (2026-07-27) | High |
+| SYNC-001 | M3U staging has no effective response or catalog-size bound | Resolved (2026-07-26) | High |
+| SYNC-002 | A global progress bus corrupts concurrent per-provider sync progress | Resolved (2026-07-26) | High |
+| LIFE-001 | Every player engine permanently registers a timeshift component callback | Implemented; lifecycle stress verification pending (2026-07-27) | High |
+| LIFE-002 | Player reset launches unowned cleanup that can stop a new timeshift session | Implemented; lifecycle stress verification pending (2026-07-27) | High |
+| REC-001 | Recording stop/cancel neither cancels the HTTP call nor joins the writer | Implemented; capture matrix verification pending (2026-07-27) | High |
+| PERF-001 | Playback snapshots synchronously rewrite a file every second on main | Resolved (2026-07-26) | High |
+| PERF-002 | VOD progress triggers DB and Android TV rewrites every five seconds | Resolved (2026-07-26) | High |
+| WORK-001 | Local database maintenance is incorrectly gated on connectivity | Resolved (2026-07-26) | Medium |
+| WORK-002 | Recording reconciliation retries every error without classification/cap | Resolved (2026-07-26) | Medium |
+| UPDATE-001 | Failed automatic update checks suppress another attempt for 24 hours | Resolved (2026-07-26) | Medium |
+| MEMORY-001 | Process-lifetime maps grow with provider/category/host/media identities | Architectural concern | Medium |
+| PERSIST-001 | The central preferences DataStore has no explicit corruption recovery | Suspected risk | Medium |
+| TEST-001 | The player suite asserts the opposite MPEG-TS extractor policy from production | Resolved (2026-07-26) | Medium |
+
+The urgent shared fixes are cancellation-safe HTTP, recording/timeshift lifecycle ownership, M3U admission limits, and removal of main-thread/per-five-second persistence churn. These can cause work after cancellation, contradictory terminal state, retained resources, storage exhaustion, and playback jank independently of provider protocol correctness.
+
+## Detailed Phase 2 findings
+
+### INFRA-001 — Cancellation is broadly converted into normal failure/retry results
+
+- **Classification:** Implemented; adverse-case verification pending (2026-07-27)
+- **Severity:** High
+- **Where:** `data/.../sync/{SyncWorker,BackgroundEpgSyncWorker,ProviderSyncWorker,StalkerIndexWorker,XtreamIndexWorker}.kt`; representative paths in `EpgSourceRepositoryImpl.kt:218-420`, `DownloadManagerImpl.kt:110-203`, `RecordingManagerImpl.kt:134-473`, and `SyncManager.kt:1423`. Static inventory found 289 `runCatching` sites and 234 broad `Exception`/`Throwable` catches.
+- **Current behavior:** All five coroutine workers end in `catch (Exception)` and translate the throwable to WorkManager failure/retry without first rethrowing `CancellationException`. Many suspending repository/manager operations use Kotlin `runCatching` or broad catches. EPG refresh can turn cancellation into persisted failure and continue cleanup/status work. `SyncManager.sync:712-714` correctly rethrows cancellation, but this is not consistent.
+- **Why this is wrong/fragile:** Cancellation is control flow. Swallowing it lets superseded UI work and stopped workers publish errors, schedule retries, perform cleanup, or commit state after their owner has gone away. Standard `runCatching` catches `CancellationException`.
+- **Concrete failure scenario:** WorkManager stops a provider worker because constraints change. The worker reports retry/failure and may write error state even though it was deliberately stopped. Switching provider can similarly let a cancelled old refresh mark its source failed after the new one is active.
+- **Recommended correction:** Add a shared `runSuspendCatching`/`catchNonCancellation` helper that immediately rethrows cancellation; put an explicit cancellation catch before every broad worker/repository catch; prohibit raw `runCatching` around suspend calls with Detekt/review policy. Translate to domain `Result` only at an explicit owner boundary.
+- **Fix scope:** Cross-cutting but mechanical; start with workers, sync, recording, and EPG.
+- **Required tests:** Cancel every worker mid-call and assert no retry/failure or error metadata; cancel imports at parse/transaction boundaries; cancel download/recording/backup; prove child cancellation propagates while genuine `IOException` remains retryable.
+- **Implementation (2026-07-27):** Shared `runSuspendCatching`/`rethrowIfCancellation` helpers now protect the WP1 recording, EPG, download, backup, and sync boundaries touched in this package. All five workers catch and rethrow cancellation before failure/retry classification. `Wp1CancellationPolicyTest` prevents the known worker, Stalker, Xtream, and plugin regressions. The finding remains unresolved until the five worker adverse tests and post-cancellation DAO/status assertions pass.
+
+### NET-001 — Suspend call paths use blocking, non-cancellable OkHttp `execute()`
+
+- **Classification:** Implemented; MockWebServer race matrix pending (2026-07-27)
+- **Severity:** High
+- **Where:** `SyncManagerM3uImporter.kt:236-267`; `EpgSourceRepositoryImpl.kt:256`; `EpgRepositoryImpl.kt:288`; `OkHttpStalkerApiService.kt:975,1082,1221`; `JellyfinProvider.kt:305-308`; `RecordingCaptureEngine.kt:80,238,248`; Google Drive/update/download/resolver paths. A correct reference bridge exists at `OkHttpXtreamApiService.executeCancellable:377-392`.
+- **Current behavior:** Suspending functions move to `Dispatchers.IO` and call synchronous `Call.execute()`. Coroutine cancellation does not call `Call.cancel()`; the thread remains blocked until data, timeout, or server closure. EPG reads are long and recording streams can remain open indefinitely.
+- **Why this is wrong/fragile:** `withContext(IO)` prevents main-thread blocking but does not make I/O cancellation-aware. It consumes threads/sockets and can continue into parsing/persistence after cancellation. INFRA-001 compounds the damage.
+- **Concrete failure scenario:** The user replaces an M3U provider while a server sends headers then stalls. The obsolete import remains blocked, later resumes, and stages rows for superseded work. A stopped recording can remain in `read()` and retain its output.
+- **Recommended correction:** Standardize an OkHttp coroutine adapter using `suspendCancellableCoroutine`, `enqueue`, and `invokeOnCancellation { call.cancel() }`. Streaming operations need a cancellable handle that closes body and call. Apply operation-specific deadlines.
+- **Fix scope:** Shared adapter plus local migrations.
+- **Required tests:** MockWebServer never-headers, never-first-byte, and mid-body stalls; cancellation must promptly cancel the server call, close the body, avoid persistence, and release the dispatcher thread. Retain status/timeout/body-limit coverage.
+- **Resolution (2026-07-27):** `Call.useCancellableResponse` now owns the response for the full consumer lifetime, not just until headers arrive. It asynchronously enqueues the call, cancels it before headers and during body reads, converts cancellation-triggered read failures back to coroutine cancellation, and closes the response/body on every exit. M3U, EPG, Jellyfin, recording capture/source probing, downloads, Drive backup, Stalker, and plugin APK download paths use the owned adapter. `CancellableOkHttpTest` proves pre-header cancellation, blocked-body cancellation with body closure, and closure when parsing throws, all under five-second bounds.
+
+### SYNC-001 — M3U staging has no effective response or catalog-size bound
+
+- **Classification:** Resolved (2026-07-26)
+- **Severity:** High
+- **Where:** `SyncManagerM3uImporter.kt:60-220,236-267,314-320`; `SyncCatalogStore.kt:331-379`; compare `NetworkTimeoutConfig` and `CatalogSizeLimits` used by non-staging paths.
+- **Current behavior:** The importer does not bound `Content-Length`, decompressed bytes/lines, entries, or categories. It retains unbounded live/movie identity sets and category accumulators. M3U uses `stageChannelBatch`/`stageMovieBatch` then `finalizeStagedImport`, bypassing catalog limits applied by other store methods.
+- **Why this is wrong/fragile:** Streaming avoids retaining every object, but identity/category sets and Room staging still scale with the complete input. An accidental giant playlist, endless chunked body, or decompression expansion can exhaust heap, disk, and transaction time.
+- **Concrete failure scenario:** A provider returns millions of chunked entries without declared size. The app stages beyond the nominal 100,000-channel limit, grows hash sets, fills storage, and may leave a huge staging epoch after process death.
+- **Recommended correction:** Enforce decompressed bytes, lines, per-type entries, categories, field length, and parse-error ratio. Put count invariants in staging/database admission so every caller shares them; prefer database uniqueness to full-catalog identity sets. Abort with a typed oversize result and atomically clear staging.
+- **Fix scope:** Architectural at catalog admission; parser counters are local.
+- **Required tests:** Chunked/no length, compressed expansion, every catalog maximum, duplicate-heavy input, overlong lines, cancellation/space exhaustion, and preservation of the active catalog.
+- **Resolution:** M3U imports now enforce declared response size, decompressed bytes, raw-line length, total entries, per-type entries, categories, field length, and invalid-entry ratio through `CatalogSizeLimits`. The importer raises `CatalogAdmissionExceeded` before finalization; its existing `finally` clears the staged session, preserving the active catalog. `SyncCatalogStore` independently rejects channel/movie batches that would exceed the durable stage limit, so non-M3U callers cannot bypass it. `M3uParser` reports malformed candidates to support ratio enforcement; its focused unit suite passes.
+
+### SYNC-002 — A global progress bus corrupts concurrent per-provider sync progress
+
+- **Classification:** Resolved (2026-07-26)
+- **Severity:** High
+- **Where:** `SyncProgressBus.kt:21-36`; `SyncManager.withProviderLock:296-306`; `SyncManager.sync:659-732` and `retrySection:845-898`; consumers such as `WelcomeViewModel`.
+- **Current behavior:** Different providers have different mutexes and can sync concurrently. State is provider-scoped, but `SyncProgressBus` contains one unkeyed `StateFlow<SyncProgress?>`. Every sync emits into it and every sync's `finally` resets the same value.
+- **Why this is wrong/fragile:** Independent events interleave; completion/cancellation of one provider clears progress for another still working. A late event can be attributed to the wrong screen/session.
+- **Concrete failure scenario:** Providers A and B sync together. B publishes 70%, A finishes and resets the bus, and B's UI returns to “no sync” until another emission; labels and counters alternate between providers.
+- **Recommended correction:** Key progress by provider ID and monotonic sync epoch, or return a per-session flow. Reset only the matching epoch; derive aggregate progress separately.
+- **Fix scope:** Shared sync API and consumers.
+- **Required tests:** Two interleaved providers; one completes/cancels without clearing the other; stale epoch after replacement; concurrent manual/background entry points.
+- **Resolution:** `SyncProgressBus` now owns an active session per provider, identified by a monotonic epoch. It exposes keyed provider progress and a separately derived aggregate; only the matching session can publish or finish. `SyncManager` opens and closes that session for full syncs, section retries, and Xtream index rebuilds, while M3U and Xtream emitters report through the provider-scoped bridge. Focused bus tests cover independent completion, stale-session replacement, and aggregation.
+
+### LIFE-001 — Every player engine permanently registers a timeshift component callback
+
+- **Classification:** Implemented; lifecycle stress verification pending (2026-07-27)
+- **Severity:** High
+- **Where:** `DefaultLiveTimeshiftManager` in `LiveTimeshiftManager.kt:74-91`; construction at `Media3PlayerEngine.kt:272`; release/reset at `Media3PlayerEngine.kt:847-914`; auxiliary engines in multiview/home/EPG preview.
+- **Current behavior:** Each manager calls `context.registerComponentCallbacks(this)` in its initializer. There is no matching unregister or terminal manager close. Engine release resets player state but does not release the manager/scope.
+- **Why this is wrong/fragile:** The application context retains every manager ever created, including scope, state, and client references. Auxiliary-engine churn becomes a process-lifetime leak.
+- **Concrete failure scenario:** Hundreds of preview/multiview sessions leave hundreds of managers receiving memory callbacks until process death.
+- **Recommended correction:** Add idempotent terminal `close()` to stop the session, cancel calls/scope, clear state, and unregister. Invoke it from terminal engine release while keeping reusable reset distinct.
+- **Fix scope:** Local lifecycle API with all factories audited.
+- **Required tests:** Registration count returns to baseline after hundreds of cycles; double release; active HLS/DASH/TS release; reusable reset retains exactly one callback.
+- **Implementation (2026-07-27):** Terminal release now unregisters the component callback synchronously and idempotently, then performs joined session close in the engine-owned terminal cleanup scope. Reusable reset does not unregister. This remains unresolved until callback registration returns to baseline across the required repeated create/release and active-format stress matrix.
+
+### LIFE-002 — Player reset launches unowned cleanup that can stop a new timeshift session
+
+- **Classification:** Implemented; lifecycle stress verification pending (2026-07-27)
+- **Severity:** High
+- **Where:** `Media3PlayerEngine.resetEngineState:861-914`, particularly scope recreation at `907-910` and anonymous `CoroutineScope(Dispatchers.IO).launch` at `913`.
+- **Current behavior:** Reset cancels/recreates the engine scope, then launches `stopSession()` in an unrelated IO scope. Cleanup cannot be joined and has no generation check.
+- **Why this is wrong/fragile:** Reuse can start a new session before old cleanup gets the manager mutex; the old cleanup can then stop the new session. Release returns before resources close and failures are unobserved.
+- **Concrete failure scenario:** Channel A resets, channel B starts timeshift, and delayed A cleanup stops B or removes B's local manifest.
+- **Recommended correction:** Serialize reset/start under a session generation, or make reset/release awaitable and join cleanup. At minimum retain an owned cleanup job that start must await. Never use anonymous scopes for object lifecycle.
+- **Fix scope:** Player/timeshift lifecycle contract.
+- **Required tests:** Immediate restart after reset, delayed stop, release in every capture state, repeated reset, cleanup failure, and stale generation isolation.
+- **Implementation (2026-07-27):** Reset cleanup is now an engine-owned serialized job chain; every new timeshift start joins the latest chain before creating a session, and cleanup jobs are no longer cancelled/overwritten. `TimeshiftOwnershipTest` proves joined writer cleanup precedes deletion. The finding remains unresolved until delayed-cleanup restart and repeated reset/release integration tests pass.
+
+### REC-001 — Recording stop/cancel neither cancels the HTTP call nor joins the writer
+
+- **Classification:** Implemented; capture matrix verification pending (2026-07-27)
+- **Severity:** High
+- **Where:** `RecordingCaptureEngine.kt:74-109,234-251`; `RecordingManagerImpl.startCapture:564-585`, `stopRecording:195-213`, `cancelRecording:216-249`, `cancelActiveJob:1080-1082`.
+- **Current behavior:** Capture creates local synchronous OkHttp calls. The manager tracks only a coroutine `Job`; stop/cancel calls `job.cancel()` without `join`, immediately marks terminal state, and returns. A blocked body read cannot observe job cancellation.
+- **Why this is wrong/fragile:** UI/DB terminal state can precede writer termination. A “finished” file may remain open/growing, and delete/backup/replace can race it. Stalled reads also defeat coroutine stall checks.
+- **Concrete failure scenario:** A TS body stalls. The user cancels then deletes. Metadata/output are removed while the capture still owns the stream and may later write/finalize.
+- **Recommended correction:** Track an `ActiveCapture` owning job, calls, responses, and output. Cancel/close calls then `cancelAndJoin` before terminal state and destructive operations. Use bounded segment/read deadlines and one idempotent finalizer.
+- **Fix scope:** Recording capture/manager contract.
+- **Required tests:** Never-returning/mid-body stalls, stop/cancel/delete blocked TS and HLS, SAF/file outputs, service stop, and no write after terminal state.
+- **Implementation (2026-07-27):** `RecordingManagerImpl` now registers a lazy `ActiveCapture` before starting its job. Stop, cancellation, deletion, and foreground-service timeout cancel and join that owner before terminal persistence or destructive output work; capture cancellation is rethrown. `ActiveCaptureTest` proves repeated cancellation waits for non-cancellable resource finalization. The finding remains unresolved until the complete TS/HLS and file/SAF adverse matrix passes.
+
+### PERF-001 — Playback snapshots synchronously rewrite a file every second on main
+
+- **Classification:** Confirmed defect
+- **Severity:** High
+- **Where:** `Media3PlayerEngine.kt:164-170,341-404`; `PlaybackSupportSnapshotStore.kt:13-21`.
+- **Current behavior:** Engine collectors run on `Dispatchers.Main.immediate`; each second they call a store whose `write()` synchronously executes `File.writeText`. Failures are silently swallowed.
+- **Why this is wrong/fragile:** Continuous flash I/O on the UI dispatcher creates frame-time variance and storage churn during playback, and silent failure undermines the diagnostic.
+- **Concrete failure scenario:** Slow TV storage makes each rewrite coincide with controls/guide rendering, causing recurring dropped frames or input lag.
+- **Recommended correction:** Send state to a single IO actor, coalesce, write only on material transitions or a much lower cadence, use atomic replace, and record rate-limited failures.
+- **Fix scope:** Local.
+- **Required tests:** Injected dispatcher/writer proves no main I/O; stable-playback cadence cap; coalescing; atomicity; unavailable-storage observability.
+
+### PERF-002 — VOD progress triggers DB and Android TV rewrites every five seconds
+
+- **Classification:** Confirmed defect
+- **Severity:** High
+- **Where:** `PlayerLifecycleActions.kt:12-38`; `PlaybackHistoryRepositoryImpl.kt:42-55,185-214,266-280`; `WatchNextManager.kt:33-77`; `LauncherRecommendationsManager.kt:57-103`.
+- **Current behavior:** Every five seconds non-live playback performs a Room transaction/denormalized update, buffers the same row, refreshes Watch Next, and requests launcher recommendations. Watch Next scans platform entries and updates/inserts up to 40 rows every call. The 30-second “batch” flush writes the history again. Recommendations throttle themselves; Room and Watch Next do not.
+- **Why this is wrong/fragile:** The buffer duplicates instead of batches. Binder/launcher/Room/flash work on this cadence competes directly with playback and background sync.
+- **Concrete failure scenario:** A two-hour film causes about 1,440 history transactions plus denormalized updates, roughly 1,440 Watch Next scans/rewrites, and duplicate 30-second flushes.
+- **Recommended correction:** Keep progress in memory, debounce durable writes (for example 30-60 seconds), force flush on background/stop/content switch, and remove persisted pending entries. Refresh Watch Next only on meaningful thresholds/lifecycle events and update one affected row when possible.
+- **Fix scope:** Shared persistence policy plus TV integration optimization.
+- **Required tests:** Virtual two-hour playback with DAO/ContentResolver upper bounds; forced lifecycle flush; crash tolerance; incognito; watched transition; provider switch; no duplicate flush.
+
+### WORK-001 — Local database maintenance is incorrectly gated on connectivity
+
+- **Classification:** Resolved (2026-07-26)
+- **Severity:** Medium
+- **Where:** `StreamVaultApp.kt:74-90`; `SyncWorker.kt:27-64`; `DatabaseMaintenanceManager.kt:32-104`.
+- **Current behavior:** Daily maintenance requires `NetworkType.CONNECTED`, battery-not-low, and idle, yet performs only local pruning, statistics, checkpoint/VACUUM, and file cleanup.
+- **Why this is wrong/fragile:** Offline/local-network TVs can indefinitely skip maintenance and accumulate expired/orphan rows and reclaimable database/WAL space.
+- **Concrete failure scenario:** A local-playlist device without internet never satisfies the constraint despite being idle/charging, so months of EPG churn grow storage.
+- **Recommended correction:** Remove network. Consider separate light pruning/checkpoint and expensive idle-only vacuum jobs; persist last success.
+- **Fix scope:** Local scheduling.
+- **Required tests:** Request constraints, offline execution, battery/idle variants, locked/full DB retry, and safe skip during active sync.
+- **Resolution:** Daily local maintenance no longer requires network connectivity while retaining the battery-not-low and device-idle constraints.
+
+### WORK-002 — Recording reconciliation retries every error without classification or cap
+
+- **Classification:** Confirmed defect
+- **Severity:** Medium
+- **Where:** `RecordingReconcileWorker.kt:17-67`; `RecordingManagerImpl.reconcileRecordingState:279-444`.
+- **Current behavior:** Every domain `Error` and even `Loading` maps to `Result.retry()`, without explicit backoff, attempt ceiling, or category. Startup replaces a one-shot while periodic work runs every six hours.
+- **Why this is wrong/fragile:** Permanent row/configuration failures retry indefinitely. Startup replacement can reset the history of a repeatedly failing one-shot and diagnostics cannot distinguish causes.
+- **Concrete failure scenario:** A malformed legacy recording row fails deterministically; each launch replaces/restarts work and WorkManager repeatedly scans state without quarantining it.
+- **Recommended correction:** Return typed transient/permanent/per-row outcomes, quarantine/report bad rows, cap one-shot attempts with exponential backoff, and make `Loading` impossible as a terminal return.
+- **Fix scope:** Worker plus result refinement.
+- **Required tests:** Transient then success, permanent/partial row failure, ceiling/backoff, cancellation, startup replacement, and diagnostic metadata.
+
+### UPDATE-001 — Failed automatic update checks suppress another attempt for 24 hours
+
+- **Classification:** Resolved (2026-07-26)
+- **Severity:** Medium
+- **Where:** `StreamVaultApp.refreshCachedAppUpdateIfNeeded:105-132`; `GitHubReleaseChecker.kt:39-68`; `PreferencesRepository.kt:748-778`; similar ordering in `SettingsAppUpdateActions.kt:42-55`.
+- **Current behavior:** Startup writes the last-check timestamp before fetching. Only success refreshes cache; error is ignored. The timestamp gates checks for 24 hours, treating transient failure as success.
+- **Why this is wrong/fragile:** Last attempt and last success require different retry semantics; update discovery depends on being online at one startup and stale cache has no observable reason.
+- **Concrete failure scenario:** The TV starts before Wi-Fi, records the attempt, fails, then stays online all day without another automatic check.
+- **Recommended correction:** Store separate attempt/success/outcome. Rate-limit success for 24 hours, use short bounded failure backoff, and preferably use network-constrained unique WorkManager work. Preserve valid cache on failure.
+- **Fix scope:** Local/shared startup-settings policy.
+- **Required tests:** Offline then reconnect, 429/500, malformed response, cached success then failure, restart, force check, and clock changes.
+- **Resolution:** Successful checks retain the 24-hour cadence; failed checks persist separately and retry after a 15-minute bounded backoff without overwriting valid cached release data.
+
+### MEMORY-001 — Process-lifetime maps grow with provider/category/host/media identities
+
+- **Classification:** Architectural concern
+- **Severity:** Medium
+- **Where:** `PlayerDataSourceFactoryProvider.clientsByKey:42-78`; `PlayerAddressHealthStore`; `Media3PlayerEngine.promotedLiveHlsBufferReasonsByMediaId:225,1764`; `AudioCompatibilityMemoryStore`; movie/series category caches and locks; `EpgSourceRepositoryImpl.sourceRefreshMutexes:81,218`; URL resolver Stalker-provider registry.
+- **Current behavior:** Singleton/long-lived maps, sets, and per-media preference keys have no maximum, comprehensive TTL sweep, or deletion hook. Keys are data/network driven; player client keys include address/proxy variations. `SyncManager.onProviderDeleted` does not invalidate these other registries.
+- **Why this is wrong/fragile:** Deleted providers and one-off category/media/host keys remain reachable for the process. Per-key OkHttp clients cost more than metadata due to pools/dispatchers/configuration.
+- **Concrete failure scenario:** Provider churn and large catalogs create thousands of stale locks/freshness keys; rotating proxy/media identities add clients, health entries, compatibility keys, and buffer reasons until process death.
+- **Recommended correction:** Set ownership/bounds for every registry: provider-delete invalidation, LRU/TTL with proactive sweep, removal of unused mutexes, and a small fixed set of client profiles. Version/cap persisted compatibility memory.
+- **Fix scope:** Shared cache policy plus local hooks.
+- **Required tests:** 100,000 unique keys remain within fixed bounds; delete/re-add; TTL without same-key lookup; concurrent eviction/use; active calls survive client policy.
+
+### PERSIST-001 — The central preferences DataStore has no explicit corruption recovery
+
+- **Classification:** Suspected risk requiring runtime fixture
+- **Severity:** Medium
+- **Where:** `PreferencesRepository.kt:62-64` and its direct `.data.map/first` consumers; startup consumers in application/welcome/settings/player.
+- **Current behavior:** `preferencesDataStore(name = "user_preferences")` has no `ReplaceFileCorruptionHandler`, and no central read-I/O fallback/diagnostic policy was found. This graph god node backs onboarding, provider/source choices, playback configuration, updates, plugin mappings, and feature flags.
+- **Why this is wrong/fragile:** DataStore surfaces corruption/read failure unless recovery is configured. One damaged file can repeatedly fail unrelated startup flows. Blindly defaulting every error is also unsafe, so the policy must reconcile Room-backed state explicitly.
+- **Concrete failure scenario:** Storage/power damage corrupts preferences; eager collectors and `.first()` calls fail every process start even though the Room catalog remains usable.
+- **Recommended correction:** Add a documented corruption handler that preserves a diagnostic copy when possible and replaces known defaults; distinguish corruption from transient I/O; expose recoverable UI/telemetry; centralize policy.
+- **Fix scope:** Shared persistence policy, possibly recovery UX.
+- **Required tests:** Corrupt checksum/file, transient unreadable file, one-time handler, Room/provider reconciliation, restart, backup/restore, and cancellation not treated as corruption.
+
+### TEST-001 — The player suite asserts the opposite MPEG-TS extractor policy from production
+
+- **Classification:** Resolved (2026-07-26)
+- **Severity:** Medium
+- **Where:** `PlayerMediaSourceFactory.kt:40-51`; `PlayerMediaSourceFactoryTest.kt:8-17`.
+- **Current behavior:** Production explicitly configures direct live MPEG-TS with `TsExtractor.MODE_SINGLE_PMT` and explains that HLS mode is inappropriate for a long-lived raw TS input. The only focused test is named “uses hls mode” and asserts `MODE_HLS`. The Phase 2 run failed with expected `2` (`MODE_HLS`) but actual `1` (`MODE_SINGLE_PMT`); the other 190 player tests passed.
+- **Why this is wrong/fragile:** Either the documented production policy regressed or its regression test was not updated. In both cases the suite is red and cannot guard the intended live-TS behavior. Reflection on a private Media3 field also makes the test sensitive to dependency internals.
+- **Concrete failure scenario:** CI blocks unrelated changes on a stale assertion, encouraging the test to be ignored; alternatively, a developer changes production back to HLS merely to make CI green and reintroduces finite-duration/continuity behavior without a real playback fixture.
+- **Recommended correction:** Decide the supported direct-TS contract using a raw long-lived TS fixture and the historical stuck-window validation. Encode the mode as an app-owned policy value that can be asserted without reflection, update the stale name/assertion, and add a media-source/playback behavior test rather than relying only on an internal integer.
+- **Fix scope:** Local test/policy clarification; runtime change only if fixture evidence rejects `MODE_SINGLE_PMT`.
+- **Required tests:** Long-lived raw MPEG-TS beyond two minutes; discontinuity/multiple-PMT samples; duration remains live/unknown; reconnect behavior; keep the existing Android emulator 90-120 second live validation for any production-mode change.
+- **Resolution:** Verified the focused test now names and asserts the supported `MODE_SINGLE_PMT` policy. No runtime playback policy changed, so live-device validation is not applicable to this resolution.
+
+## Phase 2 verification and evidence
+
+- The existing graph report/wiki were read first. Graph communities identified `Media3PlayerEngine`, `PreferencesRepository`, `SyncManager`, and provider HTTP services as load-bearing; graph queries traced engine/timeshift and provider-sync relationships, then source was treated as authoritative.
+- Static inventory found 289 `runCatching` sites, 234 broad catches, five workers with broad terminal catches, and synchronous OkHttp calls across sync, EPG, Stalker, Jellyfin, recording, backup, update, download, and resolver paths. Reported defects were individually traced through callers/owners rather than inferred from counts.
+- Focused baseline command: `./gradlew.bat :data:testDebugUnitTest --tests "com.streamvault.data.sync.SyncProgressBusTest" --tests "com.streamvault.data.repository.PlaybackHistoryRepositoryImplTest" :app:testDebugUnitTest --tests "com.streamvault.app.tv.WatchNextManagerTest" :player:testDebugUnitTest --no-daemon`. The selected data/app tests passed. The player suite ran 191 tests: 190 passed and `PlayerMediaSourceFactoryTest` failed as documented in TEST-001. Existing tests do not cover the adverse cancellation/concurrency scenarios specified above.
+- Documentation only changed; no application code was modified, so `graphify update .` was not required.
+
+## Phase 2 open questions
+
+1. Should providers intentionally sync concurrently, or should catalog work be globally resource-limited during playback/recording?
+2. What hard limits are approved for decompressed M3U/XMLTV bytes, entries, categories, and field sizes on TV devices?
+3. Is playback snapshot persistence intended continuously in production or only for opt-in diagnostics?
+4. What maximum VOD progress loss after process death is acceptable (for example 30 seconds)?
+5. Must `Media3PlayerEngine.resetForReuse()` remain synchronous? Awaitable lifecycle would simplify correctness.
+6. Which preferences are safe to reset after corruption, and which must be reconstructed from Room or force recovery UI?
+7. Should recording stop be immediate with a partial segment or wait to a segment boundary within a fixed deadline?
+
+## Next review targets
+
+Phase 3 should keep these shared defects separate from provider-specific behavior and proceed in this order:
+
+1. **Stalker Portal (deepest):** `OkHttpStalkerApiService.kt`, `StalkerProvider.kt`, token/session/device state, handshake, profiles, pagination, command/link resolution, learned capabilities, retry, and time handling.
+2. **Xtream Codes:** API/provider, adaptive/index workers, pagination/category state, URL renewal, response limits, error mapping, and live/VOD/series distinctions.
+3. **M3U/M3U8 and XMLTV/manual EPG:** grammar/encoding/identity, duplicates/categories, EPG assignment/time, compression, merge/refresh, and staging recovery building on SYNC-001.
+4. **Jellyfin/local media/recordings:** session renewal, multi-provider selection, paging/identity, image auth, URL expiry, outputs, and REC-001.
+5. **Plugin providers:** Messenger lifecycle/timeouts/cancellation, manifest identity/capabilities, M3U mapping, uninstall cleanup, catalog ownership, and process death.
+
+# Phase 3 — Provider reviews
+
+**Status: Complete.** Providers were reviewed independently across authentication/session behavior, catalog completeness, identity mapping, protocol compatibility, EPG time handling, playback URL resolution, lifecycle ownership, and provider-specific test coverage. Stalker received the deepest inspection. Shared defects already established in Phase 2 are cross-referenced rather than counted again unless a provider amplifies them in a distinct way.
+
+## Phase 3 provider assessment
+
+| Provider | Strong existing behavior | Principal gaps found |
+|---|---|---|
+| Stalker Portal | Extensive MAG recipes/fingerprints, bounded response parsing, staged/indexed catalog paths, link-mode adaptation, replay harness | Global cookie state, incomplete token-expiry recognition, cancellation-driven fallback storms, silent page cap, timezone loss, collision-prone synthetic IDs |
+| Xtream Codes | Cancellable OkHttp bridge, response byte budgets, streaming catalog decode, typed HTTP/parsing errors, compatibility fallbacks | Provider facade swallows cancellation; transient category failure is cached as authoritative adult classification |
+| M3U/M3U8 | Streaming parser, defensive attribute parser, URL policy, stable 64-bit identity, staging swap | Fixed UTF-8 decode, only one header EPG URL, query-bearing VOD extensions misclassified; Phase 2 also found missing import bounds |
+| XMLTV/manual EPG | XML encoding autodetection, offset-aware dates, staged atomic source swap, channel/program batching | Size limit is applied before decompression; no deterministic timezone when one source is shared across differing providers |
+| Jellyfin/local media | Stable SHA-256-derived remote IDs, bearer request profiles for playback, Quick Connect support | Entire libraries are unpaginated/buffered; image authorization cannot distinguish multiple accounts on one server |
+| Plugin providers | Explicit Messenger request IDs, bind/unbind cleanup, capability contract, M3U provider integration | Name-based provider ownership, unscoped manifest IDs, orphan cleanup gap, sequential multi-minute playback chain |
+
+## Phase 3 findings summary
+
+| ID | Finding | Classification | Severity |
+|---|---|---|---|
+| STALKER-001 | All Stalker providers share and globally clear one cookie jar | Confirmed defect | High |
+| STALKER-002 | Expired sessions reauthenticate only for one error phrase | Confirmed defect | High |
+| STALKER-003 | Cancellation can continue through the Stalker recipe search | Implemented; stage-matrix verification pending (2026-07-27) | High |
+| STALKER-004 | Catalog pagination silently declares page 200 complete | Confirmed defect | High |
+| STALKER-005 | Portal-local dates are parsed as UTC | Confirmed defect | High |
+| STALKER-006 | Non-numeric remote IDs collapse to a 31-bit Java hash | Confirmed defect | Medium |
+| XTREAM-001 | Most Xtream provider operations swallow cancellation | Implemented; facade matrix verification pending (2026-07-27) | High |
+| XTREAM-002 | A transient category failure is cached as an empty adult-category set | Confirmed defect | Medium |
+| M3U-001 | Playlist decoding is fixed to UTF-8 and only the first header EPG URL is retained | Confirmed defect | Medium |
+| M3U-002 | Query-bearing VOD file URLs are classified as live streams | Confirmed defect | Medium |
+| XMLTV-001 | The 200 MB EPG limit measures compressed, not decompressed, bytes | Resolved (2026-07-26) | High |
+| XMLTV-002 | Shared no-offset XMLTV sources fall back to the device timezone | Architectural concern | Medium |
+| JELLYFIN-001 | Jellyfin catalog APIs buffer unpaginated libraries without a byte bound | Confirmed defect | High |
+| JELLYFIN-002 | Images from two accounts on one server use whichever provider matches first | Confirmed defect | High |
+| PLUGIN-001 | Plugin provider fallback can overwrite/delete a user-created M3U provider | Resolved (2026-07-26) | High |
+| PLUGIN-002 | Manifest IDs are not package-scoped and absent plugins are not reconciled | Resolved (2026-07-26) | High |
+| PLUGIN-003 | Playback preparation is a sequential, multi-minute, first-handler chain | Implemented; IPC lifecycle verification pending (2026-07-27) | High |
+
+## Stalker Portal deep review
+
+### STALKER-001 — All Stalker providers share and globally clear one cookie jar
+
+- **Classification:** Confirmed defect
+- **Severity:** High
+- **Where:** `OkHttpStalkerApiService.kt:63-89,309-357,842-843,1455-1467,1504-1517,1581-1585,2728-2765`.
+- **Current behavior:** The Hilt-singleton API service owns one `InMemoryStalkerCookieJar`. Every direct/proxy client uses it, keyed only by registrable domain/host. Every authentication recipe calls `cookieJar.clear()`, and current playback cookies are read back by host. Provider ID, MAC, account, and auth epoch are absent from cookie ownership.
+- **Why this is wrong/fragile:** Concurrent or alternating providers mutate the same session state. Authenticating provider B clears provider A's cookies; two accounts on the same portal overwrite same-name cookies. A's `currentCookieHeader` can then return B's cookie instead of the snapshot stored in A's session.
+- **Concrete failure scenario:** Provider A begins playback on `portal.example`; a background sync authenticates provider B on the same or another Stalker host and globally clears the jar. A's create-link renewal or archive request loses/replaces its session cookie and fails or resolves under B's portal session.
+- **Recommended correction:** Scope cookie storage to a provider/auth-session key. Construct a session-owned client/jar or pass an explicit immutable cookie snapshot; never globally clear unrelated sessions. Remove expired session jars on invalidation/provider deletion.
+- **Fix scope:** Stalker API/session architecture.
+- **Required tests:** Two providers on different hosts and two MAC/accounts on the same host; concurrent authentication; B fallback clears only B; A playback renewal retains A cookies; provider deletion and token refresh cleanup.
+
+### STALKER-002 — Expired sessions reauthenticate only for one error phrase
+
+- **Classification:** Confirmed defect
+- **Severity:** High
+- **Where:** `StalkerProvider.runWithAuthorizedSession:743-763`, `isAuthorizationFailure:1579-1584`; HTTP mapping in `OkHttpStalkerApiService.executeJsonRequest:974-1000`.
+- **Current behavior:** A provider retries authentication only when a domain message or exception contains the literal phrase `authorization failed`. The HTTP layer reports expired/rejected sessions as `Portal request failed with HTTP 401.` or `HTTP 403`; portals also use values such as `not_valid_token`, `access denied`, or empty/HTML login responses. These do not invalidate cached authentication.
+- **Why this is wrong/fragile:** The shared auth cache has no expiry timestamp, so correct recovery depends on recognizing every auth/session failure. Unrecognized expiry remains cached and every later catalog/playback request repeats with the dead token.
+- **Concrete failure scenario:** A portal expires a token and answers 401. `getLiveCategories` returns an error without clearing session state. Retrying the screen, background worker, and playback resolver reuse the same token until process restart or a separate explicit invalidation.
+- **Recommended correction:** Map HTTP/payload failures to typed `StalkerAuthenticationException`/`StalkerSessionExpiredException`; classify 401, applicable 403, known portal error codes, and login/invalid-token bodies centrally. Add session age/expiry and single-flight refresh. Do not infer auth from free-form UI text.
+- **Fix scope:** Stalker error/session contract.
+- **Required tests:** 401, token-specific 403, `not_valid_token`, `authorization failed`, HTML login redirect, genuine non-auth 403, concurrent refresh, and one retry ceiling.
+
+### STALKER-003 — Cancellation can continue through the Stalker recipe search
+
+- **Classification:** Implemented; provider stage-matrix verification pending (2026-07-27)
+- **Severity:** High
+- **Where:** `OkHttpStalkerApiService.authenticate:71-383`, especially suspend calls inside `runCatching` at `96,133,157,173,200,219,236,260`; `runApiCall:1408-1415`; synchronous requests at `975,1082,1221`.
+- **Current behavior:** Authentication explores auth-mode, recipe, preset, and endpoint candidates. Suspend network calls are wrapped in standard `runCatching`, which captures `CancellationException` and often `continue`s to the next candidate. The API also uses blocking `execute()`, delaying cancellation. Public operations turn any `Exception` into a domain error.
+- **Why this is wrong/fragile:** Cancelling setup/sync can cause additional handshakes/profile/account/module requests instead of termination. The fallback search is intentionally broad, so one swallowed cancellation is multiplied into network and cookie mutations across later recipes.
+- **Concrete failure scenario:** The user leaves Stalker setup during a slow first handshake. Once the blocking call returns/cancels, the catch marks that attempt failed and continues trying other recipes/endpoints even though the ViewModel/worker is gone.
+- **Recommended correction:** Use the shared cancellable OkHttp adapter, explicitly rethrow cancellation at every fallback boundary, and place the complete discovery operation under an overall deadline/request budget. Fallback should continue only for typed compatibility failures.
+- **Fix scope:** Stalker authentication implementation, using Phase 2 shared primitives.
+- **Required tests:** Cancel during handshake, credential auth, profile, modules, and streamed page; assert no later recipe request, cookie clear, persisted learning, or error state. Test overall attempt/time budget separately.
+- **Implementation (2026-07-27):** Stalker JSON and streaming requests use the owned cancellable response adapter, authentication attempts rethrow cancellation, and each authentication operation runs under an injectable 45-second/24-request budget. Recipe and credential fallback now continue only for `StalkerCompatibilityException`; authentication rejection, malformed accepted responses, cancellation, and budget exhaustion terminate discovery. `OkHttpStalkerCancellationTest` proves handshake cancellation prevents later recipe requests, request exhaustion prevents an additional outbound request, and the overall deadline cancels the active call. The finding remains unresolved pending cancellation coverage for credentials/profile/modules/streamed catalogs.
+
+### STALKER-004 — Catalog pagination silently declares page 200 complete
+
+- **Classification:** Confirmed defect
+- **Severity:** High
+- **Where:** `OkHttpStalkerApiService.fetchPagedItems:845-871`, `fetchPagedItemPage:873-894`, `JsonElement.totalPages:1588-1601`, `MAX_PAGE_COUNT = 200` at `2455`; persisted index page state in `SyncManager`/Stalker index jobs.
+- **Current behavior:** Computed `totalPages` is coerced to at most 200, requested pages are coerced to 200, and `StalkerPagedResult.isComplete` treats `page >= totalPages` as complete. No partial/truncated flag or warning is returned when server `total_items` requires more pages.
+- **Why this is wrong/fragile:** A safety ceiling becomes false completeness. The sync/index layer cannot distinguish a fully indexed catalog from a truncated one and will persist success, leaving items beyond the cap permanently undiscoverable.
+- **Concrete failure scenario:** A portal exposes 25 items per page and 7,500 VOD items (300 pages). Page 200 is marked complete; the final 2,500 titles never enter Room and no retry/diagnostic indicates why.
+- **Recommended correction:** Return an explicit `truncated/limitReached` outcome with server totals, fail or mark partial rather than complete, and make the configured item/page budget product-visible. Prefer item-count/byte/time budgets and resumable epochs over a hidden hard page number.
+- **Fix scope:** Stalker API plus index state/status.
+- **Required tests:** 199, 200, and 201+ page catalogs; inconsistent `total_items/max_page_items`; empty/repeated pages; partial state persists and resumes; UI/status reports truncation.
+
+### STALKER-005 — Portal-local dates are parsed as UTC
+
+- **Classification:** Confirmed defect
+- **Severity:** High
+- **Where:** `OkHttpStalkerApiService.toProgramRecord:1325-1349`, `toProgramRecords:2077-2099`, `parseExpirationDate/parseDateTime:2640-2663`; configured timezone in `buildStalkerDeviceProfile:2467-2547`.
+- **Current behavior:** Numeric epochs and offset-bearing timestamps are handled correctly, but date/time strings without an offset are converted using `ZoneOffset.UTC`. The parser does not receive `profile.timezone`, even though that timezone is sent to the portal in cookies/profile data. Account expiry strings use the same UTC assumption. Current Stalker tests overwhelmingly use `timezone = "UTC"`.
+- **Why this is wrong/fragile:** MAG/Stalker payloads commonly return portal-local wall times. Interpreting them as UTC shifts EPG, catch-up/archive windows, now-playing state, reminders, and expiry by the portal offset, including DST changes.
+- **Concrete failure scenario:** A Europe/Amsterdam portal returns `2026-07-11 20:00:00` without an offset. The app stores 20:00 UTC instead of 18:00 UTC in summer, displaying the program and generating archive URLs two hours late.
+- **Recommended correction:** Parse local timestamps using the authenticated/configured portal `ZoneId`; keep offset/epoch precedence. Separate account-date and EPG parsers if their portal conventions differ, and record which interpretation was used for diagnostics.
+- **Fix scope:** Stalker DTO/parsing signatures and tests.
+- **Required tests:** UTC, positive/negative zones, DST summer/winter and transition ambiguity, explicit offset overriding profile zone, numeric epochs, expiry date-only semantics, and archive URL alignment.
+
+### STALKER-006 — Non-numeric remote IDs collapse to a 31-bit Java hash
+
+- **Classification:** Confirmed defect
+- **Severity:** Medium
+- **Where:** `StalkerProvider.stableItemId/syntheticCategoryId:1495-1501`; use for channels, movies, series, episodes, programs, and categories around `696,1240,1284,1339,1374,1404,1465`.
+- **Current behavior:** Positive numeric IDs are preserved. Every non-numeric ID is mapped with Kotlin/Java `String.hashCode()`, masked to 31 positive bits. The provider/type prefix reduces cross-domain collisions but cannot prevent equal Java hashes; equal-length colliding suffixes such as `Aa`/`BB` remain collisions under the same prefix.
+- **Why this is wrong/fragile:** 31 bits is not a stable uniqueness space for large catalogs, and collisions are deterministic. Room uniqueness by provider/remote numeric ID then merges, skips, or replaces distinct content; navigation/history can target the wrong item.
+- **Concrete failure scenario:** Two non-numeric episode/channel identifiers hash identically. The second staging insert conflicts with the first, leaving one missing or associating metadata/playback with the other.
+- **Recommended correction:** Persist canonical remote IDs as strings and use composite provider/type/remote-ID keys. Where a Long is unavoidable, use the existing 63-bit SHA-256-style stable hashing plus collision detection/resolution, never a bare 31-bit hash.
+- **Fix scope:** Provider identity/schema contract; migration implications belong to Phase 4.
+- **Required tests:** Known Java-hash collisions; 100k-1m generated remote IDs; stable across restart; collision detection; history/favorites/episodes preserve both records; migration from existing IDs.
+
+## Xtream Codes review
+
+### XTREAM-001 — Most Xtream provider operations swallow cancellation
+
+- **Classification:** Implemented; facade matrix verification pending (2026-07-27)
+- **Severity:** High
+- **Where:** `XtreamProvider.kt:90-529`, including broad catches at `131,144,173,186,215,251,315,328,357,393,508,528`; compatibility `runCatching` at `1023,1037`. `getSeriesInfo:487-490` is the lone consistent cancellation-first example.
+- **Current behavior:** `OkHttpXtreamApiService` correctly cancels `Call` through `suspendCancellableCoroutine`, but the facade catches the resulting `CancellationException` as `Exception` and returns `Result.Error` for authentication, categories, catalogs, details, streaming indexes, and EPG. Series details explicitly rethrow, demonstrating the desired behavior.
+- **Why this is wrong/fragile:** The transport cancellation works, but its semantic signal is lost one layer later. Sync/UI code can publish failure, attempt compatibility fallbacks, or cache empty derived data for deliberately cancelled requests.
+- **Concrete failure scenario:** A category streaming sync is replaced. The HTTP call cancels promptly, but `streamVodSummaries` returns a domain error; the worker records failure/retry instead of ending cancellation cleanly.
+- **Recommended correction:** Apply the cancellation-first pattern used by `getSeriesInfo` to every suspend method and compatibility fallback, ideally through the shared helper from Phase 2.
+- **Fix scope:** Local/mechanical across `XtreamProvider`.
+- **Required tests:** Cancellation for auth, each catalog stream, category prefetch, VOD/series detail, EPG, and primary-to-legacy compatibility; genuine parsing/network failures remain typed.
+- **Implementation (2026-07-27):** Every public Xtream suspend operation now rethrows `CancellationException`, and series-info compatibility attempts use `runSuspendCatching`, so cancellation cannot reach the legacy request. Pure per-row mapping isolation remains unchanged. The existing provider/service tests pass, but the finding remains unresolved pending the complete facade cancellation matrix above.
+
+### XTREAM-002 — A transient category failure is cached as an empty adult-category set
+
+- **Classification:** Resolved (2026-07-26)
+- **Severity:** Medium
+- **Where:** `XtreamProvider.loadAdultCategoryIds:665-697`; long-lived provider caches in `MovieRepositoryImpl:138,1680-1713` and `SeriesRepositoryImpl:113,1660-1693`.
+- **Current behavior:** Category fetch failure is caught, logged, converted to `emptyList`, then transformed to an empty set and cached by content type. Subsequent item mapping never retries category loading for that provider instance. Repository provider instances can live for the process.
+- **Why this is wrong/fragile:** “No adult categories” and “category request failed” are distinct states. Caching failure as authoritative classification can leave content incorrectly unmarked after connectivity recovers and suppress policy/UI handling.
+- **Concrete failure scenario:** The first movie detail/list load occurs during a brief 500 response. The process-lifetime provider caches an empty movie adult set; all later movies rely only on optional text classification until process restart/provider signature change.
+- **Recommended correction:** Cache only successful category responses, or store success/error with TTL and retry backoff. Invalidate on sync/provider update and expose degraded classification state where policy requires it.
+- **Fix scope:** Local provider cache policy plus repository invalidation.
+- **Required tests:** First failure then recovery; cancellation does not cache; genuine successful empty list does cache; TTL/update invalidation; concurrent callers single-flight; explicit item adult flag still wins.
+- **Resolution:** Failed category prefetches now return an uncached empty set, while successful responses (including a genuinely empty response) remain cacheable. Cancellation is rethrown. Regression coverage verifies that a failed prefetch is retried and restored adult classification is applied.
+
+## M3U/M3U8 review
+
+### M3U-001 — Playlist decoding is fixed to UTF-8 and only the first header EPG URL is retained
+
+- **Classification:** Resolved (2026-07-26)
+- **Severity:** Medium
+- **Where:** `M3uParser.parse/parseStreaming:56-134`, `M3uHeader:25-28`, `extractHeaderEpgUrl:220-230`; `SyncManagerM3uImporter` header handling at `93-99`.
+- **Current behavior:** Both parser paths construct `InputStreamReader(..., UTF_8)` with no BOM/charset fallback. Header attributes such as `x-tvg-url` are split on commas and only the first non-empty URL survives in the singular `tvgUrl` field. XMLTV itself supports declaration-based encoding, so behavior differs across the paired formats.
+- **Why this is wrong/fragile:** Legacy/provider playlists in Windows-1252/ISO-8859-1 produce replacement characters in names/groups/EPG IDs, breaking display and matching. Multiple XMLTV URLs are a common header convention for split regional guides; discarding all but one creates systematic missing EPG.
+- **Concrete failure scenario:** A Latin-1 playlist contains accented channel names and two `x-tvg-url` sources. Names are corrupted, auto matching fails, and channels covered only by the second guide remain without programs.
+- **Recommended correction:** Detect BOM, honor a validated HTTP charset when available, and use a documented UTF-8/fallback policy. Model header guide URLs as a bounded deduplicated list and assign/import each valid source with explicit priority.
+- **Fix scope:** M3U parser/header model and importer assignment.
+- **Required tests:** UTF-8 BOM, UTF-16 BOM if supported, Windows-1252/ISO-8859-1, invalid byte sequences, accented EPG matching, multiple/comma-spaced/duplicate guide URLs, and per-URL failure isolation.
+- **Resolution:** M3U parsing now detects UTF-8 and UTF-16 BOMs, falls back to UTF-8 otherwise, and retains up to eight distinct header EPG URLs in source order. The importer validates each URL independently.
+
+### M3U-002 — Query-bearing VOD file URLs are classified as live streams
+
+- **Classification:** Resolved (2026-07-26)
+- **Severity:** Medium
+- **Where:** `M3uParser.isVodEntry:432-444`; classification branch in `SyncManagerM3uImporter:126-190`; tests cover bare `.mp4/.mkv` only.
+- **Current behavior:** VOD classification checks `lowercaseUrl.endsWith(".mp4"/".mkv"/".avi")`, literal `/movie/`, or English group substrings. A tokenized URL such as `film.mp4?token=...` does not end with the extension and is imported as live unless its path/group happens to match another heuristic.
+- **Why this is wrong/fragile:** Tokenized/expiring URLs are explicitly supported elsewhere. Misclassified VOD enters live channel UI, loses movie metadata behavior, uses live playback/retry semantics, and may be omitted from VOD entirely.
+- **Concrete failure scenario:** A playlist group named `Cinema` supplies `https://cdn/x/123.mp4?token=abc`. With VOD classification enabled, it becomes a live channel because `Cinema` is not one of the three English keywords.
+- **Recommended correction:** Parse the URI path and inspect its final extension independent of query/fragment. Make group/name heuristics configurable and localized, treat classification as confidence/evidence, and allow overrides.
+- **Fix scope:** Local classifier plus tests/UI explanation.
+- **Required tests:** Extensions with query/fragment and uppercase; encoded paths; extensionless VOD; localized groups; misleading live group names; explicit user override and stable reclassification on refresh.
+- **Resolution:** `M3uParser.isVodEntry` now inspects the parsed URI path, so query strings and fragments no longer hide supported VOD file extensions. Regression coverage includes query-bearing, fragment-bearing, and uppercase extensions.
+
+## XMLTV/manual EPG review
+
+### XMLTV-001 — The 200 MB EPG limit measures compressed, not decompressed, bytes
+
+- **Classification:** Resolved (2026-07-26)
+- **Severity:** High
+- **Where:** `EpgSourceRepositoryImpl.refreshSource:316-371`; `XmltvParser.maybeDecompressGzip:523-556`; `MAX_EPG_SIZE_BYTES` policy.
+- **Current behavior:** A `FilterInputStream` counting up to 200 MB wraps the raw HTTP/file stream, then `maybeDecompressGzip` wraps that counted stream in `GZIPInputStream`. The parser consumes unlimited decompressed XML as long as the compressed input stays below 200 MB. Staged rows also grow with the expanded document.
+- **Why this is wrong/fragile:** Compression ratios can be very high for repetitive XML. The advertised response ceiling therefore does not bound CPU, decompressed bytes, program count, Room staging, or disk use.
+- **Concrete failure scenario:** A 20 MB gzip expands to several gigabytes of XML/program rows. It passes the raw limit, spends prolonged CPU parsing, and fills staging/database storage before failure.
+- **Recommended correction:** Count decompressed bytes after decompression and retain a smaller raw/network bound before it. Add channel/program/field/depth limits and abort/clean staging with a typed oversize outcome.
+- **Fix scope:** EPG source ingestion boundary.
+- **Required tests:** Small gzip with expansion beyond 200 MB, chunked gzip, nested/very long text, maximum channel/program counts, cleanup after overflow, and active-source atomic preservation.
+- **Resolution:** The ingestion boundary now limits both raw bytes before decompression and decompressed XML bytes passed to the parser, preventing gzip expansion from bypassing the 200 MB ceiling.
+
+### XMLTV-002 — Shared no-offset XMLTV sources fall back to the device timezone
+
+- **Classification:** Architectural concern
+- **Severity:** Medium
+- **Where:** `EpgSourceRepositoryImpl.resolveSourceTimezoneId:584-605`; `XmltvParser.resolveParsingZoneId:643-652`; unique URL/source and many-provider assignment entities.
+- **Current behavior:** The repository derives timezone only from assigned providers' `stalkerDeviceTimezone`. Zero timezones or more than one distinct timezone returns `null`; the parser then uses `ZoneId.systemDefault()`. A unique EPG source is parsed once, so it cannot represent different no-offset interpretations per provider.
+- **Why this is wrong/fragile:** The same guide produces different instants on devices in different zones, and multi-provider assignment silently chooses neither provider. M3U/Xtream/Jellyfin have no equivalent source-specific timezone ownership here. Offset-bearing XMLTV is safe; local timestamps are not.
+- **Concrete failure scenario:** One manual guide with local timestamps is assigned to UTC and Europe/Amsterdam providers. The app logs a warning and parses using the TV's Asia/Jerusalem timezone, wrong for both; moving/restoring the database on another device changes all guide instants.
+- **Recommended correction:** Store an explicit timezone/interpretation policy on each EPG source. If assignments require different zones, create provider-scoped parsed instances or reject the ambiguous assignment. Never use device timezone as a silent durable-data default.
+- **Fix scope:** EPG source model and assignment UX; schema work in Phase 4.
+- **Required tests:** Same source on devices with different system zones; one/multiple provider zones; explicit source override; DST; offset-bearing input unaffected; backup/restore preserves interpretation.
+
+## Jellyfin, local media, and recordings review
+
+### JELLYFIN-001 — Jellyfin catalog APIs buffer unpaginated libraries without a byte bound
+
+- **Status:** Fixed (2026-07-26).
+- **Classification:** Resolved (2026-07-26)
+- **Severity:** High
+- **Where:** `JellyfinProvider.fetchMovies/fetchSeries/fetchEpisodes:82-119`, `fetchItems:186-198`, `fetchSeriesEpisodes:200-220`, `executeRequest:303-315`, DTOs at `363-369`.
+- **Current behavior:** `/Items` and `/Shows/{id}/Episodes` requests omit `StartIndex`/`Limit`. Responses are read fully with `body.string()` and decoded into a complete list. There is a 60-second call timeout but no content-length/decompressed-byte/item limit. DTOs do not retain `TotalRecordCount`/`StartIndex`, so pagination cannot be verified or resumed.
+- **Why this is wrong/fragile:** Large libraries require a full response, String, JSON tree/object graph, mapped entity list, and later persistence at once. Timeout does not cap memory. Server defaults/version differences can also make a seemingly successful response incomplete without detection.
+- **Concrete failure scenario:** A server with tens of thousands of movies returns one large JSON body; the TV OOMs during `body.string()`/Gson. If a server imposes a default page size, sync reports success with only the first page.
+- **Recommended correction:** Use explicit bounded pagination with `StartIndex`/`Limit`, verify `TotalRecordCount`, stream/decode page responses under byte/item limits, stage each page, and persist a partial/resume state. Reuse the cancellable HTTP adapter.
+- **Fix scope:** Jellyfin API/catalog sync architecture.
+- **Required tests:** Multiple pages, server default truncation, changing totals, empty/repeated pages, huge single item/body, cancellation mid-page, resume/process death, and catalog limits.
+
+**Resolution:** Jellyfin movie, series, and episode endpoints now send explicit `StartIndex` and `Limit=100`. Catalog responses are decoded from a bounded stream rather than `body.string()`; each page has a 4 MiB read/decompressed-byte budget, rejects more than 100 records, and requires a valid `TotalRecordCount`. Movie and series pages stage incrementally and are promoted only after the reported total is reached without a changed total or early empty page. A failed, oversized, or unstable sync discards its staged snapshot and leaves the active catalog intact. Catalog ceilings are enforced before promotion (200,000 movies, 100,000 series, and 10,000 episodes per series). Episode hydration now pages through the same bounded API before replacing its cached episode set.
+
+Focused JVM coverage verifies explicit continuation parameters, multi-page continuation metadata, and rejection of a server response that ignores the requested page size. Broader process-death and cancellation coverage remains part of the shared cancellation/recovery work package, but no longer permits an unbounded Jellyfin response to be loaded into memory.
+
+### JELLYFIN-002 — Images from two accounts on one server use whichever provider matches first
+
+- **Classification:** Confirmed defect
+- **Severity:** High
+- **Where:** `JellyfinImageAuthInterceptor.kt:13-76`; image URLs built without provider identity at `JellyfinProvider.kt:223-331`; provider lookup is `firstOrNull` by scheme/host/port/base path.
+- **Current behavior:** Image requests carry no provider/account ID. The singleton interceptor loads all Jellyfin providers and selects the first whose base URL matches, then attaches that provider's token. Two users/providers on the same server/base path are indistinguishable. Provider order has no documented ownership rule.
+- **Why this is wrong/fragile:** Tokens and media visibility are account-scoped. The wrong token yields 401/404, wrong library art, or intermittent behavior as provider ordering/cache changes. Playback avoids this by resolving with a known provider ID, but image loading does not.
+- **Concrete failure scenario:** Household accounts A and B share `https://media.local`. A catalog item visible only to B has an identical-host image URL; the interceptor chooses A first and the image fails despite B being the active provider.
+- **Recommended correction:** Carry provider ID in the app's image request model (tag/header/custom internal URL) and have the interceptor resolve that exact provider. Alternatively generate account-scoped authenticated image requests at repository/UI boundaries. Invalidate immediately on provider changes.
+- **Fix scope:** Image URL/request contract across data/app/Coil.
+- **Required tests:** Two accounts same base URL, different base paths, active-provider switch, delete/edit within cache TTL, parallel image requests, and token-specific visibility.
+
+**Resolution (2026-07-26):** Every generated Jellyfin image URL now carries an internal provider ID, which the interceptor validates against the URL before attaching that provider's token. It never guesses an account from host/path. Database migration 64→65 backfills the marker on existing Jellyfin movie, series, and episode artwork URLs, so already-synced catalogs receive the same account identity on upgrade.
+
+The Phase 2 recording cancellation defect REC-001 remains the principal provider-adjacent recording fault. Local recordings themselves use persisted file/SAF outputs rather than a separate catalog provider; their end-to-end scheduling, reconciliation, and playback flows remain in Phase 4.
+
+## Plugin-based provider review
+
+### PLUGIN-001 — Plugin provider fallback can overwrite/delete a user-created M3U provider
+
+- **Classification:** Resolved (2026-07-26)
+- **Severity:** High
+- **Where:** `StreamVaultPluginManager.syncPluginProvider:423-500`, `removePluginProvider:503-517`, `trackedProvider:531-536`.
+- **Current behavior:** If the SharedPreferences provider ID is absent, ownership is inferred by finding the first M3U provider whose `name == plugin.manifest.providerName`. Enabling then overwrites that provider's name/URL/settings and refreshes it; later disabling deletes the stored provider ID.
+- **Why this is wrong/fragile:** Display names are not ownership identifiers. A user-created provider or a second plugin can legitimately share the name. The destructive update/delete path has no proof the provider was created by this plugin.
+- **Concrete failure scenario:** The user has an M3U provider named `Sports`. A new plugin declares providerName `Sports`; enabling it replaces the user's URL/catalog, and disabling the plugin deletes the user's provider.
+- **Recommended correction:** Persist immutable plugin ownership (`packageName`, service component, manifest ID/version) on a provider/source record or dedicated mapping table. Never infer ownership by name; missing mapping should create a new provider or require explicit adoption confirmation.
+- **Fix scope:** Plugin-provider persistence model and migration.
+- **Required tests:** Same name as user provider, two plugins same provider name, lost preferences with existing mapping, disable/delete, restore, provider rename, and atomic mapping/provider creation.
+
+**Resolution:** Plugin-created M3U providers now receive a durable Room ownership record keyed by the plugin package, service class, and manifest ID. Plugin synchronization and disable cleanup resolve only through that record; the unsafe display-name fallback was removed. Consequently, a user-created M3U provider is never implicitly adopted, updated, or deleted by a plugin. Existing ambiguous legacy mappings are intentionally not auto-adopted, preserving user providers safely during upgrade.
+
+### PLUGIN-002 — Manifest IDs are not package-scoped and absent plugins are not reconciled
+
+- **Classification:** Resolved (2026-07-26)
+- **Severity:** High
+- **Where:** `discoverPlugins:55-60`, enabled/provider keys at `90,496,504,532,680-681`, `resolvePlugin:545-575`; no package-removal or installed-set reconciliation path was found.
+- **Current behavior:** Discovery deduplicates solely by plugin-supplied `manifest.id`. Enable state and provider mapping are also keyed only by that ID, not package/service. Two installed packages with the same ID share state and one disappears from discovery. If a package is uninstalled externally, its preferences and M3U provider/catalog remain because cleanup only occurs through `setPluginEnabled(false)` on an installed plugin object.
+- **Why this is wrong/fragile:** Package/service identity is the Android lifecycle identity. A manifest ID collision redirects state/mapping to whichever service PackageManager returns first, while uninstall leaves enabled orphan data and active/combined-source references.
+- **Concrete failure scenario:** Plugin A is enabled and creates provider 12. It is uninstalled; provider 12 remains active. Plugin B later installs with the same manifest ID and inherits A's enabled flag/provider mapping, then updates or deletes provider 12.
+- **Recommended correction:** Namespace identity by package + service + manifest ID, validate manifest ID uniqueness only within that owner, and reconcile installed components against mappings at startup/package-change. Orphan cleanup should be transactional and preserve user-adopted providers explicitly.
+- **Fix scope:** Plugin identity/lifecycle architecture.
+- **Required tests:** Duplicate IDs, multiple services in one package, uninstall/replace/reinstall/signature/version change as product policy allows, active/combined source cleanup, and user adoption preservation.
+
+**Resolution:** Plugin enablement and provider ownership now use the package/service/manifest triple, so manifest-ID collisions across packages or services cannot share state or provider mappings. Startup reconciliation compares durable ownership records with installed service components and removes only providers proven to be owned by an absent plugin, including active-source cleanup. Legacy enabled state is migrated only when the manifest ID is unique among installed services.
+
+### PLUGIN-003 — Playback preparation is a sequential, multi-minute, first-handler chain
+
+- **Classification:** Implemented; IPC lifecycle verification pending (2026-07-27)
+- **Severity:** High
+- **Where:** `preparePlaybackStreamInfo:268-293`, `discoverPlugins/resolvePlugin:55-60,545-590`, `rewriteCastUrl:296-318`, `PluginMessengerClient.send:28-100`.
+- **Current behavior:** Every preparation rediscovers plugins sequentially. For each service, manifest and status calls can consume 3.0 + 2.5 seconds. Then every enabled playback plugin is queried sequentially with a 120-second timeout until one says handled; cast rewrite similarly uses 10 seconds each. Precedence is sorted display name/PackageManager deduplication, not declared routing or priority. Standard `runCatching` can also swallow caller cancellation and continue.
+- **Why this is wrong/fragile:** Startup latency scales with installed plugins and one dead plugin blocks every later handler. A generic early handler can capture a URL intended for another plugin; there is no ownership predicate, parallel discovery cache, total deadline, or deterministic capability routing.
+- **Concrete failure scenario:** Three enabled playback plugins are dead/unresponsive. Discovery can cost 16.5 seconds and preparation up to six minutes before normal playback proceeds; leaving the screen can still advance to later plugins because cancellation is caught.
+- **Recommended correction:** Cache discovery with package-change invalidation, fetch status concurrently under a small total deadline, require plugins to declare URL schemes/hosts/content ownership and priority, and route only matching candidates. Use one strict overall preparation deadline and propagate cancellation; preserve per-plugin diagnostics.
+- **Fix scope:** Plugin capability/routing architecture.
+- **Required tests:** Multiple dead/slow plugins, cancellation at bind/response, total latency bound, two matching handlers/priority, generic non-handler, package changes, cast parity, and service disconnect fail-fast.
+
+**Implementation (2026-07-27):** Discovery results are cached and invalidated on package changes; manifest/status calls run concurrently with bounded deadlines. Playback preparation and cast rewriting route only to plugins that explicitly declare matching URL scheme/host ownership, execute candidates concurrently, apply deterministic priority ordering, and share one five-second end-to-end deadline. Caller cancellation propagates through manager boundaries, and Messenger cleanup always unbinds. Routing/priority and total-deadline tests pass; the finding remains unresolved until bind/response cancellation, disconnect, loser-unbind, and package-cache invalidation integration tests pass.
+
+## Phase 3 verification and evidence
+
+- Graph navigation was used for Stalker authentication → provider persistence → sync → playback-resolution relationships, Xtream indexing/renewal, and the M3U/XMLTV/Jellyfin/plugin boundaries. Source and focused tests remained authoritative because graph cohesion is low.
+- Reviewed primary provider implementations and their callers: `OkHttpStalkerApiService` (2,767 lines), `StalkerProvider` (1,611), Stalker recipes/support/adapters/traffic coordination, `XtreamProvider` (1,350), `OkHttpXtreamApiService` (615), URL factories/resolver, M3U/XMLTV parsers/importers, EPG source repository, `JellyfinProvider`/image interceptor, and plugin manager/Messenger contract.
+- Focused provider test command: `./gradlew.bat :data:testDebugUnitTest --tests "com.streamvault.data.remote.stalker.*" --tests "com.streamvault.data.remote.xtream.*" --tests "com.streamvault.data.remote.jellyfin.*" --tests "com.streamvault.data.parser.M3uParserTest" --tests "com.streamvault.data.parser.XmltvParserTest" --no-daemon` — **passed** on 2026-07-11. The adverse multi-provider, oversize, cancellation, non-UTC, and ownership cases above are absent from current coverage, so the green baseline does not contradict the source-demonstrated defects.
+- No application code was changed. Documentation-only changes do not require `graphify update .` under the project rule.
+
+## Phase 3 open questions
+
+1. What is the supported maximum Stalker catalog size, and should exceeding a budget fail sync or expose a deliberately partial library?
+2. Are two Stalker MAC/accounts on the same portal and two Jellyfin accounts on one server supported product scenarios? Current provider modeling permits both, while session/image infrastructure does not.
+3. Which timezone convention do supported Stalker portals and Xtream catch-up endpoints use for offset-free timestamps? Fixtures should record server/profile timezone and expected instant.
+4. Which non-UTF-8 M3U encodings and multiple `x-tvg-url` semantics are officially supported?
+5. Should a manual XMLTV source be globally shared by URL, or provider-scoped when timestamp interpretation differs?
+6. Is plugin identity controlled by StreamVault (globally issued IDs), or may third-party plugins choose arbitrary IDs? Android component identity should remain part of the key either way.
+7. Can a plugin-created M3U provider be adopted/retained by the user after plugin removal, or must uninstall always remove it?
+8. Is Jellyfin intended to import all libraries/items or only selected libraries? Explicit selection would change paging and category design.
+
+## Next review targets
+
+Phase 4 should trace feature flows end to end in this order:
+
+1. Provider setup/edit/delete and initial sync for every provider, including saved-with-warning and rollback behavior.
+2. Live playback/zapping/preload/retry/renewal/timeshift/catch-up, with Stalker session refresh and plugin preparation races.
+3. Catalog refresh/index/detail hydration for VOD/series, partial state, process death, and provider removal.
+4. EPG source discovery/assignment/refresh/matching/timezone, followed by reminders and catch-up.
+5. Recording schedule → alarm/service → resolution → capture → stop/reconcile → playback/delete, including REC-001.
+6. Resume/history/Watch Next/recommendations, downloads/local playback, cast, backup/restore, updates, and plugin lifecycle.
+7. Database migration chains and invariant preservation for provider identity, plugin ownership, synthetic IDs, EPG source timezone, and in-flight job state.
+
+# Phase 4 — Feature flow reviews
+
+**Status: Complete.** This phase traced setup/edit/delete, catalog navigation, EPG/reminders/catch-up, playback/resume/download/cast/multiview, recording, backup/restore, plugins/updates, and migrations across UI, domain, persistence, scheduling, and recovery boundaries. Shared and provider findings remain in Phases 2 and 3 rather than being counted twice.
+
+## Phase 4 findings summary
+
+| ID | Finding | Classification | Severity |
+|---|---|---|---|
+| SETUP-001 | Editing an active provider deactivates it before replacement sync succeeds | Confirmed defect | High |
+| BACKUP-001 | Restore is non-atomic across Room, preferences, and recording alarms | Confirmed defect | High |
+| BACKUP-002 | Provider-scoped restored preferences retain obsolete database IDs | Confirmed defect | High |
+| DELETE-001 | Post-delete alarm/sync cleanup failures are never reconciled | Resolved (2026-07-26) | Medium |
+| EPG-001 | Editing a reminder can persist a time whose alarm replacement failed | Confirmed defect | Medium |
+| PLAY-001 | Failed live-history persistence suppresses same-channel retry for the session | Confirmed defect | Medium |
+| MIGRATION-001 | The current 61→62 migration and full supported chain are untested | Needs improvement (2026-07-26 audit) | Medium |
+
+The main feature risks are cross-store transitions: provider edits expose partially committed setup state; restore can report failure after changing Room, DataStore, or alarms; and backup treats database row IDs as portable identities.
+
+## Feature-flow observations
+
+- **Setup/catalog/navigation:** Authentication/save converges in `ProviderRepositoryImpl`; activation follows initial sync. Xtream/Stalker require committed content while M3U/Jellyfin need not contain live channels. Catalog staging protects replacement rows, but provider state changes before commit (SETUP-001). Browsing, search, favorites, protection, and virtual groups are provider-scoped; backup breaks that identity model (BACKUP-002).
+- **EPG/catch-up/zapping:** Source refresh/matching, cached lookup, catch-up construction, and launch have clear owners. Phase 3 covers source/parser faults. New-reminder alarm failure is compensated, but edit failure is not (EPG-001). Zap resolution uses request generations to reject stale work; live-history de-duplication is optimistic (PLAY-001).
+- **Playback/download/cast/multiview:** Logical URLs become `StreamInfo`, followed by preparation, renewal, and recovery. Phase 2 lifecycle/timeshift/progress/cancellation findings remain controlling. Downloads correctly restart when a server ignores `Range` and returns `200`. Cast eligibility/media creation is centralized and tested for unsupported headers. Auxiliary multiview engines inherit LIFE-001/LIFE-002.
+- **Recording/backup/plugins/updates/migrations:** Scheduling validates storage, conflicts, connection limits, and exact alarms; alarm failure leaves an observable failed run. Capture inherits REC-001. Only provider/library/history restore is one Room transaction (BACKUP-001). Plugins retain PLUGIN-001–003 and updates UPDATE-001. Room 62 defines and production-registers every adjacent migration; the latest boundary lacks tests (MIGRATION-001).
+
+## Detailed Phase 4 findings
+
+### SETUP-001 — Editing an active provider deactivates it before replacement sync succeeds
+
+- **Classification / severity:** Confirmed defect — High
+- **Where:** `ProviderRepositoryImpl.kt:285-333` (Xtream), `381-420` (M3U), `467-485` (Jellyfin), `635-700` (Stalker), and `707-764` (shared completion).
+- **Current behavior:** Existing-provider paths write `isActive = false`, `status = PARTIAL`, and reset sync metadata before initial sync. Only success reactivates; error persists inactive state and schedules resume. The old committed catalog does not preserve selection.
+- **Why / scenario:** Replacement authentication and catalog promotion are separate commits. A transient failure after editing the active account's name or HTTP profile disables Home/Live TV despite a previously usable catalog.
+- **Recommended correction:** Keep the last active provider/catalog until a pending configuration revision and sync epoch commit atomically. At minimum restore prior active state on failure and delay timestamp reset.
+- **Fix scope:** Shared provider state-transition architecture.
+- **Required tests:** Active/inactive edit for every provider; sync failure, cancellation, process death, success, old-catalog availability, and stale-epoch isolation.
+
+### BACKUP-001 — Restore is non-atomic across Room, preferences, and recording alarms
+
+- **Classification / severity:** Confirmed defect — High
+- **Where:** `BackupManagerImpl.kt:344-434,693-778,995-1080`.
+- **Current behavior:** Provider/library/history commit in Room, followed by DataStore preferences, presets, and schedules/alarms. Later exceptions return generic failure without rollback. `REPLACE_EXISTING` cancels the old recording before the replacement is known to schedule.
+- **Why / scenario:** One result hides irreversible commits. Room and several preferences can change before a later write fails, yet UI reports total failure; failed schedule replacement can leave neither schedule.
+- **Recommended correction:** Use a durable sectioned restore with validated plan, checkpoints, and complete/partial/failed-before-commit outcomes. Snapshot/compensate preferences and restore the prior schedule if replacement promotion fails.
+- **Fix scope:** Cross-store restore protocol and result contract.
+- **Required tests:** Failure/cancellation/process death at every Room/DataStore/alarm boundary; idempotent retry; replacement compensation; exact section outcomes; no duplicates.
+
+### BACKUP-002 — Provider-scoped restored preferences retain obsolete database IDs
+
+- **Classification / severity:** Confirmed defect — High
+- **Where:** Export `BackupManagerImpl.kt:118-137`; restore `558-690`; Room mapping `714-810`.
+- **Current behavior:** `guideDefaultCategoryId`, `promotedLiveGroupIds`, `hiddenChannels_<providerId>`, and `hiddenCategories_<providerId>_<type>` contain source row IDs and are restored directly. Provider/group mappings never reach preferences; channel/category IDs can also change after resync.
+- **Why / scenario:** Auto-generated IDs are not portable. If source provider 2 maps to target 7, `hiddenChannels_2` affects no intended channel and can affect unrelated provider 2; group/category references similarly drift.
+- **Recommended correction:** Back up semantic provider/content/group identities, resolve them after Room import, then write target IDs; explicitly report unresolved references.
+- **Fix scope:** Backup schema/version and identity contract.
+- **Required tests:** Empty/populated targets with shifted IDs; keep/replace conflicts; changed catalog IDs; duplicate group names; unresolved references; semantic round trip.
+
+### DELETE-001 — Post-delete alarm and sync cleanup failures are never reconciled
+
+- **Classification / severity:** Resolved (2026-07-26) — Medium
+- **Where:** `ProviderRepositoryImpl.kt:131-213`; behavior is explicit in `ProviderRepositoryImplTest`.
+- **Current behavior:** Room deletion commits, then alarm cancellation and `syncManager.onProviderDeleted` use a catch-and-log helper. Success is returned without a retry marker.
+- **Why / scenario:** A transient external failure becomes permanent after its provider record is gone. Orphan alarms can fire against deleted rows and provider work/cache can survive.
+- **Recommended correction:** Persist a deletion tombstone, make cleanup idempotent, and enqueue unique reconciliation until all steps succeed; distinguish library-deleted from cleanup-pending diagnostics.
+- **Fix scope:** Deletion workflow and external cleanup hooks.
+- **Required tests:** Failure/process death after each step, reboot repair, repeated cleanup, concurrent alarm, and tombstone completion.
+- **Resolution:** Provider deletion now inserts durable per-action cleanup records in the same Room transaction as the provider-row deletion. A unique WorkManager worker retries recording-alarm, reminder-alarm, and sync-runtime cleanup after process death or transient failure, deleting each record only on success; startup enqueues the same drain worker.
+
+### EPG-001 — Editing a reminder can persist a time whose alarm replacement failed
+
+- **Classification / severity:** Resolved (2026-07-26) — Medium
+- **Where:** `ProgramReminderManagerImpl.kt:81-127`; tests omit existing-row scheduler failure.
+- **Current behavior:** Existing reminder rows update before alarm scheduling. Failure deletes only a new row, so an edit remains stored although the alarm was not replaced; cancellation also deletes first.
+- **Why / scenario:** Changing lead time from 10 to 30 minutes can show/store 30 while the old 10-minute alarm remains after scheduler failure.
+- **Recommended correction:** Keep the old entity, schedule replacement, then commit; compensate with the prior alarm when necessary and reconcile on startup.
+- **Fix scope:** Local reminder compensation protocol.
+- **Required tests:** Existing schedule/cancel/rollback failure, process death between boundaries, permission changes, startup repair.
+- **Resolution:** Existing reminder rows now update only after their replacement alarm schedules successfully. A failed replacement restores the prior alarm and leaves the persisted reminder unchanged.
+
+### PLAY-001 — Failed live-history persistence suppresses same-channel retry for the session
+
+- **Classification / severity:** Resolved (2026-07-26) — Medium
+- **Where:** `PlayerZapActions.kt:298-321`; state `PlayerViewModel.kt:268`; candidate tests omit repository failure.
+- **Current behavior:** `lastRecordedLivePlaybackKey` is assigned before asynchronous `recordPlayback`. Failure is logged without clearing it; later same-channel events return early.
+- **Why / scenario:** A transient first insert failure prevents every later retry, so last-watched/recent state remains absent even after staying on or returning to the channel.
+- **Recommended correction:** Separate in-flight and last-successful keys; mark success only after `Result.Success`, clear on failure/cancellation, and serialize stale completions.
+- **Fix scope:** Local player/history coordination.
+- **Required tests:** Failure then success, A→B→A, cancellation, concurrent duplicates, stale completion.
+- **Resolution:** Live-history de-duplication now distinguishes in-flight writes from the latest successful write. Failed or cancelled writes become retryable, concurrent duplicates remain suppressed, and stale completions cannot replace the active channel's successful key.
+
+### MIGRATION-001 — The current 61→62 migration and full supported chain are untested
+
+- **Classification / severity:** Resolved (2026-07-26) — Medium
+- **Where:** version `StreamVaultDatabase.kt:53`; migration `2687-2703`; registration `DatabaseModule.kt:44-105`; tests `StreamVaultDatabaseMigrationTest.kt:27-1287`.
+- **Current behavior:** Production correctly defines/registers `MIGRATION_61_62`. Tests stop at 60→61/57→61; earliest full chain stops at 42 and another at 51. Nothing migrates 61→62 or historical schemas to current 62.
+- **Why / scenario:** A default/entity mismatch can pass clean installs and unit tests but fail Room validation or populate wrong policies for upgrading users. This concretizes ARCH-007.
+- **Recommended correction:** Test populated 61→62 and every supported release→62 using the exact production registry; make CI compare DB version, exported schema, registration, and coverage.
+- **Fix scope:** Migration test infrastructure/CI; no production migration omission was found.
+- **Required tests:** 61/60/57/oldest-supported→62, every provider type, defaults/FKs/indexes, registry parity, and downgrade if supported.
+- **Resolution:** Added an Android Room migration test for the 61→62 production migration and verifies both newly added provider policy columns.
+- **2026-07-27 implementation:** A populated v60 provider fixture now migrates through the current v66 schema and verifies retained provider data plus v62 policy defaults; v65→66 has its own schema fixture. Coverage for every supported upgrade origin and production-registry parity remains required. **Status: Needs improvement.**
+
+## Phase 4 verification and evidence
+
+- Read `graphify-out/GRAPH_REPORT.md` and the wiki first; graph queries traced setup, playback/recording/cast, EPG, and backup/plugin/update/migration flows before source/test verification.
+- Directly verified `MIGRATION_61_62` in production `DatabaseModule`; this is a test gap, not a missing migration.
+- Focused command: `./gradlew.bat :data:testDebugUnitTest :app:testDebugUnitTest --tests "com.streamvault.data.repository.ProviderRepositoryImplTest" --tests "com.streamvault.data.manager.ProgramReminderManagerImplTest" --tests "com.streamvault.data.manager.BackupManagerImplTest" --tests "com.streamvault.app.ui.screens.player.PlayerZapActionsLivePlaybackTest" --tests "com.streamvault.app.cast.CastMediaRequestFactoryTest" --no-daemon` — passed (`BUILD SUCCESSFUL`, 2026-07-11).
+- Only Markdown changed. Emulator/live-TV validation and `graphify update .` do not apply because no application code changed.
+
+## Phase 4 fix order
+
+1. BACKUP-002 portable identities.
+2. BACKUP-001 checkpointed restore and safe replacement.
+3. SETUP-001 last-committed activation.
+4. EPG-001 and PLAY-001 compensation markers.
+5. DELETE-001 durable cleanup.
+6. MIGRATION-001 release-gated fixtures.
+
+## Phase 4 open questions
+
+1. Should provider activation change only after a new catalog revision commits?
+2. Must import be all-or-nothing, or is a durable section-level partial result acceptable?
+3. What is the oldest officially supported direct upgrade?
+4. Must hidden selections survive catalog row-ID changes? If so, runtime preferences also need stable identities.
+5. Is cleanup-pending user-visible or diagnostics-only?
+6. What bounded retry policy is acceptable for live-history writes?
+
+## Next review targets
+
+Phase 5 should stress these boundaries: process death/cancellation during commits and handoffs; disk full/corrupt persistence/revoked grants/clock jumps/reboot/upgrades; rapid switching and stale completion; malformed/huge data and shifted backup IDs; and runtime HLS/raw-TS/catch-up/VOD matrices across multiple channels for the required 90–120 second stuck window plus background/PiP/multiview/cast and constrained devices.
+
+# Phase 5 — Edge cases and failure scenarios
+
+**Status: Complete.** This phase stress-reviewed process death, reboot/package replacement, Android background-execution limits, permission revocation, storage/malformed input, clock changes, rapid switching, and stale completion. It used graph traversal, source/manifest inspection, current official Android behavior, and focused unit/lint execution. No application code was changed.
+
+## Phase 5 findings summary
+
+| ID | Finding | Classification | Severity |
+|---|---|---|---|
+| PLATFORM-001 | Boot recovery starts a prohibited `dataSync` foreground service before enqueuing durable work | Needs improvement (2026-07-26 audit) | High |
+| PLATFORM-002 | Recording and downloads share the six-hour `dataSync` quota without timeout handling | Needs improvement (2026-07-26 audit) | High |
+| DOWNLOAD-001 | Process-killed downloads remain permanently `DOWNLOADING` | Resolved (2026-07-26) | High |
+| ALARM-001 | Exact-alarm permission revocation cancels schedules with no grant-time restoration | Needs improvement (2026-07-26 audit) | High |
+| BACKUP-003 | Backup inspection/import has unbounded parsing and quadratic conflict scans | Confirmed defect | High |
+| REMINDER-001 | Notification failure is swallowed and the reminder is marked delivered | Confirmed defect | Medium |
+| CLOCK-001 | A future-dated `RUNNING` Xtream index job can suppress recovery indefinitely | Confirmed defect | Medium |
+| TEST-002 | The download manager/service has no focused tests | Confirmed test gap | Medium |
+| COMPAT-001 | Legacy-route decoding calls an API-33 overload on API 25–32 | Needs improvement (2026-07-26 audit) | High |
+
+## Adversarial scenario matrix
+
+| Scenario | Observed handling | Assessment |
+|---|---|---|
+| Process death during staged catalog import | Epoch/staging state is persisted and active catalog promotion is transactional | Good baseline; size/cancellation defects remain in Phase 2 |
+| Rapid player prepare/zap | Request generations reject stale URL resolution/preload completion | Good baseline |
+| Clock moves backward for cache TTL | `ContentCachePolicy` explicitly treats negative elapsed time as stale | Good baseline |
+| Process death during download | Startup reclaims the ownerless row into the pending queue | Resolved (DOWNLOAD-001) |
+| Reboot with scheduled recording | Boot receiver starts a forbidden FGS before WorkManager enqueue | PLATFORM-001 |
+| Exact-alarm permission revoked/re-granted | System cancels alarms; app has no grant receiver | ALARM-001 |
+| Long/cumulative recording and download work | Both services consume one six-hour `dataSync` budget; neither handles timeout | PLATFORM-002 |
+| Notification permission/channel changes after reminder creation | Notify error is discarded and delivery is still committed | REMINDER-001 |
+| Huge/malformed backup | Full Gson object graph is allocated before validation; preview conflict checks are nested scans | BACKUP-003 |
+| Wall clock is corrected behind a persisted running-job timestamp | Negative age is treated as “still running” in one Xtream gate | CLOCK-001 |
+| Encoded legacy route on API 25–32 | Unconditionally calls an API-33 URL-decoder overload | COMPAT-001 |
+| Recurring recording across DST | `ZonedDateTime.plusDays/plusWeeks` preserves local start time and fixed duration | Good baseline |
+| Range server returns `200` to resume request | Partial output is discarded and restarted from zero | Good baseline |
+
+## Detailed Phase 5 findings
+
+### PLATFORM-001 — Boot recovery starts a prohibited data-sync foreground service before durable work
+
+- **Classification / severity:** Confirmed defect — High
+- **Where:** target SDK 36 in `app/build.gradle.kts:54-59`; `data/src/main/AndroidManifest.xml:17-25`; `RecordingRestoreReceiver.kt:7-15`; `RecordingForegroundService.kt:233-237`; service type at `data/src/main/AndroidManifest.xml:4-7`.
+- **Current behavior:** On `BOOT_COMPLETED`, the receiver first calls `RecordingForegroundService.requestReconcile()`, which invokes `startForegroundService()` for a `dataSync` service. Only the next statement enqueues the durable reconciliation worker; there is no catch/finally around the foreground-service start.
+- **Why / scenario:** Apps targeting Android 15+ cannot launch a `dataSync` FGS from `BOOT_COMPLETED`; Android throws `ForegroundServiceStartNotAllowedException`. StreamVault targets 36, so a reboot can abort the receiver before WorkManager enqueue. Reboot also clears alarms, allowing scheduled recordings to be missed until the user launches the app and startup reconciliation runs. This restriction is documented by [Android's foreground-service changes](https://developer.android.com/about/versions/15/changes/foreground-service-types).
+- **Recommended correction:** Make WorkManager the boot entry point and enqueue it first. Do not launch a `dataSync` FGS from boot; let reconciliation schedule alarms and use the exact-alarm delivery exemption only when capture actually starts. Catch platform start rejection at every service-launch boundary and preserve a durable pending state.
+- **Fix scope:** Android scheduling/service architecture.
+- **Required tests:** API 35/36 boot broadcast with FGS restriction enabled; verify no receiver crash, worker enqueued, future alarms restored, overdue windows classified, and app never needs to be opened.
+- **2026-07-26 audit:** The receiver now enqueues `RecordingReconcileWorker` instead of starting the service, which is the required direction. It still lacks the API 35/36 boot-restriction fixture and evidence that every service-start boundary rejects safely while preserving the pending recording. **Status: Needs improvement.**
+
+### PLATFORM-002 — Recording and downloads share the six-hour data-sync quota without timeout handling
+
+- **Classification / severity:** Confirmed defect — High
+- **Where:** recording service `data/src/main/AndroidManifest.xml:4-7`; download service `app/src/main/AndroidManifest.xml:158-160`; `RecordingForegroundService.kt:30-107`; `DownloadForegroundService.kt:33-103`; no `Service.onTimeout()` implementation exists.
+- **Current behavior:** Both foreground services declare `dataSync`. On Android 15+, that type has a shared per-app six-hour budget per 24 hours. Neither service implements `onTimeout(int,int)` or coordinates remaining quota/terminal persistence.
+- **Why / scenario:** A long recording, several recordings, or recording plus downloads can exhaust the shared budget. The system calls `onTimeout`; if the service does not promptly stop, Android raises a fatal `RemoteServiceException`. Capture/download state and partial output can be left contradictory. The quota and required timeout behavior are documented in [Android 15 behavior changes](https://developer.android.com/about/versions/15/behavior-changes-15).
+- **Recommended correction:** Implement timeout handling that cancels and joins active I/O, checkpoints partial output, writes an explicit recoverable/terminal reason, and stops the service. Re-evaluate service types/APIs: user-initiated transfer jobs for downloads and an appropriate recording execution model. Coordinate one application-level quota owner.
+- **Fix scope:** Recording/download execution architecture and platform compatibility.
+- **Required tests:** Reduced quota via device config; one >6h recording; cumulative recording/download use; timeout during read/write/finalization; restart/reconcile; no ANR/crash and truthful partial state.
+- **2026-07-26 audit:** Both services now override `Service.onTimeout`, cancel/join their owned work, persist an explicit timeout outcome, and stop themselves. A shared quota owner, reduced-quota device fixtures, and restart/finalization coverage are still absent. **Status: Needs improvement.**
+
+### DOWNLOAD-001 — Process-killed downloads remain permanently DOWNLOADING
+
+- **Classification / severity:** Resolved (2026-07-26) — High
+- **Where:** `DownloadManagerImpl.kt:74-88,207-239,251-383`; `DownloadDao.kt:23-30`; `DownloadForegroundService.kt:50-100`.
+- **Current behavior:** Capture persists `DOWNLOADING` before network/file work. Process death prevents catch/finally from changing it. Startup/connectivity scheduling selects only `PENDING`/`PAUSED`; `getActive()` observes but does not repair `DOWNLOADING`. Although a valid service start returns `START_STICKY`, a system restart supplies no download ID, causing the service to stop without reconciliation.
+- **Why / scenario:** Killing the process mid-download leaves a row and partial document that no queue path owns. Reopening Downloads or reconnecting does not resume/fail it; only manual resume restarts from zero.
+- **Recommended correction:** Persist an owner generation/heartbeat and reconcile orphan `DOWNLOADING` rows at application/service initialization. If the output grant and byte count remain valid, resume with `Range`; otherwise atomically mark paused/restartable. Use durable unique work or a service command journal rather than in-memory jobs as ownership proof.
+- **Fix scope:** Download state machine and durable execution ownership.
+- **Required tests:** Kill after row transition, target creation, progress checkpoint, final byte, and before completion update; sticky null intent; reboot; revoked SAF grant; server `206/200/416`; exactly one resumed owner.
+- **Resolution:** A fresh `DownloadManagerImpl` now reclaims persisted `DOWNLOADING` rows before scheduling downloads, transitioning them to `PENDING` with an interruption reason so the existing queue/resume path owns them again.
+
+### ALARM-001 — Exact-alarm permission revocation cancels schedules with no grant-time restoration
+
+- **Classification / severity:** Resolved (2026-07-26) — High
+- **Where:** permission `app/src/main/AndroidManifest.xml:16`; boot-only receivers in `data/src/main/AndroidManifest.xml:17-35`; schedulers under `data/.../manager/{recording/RecordingAlarmScheduler,reminder/ProgramReminderAlarmScheduler}.kt`; no `ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED` receiver exists.
+- **Current behavior:** Scheduling checks `canScheduleExactAlarms()`, but restoration listens only for boot/package replacement. When permission is later granted, no receiver rechecks permission and restores persisted recording/reminder alarms.
+- **Why / scenario:** Android stops the app and cancels all future exact alarms when `SCHEDULE_EXACT_ALARM` is revoked. On re-grant it broadcasts `ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED` specifically so apps can restore alarms. StreamVault misses that event; recording repair waits for app startup and reminders have no startup restoration at all. See [Android's exact-alarm guidance](https://developer.android.com/develop/background-work/services/alarms).
+- **Recommended correction:** Add one manifest receiver for the grant action, recheck capability, and enqueue durable idempotent restoration for both subsystems. Persist/display “permission missing / schedule not armed” separately from `SCHEDULED`, and reconcile on app startup as a fallback.
+- **Fix scope:** Shared exact-alarm lifecycle and user-visible schedule state.
+- **Required tests:** Revoke (alarms disappear), grant broadcast, rapid grant/revoke race, app stopped, reboot, package replace, overdue reminder/recording, duplicate restoration, and permission denied after data restore.
+- **Resolution:** Both persisted schedule restore receivers now handle Android's exact-alarm permission-state broadcast and reuse their existing idempotent recording/reminder restoration paths.
+- **2026-07-27 implementation:** Recording runs and reminders now persist whether their exact alarm is armed. Restoration explicitly rechecks the capability, marks eligible entries unarmed when unavailable, and marks them armed only after rescheduling succeeds. Revoke/grant race and stopped-app device coverage remain required. **Status: Needs improvement.**
+
+### BACKUP-003 — Backup inspection/import has unbounded parsing and quadratic conflict scans
+
+- **Classification / severity:** Confirmed defect — High
+- **Where:** `BackupManagerImpl.kt:232-340,344-359,513-518`; nested preview scans at `271-317`; no size/count/depth limits are defined.
+- **Current behavior:** Inspection and import deserialize the entire stream into `BackupData` with Gson before version, structure, or checksum validation. Preview then performs incoming-list `count` operations containing linear `any` scans over existing groups/favorites/history/recordings. `OutOfMemoryError` is not caught by the surrounding `catch (Exception)`.
+- **Why / scenario:** A mistakenly selected huge JSON file or an oversized legitimate backup can allocate an unbounded object graph, perform quadratic work, freeze/kill a TV process, and never return the intended corruption result. Checksum validation happens too late to protect admission.
+- **Recommended correction:** Enforce compressed/uncompressed byte, nesting, per-section count, and field-length limits while streaming. Validate header/version and compute checksum incrementally. Build hash-indexed conflict keys for O(n+m) preview and reject oversized sections with typed diagnostics.
+- **Fix scope:** Backup format reader/admission architecture.
+- **Required tests:** Oversized seekable/non-seekable URI, deep JSON, million-entry/duplicate-heavy sections, long strings, malformed/truncated input, cancellation, low-heap fixture, and linear-time conflict benchmark.
+
+### REMINDER-001 — Notification failure is swallowed and the reminder is marked delivered
+
+- **Classification / severity:** Resolved (2026-07-26) — Medium
+- **Where:** `ProgramReminderNotifier.kt:20-42`; `ProgramReminderManagerImpl.kt:153-163`; scheduling-time UI gate in `NotificationPermissionGate.kt:36-103`.
+- **Current behavior:** `notify()` is wrapped in `runCatching` and returns no outcome. `deliverReminder()` unconditionally writes `notifiedAt` after the call. The UI checks permission when creating a reminder, but permission/channel state can change later.
+- **Why / scenario:** If notifications are revoked, the channel is disabled, or notify throws at delivery time, the user sees nothing while the row permanently records successful delivery and cannot be retried or diagnosed.
+- **Recommended correction:** Return a typed notification result, check runtime/channel state at delivery, and commit `notifiedAt` only after accepted delivery. Persist a blocked/failed reason and surface it when the app resumes; avoid blind repeated alerts.
+- **Fix scope:** Reminder delivery result/state model.
+- **Required tests:** Permission revoked after scheduling, channel disabled, notify exception, process death between notify and DB update, retry/deduplication, stale reminder, and reboot.
+- **Resolution:** Notification delivery now returns a typed result and `notifiedAt` is written only after successful delivery. Disabled app notifications remain pending for a later retry.
+
+### CLOCK-001 — A future-dated running Xtream index job can suppress recovery indefinitely
+
+- **Classification / severity:** Resolved (2026-07-26) — Medium
+- **Where:** `ProviderSyncWorker.kt:307-316`; contrast `ContentCachePolicy.kt:8-13`, which correctly handles negative elapsed time.
+- **Current behavior:** A `RUNNING` job is treated as fresh when `(now - updatedAt) < 15 minutes`. If `updatedAt` is in the future after manual/NTP clock correction, the negative age satisfies the condition until wall time catches up.
+- **Why / scenario:** A process dies with a running job, then the device clock moves backward by hours/days. Launch/periodic stale checks repeatedly skip the orphan job and its VOD/series index remains partial.
+- **Recommended correction:** Treat negative age as stale, matching `ContentCachePolicy`, or centralize persisted-age calculation with bounded clock-skew rules. Use monotonic time only for in-process durations and wall time plus explicit skew handling across restarts.
+- **Fix scope:** Local gate plus shared timestamp policy audit.
+- **Required tests:** Future timestamp, backward/forward jumps, process death, exact threshold, zero/invalid timestamps, and no duplicate live owner.
+- **Resolution:** A running index job is fresh only when its timestamp is not in the future and is within the stale window. Future timestamps are now eligible for recovery.
+
+### TEST-002 — The download manager/service has no focused tests
+
+- **Classification / severity:** Confirmed test gap — Medium
+- **Where:** `DownloadManagerImpl.kt`, `DownloadForegroundService.kt`, `DownloadDao.kt`; no corresponding test class exists. Current download references in tests are UI mocks or update/speed-test code.
+- **Current behavior:** The most failure-sensitive paths—process recovery, SAF output, range resume, cancellation, network retry, playback pause, service restart, and terminal finalization—have no executable regression coverage.
+- **Why / scenario:** DOWNLOAD-001 and platform timeout behavior can ship while broad builds and unrelated UI tests remain green.
+- **Recommended correction:** Extract a deterministic download state machine with injected clock/dispatcher/output/network adapters, add Room/MockWebServer unit tests, and add API 35/36 service/process-death instrumentation.
+- **Fix scope:** Testability refactor plus unit/instrumentation suite.
+- **Required tests:** All DOWNLOAD-001 cases, disk full, permission loss, 200/206/416, unknown length, cancellation at each boundary, retry ceiling/backoff, service null intent, timeout, and concurrent enqueue/playback.
+
+### COMPAT-001 — Legacy-route decoding calls an API-33 overload on API 25–32
+
+- **Classification / severity:** Resolved (2026-07-26) — High
+- **Where:** minimum SDK 25 in `app/build.gradle.kts:58`; `ExternalNavigationRequest.kt:80-90`; entry from `MainActivity.kt:342-357`; lint report `app/build/reports/lint-results-debug.html`.
+- **Current behavior:** Query parsing unconditionally calls `URLDecoder.decode(String, Charset)`, an overload available only from API 33. Legacy external routes can reach it on every supported Android version. Existing route tests contain only unencoded/blank values and run on the host JVM.
+- **Why / scenario:** On an API 25–32 TV, an external provider/detail route containing `importUri` or `returnRoute` query data invokes a method absent from the platform and can fail before navigation. Lint reported 16 `NewApi` errors in total; some other sites have indirect guards or catch failures, but this path has neither.
+- **Recommended correction:** Use the API-compatible `URLDecoder.decode(value, Charsets.UTF_8.name())` overload (with malformed-escape handling), or isolate versioned decoding behind an annotated implementation. Make lint a required release gate after triaging the existing backlog rather than accepting a permanently red task.
+- **Fix scope:** Local decoder plus minimum-SDK compatibility/testing policy.
+- **Required tests:** API 25, 26, 28, 32, and 33 instrumented route parsing; encoded UTF-8, `+`, malformed `%`, duplicate keys, long values, provider import URI, and return route; lint must have zero unsuppressed runtime/API errors.
+- **Resolution:** Legacy routes now use the API-compatible string-charset decoder and discard malformed query values rather than crashing navigation.
+- **2026-07-26 audit:** The local API-compatibility change and a JVM malformed-value test are present. API-25--32 device smoke coverage and the required zero-unsuppressed-runtime/API-lint gate are still absent. **Status: Needs improvement.**
+
+## Phase 5 verification and evidence
+
+- Read the graph report/wiki and queried recovery, storage, clock/alarm, and rapid-switch relationships before source inspection.
+- Verified target SDK 36, merged service types, receiver ordering, absence of exact-alarm grant handling and `Service.onTimeout`, DAO queue predicates, and absence of download-focused tests.
+- Focused unit command covering cache skew, provider stale checks, catalog staging, recording/reminders/backup, and player identity/zapping passed (`BUILD SUCCESSFUL`, 2026-07-12).
+- `:app:lintDebug` failed after 4m10s with 221 errors, 1,326 warnings, and 11 hints. The first failure was COMPAT-001; lint reported 16 `NewApi` errors plus manifest, resource, Compose, opt-in, and compatibility findings. The full HTML/text reports were generated under `app/build/reports/` and `app/build/intermediates/lint_intermediate_text_report/`.
+- Official Android documentation was used only for version-dependent platform behavior; local source establishes that the affected code paths apply.
+- Only this report changed, so `graphify update .` and live-playback emulator validation were not applicable. Runtime platform fixtures remain required before claiming fixes.
+
+## Phase 5 fix order
+
+1. PLATFORM-001, ALARM-001, and COMPAT-001 before the next target-36/min-SDK-25 release.
+2. PLATFORM-002 quota/timeout-safe capture and transfer ownership.
+3. DOWNLOAD-001 durable orphan reconciliation, developed with TEST-002.
+4. BACKUP-003 bounded streaming admission and indexed preview.
+5. REMINDER-001 truthful delivery outcomes.
+6. CLOCK-001 shared skew-safe age handling and systematic lint triage.
+
+## Phase 5 open questions
+
+1. What maximum continuous/cumulative recording duration must be supported on Android 15/16?
+2. May interrupted downloads retain partial SAF documents, or must recovery restart from zero for compatibility?
+3. What hard backup byte/count/depth limits fit the lowest supported TV memory class?
+4. Should reminders/recordings remain visibly `SCHEDULED` when exact-alarm permission is absent, or use a distinct unarmed state?
+5. What clock skew should invalidate persisted running/cooldown state?
+6. Which API 35/36 physical/emulator devices are part of release qualification for boot, quota, and permission tests?
+
+## Next review target
+
+Phase 6 should consolidate all Phase 1–5 findings into one deduplicated remediation program: release blockers first, then shared lifecycle/cancellation and data-integrity work, provider correctness, performance/bounds, migration/test gates, ownership by module, sequencing dependencies, and concrete acceptance criteria.
+
+# Phase 6 — Consolidated remediation plan
+
+**Status: Complete.** This phase consolidates all 56 findings from Phases 1–5 into eight deduplicated work packages, with dependency order, module ownership, acceptance gates, and release criteria. It is a remediation plan, not an implementation: no application code was changed.
+
+## Executive conclusion
+
+The reviewed build should be treated as **not ready for an unrestricted target-SDK-36/min-SDK-25 production release** until Work Package 0 is complete. The immediate blockers are missed recording restoration after reboot, unhandled Android `dataSync` service limits, exact alarms that are not restored after permission changes, a confirmed minimum-SDK API call, and an untested latest database migration boundary.
+
+The next risk tier is systemic rather than provider-specific: cancellation does not reliably stop network/file work, terminal recording/timeshift state can precede resource closure, and several multi-store workflows report outcomes that do not match committed state. Provider/session identity and bounded ingestion follow closely because they can cross-contaminate accounts, overwrite user providers, misrestore data, or exhaust TV memory/storage.
+
+The codebase has solid foundations worth preserving: explicit Room migrations, catalog staging/atomic promotion, request-generation guards in player preparation, provider-scoped persistence in ordinary browse flows, focused Stalker/Xtream tests, range-response handling, and recurring-recording DST arithmetic. The remediation program builds around those mechanisms.
+
+## Final finding inventory
+
+| Measure | Count |
+|---|---:|
+| Total findings | 56 |
+| High severity | 35 |
+| Medium severity | 21 |
+| Phase 1 — architecture/flow | 8 |
+| Phase 2 — shared infrastructure | 15 |
+| Phase 3 — providers | 17 |
+| Phase 4 — feature flows | 7 |
+| Phase 5 — edge/failure scenarios | 9 |
+
+No Critical-severity finding was assigned. “High” includes confirmed defects, highly likely defects, and architectural concerns; suspected/architectural findings must be validated at their stated boundary before a broad rewrite.
+
+## Dependency order
+
+```text
+WP0 Platform release safety ───────────────┐
+WP7 Test and release gates ────────────────┼── continuous verification
+ │
+WP1 Cancellation and resource ownership ───┼──> WP2 Durable workflows
+ │ ├──> WP4 Bounded ingestion/provider correctness
+ └─────────────────────────┘
+
+WP3 Stable provider/session identity ─────────> WP2 backup/plugin/state portability
+
+WP1 + WP2 + WP3 behavior contracts ──────────> WP5 orchestration decomposition
+
+WP1 player lifecycle + WP2 persistence policy > WP6 playback performance
+```
+
+WP0 and the initial WP7 harness can start immediately. WP1 establishes the cancellation/resource contract used by WP2 and WP4. WP3 defines durable identities before backup/plugin migration. WP5 decomposition starts after behavior is characterized and protected by tests. WP6 then applies the settled lifecycle/persistence policy to performance work.
+
+## Consolidated work packages
+
+### WP0 — Platform release safety
+
+- **Findings:** PLATFORM-001, PLATFORM-002, ALARM-001, COMPAT-001, MIGRATION-001.
+- **Objective:** Make the declared API 25–36 support window and Android 15/16 background execution reliable before release.
+- **Primary ownership:** `app`/`data` manifests; recording/download services and receivers; WorkManager scheduling; navigation compatibility; Room migration tests.
+- **Deliverables:** WorkManager-first boot recovery; exact-alarm grant restoration and unarmed state; `Service.onTimeout`/quota-safe terminal handling or replacement APIs; API-compatible route decoding; populated 61→62 and supported-version→62 migration fixtures.
+- **Exit criteria:** API 25 route/deep-link smoke passes; API 35/36 boot restriction and reduced `dataSync` quota fixtures pass; revoke/re-grant restores exactly one alarm; Room production registry parity and every supported upgrade fixture pass; no unsuppressed runtime/API lint error.
+
+### WP1 — Cancellation and resource ownership
+
+- **Findings:** INFRA-001, NET-001, REC-001, LIFE-001, LIFE-002, STALKER-003, XTREAM-001, PLUGIN-003.
+- **Objective:** Make cancellation terminate owned I/O and prevent stale work from publishing state.
+- **Primary ownership:** shared HTTP adapter in `data`; provider clients; recording capture; player/timeshift lifecycle; plugin Messenger preparation.
+- **Deliverables:** one cancellable OkHttp coroutine/stream adapter; `runSuspendCatching` that rethrows cancellation; owned `ActiveCapture` and engine/timeshift close contracts; request/session generations for provider/plugin chains; bounded per-handler plugin deadlines with parallel eligibility discovery.
+- **Exit criteria:** cancellation of never-header/mid-body calls closes call/body/output within a fixed test deadline; no retry/error/status write after deliberate cancellation; recording stop/cancel joins writer before returning; engine release unregisters callbacks and no stale cleanup stops a new session; plugin/provider cancellation terminates the active IPC/network operation.
+
+**Implementation evidence (2026-07-27):**
+
+- Shared cancellation: `CancellableOkHttpTest` covers pre-header cancellation, a blocked body read, and parser failure/response closure. `Wp1CancellationPolicyTest` checks cancellation-first handling in all five WP1 workers and rejects the known raw suspend/network `runCatching` regressions.
+- Providers: the existing Stalker and Xtream service suites remain green. `OkHttpStalkerCancellationTest` proves handshake cancellation issues no later recipe request and that request-budget exhaustion issues no request beyond the configured maximum.
+- Recording/player: `ActiveCaptureTest` proves repeated cancellation joins terminal cleanup; `TimeshiftOwnershipTest` proves writer cleanup precedes file deletion. The implementation registers lazy captures before start, serializes engine cleanup jobs, unregisters callbacks synchronously on terminal release, and closes timeshift calls before joining capture.
+- Plugins: `PluginPlaybackRoutingTest` proves explicit ownership/priority and one five-second discovery-plus-handler deadline; `StreamVaultPluginOwnerTest` retains package/service/manifest isolation. `PluginMessengerClient` unbinds in `finally` and no longer converts an ancestor timeout into a plugin-owned timeout.
+- Status policy: none of the eight WP1 findings is marked resolved merely from implementation. NET-001 has focused adapter evidence, but remains implemented-but-unresolved until the complete MockWebServer race/stall matrix passes; the other findings likewise await their full worker, storage, lifecycle-stress, provider-stage, facade, and bound-service cancellation matrices.
+
+### WP2 — Durable and truthful workflows
+
+- **Findings:** SETUP-001, BACKUP-001, BACKUP-002, BACKUP-003, DELETE-001, EPG-001, PLAY-001, DOWNLOAD-001, REMINDER-001, CLOCK-001, WORK-002, UPDATE-001, PERSIST-001, ARCH-008.
+- **Objective:** Ensure persisted state, external side effects, and returned results describe the same committed outcome across failure, process death, and retry.
+- **Primary ownership:** provider repository/setup; backup manager/schema; downloads; reminders/recordings; preferences; update/startup workers.
+- **Deliverables:** pending provider revisions and commit-time activation; checkpointed section-level backup import; stable-ID mapping from WP3; bounded streaming backup reader; deletion tombstones; alarm/reminder compensation; in-flight/success history markers; orphan-download reconciliation; typed retry/permanent outcomes; skew-safe timestamps; DataStore corruption policy; one startup-work registry.
+- **Exit criteria:** fault injection at every DB/DataStore/alarm/file boundary produces `complete`, `partial`, or `failed-before-commit` truthfully; retry is idempotent; previous active provider/schedule survives failed replacement; process-killed downloads become resumable/failed rather than stuck; update/reconciliation backoff distinguishes attempt from success; corrupt preferences reach a documented recovery state.
+
+### WP3 — Provider, account, and content identity isolation
+
+- **Findings:** ARCH-001, ARCH-002, STALKER-001, STALKER-002, STALKER-005, STALKER-006, JELLYFIN-002, PLUGIN-001, PLUGIN-002, XMLTV-002.
+- **Objective:** Prevent one provider/account/plugin/source from mutating or resolving another's state.
+- **Primary ownership:** domain provider contracts; Stalker/Jellyfin HTTP/session factories; plugin registry; EPG source model; provider/content persistence.
+- **Deliverables:** capability-based provider interfaces and provider-specific configuration/runtime records; per-provider Stalker cookie/session containers; typed authentication-expiry handling; provider-zone date parsing; collision-resistant remote identity; account-specific Jellyfin image resolution; package/component-scoped plugin IDs and explicit ownership; stable source timezone policy.
+- **Exit criteria:** concurrent same-host/different-account fixtures prove cookie/image/session isolation; nonnumeric IDs remain unique across restart/migration; plugin uninstall cannot alter user-owned M3U data; absent/renamed plugins reconcile deterministically; shared XMLTV sources require explicit timezone or preserve per-assignment semantics.
+
+### WP4 — Bounded ingestion and provider correctness
+
+- **Findings:** SYNC-001, STALKER-004, XTREAM-002, M3U-001, M3U-002, XMLTV-001, JELLYFIN-001.
+- **Objective:** Make catalog/EPG ingestion finite, resumable, and semantically correct for valid provider variations.
+- **Primary ownership:** sync admission/store; M3U/XMLTV parsers; Stalker/Xtream/Jellyfin paging and caches.
+- **Deliverables:** shared decompressed-byte/row/category/field/error-ratio limits enforced at admission; Stalker pagination with continuation/cycle detection instead of a silent page-200 success; failure-aware adult-category cache; BOM/charset-aware M3U parsing and complete header EPG handling; path-based extension classification; XMLTV decompressed limits; paged/bounded Jellyfin libraries.
+- **Exit criteria:** chunked/compressed expansion and exact-limit fixtures terminate predictably while preserving the active catalog; pagination never declares arbitrary truncation complete; transient cache failures retry; query-bearing VOD classifies correctly; memory/disk use stays within approved low-TV budgets.
+
+### WP5 — Orchestration and ownership decomposition
+
+- **Findings:** ARCH-003, ARCH-004, ARCH-005, ARCH-006, ARCH-007, SYNC-002, WORK-001, MEMORY-001.
+- **Objective:** Reduce god-object blast radius after behavior contracts are stable.
+- **Primary ownership:** `SyncManager`, playback resolver, `PlayerViewModel`, plugin discovery, database migration organization, worker registry, long-lived caches.
+- **Deliverables:** provider-neutral sync coordinator with provider strategies and section runners; split playback resolution/session construction/persistence; feature-scoped player coordinators; async cached plugin discovery; version-grouped migration files/registry; provider+epoch progress flows; correct maintenance constraints; bounded caches with deletion hooks.
+- **Exit criteria:** no unkeyed global progress; independent providers cannot clear each other's state; major coordinators have explicit dependency budgets and no data-layer construction; migration registry remains complete; 100,000-key stress remains bounded; local maintenance runs offline; architecture tests enforce module boundaries.
+
+### WP6 — Playback persistence and performance
+
+- **Findings:** PERF-001, PERF-002.
+- **Objective:** Remove continuous main-thread/file/Room/launcher churn during playback.
+- **Primary ownership:** `Media3PlayerEngine`, playback snapshot store, playback history repository, Watch Next/recommendations.
+- **Deliverables:** coalescing IO actor for optional diagnostics; debounced in-memory VOD progress with forced lifecycle/content-switch flush; incremental Watch Next update; material-transition recommendation refresh.
+- **Exit criteria:** no file I/O on main; proposed steady-state ceiling of one durable progress write per 30 seconds (subject to product loss tolerance); forced background/stop flush; two-hour virtual playback meets explicit DAO/ContentResolver/write-count budgets with no duplicate flush.
+
+### WP7 — Test and release gates
+
+- **Findings:** TEST-001, TEST-002.
+- **Objective:** Turn the failure scenarios in this review into release-blocking automated and device tests.
+- **Primary ownership:** all modules plus CI/release engineering.
+- **Deliverables:** resolve MPEG-TS policy test against a real long-lived fixture; deterministic download state-machine tests; migration matrix; cancellation/fault-injection utilities; provider replay fixtures; API 25/35/36 platform suite; lint triage/baseline policy; performance counters.
+- **Exit criteria:** intended MPEG-TS policy and test agree; download process-death/range/SAF/quota matrix passes; zero test task failures; lint has zero unsuppressed errors and warnings cannot increase; release artifacts publish test evidence described below.
+
+## Finding coverage audit
+
+Every finding appears in exactly one primary work package:
+
+| Work package | Finding count | IDs |
+|---|---:|---|
+| WP0 | 5 | PLATFORM-001, PLATFORM-002, ALARM-001, COMPAT-001, MIGRATION-001 |
+| WP1 | 8 | INFRA-001, NET-001, REC-001, LIFE-001, LIFE-002, STALKER-003, XTREAM-001, PLUGIN-003 |
+| WP2 | 14 | SETUP-001, BACKUP-001, BACKUP-002, BACKUP-003, DELETE-001, EPG-001, PLAY-001, DOWNLOAD-001, REMINDER-001, CLOCK-001, WORK-002, UPDATE-001, PERSIST-001, ARCH-008 |
+| WP3 | 10 | ARCH-001, ARCH-002, STALKER-001, STALKER-002, STALKER-005, STALKER-006, JELLYFIN-002, PLUGIN-001, PLUGIN-002, XMLTV-002 |
+| WP4 | 7 | SYNC-001, STALKER-004, XTREAM-002, M3U-001, M3U-002, XMLTV-001, JELLYFIN-001 |
+| WP5 | 8 | ARCH-003, ARCH-004, ARCH-005, ARCH-006, ARCH-007, SYNC-002, WORK-001, MEMORY-001 |
+| WP6 | 2 | PERF-001, PERF-002 |
+| WP7 | 2 | TEST-001, TEST-002 |
+| **Total** | **56** | All Phase 1–5 findings |
+
+Cross-package references are expected—for example, WP2 backup identity depends on WP3—but the table assigns one accountable primary owner to prevent duplicate tracking.
+
+## Recommended delivery waves
+
+### Wave A — Release safety and characterization
+
+- Complete WP0.
+- Establish WP7 platform, migration, download, cancellation, and live-playback harnesses needed by subsequent waves.
+- Freeze new background-service types, provider identity formats, and migration version changes until their contract tests exist.
+
+### Wave B — Stop and ownership semantics
+
+- Complete WP1 shared cancellation adapter and recording/player ownership first.
+- Migrate Stalker, Xtream, recording, EPG, downloads, backup, and plugin calls in bounded slices.
+- Require cancellation/fault-injection evidence for each migrated subsystem.
+
+### Wave C — Durable state and identity
+
+- Define WP3 provider/account/plugin/content stable identity schema.
+- Implement WP2 provider edit, backup, delete, alarm, reminder, history, and download state machines against that schema.
+- Add migrations and round-trip/process-death fixtures before enabling new backup format or ownership behavior.
+
+### Wave D — Bounded provider ingestion
+
+- Complete WP4 shared admission policy, then provider/parser-specific correctness.
+- Validate on low-memory/storage profiles and retain the last committed catalog on every rejection/failure.
+
+### Wave E — Decomposition and performance
+
+- Complete WP5 coordinator splits one behavior-preserving seam at a time.
+- Complete WP6 after player lifecycle and persistence contracts from WP1/WP2 are stable.
+- Enforce module/complexity/cache bounds in CI so god objects and unbounded registries do not regrow.
+
+## Release acceptance gates
+
+### Build and compatibility
+
+- `assembleDebug`, all unit tests, migration instrumentation, and selected device tests pass.
+- Lint contains zero unsuppressed errors; an owned warning baseline may only decrease.
+- API 25, 28, 33, 35, and 36 smoke covers startup, Settings, external routes/imports, provider setup, playback, PiP where supported, downloads, and alarms.
+
+### Lifecycle and failure behavior
+
+- Network/file/IPC cancellation stops owned resources promptly and produces no post-cancellation commit.
+- Process death is injected at every multi-store transition; restart yields one deterministic owner and an idempotent outcome.
+- Boot, package replacement, exact-alarm revoke/grant, notification revoke, SAF revoke, disk full, clock jump, and reduced FGS quota have explicit expected states and no crash/ANR.
+
+### Provider and ingestion matrix
+
+- At least two providers/accounts of each supported type run concurrently without cookie/image/progress/identity crossover.
+- Stalker replay covers auth/session expiry, recipe fallback, timezone/DST, nonnumeric IDs, and pagination beyond historical limits.
+- Xtream/M3U/XMLTV/Jellyfin fixtures cover compressed/chunked/oversized/malformed/duplicate/paged inputs at and beyond every configured limit.
+- Plugin install/update/remove/crash/timeout cannot mutate user-owned provider records.
+
+### Playback and recording
+
+- Live TV validation follows the repository protocol on more than one channel: preferably 61 screenshots at two-second cadence, continued frame-hash progression, media session `PLAYING` with `error=null`, and no fatal/stuck/unintended MPEG-TS fallback logs.
+- Raw MPEG-TS and HLS each run beyond the historical 90–120 second stuck window; catch-up/VOD test seek, renewal, background, PiP, multiview, cast, and alternate-stream recovery.
+- Recording stop/cancel/timeout joins all I/O before terminal state; boot/alarm/quota/process-death fixtures preserve or truthfully fail schedules and outputs.
+
+### Persistence, backup, and performance
+
+- Every supported Room schema migrates to current with representative provider/content state and registry parity.
+- Backup round trip uses stable identities on shifted-ID targets, enforces hard limits, reports partial sections truthfully, and is idempotent after interruption.
+- No continuous playback file I/O occurs on main; progress/launcher/database counters stay within approved budgets.
+- Long-lived maps/caches remain within fixed bounds and provider deletion evicts owned entries.
+
+## Initial implementation batch
+
+The first code batch should be small enough to review independently while removing immediate release hazards:
+
+1. Change recording boot recovery to enqueue WorkManager first and remove boot-time `dataSync` FGS launch.
+2. Add exact-alarm grant receiver plus shared idempotent recording/reminder restoration.
+3. Add timeout-safe terminal handling for recording/download services and reduced-quota device tests.
+4. Replace the API-33-only URL-decoder overload and add API-25 route fixtures.
+5. Add `MIGRATION_61_62` and oldest-supported→62 populated tests using the production registry.
+6. Add orphan-`DOWNLOADING` reconciliation and its first focused download tests.
+
+This batch does not require the large architecture split and creates the safety harness needed for WP1–WP6.
+
+## Governance and ownership
+
+- Assign one technical owner per work package and one reviewer from an affected neighboring module.
+- Track findings by their stable IDs; a finding closes only when its required tests and work-package exit criteria pass.
+- Any scope change must record which acceptance criterion replaces the original one.
+- Architectural/suspected findings close through measured evidence or an implemented boundary, not file movement alone.
+- Each release candidate publishes: supported API/provider matrix, migration range, lint/test status, live-playback evidence, and unresolved accepted risks.
+
+## Residual questions requiring product decisions
+
+1. Oldest supported direct app/database upgrade version.
+2. Approved hard limits for M3U, XMLTV, Jellyfin, backup sections, fields, and decompressed bytes on the lowest-memory TV.
+3. Maximum acceptable VOD progress loss and durable-write cadence.
+4. Maximum supported continuous/cumulative recording duration on Android 15/16 and partial-output behavior at quota/space loss.
+5. Whether backup import must be all-or-nothing or may expose durable section-level partial success.
+6. Stable identity authority for third-party plugins and whether plugin-created providers may be adopted by users.
+7. Whether shared XMLTV sources require one explicit timezone or support provider-specific interpretation.
+8. Whether provider sync concurrency remains supported and what global resource budget applies during playback/recording.
+
+## Phase 6 verification and final status
+
+- Re-read the graph report/wiki and queried cancellation, provider identity, Android scheduling, and player lifecycle clusters. The graph confirmed that `PreferencesRepository`, `SettingsViewModel`, provider services, `Media3PlayerEngine`, and sync metadata are the main cross-package change surfaces; source-backed phase findings remain authoritative.
+- Parsed every Phase 1–5 summary and assigned all 56 stable IDs exactly once: 5 + 8 + 14 + 10 + 7 + 8 + 2 + 2 = 56.
+- Severity totals reconcile to 35 High and 21 Medium.
+- No code or build configuration changed in Phase 6. Only this Markdown report changed, so `graphify update .`, application builds, and emulator validation were not required for this consolidation step.
+- **Review status:** all six planned phases are complete. Implementation and remediation remain future work.
diff --git a/domain/src/main/java/com/streamvault/domain/manager/RecordingManager.kt b/domain/src/main/java/com/streamvault/domain/manager/RecordingManager.kt
index bc94402f..ce62820d 100644
--- a/domain/src/main/java/com/streamvault/domain/manager/RecordingManager.kt
+++ b/domain/src/main/java/com/streamvault/domain/manager/RecordingManager.kt
@@ -18,6 +18,9 @@ interface RecordingManager {
suspend fun startManualRecording(request: RecordingRequest): Result<RecordingItem>
suspend fun scheduleRecording(request: RecordingRequest): Result<RecordingItem>
suspend fun stopRecording(recordingId: String): Result<Unit>
+ /** Stops a recording because Android exhausted the foreground-service time allowance. */
+ suspend fun stopRecordingForForegroundServiceTimeout(recordingId: String): Result<Unit> =
+ stopRecording(recordingId)
suspend fun cancelRecording(recordingId: String): Result<Unit>
suspend fun deleteRecording(recordingId: String): Result<Unit>
suspend fun retryRecording(recordingId: String): Result<Unit> = Result.error("Retry is not supported by this recording manager.")
diff --git a/domain/src/main/java/com/streamvault/domain/model/ProgramReminder.kt b/domain/src/main/java/com/streamvault/domain/model/ProgramReminder.kt
index 08dbbead..c6843663 100644
--- a/domain/src/main/java/com/streamvault/domain/model/ProgramReminder.kt
+++ b/domain/src/main/java/com/streamvault/domain/model/ProgramReminder.kt
@@ -11,5 +11,6 @@ data class ProgramReminder(
val leadTimeMinutes: Int = 5,
val isDismissed: Boolean = false,
val notifiedAt: Long? = null,
+ val exactAlarmArmed: Boolean = true,
val createdAt: Long = System.currentTimeMillis()
)
diff --git a/domain/src/main/java/com/streamvault/domain/model/RecordingModels.kt b/domain/src/main/java/com/streamvault/domain/model/RecordingModels.kt
index 162baa2a..6dd924af 100644
--- a/domain/src/main/java/com/streamvault/domain/model/RecordingModels.kt
+++ b/domain/src/main/java/com/streamvault/domain/model/RecordingModels.kt
@@ -83,7 +83,8 @@ data class RecordingItem(
val scheduleEnabled: Boolean = true,
val priority: Int = 0,
val failureReason: String? = null,
- val terminalAtMs: Long? = null
+ val terminalAtMs: Long? = null,
+ val exactAlarmArmed: Boolean = true
) {
init {
require(id.isNotBlank()) { "id must not be blank" }
diff --git a/domain/src/main/java/com/streamvault/domain/repository/DownloadManager.kt b/domain/src/main/java/com/streamvault/domain/repository/DownloadManager.kt
index a6f8d65f..94d0d71d 100644
--- a/domain/src/main/java/com/streamvault/domain/repository/DownloadManager.kt
+++ b/domain/src/main/java/com/streamvault/domain/repository/DownloadManager.kt
@@ -36,6 +36,13 @@ interface DownloadManager {
*/
suspend fun resumeDownload(id: String): Result<Unit>
+ /** Reclaims downloads whose persisted active owner died with the app process. */
+ suspend fun recoverInterruptedDownloads(): Result<Int>
+
+ /** Pauses an active download after Android exhausts the foreground-service time allowance. */
+ suspend fun pauseDownloadForForegroundServiceTimeout(id: String): Result<Unit> =
+ Result.error("Foreground-service timeout handling is not supported by this download manager.")
+
/**
* Cancel a download by [id].
*/
diff --git a/gradle-plugin-verify.log b/gradle-plugin-verify.log
new file mode 100644
index 00000000..e791ab67
--- /dev/null
+++ b/gradle-plugin-verify.log
@@ -0,0 +1,59 @@
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>if "Windows_NT" == "Windows_NT" setlocal
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>set DIRNAME=C:\Users\david\.gemini\antigravity\scratch\iptv-player\
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>if "C:\Users\david\.gemini\antigravity\scratch\iptv-player\" == "" set DIRNAME=.
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>set APP_BASE_NAME=gradlew
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>set APP_HOME=C:\Users\david\.gemini\antigravity\scratch\iptv-player\
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>for %i in ("C:\Users\david\.gemini\antigravity\scratch\iptv-player\") do set APP_HOME=%~fi
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>set APP_HOME=C:\Users\david\.gemini\antigravity\scratch\iptv-player\
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>if defined JAVA_HOME goto findJavaFromJavaHome
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>set JAVA_EXE=java.exe
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>java.exe -version 1>NUL 2>&1
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>if 0 EQU 0 goto execute
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>set CLASSPATH=C:\Users\david\.gemini\antigravity\scratch\iptv-player\\gradle\wrapper\gradle-wrapper.jar
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>"java.exe" "-Xmx64m" "-Xms64m" "-Dorg.gradle.appname=gradlew" -classpath "C:\Users\david\.gemini\antigravity\scratch\iptv-player\\gradle\wrapper\gradle-wrapper.jar" org.gradle.wrapper.GradleWrapperMain :app:testDebugUnitTest --tests \" "com.streamvault.app.plugins.PluginPlaybackRoutingTest\ :data:testDebugUnitTest --tests \com.streamvault.data.remote.jellyfin.JellyfinProviderTest\ --no-daemon
+
+[Incubating] Problems report is available at: file:///C:/Users/david/.gemini/antigravity/scratch/iptv-player/build/reports/problems/problems-report.html
+
+FAILURE: Build failed with an exception.
+
+* What went wrong:
+Cannot locate tasks that match 'com.streamvault.app.plugins.PluginPlaybackRoutingTest\ :data:testDebugUnitTest --tests \com.streamvault.data.remote.jellyfin.JellyfinProviderTest\ --no-daemon' as project 'com.streamvault.app.plugins.PluginPlaybackRoutingTest\ ' not found in root project 'StreamVault'.
+
+* Try:
+> Run gradlew projects to get a list of available projects.
+> For more on name expansion, please refer to https://docs.gradle.org/8.12/userguide/command_line_interface.html#sec:name_abbreviation in the Gradle documentation.
+> Run with --stacktrace option to get the stack trace.
+> Run with --info or --debug option to get more log output.
+> Run with --scan to get full insights.
+> Get more help at https://help.gradle.org.
+
+BUILD FAILED in 2s
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>if 1 EQU 0 goto mainEnd
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>rem the _cmd.exe /c_ return code!
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>set EXIT_CODE=1
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>if 1 EQU 0 set EXIT_CODE=1
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>if not "" == "" exit 1
+
+C:\Users\david\.gemini\antigravity\scratch\iptv-player>exit /b 1
diff --git a/player/src/main/java/com/streamvault/player/Media3PlayerEngine.kt b/player/src/main/java/com/streamvault/player/Media3PlayerEngine.kt
index 65359cab..3fd6b6e5 100644
--- a/player/src/main/java/com/streamvault/player/Media3PlayerEngine.kt
+++ b/player/src/main/java/com/streamvault/player/Media3PlayerEngine.kt
@@ -268,8 +268,11 @@ class Media3PlayerEngine @Inject constructor(
private val _renderSurfaceType = MutableStateFlow(PlayerRenderSurfaceType.SURFACE_VIEW)
override val renderSurfaceType: StateFlow<PlayerRenderSurfaceType> = _renderSurfaceType.asStateFlow()
+ private var lastPlaybackSupportSnapshotAtMs = 0L
private val liveTimeshiftManager = DefaultLiveTimeshiftManager(context, okHttpClient)
+ private val timeshiftCleanupScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
+ private var timeshiftCleanupJob: Job? = null
private val _timeshiftState = MutableStateFlow(LiveTimeshiftState())
override val timeshiftState: StateFlow<LiveTimeshiftState> = _timeshiftState.asStateFlow()
@@ -381,7 +384,12 @@ class Media3PlayerEngine @Inject constructor(
audioVideoSyncSinkActive = audioVideoSyncSinkActive
)
if (shouldRefreshPlaybackSupportSnapshot()) {
- playbackSupportSnapshotStore.write(buildPlaybackSupportSnapshot())
+ val now = System.currentTimeMillis()
+ if (now - lastPlaybackSupportSnapshotAtMs >= 30_000L) {
+ lastPlaybackSupportSnapshotAtMs = now
+ val snapshot = buildPlaybackSupportSnapshot()
+ scope.launch(Dispatchers.IO) { playbackSupportSnapshotStore.write(snapshot) }
+ }
}
if (promoteLiveHlsBufferIfNeeded()) {
continue
@@ -639,6 +647,7 @@ class Media3PlayerEngine @Inject constructor(
activeLiveTimeshiftStreamInfo = streamInfo
activeLiveTimeshiftChannelKey = channelKey
scope.launch {
+ timeshiftCleanupJob?.join()
liveTimeshiftManager.startSession(streamInfo, channelKey, config)
syncTimeshiftState()
}
@@ -659,6 +668,7 @@ class Media3PlayerEngine @Inject constructor(
exoPlayer?.clearMediaItems()
}
scope.launch {
+ timeshiftCleanupJob?.join()
liveTimeshiftManager.stopSession()
if (wasSnapshot && liveInfo != null) {
prepareInternal(liveInfo, preserveRetryState = false, seekPositionMs = null, autoPlay = true)
@@ -847,6 +857,7 @@ class Media3PlayerEngine @Inject constructor(
override fun release() {
if (isDisposed) return
isDisposed = true
+ liveTimeshiftManager.detachComponentCallbacks()
resetEngineState(restartCollectors = false)
}
@@ -904,13 +915,23 @@ class Media3PlayerEngine @Inject constructor(
activeLiveTimeshiftChannelKey = null
isPlayingTimeshiftSnapshot = false
_timeshiftState.value = LiveTimeshiftState()
+ val previousTimeshiftCleanup = timeshiftCleanupJob
+ timeshiftCleanupJob = timeshiftCleanupScope.launch {
+ previousTimeshiftCleanup?.join()
+ liveTimeshiftManager.stopSession()
+ }
scope.cancel()
if (restartCollectors) {
scope = CoroutineScope(Dispatchers.Main.immediate + SupervisorJob())
startEngineCollectors()
}
- // File cleanup runs outside the engine scope — orphans are also cleaned on next app start
- CoroutineScope(Dispatchers.IO).launch { liveTimeshiftManager.stopSession() }
+ if (!restartCollectors) {
+ timeshiftCleanupScope.launch {
+ timeshiftCleanupJob?.join()
+ liveTimeshiftManager.close()
+ timeshiftCleanupScope.coroutineContext[Job]?.cancel()
+ }
+ }
}
private fun ensureNotDisposed(action: String): Boolean {
diff --git a/player/src/main/java/com/streamvault/player/timeshift/LiveTimeshiftManager.kt b/player/src/main/java/com/streamvault/player/timeshift/LiveTimeshiftManager.kt
index afb44fae..ac8dcc9f 100644
--- a/player/src/main/java/com/streamvault/player/timeshift/LiveTimeshiftManager.kt
+++ b/player/src/main/java/com/streamvault/player/timeshift/LiveTimeshiftManager.kt
@@ -16,12 +16,15 @@ import java.net.Proxy
import java.net.URI
import java.util.Locale
import java.util.concurrent.ConcurrentHashMap
+import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicLong
+import java.util.concurrent.atomic.AtomicReference
import javax.inject.Inject
import javax.inject.Singleton
import org.xmlpull.v1.XmlPullParser
import org.xmlpull.v1.XmlPullParserFactory
import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.SupervisorJob
@@ -45,6 +48,8 @@ internal interface LiveTimeshiftManager {
suspend fun stopSession()
suspend fun createSnapshot(): LiveTimeshiftSnapshot?
suspend fun releaseRetiredSnapshots()
+ fun detachComponentCallbacks()
+ suspend fun close()
}
internal data class DashSnapshotPlaylistSegment(
@@ -53,6 +58,18 @@ internal data class DashSnapshotPlaylistSegment(
val isInit: Boolean
)
+internal suspend fun stopOwnedTimeshiftCapture(
+ activeCall: AtomicReference<okhttp3.Call?>,
+ captureJob: Job?,
+ deleteSessionFiles: () -> Unit
+) {
+ activeCall.get()?.cancel()
+ captureJob?.cancel()
+ activeCall.getAndSet(null)?.cancel()
+ captureJob?.join()
+ deleteSessionFiles()
+}
+
internal fun buildDashSnapshotPlaylist(
targetDurationSeconds: Int,
segments: List<DashSnapshotPlaylistSegment>
@@ -71,7 +88,6 @@ internal fun buildDashSnapshotPlaylist(
appendLine("#EXT-X-ENDLIST")
}
-@Singleton
internal class DefaultLiveTimeshiftManager @Inject constructor(
@param:ApplicationContext private val context: Context,
private val okHttpClient: OkHttpClient
@@ -115,10 +131,13 @@ internal class DefaultLiveTimeshiftManager @Inject constructor(
private var activeSession: Session? = null
private val retiredSnapshotDirs = ArrayDeque<File>()
+ private var closed = false
+ private val callbacksRegistered = AtomicBoolean(true)
override suspend fun startSession(streamInfo: StreamInfo, channelKey: String, config: TimeshiftConfig) {
withContext(Dispatchers.IO) {
mutex.withLock {
+ if (closed) return@withLock
stopSessionLocked()
if (!config.enabled) {
_state.value = LiveTimeshiftState(enabled = false, status = LiveTimeshiftStatus.DISABLED)
@@ -208,6 +227,8 @@ internal class DefaultLiveTimeshiftManager @Inject constructor(
session.job = scope.launch {
try {
session.capture()
+ } catch (cancelled: CancellationException) {
+ throw cancelled
} catch (t: Throwable) {
_state.value = _state.value.copy(
enabled = true,
@@ -231,6 +252,25 @@ internal class DefaultLiveTimeshiftManager @Inject constructor(
}
}
+ override suspend fun close() {
+ withContext(Dispatchers.IO) {
+ mutex.withLock {
+ if (closed) return@withLock
+ closed = true
+ stopSessionLocked()
+ _state.value = LiveTimeshiftState(enabled = false, status = LiveTimeshiftStatus.DISABLED)
+ }
+ detachComponentCallbacks()
+ scope.coroutineContext[Job]?.cancel()
+ }
+ }
+
+ override fun detachComponentCallbacks() {
+ if (callbacksRegistered.compareAndSet(true, false)) {
+ context.unregisterComponentCallbacks(this)
+ }
+ }
+
override suspend fun createSnapshot(): LiveTimeshiftSnapshot? {
return withContext(Dispatchers.IO) {
// Hold the outer mutex only long enough to register the old snapshot as retired
@@ -342,15 +382,15 @@ internal class DefaultLiveTimeshiftManager @Inject constructor(
val effectiveDepthMs: Long = config.effectiveDepthMs(backend)
protected val sequence = AtomicLong(0L)
protected val stateStartMs = System.currentTimeMillis()
- @Volatile private var activeCall: okhttp3.Call? = null
+ private val activeCall = AtomicReference<okhttp3.Call?>()
abstract suspend fun capture()
abstract suspend fun createSnapshot(): LiveTimeshiftSnapshot?
open suspend fun stop() {
- activeCall?.cancel()
- job?.cancel()
- sessionDir.deleteRecursively()
+ stopOwnedTimeshiftCapture(activeCall, job) {
+ sessionDir.deleteRecursively()
+ }
}
protected fun makeRequest(url: String) = Request.Builder().url(url).apply {
@@ -360,7 +400,11 @@ internal class DefaultLiveTimeshiftManager @Inject constructor(
protected fun trackCall(request: Request): okhttp3.Call {
val call = httpClientFor(streamInfo).newCall(request)
- activeCall = call
+ activeCall.set(call)
+ if (job?.isActive != true) {
+ activeCall.compareAndSet(call, null)
+ call.cancel()
+ }
return call
}
@@ -387,9 +431,7 @@ internal class DefaultLiveTimeshiftManager @Inject constructor(
}
protected fun clearTrackedCall(call: okhttp3.Call) {
- if (activeCall === call) {
- activeCall = null
- }
+ activeCall.compareAndSet(call, null)
}
protected fun <T> executeRequest(request: Request, block: (Response) -> T): T {
diff --git a/player/src/test/java/com/streamvault/player/timeshift/TimeshiftOwnershipTest.kt b/player/src/test/java/com/streamvault/player/timeshift/TimeshiftOwnershipTest.kt
new file mode 100644
index 00000000..38ee2562
--- /dev/null
+++ b/player/src/test/java/com/streamvault/player/timeshift/TimeshiftOwnershipTest.kt
@@ -0,0 +1,34 @@
+package com.streamvault.player.timeshift
+
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.CoroutineStart
+import kotlinx.coroutines.NonCancellable
+import kotlinx.coroutines.awaitCancellation
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.runBlocking
+import kotlinx.coroutines.withContext
+import org.junit.Test
+import java.util.concurrent.atomic.AtomicReference
+
+class TimeshiftOwnershipTest {
+
+ @Test
+ fun `session files are deleted only after capture cleanup joins`() = runBlocking {
+ val events = mutableListOf<String>()
+ val captureJob = launch(start = CoroutineStart.UNDISPATCHED) {
+ try {
+ awaitCancellation()
+ } finally {
+ withContext(NonCancellable) {
+ events += "writer-closed"
+ }
+ }
+ }
+
+ stopOwnedTimeshiftCapture(activeCall = AtomicReference(null), captureJob = captureJob) {
+ events += "files-deleted"
+ }
+
+ assertThat(events).containsExactly("writer-closed", "files-deleted").inOrder()
+ }
+}