Skip to content

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

feat(stremio): protocol client, addon registry and Addons manager screen

David Nashashe96ce49ed495
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 220f0497..e78ad026 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -456,6 +456,7 @@ dependencies {
implementation(project(":feature:live"))
implementation(project(":feature:catalog"))
implementation(project(":feature:system"))
+ implementation(project(":feature:stremio"))
implementation(libs.profileinstaller)
baselineProfile(project(":benchmark"))
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 1c509b7d..4a627486 100644
--- a/app/src/main/java/com/streamvault/app/di/DatabaseModule.kt
+++ b/app/src/main/java/com/streamvault/app/di/DatabaseModule.kt
@@ -98,4 +98,5 @@ object DatabaseModule {
@Provides fun provideProviderWorkflowDao(db: StreamVaultDatabase): ProviderWorkflowDao = db.providerWorkflowDao()
@Provides fun provideM3uClassificationDao(db: StreamVaultDatabase): M3uClassificationDao = db.m3uClassificationDao()
@Provides fun providePluginProviderOwnershipDao(db: StreamVaultDatabase): PluginProviderOwnershipDao = db.pluginProviderOwnershipDao()
+ @Provides fun provideStremioAddonDao(db: StreamVaultDatabase): StremioAddonDao = db.stremioAddonDao()
}
diff --git a/app/src/main/java/com/streamvault/app/di/RepositoryModule.kt b/app/src/main/java/com/streamvault/app/di/RepositoryModule.kt
index b1588fd1..753b3cb3 100644
--- a/app/src/main/java/com/streamvault/app/di/RepositoryModule.kt
+++ b/app/src/main/java/com/streamvault/app/di/RepositoryModule.kt
@@ -94,6 +94,9 @@ abstract class RepositoryModule {
@Binds @Singleton
abstract fun bindM3uClassificationRepository(impl: M3uClassificationRepositoryImpl): M3uClassificationRepository
+ @Binds @Singleton
+ abstract fun bindStremioAddonRepository(impl: StremioAddonRepositoryImpl): StremioAddonRepository
+
@Binds @Singleton
abstract fun bindExternalRatingsRepository(impl: ExternalRatingsRepositoryImpl): ExternalRatingsRepository
diff --git a/app/src/main/java/com/streamvault/app/navigation/AppNavHost.kt b/app/src/main/java/com/streamvault/app/navigation/AppNavHost.kt
index 5d7466ed..af24f2de 100644
--- a/app/src/main/java/com/streamvault/app/navigation/AppNavHost.kt
+++ b/app/src/main/java/com/streamvault/app/navigation/AppNavHost.kt
@@ -33,6 +33,8 @@ import com.streamvault.domain.model.ContentType
import com.streamvault.feature.system.api.SystemScaffoldContent
import com.streamvault.feature.system.navigation.SystemRoutePatterns
import com.streamvault.feature.system.navigation.registerSystemGraph
+import com.streamvault.feature.stremio.api.StremioScaffoldContent
+import com.streamvault.feature.stremio.navigation.registerStremioGraph
@Composable
internal fun AppNavHost(
@@ -81,6 +83,7 @@ internal fun AppNavHost(
}
)
registerLiveGraph(actions, onTopLevelDestinationRequested)
+ registerStremioGraph(scaffold = appStremioScaffold(onTopLevelDestinationRequested))
registerCatalogGraph(
actions = actions,
platformHost = catalogPlatformHost,
@@ -186,6 +189,21 @@ private fun appSystemScaffold(
)
}
+private fun appStremioScaffold(
+ onTopLevelDestinationRequested: (AppDestination) -> Unit,
+): StremioScaffoldContent = { destination, title, subtitle, compactHeader, showScreenHeader, content ->
+ AppScreenScaffold(
+ currentRoute = AppRouteCodec.encode(destination),
+ onNavigate = { route -> AppRouteCodec.decode(route)?.let(onTopLevelDestinationRequested) },
+ title = title,
+ subtitle = subtitle,
+ navigationChrome = AppNavigationChrome.TopBar,
+ compactHeader = compactHeader,
+ showScreenHeader = showScreenHeader,
+ content = content,
+ )
+}
+
private fun appCatalogScaffold(
onTopLevelDestinationRequested: (AppDestination) -> Unit
): CatalogScaffoldContent = { currentDestination, title, subtitle, chrome, topBarVisible, compactHeader, showScreenHeader, content ->
diff --git a/app/src/main/java/com/streamvault/app/navigation/AppNavigationAdapters.kt b/app/src/main/java/com/streamvault/app/navigation/AppNavigationAdapters.kt
index 63d52dee..e6184eb9 100644
--- a/app/src/main/java/com/streamvault/app/navigation/AppNavigationAdapters.kt
+++ b/app/src/main/java/com/streamvault/app/navigation/AppNavigationAdapters.kt
@@ -13,6 +13,7 @@ internal fun AppLandingDestination.toAppRoute(): String = when (this) {
AppLandingDestination.GUIDE -> Routes.EPG
AppLandingDestination.DOWNLOADS -> Routes.DOWNLOADS
AppLandingDestination.PLUGINS -> Routes.PLUGINS
+ AppLandingDestination.ADDONS -> Routes.ADDONS
AppLandingDestination.SETTINGS -> Routes.SETTINGS
}
@@ -25,5 +26,6 @@ internal fun AppTopLevelDestination.toAppRoute(): String = when (this) {
AppTopLevelDestination.GUIDE -> Routes.EPG
AppTopLevelDestination.SEARCH -> Routes.SEARCH
AppTopLevelDestination.PLUGINS -> Routes.PLUGINS
+ AppTopLevelDestination.ADDONS -> Routes.ADDONS
AppTopLevelDestination.SETTINGS -> Routes.SETTINGS
}
diff --git a/app/src/main/java/com/streamvault/app/navigation/AppRouteCodec.kt b/app/src/main/java/com/streamvault/app/navigation/AppRouteCodec.kt
index 81dff977..3e3ae6b6 100644
--- a/app/src/main/java/com/streamvault/app/navigation/AppRouteCodec.kt
+++ b/app/src/main/java/com/streamvault/app/navigation/AppRouteCodec.kt
@@ -8,6 +8,7 @@ import com.streamvault.feature.playback.navigation.PlaybackRoutePatterns
import com.streamvault.feature.live.navigation.LiveRoutePatterns
import com.streamvault.feature.catalog.navigation.CatalogRoutePatterns
import com.streamvault.feature.system.navigation.SystemRoutePatterns
+import com.streamvault.feature.stremio.navigation.StremioRoutePatterns
import java.net.URLDecoder
internal object AppRoutePatterns {
@@ -24,6 +25,7 @@ internal object AppRoutePatterns {
const val SETTINGS = "settings"
const val SETTINGS_DESTINATION = "settings?backupUri={backupUri}"
const val PLUGINS = SystemRoutePatterns.PLUGINS
+ const val ADDONS = StremioRoutePatterns.ADDONS
const val PLAYER = PlaybackRoutePatterns.PLAYER
const val SEARCH = CatalogRoutePatterns.SEARCH
const val SEARCH_DESTINATION = CatalogRoutePatterns.SEARCH_DESTINATION
@@ -55,6 +57,7 @@ internal object AppRouteCodec {
"${AppRoutePatterns.SETTINGS}?backupUri=${Uri.encode(uri)}"
} ?: AppRoutePatterns.SETTINGS
AppDestination.Plugins -> AppRoutePatterns.PLUGINS
+ AppDestination.Addons -> AppRoutePatterns.ADDONS
is AppDestination.Search -> destination.query?.takeIf(String::isNotBlank)?.let { query ->
"${AppRoutePatterns.SEARCH}?query=${Uri.encode(query)}"
} ?: AppRoutePatterns.SEARCH
@@ -103,6 +106,7 @@ internal object AppRouteCodec {
backupUri = query["backupUri"]?.takeIf(String::isNotBlank)
)
path == AppRoutePatterns.PLUGINS -> AppDestination.Plugins
+ path == AppRoutePatterns.ADDONS -> AppDestination.Addons
path == AppRoutePatterns.PLAYER -> AppDestination.Player
path == AppRoutePatterns.MULTI_VIEW -> AppDestination.MultiView
path == AppRoutePatterns.SEARCH -> AppDestination.Search(
@@ -189,6 +193,7 @@ internal object Routes {
const val SETTINGS = AppRoutePatterns.SETTINGS
const val SETTINGS_DESTINATION = AppRoutePatterns.SETTINGS_DESTINATION
const val PLUGINS = AppRoutePatterns.PLUGINS
+ const val ADDONS = AppRoutePatterns.ADDONS
const val PLAYER = AppRoutePatterns.PLAYER
const val SEARCH = AppRoutePatterns.SEARCH
const val SEARCH_DESTINATION = AppRoutePatterns.SEARCH_DESTINATION
diff --git a/app/src/main/java/com/streamvault/app/navigation/StartupNavigationResolver.kt b/app/src/main/java/com/streamvault/app/navigation/StartupNavigationResolver.kt
index 698e2bea..e07d9e92 100644
--- a/app/src/main/java/com/streamvault/app/navigation/StartupNavigationResolver.kt
+++ b/app/src/main/java/com/streamvault/app/navigation/StartupNavigationResolver.kt
@@ -141,5 +141,6 @@ private fun AppLandingDestination.toAppDestination(): AppDestination = when (thi
AppLandingDestination.GUIDE -> AppDestination.Guide()
AppLandingDestination.DOWNLOADS -> AppDestination.Downloads
AppLandingDestination.PLUGINS -> AppDestination.Plugins
+ AppLandingDestination.ADDONS -> AppDestination.Addons
AppLandingDestination.SETTINGS -> AppDestination.Settings()
}
diff --git a/app/src/main/java/com/streamvault/app/ui/components/shell/AppShellNavigation.kt b/app/src/main/java/com/streamvault/app/ui/components/shell/AppShellNavigation.kt
index c46f9053..010a7d99 100644
--- a/app/src/main/java/com/streamvault/app/ui/components/shell/AppShellNavigation.kt
+++ b/app/src/main/java/com/streamvault/app/ui/components/shell/AppShellNavigation.kt
@@ -13,6 +13,7 @@ import androidx.compose.material.icons.filled.Search
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.filled.Star
import androidx.compose.material.icons.filled.Download
+import androidx.compose.material.icons.filled.Extension
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.staticCompositionLocalOf
@@ -147,6 +148,7 @@ private fun AppTopLevelDestination.toDestinationItem(): AppDestinationItem = whe
AppTopLevelDestination.GUIDE -> AppDestinationItem(Routes.EPG, R.string.nav_epg, Icons.Default.Info)
AppTopLevelDestination.SEARCH -> AppDestinationItem(Routes.SEARCH, R.string.search_title, Icons.Default.Search)
AppTopLevelDestination.PLUGINS -> AppDestinationItem(Routes.PLUGINS, R.string.nav_plugins, PluginBlocksIcon)
+ AppTopLevelDestination.ADDONS -> AppDestinationItem(Routes.ADDONS, R.string.nav_addons, Icons.Default.Extension)
AppTopLevelDestination.SETTINGS -> AppDestinationItem(Routes.SETTINGS, R.string.nav_settings, Icons.Default.Settings)
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5c70b156..1b3df26f 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -10,6 +10,7 @@
<string name="nav_epg">Guide</string>
<string name="nav_settings">Settings</string>
<string name="nav_plugins">Plugins</string>
+<string name="nav_addons">Addons</string>
<string name="nav_close_app">Close app</string>
diff --git a/app/src/test/java/com/streamvault/app/ui/components/shell/AppShellNavigationTest.kt b/app/src/test/java/com/streamvault/app/ui/components/shell/AppShellNavigationTest.kt
index c81d7644..f4bdc7a1 100644
--- a/app/src/test/java/com/streamvault/app/ui/components/shell/AppShellNavigationTest.kt
+++ b/app/src/test/java/com/streamvault/app/ui/components/shell/AppShellNavigationTest.kt
@@ -25,6 +25,7 @@ class AppShellNavigationTest {
Routes.EPG,
Routes.SEARCH,
Routes.PLUGINS,
+ Routes.ADDONS,
Routes.SETTINGS
)
.inOrder()
diff --git a/core/navigation/src/main/kotlin/com/streamvault/core/navigation/AppDestination.kt b/core/navigation/src/main/kotlin/com/streamvault/core/navigation/AppDestination.kt
index 7303cc79..c3a0d334 100644
--- a/core/navigation/src/main/kotlin/com/streamvault/core/navigation/AppDestination.kt
+++ b/core/navigation/src/main/kotlin/com/streamvault/core/navigation/AppDestination.kt
@@ -17,6 +17,7 @@ sealed interface AppDestination : Serializable {
) : AppDestination
data class Settings(val backupUri: String? = null) : AppDestination
data object Plugins : AppDestination
+ data object Addons : AppDestination
data class Search(val query: String? = null) : AppDestination
data class ProviderSetup(
val providerId: Long? = null,
diff --git a/data/schemas/com.streamvault.data.local.StreamVaultDatabase/79.json b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/79.json
new file mode 100644
index 00000000..c1222a2f
--- /dev/null
+++ b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/79.json
@@ -0,0 +1,7188 @@
+{
+ "formatVersion": 1,
+ "database": {
+ "version": 79,
+ "identityHash": "3ccd66e96b30b4e6bff6457e5134e833",
+ "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, `is_active` 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": "isActive",
+ "columnName": "is_active",
+ "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_type",
+ "unique": false,
+ "columnNames": [
+ "type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_providers_type` ON `${TABLE_NAME}` (`type`)"
+ },
+ {
+ "name": "index_providers_is_active",
+ "unique": false,
+ "columnNames": [
+ "is_active"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_providers_is_active` ON `${TABLE_NAME}` (`is_active`)"
+ }
+ ]
+ },
+ {
+ "tableName": "provider_configs",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `type` TEXT NOT NULL, `schema_version` INTEGER NOT NULL, `configuration_generation` INTEGER NOT NULL, `identity_key` TEXT NOT NULL, `encrypted_config_json` TEXT NOT NULL, `guide_source_policy` TEXT NOT NULL, `channel_logo_source_policy` TEXT NOT NULL, `updated_at` 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": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "schemaVersion",
+ "columnName": "schema_version",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "configurationGeneration",
+ "columnName": "configuration_generation",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "identityKey",
+ "columnName": "identity_key",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "encryptedConfigJson",
+ "columnName": "encrypted_config_json",
+ "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": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_provider_configs_provider_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_provider_configs_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_provider_configs_identity_key",
+ "unique": true,
+ "columnNames": [
+ "identity_key"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_provider_configs_identity_key` ON `${TABLE_NAME}` (`identity_key`)"
+ },
+ {
+ "name": "index_provider_configs_type",
+ "unique": false,
+ "columnNames": [
+ "type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_provider_configs_type` ON `${TABLE_NAME}` (`type`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "provider_account_runtime",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `max_connections` INTEGER NOT NULL, `expiration_date` INTEGER, `api_version` TEXT, `allowed_output_formats_json` TEXT NOT NULL, `catalog_layout` TEXT NOT NULL, `catalog_layout_detection_version` INTEGER NOT NULL, `observed_at` 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": "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": "catalogLayout",
+ "columnName": "catalog_layout",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catalogLayoutDetectionVersion",
+ "columnName": "catalog_layout_detection_version",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "observedAt",
+ "columnName": "observed_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_provider_account_runtime_provider_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_provider_account_runtime_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "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, `playback_metadata_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": "playbackMetadataJson",
+ "columnName": "playback_metadata_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, `playback_metadata_json` TEXT, 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
+ },
+ {
+ "fieldPath": "playbackMetadataJson",
+ "columnName": "playback_metadata_json",
+ "affinity": "TEXT"
+ }
+ ],
+ "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, `catalog_origin` TEXT NOT NULL, `episode_playback_template_url` TEXT, 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
+ },
+ {
+ "fieldPath": "catalogOrigin",
+ "columnName": "catalog_origin",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "episodePlaybackTemplateUrl",
+ "columnName": "episode_playback_template_url",
+ "affinity": "TEXT"
+ }
+ ],
+ "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, `provider_order` INTEGER NOT NULL DEFAULT 0, `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": "providerOrder",
+ "columnName": "provider_order",
+ "affinity": "INTEGER",
+ "notNull": true,
+ "defaultValue": "0"
+ },
+ {
+ "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, `playback_metadata_json` TEXT, `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": "playbackMetadataJson",
+ "columnName": "playback_metadata_json",
+ "affinity": "TEXT"
+ },
+ {
+ "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, `playback_metadata_json` TEXT, `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": "playbackMetadataJson",
+ "columnName": "playback_metadata_json",
+ "affinity": "TEXT"
+ },
+ {
+ "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, `provider_order` INTEGER NOT NULL DEFAULT 0, `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": "providerOrder",
+ "columnName": "provider_order",
+ "affinity": "INTEGER",
+ "notNull": true,
+ "defaultValue": "0"
+ },
+ {
+ "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, `advertised_total_items` INTEGER, `advertised_total_pages` INTEGER, `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": "advertisedTotalItems",
+ "columnName": "advertised_total_items",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "advertisedTotalPages",
+ "columnName": "advertised_total_pages",
+ "affinity": "INTEGER"
+ },
+ {
+ "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, `advertised_total_items` INTEGER, `advertised_total_pages` INTEGER, `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": "advertisedTotalItems",
+ "columnName": "advertised_total_items",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "advertisedTotalPages",
+ "columnName": "advertised_total_pages",
+ "affinity": "INTEGER"
+ },
+ {
+ "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": "vod_category_hydration",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `last_loaded_page` INTEGER NOT NULL, `last_attempted_page` INTEGER NOT NULL, `last_successful_page` INTEGER NOT NULL, `total_pages` INTEGER NOT NULL, `advertised_total_items` INTEGER, `advertised_total_pages` INTEGER, `page_size` INTEGER NOT NULL, `item_count` INTEGER NOT NULL, `is_complete` INTEGER NOT NULL, `has_movies` INTEGER NOT NULL, `has_series` INTEGER NOT NULL, `last_hydrated_at` INTEGER NOT NULL, `last_status` TEXT NOT NULL, `last_error` TEXT, `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": "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": "advertisedTotalItems",
+ "columnName": "advertised_total_items",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "advertisedTotalPages",
+ "columnName": "advertised_total_pages",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "pageSize",
+ "columnName": "page_size",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemCount",
+ "columnName": "item_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isComplete",
+ "columnName": "is_complete",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "hasMovies",
+ "columnName": "has_movies",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "hasSeries",
+ "columnName": "has_series",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastHydratedAt",
+ "columnName": "last_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastStatus",
+ "columnName": "last_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ },
+ {
+ "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_vod_category_hydration_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_vod_category_hydration_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "vod_catalog_entries",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `raw_item_id` TEXT NOT NULL, `item_type` TEXT NOT NULL, `target_id` INTEGER NOT NULL, `raw_page` INTEGER NOT NULL, `raw_index` INTEGER NOT NULL, PRIMARY KEY(`provider_id`, `category_id`, `raw_item_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": "rawItemId",
+ "columnName": "raw_item_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemType",
+ "columnName": "item_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "targetId",
+ "columnName": "target_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rawPage",
+ "columnName": "raw_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rawIndex",
+ "columnName": "raw_index",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "category_id",
+ "raw_item_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_vod_catalog_entries_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_vod_catalog_entries_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_vod_catalog_entries_provider_id_category_id_raw_page_raw_index",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id",
+ "raw_page",
+ "raw_index"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_vod_catalog_entries_provider_id_category_id_raw_page_raw_index` ON `${TABLE_NAME}` (`provider_id`, `category_id`, `raw_page`, `raw_index`)"
+ },
+ {
+ "name": "index_vod_catalog_entries_provider_id_item_type_target_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "item_type",
+ "target_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_vod_catalog_entries_provider_id_item_type_target_id` ON `${TABLE_NAME}` (`provider_id`, `item_type`, `target_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, `timezone_policy` TEXT NOT NULL, `timezone_id` 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"
+ },
+ {
+ "fieldPath": "timezonePolicy",
+ "columnName": "timezone_policy",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "timezoneId",
+ "columnName": "timezone_id",
+ "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, `delivery_state` TEXT NOT NULL, `delivery_attempt_token` TEXT, `delivery_attempted_at` INTEGER, `delivery_attempt_count` INTEGER NOT NULL, `delivery_failure_reason` TEXT, `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": "deliveryState",
+ "columnName": "delivery_state",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deliveryAttemptToken",
+ "columnName": "delivery_attempt_token",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "deliveryAttemptedAt",
+ "columnName": "delivery_attempted_at",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deliveryAttemptCount",
+ "columnName": "delivery_attempt_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deliveryFailureReason",
+ "columnName": "delivery_failure_reason",
+ "affinity": "TEXT"
+ },
+ {
+ "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": "stalker_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, `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": "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_stalker_index_jobs_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_stalker_index_jobs_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_stalker_index_jobs_state",
+ "unique": false,
+ "columnNames": [
+ "state"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_stalker_index_jobs_state` ON `${TABLE_NAME}` (`state`)"
+ },
+ {
+ "name": "index_stalker_index_jobs_updated_at",
+ "unique": false,
+ "columnNames": [
+ "updated_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_stalker_index_jobs_updated_at` ON `${TABLE_NAME}` (`updated_at`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "stalker_portal_state",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `working_endpoint` TEXT, `bootstrap_recipe` TEXT, `bulk_live_supported` INTEGER, `bulk_live_category_fidelity` INTEGER, `movie_wildcard_supported` INTEGER, `series_wildcard_supported` INTEGER, `epg_supported` INTEGER, `safe_metadata_concurrency` INTEGER NOT NULL, `stress_cooldown_until` INTEGER NOT NULL, `endpoint_health_json` TEXT NOT NULL, `endpoint_failed_until` INTEGER NOT NULL, `validated_at` INTEGER NOT NULL, `schema_version` INTEGER NOT NULL, `configuration_generation` INTEGER NOT NULL, `learning_json` TEXT NOT NULL, `observation_source` TEXT NOT NULL, `observed_at` 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": "workingEndpoint",
+ "columnName": "working_endpoint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "bootstrapRecipe",
+ "columnName": "bootstrap_recipe",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "bulkLiveSupported",
+ "columnName": "bulk_live_supported",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "bulkLiveCategoryFidelity",
+ "columnName": "bulk_live_category_fidelity",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "movieWildcardSupported",
+ "columnName": "movie_wildcard_supported",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "seriesWildcardSupported",
+ "columnName": "series_wildcard_supported",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "epgSupported",
+ "columnName": "epg_supported",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "safeMetadataConcurrency",
+ "columnName": "safe_metadata_concurrency",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stressCooldownUntil",
+ "columnName": "stress_cooldown_until",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "endpointHealthJson",
+ "columnName": "endpoint_health_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "endpointFailedUntil",
+ "columnName": "endpoint_failed_until",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "validatedAt",
+ "columnName": "validated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "schemaVersion",
+ "columnName": "schema_version",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "configurationGeneration",
+ "columnName": "configuration_generation",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "learningJson",
+ "columnName": "learning_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "observationSource",
+ "columnName": "observation_source",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "observedAt",
+ "columnName": "observed_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_stalker_portal_state_provider_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_stalker_portal_state_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "stalker_remote_identities",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `raw_id` TEXT NOT NULL, `surrogate_id` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`provider_id`, `content_type`, `raw_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": "rawId",
+ "columnName": "raw_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "surrogateId",
+ "columnName": "surrogate_id",
+ "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": [
+ "provider_id",
+ "content_type",
+ "raw_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_stalker_remote_identities_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_stalker_remote_identities_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_stalker_remote_identities_provider_id_content_type_surrogate_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "content_type",
+ "surrogate_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_stalker_remote_identities_provider_id_content_type_surrogate_id` ON `${TABLE_NAME}` (`provider_id`, `content_type`, `surrogate_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "stalker_discovery_staging",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`discovery_id` TEXT NOT NULL, `provider_id` INTEGER, `configuration_generation` INTEGER NOT NULL, `sanitized_summary` TEXT NOT NULL, `categories_json` TEXT NOT NULL, `channels_json` TEXT NOT NULL, `created_at` INTEGER NOT NULL, PRIMARY KEY(`discovery_id`))",
+ "fields": [
+ {
+ "fieldPath": "discoveryId",
+ "columnName": "discovery_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "configurationGeneration",
+ "columnName": "configuration_generation",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sanitizedSummary",
+ "columnName": "sanitized_summary",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoriesJson",
+ "columnName": "categories_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelsJson",
+ "columnName": "channels_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "discovery_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_stalker_discovery_staging_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_stalker_discovery_staging_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_stalker_discovery_staging_created_at",
+ "unique": false,
+ "columnNames": [
+ "created_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_stalker_discovery_staging_created_at` ON `${TABLE_NAME}` (`created_at`)"
+ }
+ ]
+ },
+ {
+ "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, `owner_id` TEXT, `owner_epoch` INTEGER NOT NULL, `heartbeat_at` INTEGER, `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": "ownerId",
+ "columnName": "owner_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "ownerEpoch",
+ "columnName": "owner_epoch",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "heartbeatAt",
+ "columnName": "heartbeat_at",
+ "affinity": "INTEGER"
+ },
+ {
+ "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"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "provider_config_revisions",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `revision` INTEGER NOT NULL, `config_json` TEXT NOT NULL, `state` TEXT NOT NULL, `attempt_count` INTEGER NOT NULL, `last_error` TEXT, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`provider_id`, `revision`), 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": "revision",
+ "columnName": "revision",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "configJson",
+ "columnName": "config_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "state",
+ "columnName": "state",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "attemptCount",
+ "columnName": "attempt_count",
+ "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
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "revision"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_provider_config_revisions_provider_id_state",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "state"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_provider_config_revisions_provider_id_state` ON `${TABLE_NAME}` (`provider_id`, `state`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "backup_restore_checkpoints",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`restore_key` TEXT NOT NULL, `room_complete` INTEGER NOT NULL, `preferences_complete` INTEGER NOT NULL, `presets_complete` INTEGER NOT NULL, `schedules_complete` INTEGER NOT NULL, `state` TEXT NOT NULL, `preference_snapshot_json` TEXT, `last_error` TEXT, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`restore_key`))",
+ "fields": [
+ {
+ "fieldPath": "restoreKey",
+ "columnName": "restore_key",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "roomComplete",
+ "columnName": "room_complete",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "preferencesComplete",
+ "columnName": "preferences_complete",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "presetsComplete",
+ "columnName": "presets_complete",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "schedulesComplete",
+ "columnName": "schedules_complete",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "state",
+ "columnName": "state",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "preferenceSnapshotJson",
+ "columnName": "preference_snapshot_json",
+ "affinity": "TEXT"
+ },
+ {
+ "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
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "restore_key"
+ ]
+ }
+ },
+ {
+ "tableName": "backup_restore_jobs",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `restore_key` TEXT NOT NULL, `backup_version` INTEGER NOT NULL, `conflict_strategy` TEXT NOT NULL, `status` TEXT NOT NULL, `total_count` INTEGER NOT NULL, `pending_count` INTEGER NOT NULL, `applied_count` INTEGER NOT NULL, `unresolved_count` INTEGER NOT NULL, `failed_count` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "restoreKey",
+ "columnName": "restore_key",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "backupVersion",
+ "columnName": "backup_version",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "conflictStrategy",
+ "columnName": "conflict_strategy",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalCount",
+ "columnName": "total_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "pendingCount",
+ "columnName": "pending_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "appliedCount",
+ "columnName": "applied_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "unresolvedCount",
+ "columnName": "unresolved_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failedCount",
+ "columnName": "failed_count",
+ "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_backup_restore_jobs_restore_key",
+ "unique": true,
+ "columnNames": [
+ "restore_key"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_backup_restore_jobs_restore_key` ON `${TABLE_NAME}` (`restore_key`)"
+ },
+ {
+ "name": "index_backup_restore_jobs_status",
+ "unique": false,
+ "columnNames": [
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_backup_restore_jobs_status` ON `${TABLE_NAME}` (`status`)"
+ },
+ {
+ "name": "index_backup_restore_jobs_updated_at",
+ "unique": false,
+ "columnNames": [
+ "updated_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_backup_restore_jobs_updated_at` ON `${TABLE_NAME}` (`updated_at`)"
+ }
+ ]
+ },
+ {
+ "tableName": "backup_restore_items",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `job_id` TEXT NOT NULL, `provider_identity_key` TEXT NOT NULL, `local_provider_id` INTEGER, `section` TEXT NOT NULL, `content_type` TEXT, `stable_reference_key` TEXT NOT NULL, `reference_json` TEXT NOT NULL, `payload_json` TEXT NOT NULL, `status` TEXT NOT NULL, `attempt_count` INTEGER NOT NULL, `last_error` TEXT, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`job_id`) REFERENCES `backup_restore_jobs`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "jobId",
+ "columnName": "job_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerIdentityKey",
+ "columnName": "provider_identity_key",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "localProviderId",
+ "columnName": "local_provider_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "section",
+ "columnName": "section",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "stableReferenceKey",
+ "columnName": "stable_reference_key",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "referenceJson",
+ "columnName": "reference_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "payloadJson",
+ "columnName": "payload_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "attemptCount",
+ "columnName": "attempt_count",
+ "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
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_backup_restore_items_job_id",
+ "unique": false,
+ "columnNames": [
+ "job_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_backup_restore_items_job_id` ON `${TABLE_NAME}` (`job_id`)"
+ },
+ {
+ "name": "index_backup_restore_items_provider_identity_key_status",
+ "unique": false,
+ "columnNames": [
+ "provider_identity_key",
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_backup_restore_items_provider_identity_key_status` ON `${TABLE_NAME}` (`provider_identity_key`, `status`)"
+ },
+ {
+ "name": "index_backup_restore_items_job_id_status",
+ "unique": false,
+ "columnNames": [
+ "job_id",
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_backup_restore_items_job_id_status` ON `${TABLE_NAME}` (`job_id`, `status`)"
+ },
+ {
+ "name": "index_backup_restore_items_job_id_section_stable_reference_key",
+ "unique": true,
+ "columnNames": [
+ "job_id",
+ "section",
+ "stable_reference_key"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_backup_restore_items_job_id_section_stable_reference_key` ON `${TABLE_NAME}` (`job_id`, `section`, `stable_reference_key`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "backup_restore_jobs",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "job_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "provider_workflows",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `generation` INTEGER NOT NULL, `state` TEXT NOT NULL, `reason` TEXT NOT NULL, `priority` INTEGER NOT NULL, `force` INTEGER NOT NULL, `current_phase` TEXT, `lease_token` TEXT, `lease_expires_at` INTEGER, `heartbeat_at` INTEGER, `progress_message` TEXT, `last_error_code` TEXT, `last_error_message` 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": "generation",
+ "columnName": "generation",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "state",
+ "columnName": "state",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "reason",
+ "columnName": "reason",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "force",
+ "columnName": "force",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "currentPhase",
+ "columnName": "current_phase",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "leaseToken",
+ "columnName": "lease_token",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "leaseExpiresAt",
+ "columnName": "lease_expires_at",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "heartbeatAt",
+ "columnName": "heartbeat_at",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "progressMessage",
+ "columnName": "progress_message",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastErrorCode",
+ "columnName": "last_error_code",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastErrorMessage",
+ "columnName": "last_error_message",
+ "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_provider_workflows_state",
+ "unique": false,
+ "columnNames": [
+ "state"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_provider_workflows_state` ON `${TABLE_NAME}` (`state`)"
+ },
+ {
+ "name": "index_provider_workflows_updated_at",
+ "unique": false,
+ "columnNames": [
+ "updated_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_provider_workflows_updated_at` ON `${TABLE_NAME}` (`updated_at`)"
+ },
+ {
+ "name": "index_provider_workflows_lease_expires_at",
+ "unique": false,
+ "columnNames": [
+ "lease_expires_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_provider_workflows_lease_expires_at` ON `${TABLE_NAME}` (`lease_expires_at`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "provider_workflow_phases",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `generation` INTEGER NOT NULL, `phase` TEXT NOT NULL, `state` TEXT NOT NULL, `attempt_count` INTEGER NOT NULL, `checkpoint` TEXT, `last_error_code` TEXT, `last_error_message` TEXT, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, `completed_at` INTEGER, PRIMARY KEY(`provider_id`, `generation`, `phase`), 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": "generation",
+ "columnName": "generation",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "phase",
+ "columnName": "phase",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "state",
+ "columnName": "state",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "attemptCount",
+ "columnName": "attempt_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "checkpoint",
+ "columnName": "checkpoint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastErrorCode",
+ "columnName": "last_error_code",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastErrorMessage",
+ "columnName": "last_error_message",
+ "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",
+ "generation",
+ "phase"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_provider_workflow_phases_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_provider_workflow_phases_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_provider_workflow_phases_state",
+ "unique": false,
+ "columnNames": [
+ "state"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_provider_workflow_phases_state` ON `${TABLE_NAME}` (`state`)"
+ },
+ {
+ "name": "index_provider_workflow_phases_updated_at",
+ "unique": false,
+ "columnNames": [
+ "updated_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_provider_workflow_phases_updated_at` ON `${TABLE_NAME}` (`updated_at`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "m3u_classification_overrides",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `source_key` TEXT NOT NULL, `stream_id` INTEGER NOT NULL, `target_type` TEXT NOT NULL, `group_key` TEXT NOT NULL, `series_key` TEXT, `series_name` TEXT, `season_number` INTEGER, `episode_number` INTEGER, `episode_title` TEXT, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`provider_id`, `source_key`), 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": "sourceKey",
+ "columnName": "source_key",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "targetType",
+ "columnName": "target_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "groupKey",
+ "columnName": "group_key",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesKey",
+ "columnName": "series_key",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "seriesName",
+ "columnName": "series_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "seasonNumber",
+ "columnName": "season_number",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "episodeNumber",
+ "columnName": "episode_number",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "episodeTitle",
+ "columnName": "episode_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "source_key"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_m3u_classification_overrides_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_m3u_classification_overrides_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "m3u_category_classification_rules",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `group_key` TEXT NOT NULL, `target_type` TEXT NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`provider_id`, `group_key`), 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": "groupKey",
+ "columnName": "group_key",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "targetType",
+ "columnName": "target_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "group_key"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_m3u_category_classification_rules_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_m3u_category_classification_rules_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "stremio_addons",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `install_url` TEXT NOT NULL, `manifest_id` TEXT NOT NULL, `name` TEXT NOT NULL, `version` TEXT NOT NULL, `manifest_json` TEXT NOT NULL, `enabled` INTEGER NOT NULL, `sort_order` INTEGER NOT NULL, `catalog_settings_json` TEXT NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "installUrl",
+ "columnName": "install_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "manifestId",
+ "columnName": "manifest_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "version",
+ "columnName": "version",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "manifestJson",
+ "columnName": "manifest_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sortOrder",
+ "columnName": "sort_order",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catalogSettingsJson",
+ "columnName": "catalog_settings_json",
+ "affinity": "TEXT",
+ "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_stremio_addons_install_url",
+ "unique": true,
+ "columnNames": [
+ "install_url"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_stremio_addons_install_url` ON `${TABLE_NAME}` (`install_url`)"
+ }
+ ]
+ }
+ ],
+ "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, '3ccd66e96b30b4e6bff6457e5134e833')"
+ ]
+ }
+}
\ 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 ddcaba54..121f8552 100644
--- a/data/src/androidTest/java/com/streamvault/data/local/StreamVaultDatabaseMigrationTest.kt
+++ b/data/src/androidTest/java/com/streamvault/data/local/StreamVaultDatabaseMigrationTest.kt
@@ -1978,6 +1978,52 @@ class StreamVaultDatabaseMigrationTest {
migrated.close()
}
+ @Test
+ fun migrate78To79_createsStremioAddonsAndPreservesExistingData() {
+ val name = "streamvault-78-79-stremio-addons"
+ migrationTestHelper.createDatabase(name, 78).apply {
+ execSQL(
+ """
+ INSERT INTO search_history (query, content_scope, provider_id, used_at, use_count)
+ VALUES ('shawshank', 'MOVIE', 0, 100, 1)
+ """.trimIndent()
+ )
+ close()
+ }
+
+ val migrated = migrationTestHelper.runMigrationsAndValidate(
+ name,
+ 79,
+ true,
+ *StreamVaultDatabaseMigrationRegistry.v78To79.toTypedArray()
+ )
+
+ assertEquals(1, countRows(migrated, "SELECT COUNT(*) FROM search_history WHERE query='shawshank'"))
+ assertEquals(1, countRows(migrated, "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='stremio_addons'"))
+ assertEquals(
+ 1,
+ countRows(
+ migrated,
+ "SELECT COUNT(*) FROM pragma_index_list('stremio_addons') " +
+ "WHERE name='index_stremio_addons_install_url' AND `unique`=1"
+ )
+ )
+ migrated.execSQL(
+ """
+ INSERT INTO stremio_addons (
+ install_url, manifest_id, name, version, manifest_json, enabled, sort_order,
+ catalog_settings_json, created_at, updated_at
+ ) VALUES (
+ 'https://v3-cinemeta.strem.io/manifest.json', 'com.linvo.cinemeta', 'Cinemeta',
+ '3.0.14', '{}', 1, 0, '', 1, 1
+ )
+ """.trimIndent()
+ )
+ assertEquals(1, countRows(migrated, "SELECT COUNT(*) FROM stremio_addons WHERE manifest_id='com.linvo.cinemeta'"))
+ assertEquals(0, countRows(migrated, "SELECT COUNT(*) FROM pragma_foreign_key_check"))
+ migrated.close()
+ }
+
private fun SupportSQLiteDatabase.insertProvider72(id: Long, name: String, type: String) {
execSQL(
"""
diff --git a/data/src/main/java/com/streamvault/data/local/FeatureMigrationsV78To79.kt b/data/src/main/java/com/streamvault/data/local/FeatureMigrationsV78To79.kt
new file mode 100644
index 00000000..0acd330c
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/local/FeatureMigrationsV78To79.kt
@@ -0,0 +1,33 @@
+package com.streamvault.data.local
+
+import androidx.room.migration.Migration
+import androidx.sqlite.db.SupportSQLiteDatabase
+
+/** Adds the installed Stremio addon registry. Addon content is fetched on demand, not synced. */
+object FeatureMigrationsV78To79 {
+ val MIGRATION_78_79 = object : Migration(78, 79) {
+ override fun migrate(db: SupportSQLiteDatabase) {
+ db.execSQL(
+ """
+ CREATE TABLE IF NOT EXISTS `stremio_addons` (
+ `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
+ `install_url` TEXT NOT NULL,
+ `manifest_id` TEXT NOT NULL,
+ `name` TEXT NOT NULL,
+ `version` TEXT NOT NULL,
+ `manifest_json` TEXT NOT NULL,
+ `enabled` INTEGER NOT NULL,
+ `sort_order` INTEGER NOT NULL,
+ `catalog_settings_json` TEXT NOT NULL,
+ `created_at` INTEGER NOT NULL,
+ `updated_at` INTEGER NOT NULL
+ )
+ """.trimIndent()
+ )
+ db.execSQL(
+ "CREATE UNIQUE INDEX IF NOT EXISTS `index_stremio_addons_install_url` " +
+ "ON `stremio_addons` (`install_url`)"
+ )
+ }
+ }
+}
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 70b6db8c..fcc04072 100644
--- a/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt
+++ b/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt
@@ -12,7 +12,7 @@ import org.json.JSONObject
import java.net.URI
import java.security.MessageDigest
-internal const val STREAM_VAULT_DATABASE_VERSION = 78
+internal const val STREAM_VAULT_DATABASE_VERSION = 79
@Database(
entities = [
@@ -72,7 +72,8 @@ internal const val STREAM_VAULT_DATABASE_VERSION = 78
ProviderWorkflowEntity::class,
ProviderWorkflowPhaseEntity::class,
M3uClassificationOverrideEntity::class,
- M3uCategoryClassificationRuleEntity::class
+ M3uCategoryClassificationRuleEntity::class,
+ StremioAddonEntity::class
],
version = STREAM_VAULT_DATABASE_VERSION,
exportSchema = true // ← was false; schema JSON now tracked in version control
@@ -127,6 +128,7 @@ abstract class StreamVaultDatabase : RoomDatabase() {
abstract fun backupRestoreLedgerDao(): BackupRestoreLedgerDao
abstract fun providerWorkflowDao(): ProviderWorkflowDao
abstract fun m3uClassificationDao(): M3uClassificationDao
+ abstract fun stremioAddonDao(): StremioAddonDao
companion object {
val MIGRATION_1_2 = LegacyMigrationsV1To24.MIGRATION_1_2
@@ -206,5 +208,6 @@ abstract class StreamVaultDatabase : RoomDatabase() {
val MIGRATION_75_76 = FeatureMigrationsV75To76.MIGRATION_75_76
val MIGRATION_76_77 = FeatureMigrationsV76To77.MIGRATION_76_77
val MIGRATION_77_78 = FeatureMigrationsV77To78.MIGRATION_77_78
+ val MIGRATION_78_79 = FeatureMigrationsV78To79.MIGRATION_78_79
}
}
diff --git a/data/src/main/java/com/streamvault/data/local/StreamVaultDatabaseMigrationRegistry.kt b/data/src/main/java/com/streamvault/data/local/StreamVaultDatabaseMigrationRegistry.kt
index fe49f49f..75148d2f 100644
--- a/data/src/main/java/com/streamvault/data/local/StreamVaultDatabaseMigrationRegistry.kt
+++ b/data/src/main/java/com/streamvault/data/local/StreamVaultDatabaseMigrationRegistry.kt
@@ -15,7 +15,8 @@ object StreamVaultDatabaseMigrationRegistry {
val v75To76: List<Migration> = listOf(FeatureMigrationsV75To76.MIGRATION_75_76)
val v76To77: List<Migration> = listOf(FeatureMigrationsV76To77.MIGRATION_76_77)
val v77To78: List<Migration> = listOf(FeatureMigrationsV77To78.MIGRATION_77_78)
- val all: List<Migration> = (v1To24 + v24To49 + v49To75 + v75To76 + v76To77 + v77To78).also(::validate)
+ val v78To79: List<Migration> = listOf(FeatureMigrationsV78To79.MIGRATION_78_79)
+ val all: List<Migration> = (v1To24 + v24To49 + v49To75 + v75To76 + v76To77 + v77To78 + v78To79).also(::validate)
private fun validate(migrations: List<Migration>) {
require(migrations.map { it.startVersion }.distinct().size == migrations.size) {
diff --git a/data/src/main/java/com/streamvault/data/local/dao/StremioAddonDao.kt b/data/src/main/java/com/streamvault/data/local/dao/StremioAddonDao.kt
new file mode 100644
index 00000000..989504ab
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/local/dao/StremioAddonDao.kt
@@ -0,0 +1,48 @@
+package com.streamvault.data.local.dao
+
+import androidx.room.Dao
+import androidx.room.Insert
+import androidx.room.Query
+import androidx.room.Transaction
+import com.streamvault.data.local.entity.StremioAddonEntity
+import kotlinx.coroutines.flow.Flow
+
+@Dao
+interface StremioAddonDao {
+ @Query("SELECT * FROM stremio_addons ORDER BY sort_order ASC, id ASC")
+ fun observeAll(): Flow<List<StremioAddonEntity>>
+
+ @Query("SELECT * FROM stremio_addons ORDER BY sort_order ASC, id ASC")
+ suspend fun getAll(): List<StremioAddonEntity>
+
+ @Query("SELECT * FROM stremio_addons WHERE id = :id LIMIT 1")
+ suspend fun getById(id: Long): StremioAddonEntity?
+
+ @Query("SELECT * FROM stremio_addons WHERE install_url = :installUrl LIMIT 1")
+ suspend fun getByInstallUrl(installUrl: String): StremioAddonEntity?
+
+ @Query("SELECT COALESCE(MAX(sort_order), -1) FROM stremio_addons")
+ suspend fun maxSortOrder(): Int
+
+ @Insert
+ suspend fun insert(entity: StremioAddonEntity): Long
+
+ @Query("UPDATE stremio_addons SET enabled = :enabled, updated_at = :updatedAt WHERE id = :id")
+ suspend fun setEnabled(id: Long, enabled: Boolean, updatedAt: Long)
+
+ @Query("UPDATE stremio_addons SET sort_order = :sortOrder, updated_at = :updatedAt WHERE id = :id")
+ suspend fun setSortOrder(id: Long, sortOrder: Int, updatedAt: Long)
+
+ @Query(
+ "UPDATE stremio_addons SET catalog_settings_json = :catalogSettingsJson, updated_at = :updatedAt WHERE id = :id"
+ )
+ suspend fun setCatalogSettings(id: Long, catalogSettingsJson: String, updatedAt: Long)
+
+ @Query("DELETE FROM stremio_addons WHERE id = :id")
+ suspend fun delete(id: Long)
+
+ @Transaction
+ suspend fun applyOrder(positions: List<Pair<Long, Int>>, updatedAt: Long) {
+ positions.forEach { (id, sortOrder) -> setSortOrder(id, sortOrder, updatedAt) }
+ }
+}
diff --git a/data/src/main/java/com/streamvault/data/local/entity/StremioAddonEntity.kt b/data/src/main/java/com/streamvault/data/local/entity/StremioAddonEntity.kt
new file mode 100644
index 00000000..621c8270
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/local/entity/StremioAddonEntity.kt
@@ -0,0 +1,25 @@
+package com.streamvault.data.local.entity
+
+import androidx.room.ColumnInfo
+import androidx.room.Entity
+import androidx.room.Index
+import androidx.room.PrimaryKey
+
+@Entity(
+ tableName = "stremio_addons",
+ indices = [Index(value = ["install_url"], unique = true)]
+)
+data class StremioAddonEntity(
+ @PrimaryKey(autoGenerate = true)
+ @ColumnInfo(name = "id") val id: Long = 0L,
+ @ColumnInfo(name = "install_url") val installUrl: String,
+ @ColumnInfo(name = "manifest_id") val manifestId: String,
+ @ColumnInfo(name = "name") val name: String,
+ @ColumnInfo(name = "version") val version: String,
+ @ColumnInfo(name = "manifest_json") val manifestJson: String,
+ @ColumnInfo(name = "enabled") val enabled: Boolean,
+ @ColumnInfo(name = "sort_order") val sortOrder: Int,
+ @ColumnInfo(name = "catalog_settings_json") val catalogSettingsJson: String,
+ @ColumnInfo(name = "created_at") val createdAt: Long,
+ @ColumnInfo(name = "updated_at") val updatedAt: Long
+)
diff --git a/data/src/main/java/com/streamvault/data/remote/stremio/StremioAddonClient.kt b/data/src/main/java/com/streamvault/data/remote/stremio/StremioAddonClient.kt
new file mode 100644
index 00000000..bba49727
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/remote/stremio/StremioAddonClient.kt
@@ -0,0 +1,199 @@
+package com.streamvault.data.remote.stremio
+
+import com.streamvault.data.remote.http.useCancellableResponse
+import com.streamvault.domain.model.Result
+import com.streamvault.domain.model.stremio.StremioCatalogPage
+import com.streamvault.domain.model.stremio.StremioCatalogQuery
+import com.streamvault.domain.model.stremio.StremioManifest
+import com.streamvault.domain.model.stremio.StremioMediaType
+import com.streamvault.domain.model.stremio.StremioMetaDetail
+import com.streamvault.domain.model.stremio.StremioStream
+import com.streamvault.domain.model.stremio.StremioSubtitle
+import java.io.ByteArrayOutputStream
+import java.io.IOException
+import java.util.concurrent.TimeUnit
+import javax.inject.Inject
+import javax.inject.Singleton
+import kotlinx.coroutines.CancellationException
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
+import kotlinx.serialization.DeserializationStrategy
+import kotlinx.serialization.SerializationException
+import kotlinx.serialization.json.Json
+import okhttp3.OkHttpClient
+import okhttp3.Request
+import okhttp3.Response
+
+@Singleton
+class StremioAddonClient @Inject constructor(
+ private val okHttpClient: OkHttpClient,
+ private val json: Json
+) {
+ fun parseManifest(manifestJson: String): StremioManifest? = runCatching {
+ json.decodeFromString(StremioManifestDto.serializer(), manifestJson)
+ }.getOrNull()?.toDomain()
+
+ suspend fun fetchManifest(addonUrl: String): Result<StremioManifest> =
+ fetchManifestSnapshot(addonUrl).map { it.manifest }
+
+ suspend fun fetchManifestSnapshot(addonUrl: String): Result<StremioManifestSnapshot> {
+ val location = StremioAddonUrl.parse(addonUrl) ?: return Result.error(INVALID_URL_MESSAGE)
+ return fetchBody(location.manifestUrl, StremioManifestDto.serializer()) { dto, raw ->
+ val manifest = dto.toDomain() ?: throw StremioParseException("Addon manifest is missing its id")
+ StremioManifestSnapshot(
+ manifest = manifest,
+ manifestJson = raw,
+ manifestUrl = location.manifestUrl
+ )
+ }
+ }
+
+ suspend fun fetchCatalog(
+ addonUrl: String,
+ type: StremioMediaType,
+ catalogId: String,
+ query: StremioCatalogQuery = StremioCatalogQuery()
+ ): Result<StremioCatalogPage> {
+ if (catalogId.isBlank()) return Result.error("Addon catalog id is missing")
+ if (type == StremioMediaType.UNKNOWN) return Result.error(UNSUPPORTED_TYPE_MESSAGE)
+ val location = StremioAddonUrl.parse(addonUrl) ?: return Result.error(INVALID_URL_MESSAGE)
+ val path = StremioAddonUrl.catalogPath(type, catalogId, query.toExtras())
+ return fetch(location.endpointUrl(path), StremioCatalogResponseDto.serializer()) { dto ->
+ dto.toDomain()
+ }
+ }
+
+ suspend fun fetchMeta(
+ addonUrl: String,
+ type: StremioMediaType,
+ id: String
+ ): Result<StremioMetaDetail> {
+ if (id.isBlank()) return Result.error(MISSING_ID_MESSAGE)
+ if (type == StremioMediaType.UNKNOWN) return Result.error(UNSUPPORTED_TYPE_MESSAGE)
+ val location = StremioAddonUrl.parse(addonUrl) ?: return Result.error(INVALID_URL_MESSAGE)
+ val path = StremioAddonUrl.metaPath(type, id)
+ return fetch(location.endpointUrl(path), StremioMetaResponseDto.serializer()) { dto ->
+ dto.meta?.toDomain() ?: throw StremioParseException("Addon did not return metadata for this item")
+ }
+ }
+
+ suspend fun fetchStreams(
+ addonUrl: String,
+ type: StremioMediaType,
+ id: String
+ ): Result<List<StremioStream>> {
+ if (id.isBlank()) return Result.error(MISSING_ID_MESSAGE)
+ if (type == StremioMediaType.UNKNOWN) return Result.error(UNSUPPORTED_TYPE_MESSAGE)
+ val location = StremioAddonUrl.parse(addonUrl) ?: return Result.error(INVALID_URL_MESSAGE)
+ val path = StremioAddonUrl.streamPath(type, id)
+ return fetch(location.endpointUrl(path), StremioStreamResponseDto.serializer()) { dto ->
+ dto.streams.orEmpty().mapNotNull { it.toDomain() }
+ }
+ }
+
+ suspend fun fetchSubtitles(
+ addonUrl: String,
+ type: StremioMediaType,
+ id: String,
+ videoHash: String? = null,
+ filename: String? = null
+ ): Result<List<StremioSubtitle>> {
+ if (id.isBlank()) return Result.error(MISSING_ID_MESSAGE)
+ if (type == StremioMediaType.UNKNOWN) return Result.error(UNSUPPORTED_TYPE_MESSAGE)
+ val location = StremioAddonUrl.parse(addonUrl) ?: return Result.error(INVALID_URL_MESSAGE)
+ val extras = buildList {
+ videoHash?.trim()?.takeIf { it.isNotEmpty() }?.let { add("videoHash" to it) }
+ filename?.trim()?.takeIf { it.isNotEmpty() }?.let { add("filename" to it) }
+ }
+ val path = StremioAddonUrl.subtitlePath(type, id, extras)
+ return fetch(location.endpointUrl(path), StremioSubtitleResponseDto.serializer()) { dto ->
+ dto.subtitles.orEmpty().mapNotNull { it.toDomain() }
+ }
+ }
+
+ private suspend fun <D, T> fetch(
+ url: String,
+ deserializer: DeserializationStrategy<D>,
+ map: (D) -> T
+ ): Result<T> = fetchBody(url, deserializer) { dto, _ -> map(dto) }
+
+ private suspend fun <D, T> fetchBody(
+ url: String,
+ deserializer: DeserializationStrategy<D>,
+ map: (D, String) -> T
+ ): Result<T> = try {
+ val body = withContext(Dispatchers.IO) { executeBody(url) }
+ Result.success(map(json.decodeFromString(deserializer, body), body))
+ } catch (cancellation: CancellationException) {
+ throw cancellation
+ } catch (parseError: SerializationException) {
+ Result.error("Addon response could not be parsed", parseError)
+ } catch (parseError: IllegalArgumentException) {
+ Result.error("Addon response could not be parsed", parseError)
+ } catch (error: Exception) {
+ Result.error(error.message ?: "Addon request failed", error)
+ }
+
+ private suspend fun executeBody(url: String): String {
+ val request = Request.Builder()
+ .url(url)
+ .header("Accept", ACCEPT_JSON)
+ .get()
+ .build()
+ return okHttpClient.newBuilder()
+ .callTimeout(REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS)
+ .build()
+ .newCall(request)
+ .useCancellableResponse { response ->
+ if (!response.isSuccessful) {
+ throw StremioHttpException(response.code)
+ }
+ readBodyBounded(response)
+ }
+ }
+
+ private fun readBodyBounded(response: Response): String {
+ val body = response.body ?: throw StremioParseException("Addon returned an empty response")
+ val declaredLength = body.contentLength()
+ if (declaredLength > MAX_RESPONSE_BYTES) {
+ throw StremioResponseTooLargeException(declaredLength)
+ }
+ val output = ByteArrayOutputStream()
+ val chunk = ByteArray(16 * 1024)
+ var total = 0L
+ body.byteStream().use { stream ->
+ while (true) {
+ val read = stream.read(chunk)
+ if (read == -1) break
+ total += read
+ if (total > MAX_RESPONSE_BYTES) {
+ throw StremioResponseTooLargeException(total)
+ }
+ output.write(chunk, 0, read)
+ }
+ }
+ return output.toString(Charsets.UTF_8.name())
+ }
+
+ internal companion object {
+ internal const val MAX_RESPONSE_BYTES = 8L * 1024 * 1024
+ private const val REQUEST_TIMEOUT_SECONDS = 30L
+ private const val ACCEPT_JSON = "application/json"
+ private const val INVALID_URL_MESSAGE = "Addon URL is not a valid http(s) or stremio:// address"
+ private const val MISSING_ID_MESSAGE = "Addon content id is missing"
+ private const val UNSUPPORTED_TYPE_MESSAGE = "Addon request has an unsupported content type"
+ }
+}
+
+class StremioHttpException(val statusCode: Int) : IOException("Addon request failed with HTTP $statusCode")
+
+class StremioResponseTooLargeException(observedBytes: Long) :
+ IOException("Addon response is too large ($observedBytes bytes)")
+
+class StremioParseException(message: String) : IOException(message)
+
+data class StremioManifestSnapshot(
+ val manifest: StremioManifest,
+ val manifestJson: String,
+ val manifestUrl: String
+)
diff --git a/data/src/main/java/com/streamvault/data/remote/stremio/StremioAddonDtos.kt b/data/src/main/java/com/streamvault/data/remote/stremio/StremioAddonDtos.kt
new file mode 100644
index 00000000..e16ea325
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/remote/stremio/StremioAddonDtos.kt
@@ -0,0 +1,138 @@
+package com.streamvault.data.remote.stremio
+
+import kotlinx.serialization.Serializable
+import kotlinx.serialization.json.JsonElement
+
+@Serializable
+internal data class StremioManifestDto(
+ val id: String? = null,
+ val version: String? = null,
+ val name: String? = null,
+ val description: String? = null,
+ val logo: String? = null,
+ val background: String? = null,
+ val types: List<String>? = null,
+ val resources: List<JsonElement>? = null,
+ val catalogs: List<StremioCatalogDto>? = null,
+ val idPrefixes: List<String>? = null,
+ val behaviorHints: StremioManifestBehaviorHintsDto? = null
+)
+
+@Serializable
+internal data class StremioManifestBehaviorHintsDto(
+ val configurable: Boolean? = null,
+ val configurationRequired: Boolean? = null
+)
+
+@Serializable
+internal data class StremioCatalogDto(
+ val type: String? = null,
+ val id: String? = null,
+ val name: String? = null,
+ val genres: List<String>? = null,
+ val extra: JsonElement? = null
+)
+
+@Serializable
+internal data class StremioCatalogResponseDto(
+ val metas: List<StremioMetaPreviewDto>? = null,
+ val hasMore: Boolean? = null
+)
+
+@Serializable
+internal data class StremioMetaPreviewDto(
+ val id: String? = null,
+ val type: String? = null,
+ val name: String? = null,
+ val poster: String? = null,
+ val background: String? = null,
+ val logo: String? = null,
+ val description: String? = null,
+ val releaseInfo: String? = null,
+ val imdbRating: String? = null,
+ val genres: List<String>? = null,
+ val runtime: String? = null
+)
+
+@Serializable
+internal data class StremioMetaResponseDto(
+ val meta: StremioMetaDto? = null
+)
+
+@Serializable
+internal data class StremioMetaDto(
+ val id: String? = null,
+ val type: String? = null,
+ val name: String? = null,
+ val poster: String? = null,
+ val background: String? = null,
+ val logo: String? = null,
+ val description: String? = null,
+ val releaseInfo: String? = null,
+ val imdbRating: String? = null,
+ val genres: List<String>? = null,
+ val runtime: String? = null,
+ val cast: List<String>? = null,
+ val director: JsonElement? = null,
+ val videos: List<StremioVideoDto>? = null
+)
+
+@Serializable
+internal data class StremioVideoDto(
+ val id: String? = null,
+ val name: String? = null,
+ val title: String? = null,
+ val season: Int? = null,
+ val episode: Int? = null,
+ val number: Int? = null,
+ val released: String? = null,
+ val thumbnail: String? = null,
+ val overview: String? = null
+)
+
+@Serializable
+internal data class StremioStreamResponseDto(
+ val streams: List<StremioStreamDto>? = null
+)
+
+@Serializable
+internal data class StremioStreamDto(
+ val name: String? = null,
+ val title: String? = null,
+ val description: String? = null,
+ val url: String? = null,
+ val ytId: String? = null,
+ val infoHash: String? = null,
+ val fileIdx: Int? = null,
+ val externalUrl: String? = null,
+ val sources: List<String>? = null,
+ val behaviorHints: StremioStreamBehaviorHintsDto? = null
+)
+
+@Serializable
+internal data class StremioStreamBehaviorHintsDto(
+ val notWebReady: Boolean? = null,
+ val bingeGroup: String? = null,
+ val filename: String? = null,
+ val videoSize: Long? = null,
+ val videoHash: String? = null,
+ val proxyHeaders: StremioProxyHeadersDto? = null
+)
+
+@Serializable
+internal data class StremioProxyHeadersDto(
+ val request: Map<String, String>? = null,
+ val response: Map<String, String>? = null
+)
+
+@Serializable
+internal data class StremioSubtitleResponseDto(
+ val subtitles: List<StremioSubtitleDto>? = null
+)
+
+@Serializable
+internal data class StremioSubtitleDto(
+ val id: String? = null,
+ val url: String? = null,
+ val lang: String? = null
+)
diff --git a/data/src/main/java/com/streamvault/data/remote/stremio/StremioAddonUrl.kt b/data/src/main/java/com/streamvault/data/remote/stremio/StremioAddonUrl.kt
new file mode 100644
index 00000000..f417de03
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/remote/stremio/StremioAddonUrl.kt
@@ -0,0 +1,81 @@
+package com.streamvault.data.remote.stremio
+
+import com.streamvault.domain.model.stremio.StremioMediaType
+import java.net.URI
+import java.net.URLEncoder
+
+data class StremioAddonLocation(
+ val baseUrl: String,
+ val query: String = ""
+) {
+ val manifestUrl: String get() = withQuery("$baseUrl/manifest.json")
+
+ fun endpointUrl(path: String): String = withQuery("$baseUrl$path")
+
+ private fun withQuery(url: String): String = if (query.isBlank()) url else "$url?$query"
+}
+
+object StremioAddonUrl {
+ private const val MANIFEST_SUFFIX = "/manifest.json"
+
+ fun parse(raw: String): StremioAddonLocation? {
+ val trimmed = raw.trim()
+ if (trimmed.isEmpty()) return null
+ val upgraded = if (trimmed.startsWith("stremio://", ignoreCase = true)) {
+ "https://" + trimmed.substring("stremio://".length)
+ } else {
+ trimmed
+ }
+ val uri = runCatching { URI(upgraded) }.getOrNull() ?: return null
+ val scheme = uri.scheme?.lowercase() ?: return null
+ if (scheme != "http" && scheme != "https") return null
+ val host = uri.host?.takeIf { it.isNotBlank() } ?: return null
+ val authority = if (uri.port == -1) host else "$host:${uri.port}"
+ val basePath = normalizedBasePath(uri.path.orEmpty())
+ return StremioAddonLocation(
+ baseUrl = "$scheme://$authority$basePath",
+ query = uri.rawQuery.orEmpty()
+ )
+ }
+
+ fun catalogPath(
+ type: StremioMediaType,
+ catalogId: String,
+ extras: List<Pair<String, String>>
+ ): String = "/catalog/${encodeSegment(type.typeName)}/${encodeSegment(catalogId)}${extrasPath(extras)}.json"
+
+ fun metaPath(type: StremioMediaType, id: String): String =
+ "/meta/${encodeSegment(type.typeName)}/${encodeSegment(id)}.json"
+
+ fun streamPath(type: StremioMediaType, id: String): String =
+ "/stream/${encodeSegment(type.typeName)}/${encodeSegment(id)}.json"
+
+ fun subtitlePath(
+ type: StremioMediaType,
+ id: String,
+ extras: List<Pair<String, String>>
+ ): String = "/subtitles/${encodeSegment(type.typeName)}/${encodeSegment(id)}${extrasPath(extras)}.json"
+
+ private fun normalizedBasePath(path: String): String {
+ val trimmed = path.trimEnd('/')
+ return when {
+ trimmed.isEmpty() || trimmed == "/" -> ""
+ trimmed.endsWith(MANIFEST_SUFFIX, ignoreCase = true) -> trimmed.dropLast(MANIFEST_SUFFIX.length)
+ else -> trimmed
+ }
+ }
+
+ private fun extrasPath(extras: List<Pair<String, String>>): String =
+ if (extras.isEmpty()) {
+ ""
+ } else {
+ extras.joinToString(prefix = "/", separator = "&") { (key, value) ->
+ "$key=${encodeSegment(value)}"
+ }
+ }
+
+ private fun encodeSegment(value: String): String =
+ URLEncoder.encode(value, Charsets.UTF_8.name())
+ .replace("+", "%20")
+ .replace("%3A", ":")
+}
diff --git a/data/src/main/java/com/streamvault/data/remote/stremio/StremioMapper.kt b/data/src/main/java/com/streamvault/data/remote/stremio/StremioMapper.kt
new file mode 100644
index 00000000..b1adcae8
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/remote/stremio/StremioMapper.kt
@@ -0,0 +1,247 @@
+package com.streamvault.data.remote.stremio
+
+import com.streamvault.domain.model.stremio.StremioCatalogExtraDef
+import com.streamvault.domain.model.stremio.StremioCatalogPage
+import com.streamvault.domain.model.stremio.StremioCatalogRef
+import com.streamvault.domain.model.stremio.StremioManifest
+import com.streamvault.domain.model.stremio.StremioManifestBehaviorHints
+import com.streamvault.domain.model.stremio.StremioManifestResource
+import com.streamvault.domain.model.stremio.StremioMediaType
+import com.streamvault.domain.model.stremio.StremioMetaDetail
+import com.streamvault.domain.model.stremio.StremioMetaPreview
+import com.streamvault.domain.model.stremio.StremioProxyHeaders
+import com.streamvault.domain.model.stremio.StremioResourceKind
+import com.streamvault.domain.model.stremio.StremioStream
+import com.streamvault.domain.model.stremio.StremioStreamBehaviorHints
+import com.streamvault.domain.model.stremio.StremioStreamKind
+import com.streamvault.domain.model.stremio.StremioSubtitle
+import com.streamvault.domain.model.stremio.StremioVideo
+import kotlinx.serialization.json.JsonArray
+import kotlinx.serialization.json.JsonElement
+import kotlinx.serialization.json.JsonObject
+import kotlinx.serialization.json.JsonPrimitive
+import kotlinx.serialization.json.booleanOrNull
+import kotlinx.serialization.json.contentOrNull
+
+internal fun StremioManifestDto.toDomain(): StremioManifest? {
+ val manifestId = id?.trim().orEmpty()
+ if (manifestId.isEmpty()) return null
+ val manifestTypes = types.orEmpty()
+ .map(StremioMediaType::fromTypeName)
+ .filter { it != StremioMediaType.UNKNOWN }
+ .distinct()
+ val parsedResources = parseResources(resources)
+ return StremioManifest(
+ id = manifestId,
+ name = name?.trim()?.takeIf { it.isNotEmpty() } ?: manifestId,
+ version = version?.trim().orEmpty(),
+ description = description?.trim()?.takeIf { it.isNotEmpty() },
+ logo = logo?.trim()?.takeIf { it.isNotEmpty() },
+ background = background?.trim()?.takeIf { it.isNotEmpty() },
+ types = manifestTypes,
+ resources = parsedResources.map { resource ->
+ if (resource.types.isEmpty() && manifestTypes.isNotEmpty()) {
+ resource.copy(types = manifestTypes)
+ } else {
+ resource
+ }
+ },
+ catalogs = parseCatalogs(catalogs),
+ idPrefixes = idPrefixes.orEmpty().mapNotNull { it.trim().takeIf(String::isNotEmpty) }.distinct(),
+ behaviorHints = behaviorHints?.toDomain() ?: StremioManifestBehaviorHints()
+ )
+}
+
+internal fun StremioManifestBehaviorHintsDto.toDomain(): StremioManifestBehaviorHints =
+ StremioManifestBehaviorHints(
+ configurable = configurable ?: false,
+ configurationRequired = configurationRequired ?: false
+ )
+
+internal fun StremioCatalogResponseDto.toDomain(): StremioCatalogPage =
+ StremioCatalogPage(
+ metas = metas.orEmpty().mapNotNull { it.toDomain() },
+ hasMore = hasMore ?: false
+ )
+
+internal fun StremioMetaPreviewDto.toDomain(): StremioMetaPreview? {
+ val previewId = id?.trim().orEmpty()
+ if (previewId.isEmpty()) return null
+ return StremioMetaPreview(
+ id = previewId,
+ type = StremioMediaType.fromTypeName(type),
+ name = name?.trim()?.takeIf { it.isNotEmpty() } ?: previewId,
+ poster = poster?.trim()?.takeIf { it.isNotEmpty() },
+ background = background?.trim()?.takeIf { it.isNotEmpty() },
+ logo = logo?.trim()?.takeIf { it.isNotEmpty() },
+ description = description?.trim()?.takeIf { it.isNotEmpty() },
+ releaseInfo = releaseInfo?.trim()?.takeIf { it.isNotEmpty() },
+ imdbRating = imdbRating?.trim()?.takeIf { it.isNotEmpty() },
+ genres = genres.orEmpty().mapNotNull { it.trim().takeIf(String::isNotEmpty) },
+ runtime = runtime?.trim()?.takeIf { it.isNotEmpty() }
+ )
+}
+
+internal fun StremioMetaDto.toDomain(): StremioMetaDetail? {
+ val metaId = id?.trim().orEmpty()
+ if (metaId.isEmpty()) return null
+ return StremioMetaDetail(
+ id = metaId,
+ type = StremioMediaType.fromTypeName(type),
+ name = name?.trim()?.takeIf { it.isNotEmpty() } ?: metaId,
+ poster = poster?.trim()?.takeIf { it.isNotEmpty() },
+ background = background?.trim()?.takeIf { it.isNotEmpty() },
+ logo = logo?.trim()?.takeIf { it.isNotEmpty() },
+ description = description?.trim()?.takeIf { it.isNotEmpty() },
+ releaseInfo = releaseInfo?.trim()?.takeIf { it.isNotEmpty() },
+ imdbRating = imdbRating?.trim()?.takeIf { it.isNotEmpty() },
+ genres = genres.orEmpty().mapNotNull { it.trim().takeIf(String::isNotEmpty) },
+ runtime = runtime?.trim()?.takeIf { it.isNotEmpty() },
+ cast = cast.orEmpty().mapNotNull { it.trim().takeIf(String::isNotEmpty) },
+ director = director.asStringOrStringList(),
+ videos = videos.orEmpty().mapNotNull { it.toDomain() }
+ )
+}
+
+internal fun StremioVideoDto.toDomain(): StremioVideo? {
+ val videoId = id?.trim().orEmpty()
+ if (videoId.isEmpty()) return null
+ return StremioVideo(
+ id = videoId,
+ title = name?.trim()?.takeIf { it.isNotEmpty() } ?: title?.trim()?.takeIf { it.isNotEmpty() },
+ season = season,
+ episode = episode ?: number,
+ released = released?.trim()?.takeIf { it.isNotEmpty() },
+ thumbnail = thumbnail?.trim()?.takeIf { it.isNotEmpty() },
+ overview = overview?.trim()?.takeIf { it.isNotEmpty() }
+ )
+}
+
+internal fun StremioStreamDto.toDomain(): StremioStream? {
+ val stream = StremioStream(
+ name = name?.trim()?.takeIf { it.isNotEmpty() },
+ title = title?.trim()?.takeIf { it.isNotEmpty() },
+ description = description?.trim()?.takeIf { it.isNotEmpty() },
+ url = url?.trim()?.takeIf { it.isNotEmpty() },
+ ytId = ytId?.trim()?.takeIf { it.isNotEmpty() },
+ infoHash = infoHash?.trim()?.takeIf { it.isNotEmpty() }?.lowercase(),
+ fileIdx = fileIdx?.takeIf { it >= 0 },
+ externalUrl = externalUrl?.trim()?.takeIf { it.isNotEmpty() },
+ sources = sources.orEmpty().mapNotNull { it.trim().takeIf(String::isNotEmpty) },
+ behaviorHints = behaviorHints?.toDomain()
+ )
+ return stream.takeIf { it.kind != StremioStreamKind.UNKNOWN }
+}
+
+internal fun StremioStreamBehaviorHintsDto.toDomain(): StremioStreamBehaviorHints =
+ StremioStreamBehaviorHints(
+ notWebReady = notWebReady ?: false,
+ bingeGroup = bingeGroup?.trim()?.takeIf { it.isNotEmpty() },
+ filename = filename?.trim()?.takeIf { it.isNotEmpty() },
+ videoSize = videoSize?.takeIf { it > 0 },
+ videoHash = videoHash?.trim()?.takeIf { it.isNotEmpty() },
+ proxyHeaders = proxyHeaders?.let { headers ->
+ StremioProxyHeaders(
+ request = headers.request.orEmpty().filterValues { it.isNotBlank() },
+ response = headers.response.orEmpty().filterValues { it.isNotBlank() }
+ ).takeIf { it.request.isNotEmpty() || it.response.isNotEmpty() }
+ }
+ )
+
+internal fun StremioSubtitleDto.toDomain(): StremioSubtitle? {
+ val subtitleUrl = url?.trim().orEmpty()
+ if (subtitleUrl.isEmpty()) return null
+ return StremioSubtitle(
+ url = subtitleUrl,
+ lang = lang?.trim().orEmpty(),
+ id = id?.trim()?.takeIf { it.isNotEmpty() }
+ )
+}
+
+private fun parseResources(resources: List<JsonElement>?): List<StremioManifestResource> =
+ resources.orEmpty().mapNotNull { element ->
+ when (element) {
+ is JsonPrimitive -> element.contentOrNull
+ ?.let(StremioResourceKind::fromResourceName)
+ ?.takeIf { it != StremioResourceKind.UNKNOWN }
+ ?.let { StremioManifestResource(kind = it) }
+ is JsonObject -> {
+ val kind = StremioResourceKind.fromResourceName(element["name"].asString())
+ if (kind == StremioResourceKind.UNKNOWN) {
+ null
+ } else {
+ StremioManifestResource(
+ kind = kind,
+ types = element["types"].asStringList()
+ .map(StremioMediaType::fromTypeName)
+ .filter { it != StremioMediaType.UNKNOWN }
+ .distinct(),
+ idPrefixes = element["idPrefixes"].asStringList().distinct()
+ )
+ }
+ }
+ else -> null
+ }
+ }
+
+private fun parseCatalogs(catalogs: List<StremioCatalogDto>?): List<StremioCatalogRef> =
+ catalogs.orEmpty().mapNotNull { dto ->
+ val catalogId = dto.id?.trim().orEmpty()
+ val type = StremioMediaType.fromTypeName(dto.type)
+ if (catalogId.isEmpty() || type == StremioMediaType.UNKNOWN) {
+ null
+ } else {
+ StremioCatalogRef(
+ type = type,
+ id = catalogId,
+ name = dto.name?.trim()?.takeIf { it.isNotEmpty() },
+ genres = dto.genres.orEmpty().mapNotNull { it.trim().takeIf(String::isNotEmpty) },
+ extras = parseCatalogExtras(dto.extra)
+ )
+ }
+ }
+
+private fun parseCatalogExtras(extra: JsonElement?): List<StremioCatalogExtraDef> =
+ when (extra) {
+ is JsonArray -> extra.mapNotNull { entry ->
+ when (entry) {
+ is JsonPrimitive -> entry.contentOrNull
+ ?.trim()
+ ?.takeIf { it.isNotEmpty() }
+ ?.let { StremioCatalogExtraDef(name = it) }
+ is JsonObject -> entry["name"].asString()?.let { name ->
+ StremioCatalogExtraDef(
+ name = name,
+ isRequired = entry["isRequired"].asBoolean(),
+ options = entry["options"].asOptionList()
+ )
+ }
+ else -> null
+ }
+ }
+ else -> emptyList()
+ }
+
+private fun JsonElement?.asString(): String? =
+ (this as? JsonPrimitive)?.contentOrNull?.trim()?.takeIf { it.isNotEmpty() }
+
+private fun JsonElement?.asStringList(): List<String> =
+ (this as? JsonArray).orEmpty().mapNotNull { (it as? JsonPrimitive)?.contentOrNull?.trim()?.takeIf(String::isNotEmpty) }
+
+private fun JsonElement?.asBoolean(): Boolean = (this as? JsonPrimitive)?.booleanOrNull ?: false
+
+private fun JsonElement?.asOptionList(): List<String> =
+ (this as? JsonArray).orEmpty().mapNotNull { entry ->
+ when (entry) {
+ is JsonPrimitive -> entry.contentOrNull?.trim()?.takeIf { it.isNotEmpty() }
+ is JsonObject -> entry["value"].asString() ?: entry["label"].asString()
+ else -> null
+ }
+ }
+
+private fun JsonElement?.asStringOrStringList(): List<String> =
+ when (this) {
+ is JsonPrimitive -> listOfNotNull(contentOrNull?.trim()?.takeIf { it.isNotEmpty() })
+ is JsonArray -> mapNotNull { (it as? JsonPrimitive)?.contentOrNull?.trim()?.takeIf(String::isNotEmpty) }
+ else -> emptyList()
+ }
diff --git a/data/src/main/java/com/streamvault/data/repository/StremioAddonRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/StremioAddonRepositoryImpl.kt
new file mode 100644
index 00000000..245a45b5
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/repository/StremioAddonRepositoryImpl.kt
@@ -0,0 +1,114 @@
+package com.streamvault.data.repository
+
+import com.streamvault.data.local.dao.StremioAddonDao
+import com.streamvault.data.local.entity.StremioAddonEntity
+import com.streamvault.data.remote.stremio.StremioAddonClient
+import com.streamvault.domain.model.Result
+import com.streamvault.domain.model.stremio.StremioAddon
+import com.streamvault.domain.model.stremio.StremioManifest
+import com.streamvault.domain.repository.StremioAddonRepository
+import javax.inject.Inject
+import javax.inject.Singleton
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.map
+
+@Singleton
+class StremioAddonRepositoryImpl @Inject constructor(
+ private val dao: StremioAddonDao,
+ private val client: StremioAddonClient
+) : StremioAddonRepository {
+
+ override fun observeAddons(): Flow<List<StremioAddon>> =
+ dao.observeAll().map { entities -> entities.map(StremioAddonEntity::toDomain) }
+
+ override suspend fun getAddon(id: Long): StremioAddon? = dao.getById(id)?.toDomain()
+
+ override suspend fun getManifest(addonId: Long): StremioManifest? =
+ dao.getById(addonId)?.let { entity -> client.parseManifest(entity.manifestJson) }
+
+ override suspend fun installAddon(installUrl: String): Result<StremioAddon> {
+ val snapshotResult = client.fetchManifestSnapshot(installUrl)
+ val snapshot = snapshotResult.getOrNull() ?: return Result.error(
+ snapshotResult.errorMessageOrNull() ?: "Addon could not be installed",
+ (snapshotResult as? Result.Error)?.exception
+ )
+ if (snapshot.manifest.behaviorHints.configurationRequired) {
+ return Result.error(
+ "This addon requires configuration. Configure it in your browser, then paste its configured manifest URL."
+ )
+ }
+ if (dao.getByInstallUrl(snapshot.manifestUrl) != null) {
+ return Result.error("This addon is already installed")
+ }
+ val now = System.currentTimeMillis()
+ val entity = StremioAddonEntity(
+ installUrl = snapshot.manifestUrl,
+ manifestId = snapshot.manifest.id,
+ name = snapshot.manifest.name,
+ version = snapshot.manifest.version,
+ manifestJson = snapshot.manifestJson,
+ enabled = true,
+ sortOrder = dao.maxSortOrder() + 1,
+ catalogSettingsJson = "",
+ createdAt = now,
+ updatedAt = now
+ )
+ val id = dao.insert(entity)
+ return Result.success(entity.copy(id = id).toDomain())
+ }
+
+ override suspend fun removeAddon(id: Long): Result<Unit> {
+ dao.delete(id)
+ return Result.success(Unit)
+ }
+
+ override suspend fun setAddonEnabled(id: Long, enabled: Boolean): Result<Unit> {
+ dao.setEnabled(id, enabled, System.currentTimeMillis())
+ return Result.success(Unit)
+ }
+
+ override suspend fun moveAddon(id: Long, offset: Int): Result<Unit> {
+ if (offset == 0) return Result.success(Unit)
+ val addons = dao.getAll()
+ val index = addons.indexOfFirst { it.id == id }
+ if (index < 0) return Result.error("Addon is not installed")
+ val target = (index + offset).coerceIn(0, addons.lastIndex)
+ if (target == index) return Result.success(Unit)
+ val reordered = addons.toMutableList().apply { add(target, removeAt(index)) }
+ dao.applyOrder(
+ reordered.mapIndexed { position, addon -> addon.id to position },
+ System.currentTimeMillis()
+ )
+ return Result.success(Unit)
+ }
+
+ override suspend fun setCatalogEnabled(
+ addonId: Long,
+ catalogKey: String,
+ enabled: Boolean
+ ): Result<Unit> {
+ val entity = dao.getById(addonId) ?: return Result.error("Addon is not installed")
+ val settings = StremioCatalogSettingsCodec.decode(entity.catalogSettingsJson).toMutableMap()
+ settings[catalogKey] = enabled
+ dao.setCatalogSettings(
+ addonId,
+ StremioCatalogSettingsCodec.encode(settings),
+ System.currentTimeMillis()
+ )
+ return Result.success(Unit)
+ }
+}
+
+private fun StremioAddonEntity.toDomain(): StremioAddon = StremioAddon(
+ id = id,
+ installUrl = installUrl,
+ manifestId = manifestId,
+ name = name,
+ version = version,
+ manifestJson = manifestJson,
+ enabled = enabled,
+ sortOrder = sortOrder,
+ catalogSettings = StremioCatalogSettingsCodec.decode(catalogSettingsJson),
+ createdAt = createdAt,
+ updatedAt = updatedAt
+)
diff --git a/data/src/main/java/com/streamvault/data/repository/StremioCatalogSettingsCodec.kt b/data/src/main/java/com/streamvault/data/repository/StremioCatalogSettingsCodec.kt
new file mode 100644
index 00000000..7131d8a5
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/repository/StremioCatalogSettingsCodec.kt
@@ -0,0 +1,27 @@
+package com.streamvault.data.repository
+
+import kotlinx.serialization.json.Json
+import kotlinx.serialization.json.booleanOrNull
+import kotlinx.serialization.json.buildJsonObject
+import kotlinx.serialization.json.jsonObject
+import kotlinx.serialization.json.jsonPrimitive
+import kotlinx.serialization.json.put
+
+internal object StremioCatalogSettingsCodec {
+ fun decode(raw: String): Map<String, Boolean> = runCatching {
+ if (raw.isBlank()) return@runCatching emptyMap()
+ Json.parseToJsonElement(raw).jsonObject.mapNotNull { (key, value) ->
+ val enabled = value.jsonPrimitive.booleanOrNull ?: return@mapNotNull null
+ key to enabled
+ }.toMap()
+ }.getOrDefault(emptyMap())
+
+ fun encode(settings: Map<String, Boolean>): String =
+ if (settings.isEmpty()) {
+ ""
+ } else {
+ buildJsonObject {
+ settings.toSortedMap().forEach { (key, enabled) -> put(key, enabled) }
+ }.toString()
+ }
+}
diff --git a/data/src/test/java/com/streamvault/data/remote/stremio/StremioAddonClientTest.kt b/data/src/test/java/com/streamvault/data/remote/stremio/StremioAddonClientTest.kt
new file mode 100644
index 00000000..2a366316
--- /dev/null
+++ b/data/src/test/java/com/streamvault/data/remote/stremio/StremioAddonClientTest.kt
@@ -0,0 +1,290 @@
+package com.streamvault.data.remote.stremio
+
+import com.google.common.truth.Truth.assertThat
+import com.streamvault.domain.model.stremio.StremioCatalogQuery
+import com.streamvault.domain.model.stremio.StremioMediaType
+import com.streamvault.domain.model.stremio.StremioResourceKind
+import com.streamvault.domain.model.stremio.StremioStreamKind
+import java.io.InputStreamReader
+import kotlinx.coroutines.test.runTest
+import kotlinx.serialization.json.Json
+import okhttp3.OkHttpClient
+import okhttp3.mockwebserver.MockResponse
+import okhttp3.mockwebserver.MockWebServer
+import org.junit.After
+import org.junit.Before
+import org.junit.Test
+
+class StremioAddonClientTest {
+
+ private lateinit var server: MockWebServer
+ private lateinit var client: StremioAddonClient
+
+ @Before
+ fun setUp() {
+ server = MockWebServer()
+ server.start()
+ client = StremioAddonClient(
+ okHttpClient = OkHttpClient(),
+ json = Json {
+ ignoreUnknownKeys = true
+ isLenient = true
+ explicitNulls = false
+ coerceInputValues = true
+ }
+ )
+ }
+
+ @After
+ fun tearDown() {
+ server.shutdown()
+ }
+
+ @Test
+ fun `manifest parses resources catalogs and behavior hints`() = runTest {
+ server.enqueue(MockResponse().setBody(fixture("stremio/fixtures/cinemeta_manifest.json")))
+
+ val result = client.fetchManifest(baseUrl())
+
+ assertThat(result.isSuccess).isTrue()
+ assertThat(server.takeRequest().path).isEqualTo("/manifest.json")
+ val manifest = result.getOrNull()!!
+ assertThat(manifest.id).isEqualTo("com.linvo.cinemeta")
+ assertThat(manifest.name).isEqualTo("Cinemeta")
+ assertThat(manifest.version).isEqualTo("3.0.14")
+ assertThat(manifest.types)
+ .containsExactly(StremioMediaType.MOVIE, StremioMediaType.SERIES)
+ .inOrder()
+ assertThat(manifest.resources.map { it.kind }).containsExactly(
+ StremioResourceKind.CATALOG,
+ StremioResourceKind.META,
+ StremioResourceKind.STREAM,
+ StremioResourceKind.SUBTITLES
+ ).inOrder()
+ val metaResource = manifest.resources.first { it.kind == StremioResourceKind.META }
+ assertThat(metaResource.idPrefixes).containsExactly("tt")
+ assertThat(metaResource.types)
+ .containsExactly(StremioMediaType.MOVIE, StremioMediaType.SERIES)
+ val catalogResource = manifest.resources.first { it.kind == StremioResourceKind.CATALOG }
+ assertThat(catalogResource.types)
+ .containsExactly(StremioMediaType.MOVIE, StremioMediaType.SERIES)
+ assertThat(manifest.supportsResource(StremioResourceKind.STREAM, StremioMediaType.SERIES)).isTrue()
+ assertThat(manifest.supportsResource(StremioResourceKind.STREAM, StremioMediaType.CHANNEL)).isFalse()
+ assertThat(manifest.idPrefixes).containsExactly("tt")
+ assertThat(manifest.behaviorHints.configurable).isFalse()
+ assertThat(manifest.catalogs).hasSize(2)
+ val movieCatalog = manifest.catalogs.first { it.type == StremioMediaType.MOVIE }
+ assertThat(movieCatalog.id).isEqualTo("top")
+ assertThat(movieCatalog.name).isEqualTo("Popular")
+ assertThat(movieCatalog.genres).containsExactly("Action", "Comedy")
+ assertThat(movieCatalog.supportsSearch).isTrue()
+ assertThat(movieCatalog.supportsSkip).isTrue()
+ assertThat(movieCatalog.supportsGenre).isTrue()
+ assertThat(movieCatalog.extras.first { it.name == "search" }.isRequired).isFalse()
+ assertThat(movieCatalog.extras.first { it.name == "genre" }.options)
+ .containsExactly("Action", "Comedy", "Drama")
+ .inOrder()
+ val skipExtra = movieCatalog.extras.first { it.name == "skip" }
+ assertThat(skipExtra.isRequired).isFalse()
+ assertThat(skipExtra.options).isEmpty()
+ val seriesCatalog = manifest.catalogs.first { it.type == StremioMediaType.SERIES }
+ assertThat(seriesCatalog.extras.map { it.name }).containsExactly("search", "skip").inOrder()
+ }
+
+ @Test
+ fun `catalog page parses metas and hasMore`() = runTest {
+ server.enqueue(MockResponse().setBody(fixture("stremio/fixtures/catalog_movies_top.json")))
+
+ val result = client.fetchCatalog(baseUrl(), StremioMediaType.MOVIE, "top")
+
+ assertThat(result.isSuccess).isTrue()
+ assertThat(server.takeRequest().path).isEqualTo("/catalog/movie/top.json")
+ val page = result.getOrNull()!!
+ assertThat(page.hasMore).isTrue()
+ assertThat(page.metas).hasSize(2)
+ val first = page.metas.first()
+ assertThat(first.id).isEqualTo("tt0111161")
+ assertThat(first.name).isEqualTo("The Shawshank Redemption")
+ assertThat(first.poster).isEqualTo("https://images.metahub.space/poster/medium/tt0111161/img")
+ assertThat(first.releaseInfo).isEqualTo("1994")
+ assertThat(first.imdbRating).isEqualTo("9.3")
+ assertThat(first.genres).containsExactly("Drama")
+ }
+
+ @Test
+ fun `catalog request encodes search genre and skip extras`() = runTest {
+ server.enqueue(MockResponse().setBody(fixture("stremio/fixtures/catalog_search.json")))
+
+ val result = client.fetchCatalog(
+ baseUrl(),
+ StremioMediaType.MOVIE,
+ "top",
+ StremioCatalogQuery(search = "guardians of the galaxy", genre = "Sci-Fi & Fantasy", skip = 100)
+ )
+
+ assertThat(result.isSuccess).isTrue()
+ assertThat(server.takeRequest().path).isEqualTo(
+ "/catalog/movie/top/search=guardians%20of%20the%20galaxy&genre=Sci-Fi%20%26%20Fantasy&skip=100.json"
+ )
+ assertThat(result.getOrNull()!!.metas.single().name).isEqualTo("Guardians of the Galaxy Vol. 2")
+ }
+
+ @Test
+ fun `meta parses movie details`() = runTest {
+ server.enqueue(MockResponse().setBody(fixture("stremio/fixtures/meta_movie.json")))
+
+ val result = client.fetchMeta(baseUrl(), StremioMediaType.MOVIE, "tt0111161")
+
+ assertThat(result.isSuccess).isTrue()
+ assertThat(server.takeRequest().path).isEqualTo("/meta/movie/tt0111161.json")
+ val meta = result.getOrNull()!!
+ assertThat(meta.name).isEqualTo("The Shawshank Redemption")
+ assertThat(meta.director).containsExactly("Frank Darabont")
+ assertThat(meta.cast).hasSize(3)
+ assertThat(meta.genres).containsExactly("Drama", "Crime").inOrder()
+ assertThat(meta.videos).isEmpty()
+ }
+
+ @Test
+ fun `meta parses series videos`() = runTest {
+ server.enqueue(MockResponse().setBody(fixture("stremio/fixtures/meta_series.json")))
+
+ val result = client.fetchMeta(baseUrl(), StremioMediaType.SERIES, "tt0903747")
+
+ assertThat(result.isSuccess).isTrue()
+ assertThat(server.takeRequest().path).isEqualTo("/meta/series/tt0903747.json")
+ val meta = result.getOrNull()!!
+ assertThat(meta.videos).hasSize(3)
+ assertThat(meta.seasons()).containsExactly(1, 2).inOrder()
+ assertThat(meta.episodes(1)).hasSize(2)
+ assertThat(meta.episodes(1)[1].title).isEqualTo("Cat's in the Bag...")
+ assertThat(meta.episodeVideoId(1, 2)).isEqualTo("tt0903747:1:2")
+ assertThat(meta.director).containsExactly("Vince Gilligan")
+ }
+
+ @Test
+ fun `streams parse direct torrent youtube and external kinds`() = runTest {
+ server.enqueue(MockResponse().setBody(fixture("stremio/fixtures/streams_movie.json")))
+
+ val result = client.fetchStreams(baseUrl(), StremioMediaType.MOVIE, "tt0111161")
+
+ assertThat(result.isSuccess).isTrue()
+ assertThat(server.takeRequest().path).isEqualTo("/stream/movie/tt0111161.json")
+ val streams = result.getOrNull()!!
+ assertThat(streams).hasSize(4)
+ assertThat(streams.map { it.kind }).containsExactly(
+ StremioStreamKind.TORRENT,
+ StremioStreamKind.DIRECT,
+ StremioStreamKind.YOUTUBE,
+ StremioStreamKind.EXTERNAL
+ ).inOrder()
+ val torrent = streams[0]
+ assertThat(torrent.infoHash).isEqualTo("abcdef1234567890abcdef1234567890abcdef12")
+ assertThat(torrent.fileIdx).isEqualTo(3)
+ assertThat(torrent.sources).hasSize(2)
+ assertThat(torrent.behaviorHints?.filename)
+ .isEqualTo("The.Shawshank.Redemption.1994.1080p.BluRay.x264.mkv")
+ assertThat(torrent.behaviorHints?.videoSize).isEqualTo(2198453013L)
+ assertThat(torrent.behaviorHints?.bingeGroup).isEqualTo("torrentio-1080p")
+ val direct = streams[1]
+ assertThat(direct.url).isEqualTo("https://cdn.example.test/movies/shawshank/1080p.mp4")
+ assertThat(direct.behaviorHints?.proxyHeaders?.request?.get("Authorization"))
+ .isEqualTo("Bearer token123")
+ assertThat(streams[2].ytId).isEqualTo("6hB3S9bIaco")
+ assertThat(streams[3].externalUrl).isEqualTo("https://example.test/watch/tt0111161")
+ }
+
+ @Test
+ fun `episode stream requests keep colon ids`() = runTest {
+ server.enqueue(MockResponse().setBody("""{"streams":[]}"""))
+
+ val result = client.fetchStreams(baseUrl(), StremioMediaType.SERIES, "tt0903747:1:2")
+
+ assertThat(result.isSuccess).isTrue()
+ assertThat(server.takeRequest().path).isEqualTo("/stream/series/tt0903747:1:2.json")
+ assertThat(result.getOrNull()).isEmpty()
+ }
+
+ @Test
+ fun `subtitles parse and request extras`() = runTest {
+ server.enqueue(MockResponse().setBody(fixture("stremio/fixtures/subtitles.json")))
+
+ val result = client.fetchSubtitles(
+ baseUrl(),
+ StremioMediaType.MOVIE,
+ "tt0111161",
+ videoHash = "abc123",
+ filename = "The Shawshank Redemption.mkv"
+ )
+
+ assertThat(result.isSuccess).isTrue()
+ assertThat(server.takeRequest().path).isEqualTo(
+ "/subtitles/movie/tt0111161/videoHash=abc123&filename=The%20Shawshank%20Redemption.mkv.json"
+ )
+ val subtitles = result.getOrNull()!!
+ assertThat(subtitles).hasSize(2)
+ assertThat(subtitles.map { it.lang }).containsExactly("eng", "ger").inOrder()
+ }
+
+ @Test
+ fun `http errors surface the status code`() = runTest {
+ server.enqueue(MockResponse().setResponseCode(503).setBody("unavailable"))
+
+ val result = client.fetchManifest(baseUrl())
+
+ assertThat(result.isError).isTrue()
+ assertThat(result.errorMessageOrNull()).contains("503")
+ }
+
+ @Test
+ fun `unparseable responses surface a parse error`() = runTest {
+ server.enqueue(MockResponse().setBody("{ not json"))
+
+ val result = client.fetchManifest(baseUrl())
+
+ assertThat(result.isError).isTrue()
+ assertThat(result.errorMessageOrNull()).contains("parsed")
+ }
+
+ @Test
+ fun `manifest without an id is rejected`() = runTest {
+ server.enqueue(
+ MockResponse().setBody("""{"version":"1.0.0","name":"No Id Addon","resources":["catalog"]}""")
+ )
+
+ val result = client.fetchManifest(baseUrl())
+
+ assertThat(result.isError).isTrue()
+ assertThat(result.errorMessageOrNull()).contains("id")
+ }
+
+ @Test
+ fun `oversized responses are rejected`() = runTest {
+ server.enqueue(
+ MockResponse().setBody("x".repeat((StremioAddonClient.MAX_RESPONSE_BYTES + 1).toInt()))
+ )
+
+ val result = client.fetchManifest(baseUrl())
+
+ assertThat(result.isError).isTrue()
+ assertThat(result.errorMessageOrNull()).contains("too large")
+ }
+
+ @Test
+ fun `invalid addon urls are rejected before any request`() = runTest {
+ val result = client.fetchManifest("not a url")
+
+ assertThat(result.isError).isTrue()
+ assertThat(result.errorMessageOrNull()).contains("not a valid")
+ assertThat(server.requestCount).isEqualTo(0)
+ }
+
+ private fun baseUrl(): String = server.url("/").toString().trimEnd('/')
+
+ private fun fixture(path: String): String {
+ val stream = checkNotNull(javaClass.classLoader?.getResourceAsStream(path)) {
+ "Missing fixture $path"
+ }
+ return stream.use { InputStreamReader(it).readText() }
+ }
+}
diff --git a/data/src/test/java/com/streamvault/data/remote/stremio/StremioAddonUrlTest.kt b/data/src/test/java/com/streamvault/data/remote/stremio/StremioAddonUrlTest.kt
new file mode 100644
index 00000000..83eaf79c
--- /dev/null
+++ b/data/src/test/java/com/streamvault/data/remote/stremio/StremioAddonUrlTest.kt
@@ -0,0 +1,84 @@
+package com.streamvault.data.remote.stremio
+
+import com.google.common.truth.Truth.assertThat
+import com.streamvault.domain.model.stremio.StremioMediaType
+import org.junit.Test
+
+class StremioAddonUrlTest {
+
+ @Test
+ fun `stremio scheme is upgraded and manifest appended`() {
+ val location = StremioAddonUrl.parse("stremio://v3-cinemeta.strem.io")
+ assertThat(location).isNotNull()
+ assertThat(location!!.baseUrl).isEqualTo("https://v3-cinemeta.strem.io")
+ assertThat(location.manifestUrl).isEqualTo("https://v3-cinemeta.strem.io/manifest.json")
+ }
+
+ @Test
+ fun `configured manifest path is preserved`() {
+ val location = StremioAddonUrl.parse("https://torrentio.strem.fun/qualityfilter=720p,av1/manifest.json")
+ assertThat(location).isNotNull()
+ assertThat(location!!.baseUrl).isEqualTo("https://torrentio.strem.fun/qualityfilter=720p,av1")
+ }
+
+ @Test
+ fun `trailing slash and manifest suffix normalize to the same base`() {
+ assertThat(StremioAddonUrl.parse("https://example.test/addon/")!!.baseUrl)
+ .isEqualTo("https://example.test/addon")
+ assertThat(StremioAddonUrl.parse("https://example.test/addon/manifest.json")!!.baseUrl)
+ .isEqualTo("https://example.test/addon")
+ }
+
+ @Test
+ fun `query string is preserved on manifest and endpoint urls`() {
+ val location = StremioAddonUrl.parse("https://example.test/addon/manifest.json?token=abc123")!!
+ assertThat(location.query).isEqualTo("token=abc123")
+ assertThat(location.manifestUrl).isEqualTo("https://example.test/addon/manifest.json?token=abc123")
+ assertThat(location.endpointUrl("/catalog/movie/top.json"))
+ .isEqualTo("https://example.test/addon/catalog/movie/top.json?token=abc123")
+ }
+
+ @Test
+ fun `port is preserved`() {
+ val location = StremioAddonUrl.parse("http://192.168.1.5:7000/manifest.json")
+ assertThat(location).isNotNull()
+ assertThat(location!!.baseUrl).isEqualTo("http://192.168.1.5:7000")
+ }
+
+ @Test
+ fun `invalid urls are rejected`() {
+ assertThat(StremioAddonUrl.parse("")).isNull()
+ assertThat(StremioAddonUrl.parse("v3-cinemeta.strem.io")).isNull()
+ assertThat(StremioAddonUrl.parse("ftp://example.test/manifest.json")).isNull()
+ assertThat(StremioAddonUrl.parse("https:///manifest.json")).isNull()
+ }
+
+ @Test
+ fun `catalog path encodes extra values`() {
+ val path = StremioAddonUrl.catalogPath(
+ StremioMediaType.MOVIE,
+ "top",
+ listOf("genre" to "Sci-Fi & Fantasy", "skip" to "100")
+ )
+ assertThat(path).isEqualTo("/catalog/movie/top/genre=Sci-Fi%20%26%20Fantasy&skip=100.json")
+ }
+
+ @Test
+ fun `meta and stream paths keep colon ids`() {
+ assertThat(StremioAddonUrl.metaPath(StremioMediaType.SERIES, "tt0903747:1:2"))
+ .isEqualTo("/meta/series/tt0903747:1:2.json")
+ assertThat(StremioAddonUrl.streamPath(StremioMediaType.SERIES, "tt0903747:1:2"))
+ .isEqualTo("/stream/series/tt0903747:1:2.json")
+ }
+
+ @Test
+ fun `subtitle path encodes filename extras`() {
+ val path = StremioAddonUrl.subtitlePath(
+ StremioMediaType.MOVIE,
+ "tt0111161",
+ listOf("videoHash" to "abc", "filename" to "The Shawshank Redemption.mkv")
+ )
+ assertThat(path)
+ .isEqualTo("/subtitles/movie/tt0111161/videoHash=abc&filename=The%20Shawshank%20Redemption.mkv.json")
+ }
+}
diff --git a/data/src/test/java/com/streamvault/data/repository/StremioAddonRepositoryImplTest.kt b/data/src/test/java/com/streamvault/data/repository/StremioAddonRepositoryImplTest.kt
new file mode 100644
index 00000000..0d58dc51
--- /dev/null
+++ b/data/src/test/java/com/streamvault/data/repository/StremioAddonRepositoryImplTest.kt
@@ -0,0 +1,268 @@
+package com.streamvault.data.repository
+
+import com.google.common.truth.Truth.assertThat
+import com.streamvault.data.local.dao.StremioAddonDao
+import com.streamvault.data.local.entity.StremioAddonEntity
+import com.streamvault.data.remote.stremio.StremioAddonClient
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.asStateFlow
+import kotlinx.coroutines.test.runTest
+import kotlinx.serialization.json.Json
+import okhttp3.OkHttpClient
+import okhttp3.mockwebserver.MockResponse
+import okhttp3.mockwebserver.MockWebServer
+import org.junit.After
+import org.junit.Before
+import org.junit.Test
+
+class StremioAddonRepositoryImplTest {
+
+ private lateinit var server: MockWebServer
+ private lateinit var dao: FakeStremioAddonDao
+ private lateinit var repository: StremioAddonRepositoryImpl
+
+ @Before
+ fun setUp() {
+ server = MockWebServer()
+ server.start()
+ dao = FakeStremioAddonDao()
+ repository = StremioAddonRepositoryImpl(
+ dao = dao,
+ client = StremioAddonClient(
+ okHttpClient = OkHttpClient(),
+ json = Json {
+ ignoreUnknownKeys = true
+ isLenient = true
+ explicitNulls = false
+ coerceInputValues = true
+ }
+ )
+ )
+ }
+
+ @After
+ fun tearDown() {
+ server.shutdown()
+ }
+
+ @Test
+ fun `install stores the normalized manifest snapshot`() = runTest {
+ server.enqueue(manifestResponse("com.linvo.cinemeta", "Cinemeta"))
+ val baseUrl = "${baseUrl()}/addon-a"
+
+ val result = repository.installAddon(baseUrl)
+
+ assertThat(result.isSuccess).isTrue()
+ val addon = result.getOrNull()!!
+ assertThat(addon.installUrl).isEqualTo("$baseUrl/manifest.json")
+ assertThat(addon.manifestId).isEqualTo("com.linvo.cinemeta")
+ assertThat(addon.name).isEqualTo("Cinemeta")
+ assertThat(addon.version).isEqualTo("1.0.0")
+ assertThat(addon.enabled).isTrue()
+ assertThat(addon.sortOrder).isEqualTo(0)
+ assertThat(addon.manifestJson).contains("com.linvo.cinemeta")
+ assertThat(addon.isCatalogEnabled("movie:top")).isTrue()
+ assertThat(dao.getAll()).hasSize(1)
+ }
+
+ @Test
+ fun `duplicate installs are rejected`() = runTest {
+ server.enqueue(manifestResponse("com.linvo.cinemeta", "Cinemeta"))
+ server.enqueue(manifestResponse("com.linvo.cinemeta", "Cinemeta"))
+ val baseUrl = "${baseUrl()}/addon-a"
+
+ assertThat(repository.installAddon(baseUrl).isSuccess).isTrue()
+ val duplicate = repository.installAddon(baseUrl)
+
+ assertThat(duplicate.isError).isTrue()
+ assertThat(duplicate.errorMessageOrNull()).contains("already installed")
+ assertThat(dao.getAll()).hasSize(1)
+ }
+
+ @Test
+ fun `installs append in sort order`() = runTest {
+ server.enqueue(manifestResponse("com.one", "One"))
+ server.enqueue(manifestResponse("com.two", "Two"))
+
+ repository.installAddon("${baseUrl()}/one")
+ repository.installAddon("${baseUrl()}/two")
+
+ val addons = dao.getAll()
+ assertThat(addons.map { it.sortOrder }).containsExactly(0, 1).inOrder()
+ assertThat(addons.map { it.name }).containsExactly("One", "Two").inOrder()
+ }
+
+ @Test
+ fun `manifest failures surface the addon error`() = runTest {
+ server.enqueue(MockResponse().setResponseCode(500).setBody("boom"))
+
+ val result = repository.installAddon("${baseUrl()}/broken")
+
+ assertThat(result.isError).isTrue()
+ assertThat(result.errorMessageOrNull()).contains("500")
+ }
+
+ @Test
+ fun `manifest without an id is rejected`() = runTest {
+ server.enqueue(MockResponse().setBody("""{"version":"1.0.0","name":"No Id","resources":["catalog"]}"""))
+
+ val result = repository.installAddon("${baseUrl()}/no-id")
+
+ assertThat(result.isError).isTrue()
+ assertThat(result.errorMessageOrNull()).contains("id")
+ assertThat(dao.getAll()).isEmpty()
+ }
+
+ @Test
+ fun `addons that require configuration are rejected`() = runTest {
+ server.enqueue(
+ MockResponse().setBody(
+ """
+ {
+ "id": "com.configured.addon",
+ "version": "1.0.0",
+ "name": "Configured Addon",
+ "resources": ["stream"],
+ "behaviorHints": {"configurationRequired": true}
+ }
+ """.trimIndent()
+ )
+ )
+
+ val result = repository.installAddon("${baseUrl()}/configured")
+
+ assertThat(result.isError).isTrue()
+ assertThat(result.errorMessageOrNull()).contains("requires configuration")
+ assertThat(dao.getAll()).isEmpty()
+ }
+
+ @Test
+ fun `invalid install urls never reach the network`() = runTest {
+ val result = repository.installAddon("not a url")
+
+ assertThat(result.isError).isTrue()
+ assertThat(server.requestCount).isEqualTo(0)
+ }
+
+ @Test
+ fun `enable remove and catalog settings persist`() = runTest {
+ server.enqueue(manifestResponse("com.one", "One"))
+ val addon = repository.installAddon("${baseUrl()}/one").getOrNull()!!
+
+ assertThat(repository.setAddonEnabled(addon.id, false).isSuccess).isTrue()
+ assertThat(dao.getById(addon.id)!!.enabled).isFalse()
+
+ assertThat(repository.setCatalogEnabled(addon.id, "movie:top", false).isSuccess).isTrue()
+ val updated = repository.getAddon(addon.id)!!
+ assertThat(updated.isCatalogEnabled("movie:top")).isFalse()
+ assertThat(updated.isCatalogEnabled("series:top")).isTrue()
+
+ assertThat(repository.setCatalogEnabled(addon.id, "movie:top", true).isSuccess).isTrue()
+ assertThat(repository.getAddon(addon.id)!!.isCatalogEnabled("movie:top")).isTrue()
+
+ assertThat(repository.removeAddon(addon.id).isSuccess).isTrue()
+ assertThat(repository.getAddon(addon.id)).isNull()
+ }
+
+ @Test
+ fun `move reorders addons by offset and clamps at the edges`() = runTest {
+ server.enqueue(manifestResponse("com.one", "One"))
+ server.enqueue(manifestResponse("com.two", "Two"))
+ server.enqueue(manifestResponse("com.three", "Three"))
+ val one = repository.installAddon("${baseUrl()}/one").getOrNull()!!
+ repository.installAddon("${baseUrl()}/two")
+ repository.installAddon("${baseUrl()}/three")
+
+ assertThat(repository.moveAddon(one.id, 1).isSuccess).isTrue()
+ assertThat(dao.getAll().map { it.name }).containsExactly("Two", "One", "Three").inOrder()
+ assertThat(dao.getAll().map { it.sortOrder }).containsExactly(0, 1, 2).inOrder()
+
+ assertThat(repository.moveAddon(one.id, -5).isSuccess).isTrue()
+ assertThat(dao.getAll().map { it.name }).containsExactly("One", "Two", "Three").inOrder()
+
+ assertThat(repository.moveAddon(9999L, 1).isError).isTrue()
+ }
+
+ @Test
+ fun `catalog settings codec ignores junk and round-trips`() {
+ assertThat(StremioCatalogSettingsCodec.decode("")).isEmpty()
+ assertThat(StremioCatalogSettingsCodec.decode("not json")).isEmpty()
+ assertThat(StremioCatalogSettingsCodec.encode(emptyMap())).isEmpty()
+ val encoded = StremioCatalogSettingsCodec.encode(mapOf("movie:top" to false, "series:top" to true))
+ assertThat(StremioCatalogSettingsCodec.decode(encoded))
+ .containsExactly("movie:top", false, "series:top", true)
+ }
+
+ private fun baseUrl(): String = server.url("/").toString().trimEnd('/')
+
+ private fun manifestResponse(id: String, name: String): MockResponse =
+ MockResponse().setBody(
+ """
+ {
+ "id": "$id",
+ "version": "1.0.0",
+ "name": "$name",
+ "resources": ["catalog", "meta", "stream"],
+ "types": ["movie", "series"],
+ "catalogs": [
+ {"type": "movie", "id": "top", "name": "Popular", "extra": ["search", "skip"]}
+ ]
+ }
+ """.trimIndent()
+ )
+}
+
+private class FakeStremioAddonDao : StremioAddonDao {
+ private val addons = MutableStateFlow<List<StremioAddonEntity>>(emptyList())
+ private var nextId = 1L
+
+ override fun observeAll(): Flow<List<StremioAddonEntity>> = addons.asStateFlow()
+
+ override suspend fun getAll(): List<StremioAddonEntity> =
+ addons.value.sortedWith(compareBy({ it.sortOrder }, { it.id }))
+
+ override suspend fun getById(id: Long): StremioAddonEntity? =
+ addons.value.firstOrNull { it.id == id }
+
+ override suspend fun getByInstallUrl(installUrl: String): StremioAddonEntity? =
+ addons.value.firstOrNull { it.installUrl == installUrl }
+
+ override suspend fun maxSortOrder(): Int = addons.value.maxOfOrNull { it.sortOrder } ?: -1
+
+ override suspend fun insert(entity: StremioAddonEntity): Long {
+ val id = nextId++
+ addons.value = addons.value + entity.copy(id = id)
+ return id
+ }
+
+ override suspend fun setEnabled(id: Long, enabled: Boolean, updatedAt: Long) {
+ addons.value = addons.value.map {
+ if (it.id == id) it.copy(enabled = enabled, updatedAt = updatedAt) else it
+ }
+ }
+
+ override suspend fun setSortOrder(id: Long, sortOrder: Int, updatedAt: Long) {
+ addons.value = addons.value.map {
+ if (it.id == id) it.copy(sortOrder = sortOrder, updatedAt = updatedAt) else it
+ }
+ }
+
+ override suspend fun setCatalogSettings(id: Long, catalogSettingsJson: String, updatedAt: Long) {
+ addons.value = addons.value.map {
+ if (it.id == id) it.copy(catalogSettingsJson = catalogSettingsJson, updatedAt = updatedAt) else it
+ }
+ }
+
+ override suspend fun delete(id: Long) {
+ addons.value = addons.value.filterNot { it.id == id }
+ }
+
+ override suspend fun applyOrder(positions: List<Pair<Long, Int>>, updatedAt: Long) {
+ val byId = positions.toMap()
+ addons.value = addons.value.map { entity ->
+ byId[entity.id]?.let { position -> entity.copy(sortOrder = position, updatedAt = updatedAt) }
+ ?: entity
+ }
+ }
+}
diff --git a/data/src/test/resources/stremio/fixtures/catalog_movies_top.json b/data/src/test/resources/stremio/fixtures/catalog_movies_top.json
new file mode 100644
index 00000000..7970bb6d
--- /dev/null
+++ b/data/src/test/resources/stremio/fixtures/catalog_movies_top.json
@@ -0,0 +1,33 @@
+{
+ "metas": [
+ {
+ "id": "tt0111161",
+ "type": "movie",
+ "name": "The Shawshank Redemption",
+ "poster": "https://images.metahub.space/poster/medium/tt0111161/img",
+ "posterShape": "regular",
+ "background": "https://images.metahub.space/background/medium/tt0111161/img",
+ "logo": "https://images.metahub.space/logo/medium/tt0111161/img",
+ "description": "Two imprisoned men bond over a number of years, finding solace and eventual redemption.",
+ "releaseInfo": "1994",
+ "imdbRating": "9.3",
+ "genres": ["Drama"],
+ "runtime": "142 min",
+ "appOnlyField": { "nested": true }
+ },
+ {
+ "id": "tt0068646",
+ "type": "movie",
+ "name": "The Godfather",
+ "releaseInfo": "1972",
+ "imdbRating": "9.2"
+ },
+ {
+ "id": "",
+ "type": "movie",
+ "name": "Broken entry without an id"
+ }
+ ],
+ "hasMore": true,
+ "cacheMaxAge": 3600
+}
diff --git a/data/src/test/resources/stremio/fixtures/catalog_search.json b/data/src/test/resources/stremio/fixtures/catalog_search.json
new file mode 100644
index 00000000..43ce5525
--- /dev/null
+++ b/data/src/test/resources/stremio/fixtures/catalog_search.json
@@ -0,0 +1,12 @@
+{
+ "metas": [
+ {
+ "id": "tt3896198",
+ "type": "movie",
+ "name": "Guardians of the Galaxy Vol. 2",
+ "releaseInfo": "2017",
+ "imdbRating": "7.6"
+ }
+ ],
+ "hasMore": false
+}
diff --git a/data/src/test/resources/stremio/fixtures/cinemeta_manifest.json b/data/src/test/resources/stremio/fixtures/cinemeta_manifest.json
new file mode 100644
index 00000000..49c04ebd
--- /dev/null
+++ b/data/src/test/resources/stremio/fixtures/cinemeta_manifest.json
@@ -0,0 +1,42 @@
+{
+ "id": "com.linvo.cinemeta",
+ "version": "3.0.14",
+ "name": "Cinemeta",
+ "description": "The official addon for movie and series catalogs, powered by TMDB and IMDB.",
+ "logo": "https://www.stremio.com/website/stremio-logo-small.png",
+ "background": "https://images.metahub.space/background/tt0111161/big/img",
+ "types": ["movie", "series"],
+ "resources": [
+ "catalog",
+ {
+ "name": "meta",
+ "types": ["movie", "series"],
+ "idPrefixes": ["tt"]
+ },
+ "stream",
+ "subtitles"
+ ],
+ "catalogs": [
+ {
+ "type": "movie",
+ "id": "top",
+ "name": "Popular",
+ "genres": ["Action", "Comedy"],
+ "extra": [
+ { "name": "search", "isRequired": false },
+ { "name": "genre", "options": ["Action", "Comedy", "Drama"] },
+ { "name": "skip" }
+ ]
+ },
+ {
+ "type": "series",
+ "id": "top",
+ "name": "Popular",
+ "extra": ["search", "skip"]
+ }
+ ],
+ "idPrefixes": ["tt"],
+ "behaviorHints": {
+ "configurable": false
+ }
+}
diff --git a/data/src/test/resources/stremio/fixtures/meta_movie.json b/data/src/test/resources/stremio/fixtures/meta_movie.json
new file mode 100644
index 00000000..3cda7b21
--- /dev/null
+++ b/data/src/test/resources/stremio/fixtures/meta_movie.json
@@ -0,0 +1,19 @@
+{
+ "meta": {
+ "id": "tt0111161",
+ "type": "movie",
+ "name": "The Shawshank Redemption",
+ "poster": "https://images.metahub.space/poster/medium/tt0111161/img",
+ "background": "https://images.metahub.space/background/medium/tt0111161/img",
+ "logo": "https://images.metahub.space/logo/medium/tt0111161/img",
+ "description": "Two imprisoned men bond over a number of years, finding solace and eventual redemption.",
+ "releaseInfo": "1994",
+ "imdbRating": "9.3",
+ "genres": ["Drama", "Crime"],
+ "runtime": "142 min",
+ "cast": ["Tim Robbins", "Morgan Freeman", "Bob Gunton"],
+ "director": "Frank Darabont",
+ "country": "United States",
+ "awards": "Nominated for 7 Oscars"
+ }
+}
diff --git a/data/src/test/resources/stremio/fixtures/meta_series.json b/data/src/test/resources/stremio/fixtures/meta_series.json
new file mode 100644
index 00000000..66b98c58
--- /dev/null
+++ b/data/src/test/resources/stremio/fixtures/meta_series.json
@@ -0,0 +1,40 @@
+{
+ "meta": {
+ "id": "tt0903747",
+ "type": "series",
+ "name": "Breaking Bad",
+ "releaseInfo": "2008-2013",
+ "genres": ["Crime", "Drama", "Thriller"],
+ "cast": ["Bryan Cranston", "Aaron Paul"],
+ "director": ["Vince Gilligan"],
+ "videos": [
+ {
+ "id": "tt0903747:1:1",
+ "name": "Pilot",
+ "season": 1,
+ "episode": 1,
+ "released": "2008-01-20T05:00:00.000Z",
+ "thumbnail": "https://images.metahub.space/still/medium/tt0959621/img",
+ "overview": "Diagnosed with terminal lung cancer, a chemistry teacher starts cooking meth."
+ },
+ {
+ "id": "tt0903747:1:2",
+ "title": "Cat's in the Bag...",
+ "season": 1,
+ "episode": 2,
+ "released": "2008-01-27T05:00:00.000Z"
+ },
+ {
+ "id": "tt0903747:2:1",
+ "name": "Seven Thirty-Seven",
+ "season": 2,
+ "episode": 1
+ },
+ {
+ "name": "Specials entry without an id",
+ "season": 0,
+ "episode": 1
+ }
+ ]
+ }
+}
diff --git a/data/src/test/resources/stremio/fixtures/streams_movie.json b/data/src/test/resources/stremio/fixtures/streams_movie.json
new file mode 100644
index 00000000..e59b39ec
--- /dev/null
+++ b/data/src/test/resources/stremio/fixtures/streams_movie.json
@@ -0,0 +1,45 @@
+{
+ "streams": [
+ {
+ "name": "Torrentio\n1080p",
+ "title": "The Shawshank Redemption 1994 1080p BluRay x264",
+ "infoHash": "ABCDEF1234567890ABCDEF1234567890ABCDEF12",
+ "fileIdx": 3,
+ "sources": [
+ "tracker:udp://tracker.opentrackr.org:1337/announce",
+ "dht:abcdef1234567890abcdef1234567890abcdef12"
+ ],
+ "behaviorHints": {
+ "bingeGroup": "torrentio-1080p",
+ "filename": "The.Shawshank.Redemption.1994.1080p.BluRay.x264.mkv",
+ "videoSize": 2198453013,
+ "notWebReady": false
+ }
+ },
+ {
+ "name": "Premium",
+ "title": "1080p direct",
+ "url": "https://cdn.example.test/movies/shawshank/1080p.mp4",
+ "behaviorHints": {
+ "proxyHeaders": {
+ "request": {
+ "User-Agent": "Stremio",
+ "Authorization": "Bearer token123"
+ },
+ "response": {}
+ }
+ }
+ },
+ {
+ "name": "YouTube Trailer",
+ "ytId": "6hB3S9bIaco"
+ },
+ {
+ "name": "Open in browser",
+ "externalUrl": "https://example.test/watch/tt0111161"
+ },
+ {
+ "name": "Junk entry with no source"
+ }
+ ]
+}
diff --git a/data/src/test/resources/stremio/fixtures/subtitles.json b/data/src/test/resources/stremio/fixtures/subtitles.json
new file mode 100644
index 00000000..248042c6
--- /dev/null
+++ b/data/src/test/resources/stremio/fixtures/subtitles.json
@@ -0,0 +1,22 @@
+{
+ "subtitles": [
+ {
+ "id": "sub-1",
+ "url": "https://subs.example.test/srt/tt0111161.en.srt",
+ "lang": "eng"
+ },
+ {
+ "id": "sub-2",
+ "url": "https://subs.example.test/srt/tt0111161.ger.srt",
+ "lang": "ger"
+ },
+ {
+ "id": "sub-3",
+ "url": "",
+ "lang": "fra"
+ },
+ {
+ "lang": "spa"
+ }
+ ]
+}
diff --git a/docs/STREMIO_ADDONS_HANDOFF.md b/docs/STREMIO_ADDONS_HANDOFF.md
new file mode 100644
index 00000000..87642cc5
--- /dev/null
+++ b/docs/STREMIO_ADDONS_HANDOFF.md
@@ -0,0 +1,46 @@
+# Stremio addons — continuation handoff
+
+Review update (2026-10-11): read `STREMIO_ADDONS_PLAN_REVIEW.md` before continuing.
+The implementation plan records the correct 78→79 migration. Follow-up work fixed
+the missing `StremioManifestResource` test import and rejects manifests marked
+`configurationRequired`; the latter has repository test coverage. Fresh unit and
+emulator smoke results are below. The review still tracks cross-addon routing,
+playback identity/privacy, subtitles, parental-control, and torrent-contract work.
+
+Copy this whole block into a new session working in the worktree.
+
+---
+
+Continue the StreamVault Stremio addon feature. Work only in:
+`D:\antigravity-scratch\iptv-player\.worktrees\stremio-addons` (branch `feature/stremio-addons`, based on `develop` @ 540ec30c). Read `docs/STREMIO_ADDONS_IMPLEMENTATION_PLAN.md` first. P1 was committed after its verification; check the current branch history for the commit.
+
+Important: this branch's Room DB version is 78 (not 81 — that number in the plan belongs to the `codex/stalker-sync-improvements` branch). The migration added here is 78→79.
+
+## Done and verified
+
+- P0 (protocol client): `data/src/main/java/com/streamvault/data/remote/stremio/` (`StremioAddonClient`, `StremioAddonUrl`, `StremioAddonDtos`, `StremioMapper`) + domain models `domain/src/main/java/com/streamvault/domain/model/stremio/`; 22 unit tests green.
+- P1 data layer: `StremioAddonEntity`, `StremioAddonDao`, `FeatureMigrationsV78To79`, `StremioAddonRepository` (domain) + `StremioAddonRepositoryImpl`, `StremioCatalogSettingsCodec`, `StremioAddonClient.fetchManifestSnapshot/parseManifest`; DI wired in `DatabaseModule`/`RepositoryModule`; schema export `data/schemas/com.streamvault.data.local.StreamVaultDatabase/79.json`; `StremioAddonRepositoryImplTest` now has 10 passing tests including configuration-required rejection; `StreamVaultDatabaseMigrationTest` — 43 tests green on emulator-5554 (API 36), including the new `migrate78To79_...` test.
+- P1 verification update: `:app:testDebugUnitTest` passed 163 tests; `:feature:stremio:testDebugUnitTest` passed 6; focused data tests passed 34 (`StremioAddonClientTest` 13, `StremioAddonUrlTest` 9, `StremioAddonRepositoryImplTest` 10, migration registry 2). `:app:assembleDebug` succeeded. A broader data run hit unrelated download mock-server and Google Drive backup test failures; the focused Stremio rerun passed.
+- Emulator smoke: installed `com.streamvault.app.debug` on `Television_1080p` (API 36, temporary read-only session), opened Addons, and installed `https://v3-cinemeta.strem.io/manifest.json`. Screenshot: `addons.png`. `Television_4K_2` already has a version-81 database, so this version-79 branch crashes there on the unsupported 81→79 downgrade; its data was left untouched.
+- P1 nav/UI: `AppDestination.Addons`; `AppTopLevelDestination.ADDONS`; route codec/adapters/startup resolver/shell nav (`Icons.Default.Extension`, `R.string.nav_addons`); new module `feature:stremio` (build.gradle.kts, `StremioRoutePatterns.ADDONS="addons"`, `registerStremioGraph`, `StremioScaffoldContent`, `AddonsViewModel`, `AddonsScreen`, `AddonsViewModelTest`); wired in `AppNavHost` via `appStremioScaffold`; settings exhaustive `when`s updated; `nav_addons` added to app/settings strings and 25 app locale `strings_missing.xml` files. Unit and emulator smoke validation are complete.
+
+## Immediate next steps
+
+1. P1 unit verification, emulator install smoke, and the reviewed P1 commit are
+ complete; see the results above.
+2. Design cross-addon resource resolution and a compatible stable playback
+ identity before beginning P2/P3, following `STREMIO_ADDONS_PLAN_REVIEW.md`.
+
+## Environment gotchas
+
+- Windows PowerShell; use `.\gradlew.bat`. Long builds: run detached `Start-Process cmd.exe -ArgumentList "/c",".\gradlew.bat ... > log 2>&1" -PassThru -NoNewWindow` and poll the log — don't block in foreground >2 min.
+- Worktree has its own `local.properties` (sdk.dir=C:\Users\David\AppData\Local\Android\Sdk).
+- Emulator `emulator-5554` (API 36) is connected; instrumented: `:data:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.streamvault.data.local.StreamVaultDatabaseMigrationTest`.
+- `Television_4K_2` emulator may hold database version 81 from another branch; use a clean/read-only emulator profile for this 78→79 branch smoke test rather than clearing shared app data.
+- Data module uses OkHttp + kotlinx.serialization DTOs; domain has no serialization — keep that split.
+- Cosmetic compiler warning: `@StringRes` on data-class property (KT-73255) in `AddonsViewModel` — can switch to `@param:StringRes`.
+- Do not reuse provider URL policies for addon streams (relevant in P4).
+
+## Remaining phases (details in the plan doc)
+
+P2 catalog browsing UI, P3 meta + stream picker, P4 playback integration (+ magnet cast guard), P5 subtitles, P6 torrent companion plugin, P7 polish. Do not start until P1 is verified and committed.
diff --git a/docs/STREMIO_ADDONS_IMPLEMENTATION_PLAN.md b/docs/STREMIO_ADDONS_IMPLEMENTATION_PLAN.md
new file mode 100644
index 00000000..867547b5
--- /dev/null
+++ b/docs/STREMIO_ADDONS_IMPLEMENTATION_PLAN.md
@@ -0,0 +1,343 @@
+# Stremio addon support implementation plan
+
+Status: P0 and P1 implemented; P1 unit and emulator smoke verification complete. Plan reviewed
+2026-10-11; see `STREMIO_ADDONS_PLAN_REVIEW.md` for required additions and gates.
+Prepared 2026-10-10 against source
+revision `540ec30c` (`develop`), branch `feature/stremio-addons`, worktree
+`.worktrees/stremio-addons`.
+
+Goal: StreamVault can install Stremio addons by URL and use them natively — browse
+catalogs, open meta/details, choose from a stream list, play direct and torrent-backed
+streams, and load addon subtitles. Torrent playback is delivered by a companion
+StreamVault plugin APK so the main application and repository never ship a BitTorrent
+engine.
+
+## Outcome and scope
+
+Deliver a first-class "Addons" surface in StreamVault:
+
+- Install an addon by pasting its manifest URL or a `stremio://` install link.
+- Manage installed addons (enable/disable, remove, reorder, catalog selection).
+- Browse catalog rows per addon with pagination, genre filters, and catalog search.
+- Open movie/series meta pages for addon items (poster, background, description,
+ cast, release info, seasons/episodes).
+- Pick from the addon's stream list ("stream picker"), showing name/title/quality
+ hints exactly as the addon returns them.
+- Play direct (http/https, including debrid-resolved) streams through the existing
+ player pipeline, with resume and history.
+- Load addon-provided subtitles into playback.
+- When a torrent stream (infoHash/magnet) is selected and the companion torrent
+ plugin is installed, resolve it through the plugin into loopback playback.
+ Without the plugin, show an explicit "torrent playback requires the StreamVault
+ Torrent plugin" state instead of failing playback.
+
+V1 scope note: direct/debrid streams are the phase-1 usable product. Torrent
+playback is phase-gated (P6) behind the companion plugin and a separate repository.
+
+Non-goals for this plan:
+
+- Stremio account, sync, or Trakt integration.
+- YouTube (`ytId`) stream playback.
+- `externalUrl` / opener streams, NZB, or other non-media endpoints.
+- A web-based addon configuration editor. V1 accepts already-configured manifest
+ URLs (users configure addon URLs in their browser, then paste the result).
+- Addon content inside the Live TV, Movies, Series, or Guide tabs in v1. Stremio
+ content lives in its own destination; Home/global-search integration is a P7
+ option.
+- Casting torrent-backed streams. See AD-6.
+
+## Why the existing plugin M3U path is not enough
+
+The plugin API can already surface a companion APK as a provider
+(`MSG_GET_PROVIDER_URL`, `StreamVaultPluginManager.kt:661`) and can prepare playback
+URLs (`MSG_PREPARE_PLAYBACK`, `StreamVaultPluginManager.kt:481`), but it cannot
+produce the Stremio experience:
+
+- The M3U importer flattens everything into channels/movies/series rows with a
+ single stream URL. Plugin providers are additionally forced to live-only
+ classification (`m3uVodClassificationEnabled = false` reset at
+ `StreamVaultPluginManager.kt:700`; importer treats entries as LIVE at
+ `SyncManagerM3uImporter.kt:240`).
+- Stremio's model is one meta to many streams, with user selection at play time.
+ No catalog rows, meta pages, or stream-picker UI exist in StreamVault's catalog
+ surfaces (`feature/catalog/.../presentation`).
+- A plugin cannot inject UI into the host. Only its own configuration Activity.
+- Sync-based ingestion is the wrong data flow: Stremio catalogs are remote,
+ dynamic (IMDB-id keyed), paginated, and change per request. They must not be
+ copied into the synced provider catalog tables.
+
+Conclusion: the host application must become the Stremio addon client. The plugin
+boundary is kept only where it is genuinely needed — torrent resolution — using the
+existing `playback.prepare` capability with a `magnet:` scheme (see AD-3).
+
+## Stremio addon protocol summary (implementation-relevant)
+
+Transport: plain HTTP(S) JSON endpoints under the addon base URL.
+
+- Manifest: `GET {base}/manifest.json` → `id`, `version`, `name`, `description`,
+ `logo`, `background`, `resources` (e.g.
+ `["catalog","meta","stream","subtitles"]`), `types` (`movie`, `series`,
+ `channel`, `tv`), `catalogs` (`type`, `id`, `name`, optional `extra`,
+ `genres`), `idPrefixes` (e.g. `["tt"]`), `behaviorHints`
+ (`configurable`, `configurationRequired`).
+- Catalog: `GET {base}/catalog/{type}/{id}.json`, with extras:
+ `/catalog/{type}/{id}/skip={n}.json`, `/genre={genre}.json`,
+ `/search={query}.json`. Response: `metas` array of meta previews plus optional
+ `hasMore`.
+- Meta: `GET {base}/meta/{type}/{id}.json` → `meta` with full detail; series meta
+ carries `videos` (seasons/episodes, id format `tt1234:1:2`).
+- Stream: `GET {base}/stream/{type}/{id}.json` → `streams` array. A stream is one
+ of: `url` (http/https direct, debrid addons use this), `infoHash` (+ optional
+ `fileIdx`, tracker `sources`), `ytId`, `externalUrl`. Optional `name`, `title`,
+ `description`, `behaviorHints` (`notWebReady`, `bingeGroup`, `filename`,
+ `videoSize`, `proxyHeaders`).
+- Subtitles: `GET {base}/subtitles/{type}/{id}.json` (plus optional
+ `/videoHash=...`/`/filename=...` extras) → `subtitles` array with `id`, `url`,
+ `lang` (3-letter codes).
+- Install links: `stremio://host/path/manifest.json` is an install alias for the
+ corresponding `https://` manifest URL. Many addons are configured by query
+ parameters, so the "install URL" is the whole configured manifest URL and must
+ be stored verbatim (minus the scheme rewrite).
+
+Compatibility notes for the client:
+
+- Unknown fields anywhere must be ignored (forward compatibility).
+- `resources` may be objects with per-resource `types`/`idPrefixes`; catalog
+ entries may each declare their own `extra`.
+- Missing `idPrefixes` means the addon handles all ids of its declared types.
+- Long catalog/meta responses can be large; keep timeouts and page sizes bounded.
+
+## Architecture decisions
+
+### AD-1: Host-native Stremio addon client
+
+The host implements the protocol directly (HTTP + kotlinx.serialization + OkHttp,
+following existing data-module network client conventions and the Hilt `Json`
+config in `app/.../di/NetworkModule.kt`). Addons are ordinary HTTP resources; no
+plugin or WebView is required. This is the only way to get native catalog/meta/
+stream-picker UX in the host, and it keeps the plugin contract untouched for
+P0–P5.
+
+### AD-2: Separate content store, not a provider type
+
+Stremio addons are not `ProviderType` entries and do not run through provider sync.
+New Room table `stremio_addons` (P1) stores install records; catalogs/meta/streams
+are fetched on demand (bounded in-memory cache per session; a persistent response
+cache is explicitly deferred). This avoids polluting provider-scoped catalog DAOs,
+`ProviderSnapshot` assumptions, and the sync pipeline. `LegacyProvider`/
+`ProviderSnapshot` (`domain/.../model/Provider.kt`, `ProviderConfiguration.kt`)
+are untouched by this feature.
+
+### AD-3: Torrent playback via companion plugin, existing IPC
+
+The plugin IPC already supports this without contract changes:
+
+- `preparePlaybackStreamInfo` accepts any non-blank URL; a `magnet:` URI has no
+ host, so scheme-only ownership applies (`PluginPlaybackRouting.kt:37-41`). A
+ plugin declaring `playbackUrlSchemes: ["magnet"]` receives
+ `MSG_PREPARE_PLAYBACK` and can return `output_url` (an http loopback proxy),
+ `stream_type`, and headers (`applyPlaybackPreparationResponse`,
+ `StreamVaultPluginManager.kt:553`).
+- What blocks magnet today is only ingress: `StreamEntryUrlPolicy` /
+ `UrlSecurityPolicy` allowlists (http, https, rtsp, rtsps, rtmp, file, content)
+ reject `magnet:` before playback. Addon streams bypass those provider-path
+ policies and get their own ingress policy (AD-5).
+
+Decision: the torrent engine (libtorrent4j or equivalent JNI) lives in a separate
+companion APK in its own repository, not in this repo or the main APK. The host
+learns nothing about torrents beyond "a `magnet:` URL may be resolved by an
+enabled plugin".
+
+### AD-4: New top-level "Addons" destination
+
+Add `AppDestination.Addons`, `AppTopLevelDestination.ADDONS` ("addons",
+`AppLandingDestination.ADDONS`), route constant, shell nav item, and startup
+landing mapping. Users can reorder/hide it like existing tabs
+(`AppTopLevelDestination.defaultOrder`), and redirect startup to it. The addon
+manager UI is part of the Addons surface, not the APK Plugins screen; the torrent
+plugin is still managed as an APK plugin under Plugins.
+Files: `domain/.../model/AppTopLevelDestination.kt`,
+`domain/.../model/AppLandingDestination.kt`,
+`app/.../navigation/AppRouteCodec.kt`, `app/.../navigation/AppNavigationAdapters.kt`,
+`app/.../ui/components/shell/AppShellNavigation.kt`,
+`app/.../navigation/StartupNavigationResolver.kt`, `app/.../navigation/AppNavHost.kt`.
+
+### AD-5: Dedicated addon-stream ingress policy
+
+Do not reuse provider URL policy. Introduce a Stremio-specific validation:
+
+- Playable now: `http`, `https`, `magnet` (magnet only resolvable with the torrent
+ plugin enabled).
+- Recognized but unsupported: `ytId`, `externalUrl`, `nzbUrl` → show a clear
+ "not supported" row state in the picker, never a broken player start.
+- Everything else: rejected.
+Also sanitize poster/background/logo URLs (https preferred), bound response sizes,
+and never forward addon-supplied headers to non-addon hosts.
+
+### AD-6: Cast and external-playback stance
+
+- `magnet:` streams are never castable. Add an explicit guard in
+ `CastMediaRequestFactory` (`feature/playback/.../cast/`) so an unresolved magnet
+ can never reach a receiver; the picker hides the Cast action for them.
+- After plugin resolution the URL is `http://127.0.0.1:<port>/...`; the existing
+ cast rewrite path (`cast.rewriteUrl` with `LOCAL_URI` reason) already handles
+ loopback URLs — without a cast-capable plugin the cast attempt fails as
+ `UNSUPPORTED`, which is acceptable and should surface a clear message.
+- External player handoff: only resolved http(s) URLs are offered; the external
+ launcher allowlist already excludes `magnet`.
+
+### AD-7: Phase gating — direct/debrid first, torrents at P6
+
+P0–P5 ship a complete, useful product for addons that return direct URLs
+(debrid-backed Torrentio, catalog addons, etc.). P6 adds the torrent plugin and
+the magnet flow end to end. This keeps legal exposure and schedule risk out of the
+main repository for as long as possible.
+
+### AD-8: Content identity, resume, and history
+
+Use a stable identity: `stremio:{type}:{id}` (e.g. `stremio:series:tt1234:1:2` for
+episodes). This keeps resume/history working across addons and re-installs and is
+the future key for Watch Next integration. Do not map addon items onto synced
+catalog ids.
+
+## Phases
+
+| Phase | Work item | Status | Exit criteria |
+| --- | --- | --- | --- |
+| P0 | Protocol client + models | Done | Domain models (manifest/catalog/meta/stream/subtitle), lenient DTO mapping, URL normalization (`stremio://` → https, configured paths, query preservation) and endpoint builders, `StremioAddonClient` with bounded responses and fixture-based tests — 22 tests passing (`StremioAddonClientTest`, `StremioAddonUrlTest`) |
+| P1 | Persistence + addon manager | Implemented and verified | Room migration 78 → 79 (`stremio_addons`) with `MigrationTestHelper` coverage and schema export per `docs/DATABASE_MIGRATION_INVARIANTS.md`; add/remove/enable/reorder/catalog-select; configuration-required manifests rejected with a clear message; unit tests and emulator install smoke pass. Remaining release concerns are tracked in `docs/STREMIO_ADDONS_PLAN_REVIEW.md`. |
+| P2 | Catalog browsing | Planned | Addons screen with per-addon catalog rows, pagination (`skip`), genre filter, catalog search, loading/empty/error states, D-pad focus pass on TV |
+| P3 | Meta + stream picker | Planned | Movie and series meta pages (videos → seasons/episodes), stream list rendering name/title/description/behaviorHints, unsupported-kind rows marked, selection hands a play request to the player |
+| P4 | Playback integration | Planned | Direct http/https streams play through `PlayerPreparationCoordinator` with headers/UA from the addon when declared; resume/history on `stremio:` ids; cast guard for magnet; clear "needs torrent plugin" state |
+| P5 | Subtitles | Planned | Addon subtitles fetched lazily in the player, language mapping from 3-letter codes, wired via `PlayerEngine.addExternalSubtitle` (`player/.../PlayerEngine.kt:104`), respects existing subtitle style/preferences |
+| P6 | Torrent companion plugin | Planned | Separate repo/APK: libtorrent4j engine + loopback HTTP streaming server; `playbackUrlSchemes: ["magnet"]`; `MSG_PREPARE_PLAYBACK` resolves `magnet:` → `http://127.0.0.1:<port>/...`; config Activity with buffer/speed/status; end-to-end emulator validation with real torrent-backed addon |
+| P7 | Polish + integration options | Planned | Parental filtering stance for addon content, startup destination wiring, optional Home row / global search fan-out, docs (`docs/PLUGIN_API.md` magnet appendix, this plan updated to Done), CHANGELOG entries |
+
+Effort estimate: P0–P5 ≈ 5–6 weeks for a shippable direct/debrid v1; P6 adds
+≈ 4–8 weeks (torrent engine quality on TV hardware is the dominant risk); P7
+≈ 1–2 weeks. Total to full parity ≈ 2–4 months.
+
+## Host change map
+
+New module `feature:stremio` (add to `settings.gradle.kts`), following the
+`feature/catalog` conventions:
+
+- `feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/`
+ — AddonsScreen, AddonInstallDialog, AddonManagerScreen, StremioMetaScreen,
+ StremioStreamPickerScreen.
+- `feature/stremio/.../api/` — ports consumed by `app` (navigation actions,
+ playback handoff), mirroring `feature/catalog/.../api`.
+
+Data layer:
+
+- `data/.../local/` — `stremio_addons` entity, DAO, database version bump
+ (`STREAM_VAULT_DATABASE_VERSION` → 79) and `78 → 79` migration, schema export.
+- `data/.../stremio/` — `StremioAddonRepository`, `StremioCatalogClient` (HTTP),
+ response models, bounded cache.
+
+Domain:
+
+- `domain/.../model/` — addon, catalog, meta, stream, subtitle models (pure
+ Kotlin), plus `AppTopLevelDestination.ADDONS` / `AppLandingDestination.ADDONS`.
+
+App wiring:
+
+- `app/.../navigation/AppRouteCodec.kt`, `AppNavigationAdapters.kt`,
+ `StartupNavigationResolver.kt`, `AppNavHost.kt` (+ new graph registration),
+ `app/.../ui/components/shell/AppShellNavigation.kt`.
+- `app/.../di/` — repository/client bindings.
+
+Playback (small, surgical):
+
+- `feature/playback/.../cast/CastMediaRequestFactory.kt` — magnet guard.
+- `feature/playback/.../player/PlayerPreparationCoordinator.kt` — already routes
+ through plugin prepare (`:72`); verify non-http probe skip (`:193`) and that a
+ magnet that fails plugin resolution produces a user-facing error rather than an
+ engine start.
+- `player/.../Media3PlayerEngine.kt` / `PlayerEngine.kt` — no changes expected for
+ P4; P5 uses `addExternalSubtitle`.
+
+Plugin docs:
+
+- `docs/PLUGIN_API.md` — appendix: torrent-style plugins declare
+ `playbackUrlSchemes: ["magnet"]`, must return loopback `output_url`, must never
+ expect host headers/credentials, and are non-castable.
+
+## Companion torrent plugin (P6) — integration spec
+
+Separate repository and APK (working name StreamVault Torrent Plugin). It uses the
+existing plugin API; the host needs zero torrent-specific code.
+
+- Manifest: `capabilities: ["playback.prepare", "configuration.activity"]`,
+ `playbackUrlSchemes: ["magnet"]`, no `playbackUrlHosts`,
+ `configurationMode: "activity"`.
+- `MSG_PREPARE_PLAYBACK` with `input_url = magnet:?...` (or assembled from
+ `infoHash` + trackers):
+ 1. Start/attach a torrent session (foreground service, persistent notification).
+ 2. Prioritize the target file (respect `fileIdx` when present; otherwise largest
+ video file), streaming piece deadlines around the play head.
+ 3. Serve ranges on `http://127.0.0.1:<port>/stream/<token>`; return
+ `success=true`, `handled=true`, `output_url`, `stream_type=progressive`
+ (or `hls` if the plugin remuxes), and an `expirationTime`-like short-lived
+ token recommendation (host currently has no expiry field in the response —
+ acceptable; the URL stays valid while the session is alive).
+ 4. Return `success=false` with a user-facing `message` for magnets it cannot
+ resolve; the host then shows the plugin's message.
+- Config Activity: download directory, buffer target, upload/speed caps, connected
+ peer/status view, active session list, stop/clear actions. TV-first layout per
+ the native Activity guidance in `docs/PLUGIN_API.md`.
+- Security posture: loopback bind only, no LAN exposure by default, no telemetry,
+ session teardown when playback stops.
+- Legal posture: engine and indexing live only in this separate APK/repo; the main
+ app references nothing torrent-specific in code, branding, or docs beyond the
+ plugin capability description.
+
+## Testing and validation strategy
+
+- P0–P1: pure unit tests for URL normalization, manifest validation, extra/query
+ encoding, response parsing (fixture JSON committed under test resources,
+ including malformed/unknown-field cases).
+- P1: Room migration tests per `docs/DATABASE_MIGRATION_INVARIANTS.md`
+ (`StreamVaultDatabaseMigrationTest` adjacent hop + populated multi-hop origin),
+ schema JSON export committed, `PRAGMA foreign_key_check` on the new table.
+- P2–P3: viewmodel/repository tests with a fake client; D-pad focus checks on
+ emulator for the new screens (TV-first).
+- P4: playback validation on emulator with screenshots — direct stream from a
+ fixture addon plays to first frame and keeps progressing; resume restores
+ position; magnet without plugin shows the explicit state (no engine start).
+- P5: subtitle selection test using `ExternalSubtitlePlayback` paths.
+- P6: end-to-end on emulator with the torrent plugin APK: magnet → plugin prepare
+ → first frame; seek forward/back; plugin stop tears the session down; capture
+ log evidence analogous to the AGENTS.md live playback validation discipline
+ (screenshot cadence during the stream, player health, no unintended fallbacks).
+- Regression: run existing migration suite and feature/catalog tests; verify no
+ changes to provider sync behavior.
+
+## Risks and mitigations
+
+| Risk | Impact | Mitigation |
+| --- | --- | --- |
+| Addon ecosystem drift (protocol variance, giant responses) | Broken browsing | Lenient parsing (ignore unknown fields), bounded page sizes/timeouts, per-addon error surfaces, fixture tests |
+| Legal exposure for torrent support | Takedown/abuse reports | Engine only in separate plugin APK/repo; main repo has no torrent code; document posture |
+| TV hardware limits for torrent streaming | Poor playback | Buffer/peer caps, file selection heuristics, clear errors; validate on 4K TV emulator and real device before calling P6 done |
+| Room migration mistakes | Data loss | Follow `DATABASE_MIGRATION_INVARIANTS.md`; migration tests + schema export as a hard gate |
+| Adult content via addon catalogs | Parental controls bypass | P7 filtering stance: per-addon disable + adult catalog/meta flag handling; decide before enabling Home/search integration |
+| Cast expectations | User confusion | Cast hidden for magnet; resolved loopback streams surface the existing `UNSUPPORTED` path with a clear message |
+| Scope creep (config webviews, Home integration early) | Slips v1 | Phase gate: P0–P5 is the product; P6/P7 are explicit follow-ons |
+
+## Open questions
+
+- Do we ship an in-app "not supported (YouTube/external)" stream row, or hide
+ unsupported kinds per addon? (P3 decision, default: show a disabled row with
+ reason.)
+- Subtitle language mapping from Stremio 3-letter codes to Android locales — do we
+ reuse `VodTrackPreference` or add a Stremio-specific preference? (P5.)
+- Persistent response caching (disk) — worth it, or session cache only? (Defer
+ unless browsing performance proves it necessary.)
+- `stremio://` deep-link registration on the host manifest — required for browser
+ install buttons, or is copy/paste enough for TV? (P1 decision; manifest change
+ is cheap.)
+- Per-addon account/config flows for addons whose manifest is
+ `configurationRequired` — v1 rejects with a clear message; revisit in P7.
+- Debrid API keys: plan assumes addons (e.g. Torrentio) return already-resolved
+ direct URLs; no in-app debrid credential UI. Confirm desired.
diff --git a/docs/STREMIO_ADDONS_PLAN_REVIEW.md b/docs/STREMIO_ADDONS_PLAN_REVIEW.md
new file mode 100644
index 00000000..2681c986
--- /dev/null
+++ b/docs/STREMIO_ADDONS_PLAN_REVIEW.md
@@ -0,0 +1,222 @@
+# Stremio addons plan review
+
+Reviewed 2026-10-11 in `.worktrees/stremio-addons`, branch
+`feature/stremio-addons`, against the uncommitted implementation and the official
+Stremio SDK protocol documentation. The review itself was a planning/code
+inspection pass; subsequent verification results are recorded in
+`STREMIO_ADDONS_HANDOFF.md`.
+
+The host-native client, separate addon registry, dedicated Addons destination,
+and direct/debrid-first delivery are appropriate. Keep those decisions. The
+following additions are needed before treating the plan as implementation-ready.
+
+## Required additions
+
+### 1. Cross-addon resource routing (P2–P3, release blocker)
+
+The plan describes picking from "the addon's" streams but does not define how a
+catalog-only addon such as Cinemeta connects to stream-only and subtitle-only
+addons. Add a resource resolver that queries enabled installed addons matching
+resource, media type, and content/video ID. Honor global restrictions and
+per-resource overrides, including `idPrefixes`; distinguish absent restrictions
+from explicitly empty ones where the protocol requires it. The current
+`StremioManifest.supportsResource` only checks resource/type, not ID prefixes.
+
+Keep catalog origin as provenance. For metadata, define deterministic precedence
+(origin first when eligible, then installed order), fallback after empty/failure,
+and a useful preview-only state if no metadata provider is available. Never assume
+Cinemeta is installed automatically. For streams/subtitles, use bounded concurrent
+fan-out, preserve addon attribution/order, allow partial results and per-addon
+retry, and cancel obsolete requests when leaving/changing the item. Disabling
+catalog rows must not disable that addon's stream/subtitle resources.
+
+Acceptance: browse a Cinemeta item and see streams from a separate stream-only
+addon; one failing addon does not hide successful results; an unrelated ID prefix
+is never queried; disabling an addon removes it from resource routing.
+
+### 2. Catalog capability and pagination semantics (P2, release blocker)
+
+`StremioMapper` currently converts absent `hasMore` to `false`. The standard
+catalog response does not require that field, so consuming this boolean directly
+would stop many catalogs after page one. Preserve whether it was supplied, and
+define the standard fallback: only paginate catalogs advertising `skip`; use
+100-item pages/offsets and stop on a short page. Track raw response count before
+filtering or deduplication so dropped cards do not change server offsets. Support
+an explicit `hasMore` extension without creating an infinite repeated-page loop.
+
+Honor required extras, including search-only catalogs and genre options; don't
+request a default row when required inputs are missing. Decide which extra names
+v1 supports and display a clear limitation for unknown required extras. Reset
+pagination on query/filter changes, cancel stale searches, retain focus/scroll
+when returning from details, and define bounded cache keys/TTL/invalidation.
+
+Acceptance: a 100-item response without `hasMore` loads page two; a short page
+ends pagination; repeated pages cannot cause endless fetching; required-search
+catalogs receive requests only after search input exists.
+
+### 3. Playback identity and history reopening (design before P3; implement P4)
+
+AD-8's string key is not directly compatible with the existing pipeline:
+`PlaybackHistory` and `PlayerHistoryCoordinator` require numeric `contentId` and
+`providerId`. `PlaybackHistoryNavigation` replays a stored `streamUrl`, which can
+expire for debrid media or refer to an old plugin loopback session.
+
+Choose an explicit persistence/navigation integration: a dedicated addon progress
+store or an extension of the existing identity model, with any required Room
+migration. Do not invent a provider row or use an unchecked string hash as an ID.
+Keep the exact video ID returned in `meta.videos`; do not synthesize all episode
+IDs as `tt...:season:episode`. Keep parent series identity separately. Specify
+whether custom addon IDs share a namespace; only merge identities when they
+represent the same content. Reopening history must resolve fresh streams and
+restore progress, with a picker when automatic selection is not reliable.
+
+Acceptance: progress survives process death and addon reinstall; changing stream
+providers retains position for the same video; expired URLs are resolved again;
+two unrelated custom-ID addons cannot overwrite each other's progress.
+
+### 4. Media headers and credentials (P1/P4, release blocker)
+
+AD-5 says never forward addon headers to non-addon hosts, while P4 requires
+`proxyHeaders.request` for playback. Stream/CDN hosts commonly differ from the
+addon API host. Replace this conflict with an explicit media-origin policy:
+validated request headers belong to the selected stream's media requests, not to
+every addon API/image/subtitle request. Define handling for redirects and HLS/DASH
+child resources on other hosts, with credential scoping and fixtures. Response
+proxy headers are not outgoing request headers. Header-dependent casting and
+external-player handoff need explicit support or a clear unavailable state.
+
+Configured install paths/queries and returned media URLs may contain secrets.
+Preserve encoded path bytes (`StremioAddonUrl.parse` currently uses decoded
+`URI.path`), redact entire sensitive paths/queries from logs/errors/screenshots,
+and decide storage, backup/export, and removal policy. Verify the injected HTTP
+client's interceptors do not log configured URLs or attach provider credentials.
+Validate schemes for API, media, artwork, subtitles, and plugin output separately;
+HTTP support must also be checked against Android network configuration.
+
+Acceptance: encoded configuration paths round-trip; a header-dependent stream
+plays without credentials leaking to unrelated hosts; sanitized diagnostics
+contain no configured URL secrets.
+
+### 5. P1 completeness and manifest lifecycle (before the P1 gate)
+
+The plan claims rejection of `configurationRequired`, but
+`StremioAddonRepositoryImpl.installAddon` currently persists such manifests.
+Define a clear configure-in-browser/paste-configured-URL error and implement it.
+Manifest parsing currently requires only an ID and defaults missing name/version;
+decide which malformed or unusable manifests to reject while still accepting
+valid stream-only/subtitle-only addons. Define duplicate identity as configured
+install URL (same manifest ID with different configuration can be legitimate).
+Map database/uniqueness errors to user-facing failures; serialize or transact
+conflicting registry operations rather than letting rapid updates lose settings.
+
+Add explicit manifest refresh with last-known-good fallback, version/capability
+changes, and reconciliation of catalog selections. Decide now that v1 supports
+copy/paste install links; OS `stremio://` intent registration is optional and must
+not be implied by URL parsing support. Separate the manager from catalog browsing
+within the Addons destination.
+
+Existing `stremio-test-run2.log` ends in a compile failure:
+`AddonsViewModelTest.kt:157` cannot resolve `StremioManifestResource`; its import
+is absent in the inspected file. The handoff's previously reported passes are
+historical evidence, not fresh verification. Run app, Stremio, settings, and
+targeted data tests as separate invocations so data test filters don't exclude
+unrelated test classes. Then complete manager emulator validation (install,
+duplicate/configuration errors, enable/disable, reorder, catalog selection,
+removal, restart persistence, and TV focus), beyond the single install screenshot.
+
+### 6. Torrent plugin contract feasibility (design spike before P6)
+
+Existing IPC can route `magnet:` but the claim that the plugin needs no host
+contract work is premature:
+
+- `MSG_PREPARE_PLAYBACK` sends only `input_url`. Specify a documented URI encoding
+ for `fileIdx` and tracker sources, or version an IPC field; prove the plugin
+ selects the requested episode file. Normalize `tracker:` source prefixes and
+ define DHT handling rather than passing source strings blindly as magnet trackers.
+- Preparation currently has both a five-second handler deadline and a five-second
+ total deadline. Timeout/no handler returns the original stream. A cold torrent
+ may exceed this: choose fast loopback endpoint allocation with asynchronous
+ buffering, or a bounded readiness/progress contract. Reject unresolved magnet
+ output before engine start, including plugin failure, timeout, disabled state,
+ and a nominal success response lacking usable output.
+- There is no playback-session stop signal in the documented IPC. Define session
+ ownership, cancellation, cleanup on switch/back/process death, inactivity expiry,
+ and seek/range behavior; an HTTP disconnect alone is not a reliable stop signal.
+
+Keep torrent provenance after resolution. AD-6's possible loopback cast rewrite
+conflicts with the stated non-goal of torrent casting: block cast for the whole
+torrent-backed session, including resolved URLs. Decide external-player support
+separately, since handoff changes session ownership. A separate APK does not itself
+settle distribution or licensing requirements; review those when choosing an engine.
+
+Acceptance: file-index preservation, cold-start beyond five seconds, cancellation,
+plugin death, seek/range requests, and cleanup all work using a deterministic
+fixture before a real-network end-to-end trial.
+
+### 7. Subtitle coverage (P5)
+
+Handle both inline `stream.subtitles` and enabled subtitle-resource addons. The
+current DTO/model does not include inline subtitles; `fetchSubtitles` lacks the
+standard `videoSize` extra although behavior hints already retain it. Carry video
+ID/hash/size/filename through the playback request. Deduplicate with provenance,
+handle unavailable tracks without interrupting video, reset on stream/episode
+changes, and reuse existing language/style preferences. Verify three-letter
+language aliases, unknown codes, and supported formats against player capabilities.
+
+Acceptance: inline-only subtitles and an independent subtitle addon both work;
+the correct episode and optional hash/size/filename reach the addon; switching
+episodes cannot retain the previous subtitle request/result.
+
+### 8. Parental controls and content-type scope (before v1 release)
+
+Move the parental-control decision out of optional P7 polish. An Addons screen
+can bypass restrictions even without Home/search integration. Manifest
+`behaviorHints.adult` exists but is absent from the current model. Do not assume
+all catalogs/meta expose a reliable adult flag. Decide a conservative behavior for
+unrated/custom addon content under a locked profile, and gate install, details,
+playback, and history entry points consistently with the app's existing controls.
+
+Explicitly define v1 as movie/series playback, with `tv`/`channel` browsing or
+playback deferred unless separately implemented. The current model recognizes
+these types, while the plan's playback/resume design assumes VOD. Newer guide and
+archive-source capabilities remain unsupported v1 states; preserve a visible
+unsupported row rather than silently dropping identifiable stream kinds.
+
+### 9. Release validation and documentation (P4–P5 release gate)
+
+Add a deterministic multi-addon fixture setup covering catalog-only, stream-only,
+subtitle-only, custom episode IDs, missing `hasMore`, required extras, redirects,
+headers, unsupported stream kinds, cancellation, partial failures, and expiring
+URLs. Use legitimate direct MP4 and HLS media; exercise seek, resume after restart,
+audio/subtitle selection, TV focus restoration, and existing provider playback.
+
+First frame/build/install alone are not playback acceptance. Capture progression
+and sanitized player logs across a meaningful playback window. If live addon
+playback is added, follow AGENTS.md exactly: at least 45 screenshots at two-second
+intervals (prefer 61 for prior one-minute failures), healthy media session, no
+fatal/stuck/unintended fallback, and multiple channels for general live bugs.
+Do not claim live validation from the VOD fixture runs.
+
+Separate mandatory v1 polish/documentation from optional Home/search integration
+and P6 torrent work. Revise the schedule after identity and plugin spikes; the
+original estimates do not account for these unresolved integration contracts.
+
+## Recommended continuation order
+
+1. Close P1 registry/configuration and verification gaps; obtain the requested
+ commit decision only after concrete test/emulator evidence exists.
+2. Design resource resolution and playback identity before starting P2/P3 UI.
+3. Implement P2/P3 with fake multi-addon fixtures, then P4 direct playback and
+ history reopening, then P5 subtitles.
+4. Ship direct/debrid v1 only after parental controls, privacy, TV interaction,
+ and regression validation pass.
+5. Run the plugin feasibility spike before committing to the P6 implementation
+ spec. Home/global search remains optional after v1.
+
+## Primary protocol references
+
+- [Resource routing and cross-addon IDs](https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/protocol.md)
+- [Manifest resources, required extras, and adult/configuration hints](https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/responses/manifest.md)
+- [Catalog pagination](https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/requests/defineCatalogHandler.md)
+- [Stream headers, file indices, tracker sources, and inline subtitles](https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/responses/stream.md)
+- [Subtitle request extras](https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/requests/defineSubtitlesHandler.md)
diff --git a/domain/src/main/java/com/streamvault/domain/model/AppLandingDestination.kt b/domain/src/main/java/com/streamvault/domain/model/AppLandingDestination.kt
index c6f8df40..4d95c1c6 100644
--- a/domain/src/main/java/com/streamvault/domain/model/AppLandingDestination.kt
+++ b/domain/src/main/java/com/streamvault/domain/model/AppLandingDestination.kt
@@ -10,6 +10,7 @@ enum class AppLandingDestination(val storageValue: String) {
GUIDE("guide"),
DOWNLOADS("downloads"),
PLUGINS("plugins"),
+ ADDONS("addons"),
SETTINGS("settings");
companion object {
diff --git a/domain/src/main/java/com/streamvault/domain/model/AppTopLevelDestination.kt b/domain/src/main/java/com/streamvault/domain/model/AppTopLevelDestination.kt
index cf3923cc..4cafe665 100644
--- a/domain/src/main/java/com/streamvault/domain/model/AppTopLevelDestination.kt
+++ b/domain/src/main/java/com/streamvault/domain/model/AppTopLevelDestination.kt
@@ -13,6 +13,7 @@ enum class AppTopLevelDestination(
GUIDE("guide", AppLandingDestination.GUIDE),
SEARCH("search"),
PLUGINS("plugins", AppLandingDestination.PLUGINS),
+ ADDONS("addons", AppLandingDestination.ADDONS),
SETTINGS("settings", AppLandingDestination.SETTINGS, isRequired = true);
companion object {
@@ -25,6 +26,7 @@ enum class AppTopLevelDestination(
GUIDE,
SEARCH,
PLUGINS,
+ ADDONS,
SETTINGS
)
diff --git a/domain/src/main/java/com/streamvault/domain/model/stremio/StremioAddon.kt b/domain/src/main/java/com/streamvault/domain/model/stremio/StremioAddon.kt
new file mode 100644
index 00000000..d122b0ea
--- /dev/null
+++ b/domain/src/main/java/com/streamvault/domain/model/stremio/StremioAddon.kt
@@ -0,0 +1,23 @@
+package com.streamvault.domain.model.stremio
+
+data class StremioAddon(
+ val id: Long = 0L,
+ val installUrl: String,
+ val manifestId: String,
+ val name: String,
+ val version: String,
+ val manifestJson: String = "",
+ val enabled: Boolean = true,
+ val sortOrder: Int = 0,
+ val catalogSettings: Map<String, Boolean> = emptyMap(),
+ val createdAt: Long = 0L,
+ val updatedAt: Long = 0L
+) {
+ init {
+ require(installUrl.isNotBlank()) { "installUrl must not be blank" }
+ require(manifestId.isNotBlank()) { "manifestId must not be blank" }
+ require(name.isNotBlank()) { "name must not be blank" }
+ }
+
+ fun isCatalogEnabled(catalogKey: String): Boolean = catalogSettings[catalogKey] ?: true
+}
diff --git a/domain/src/main/java/com/streamvault/domain/model/stremio/StremioCatalog.kt b/domain/src/main/java/com/streamvault/domain/model/stremio/StremioCatalog.kt
new file mode 100644
index 00000000..c7b2ead0
--- /dev/null
+++ b/domain/src/main/java/com/streamvault/domain/model/stremio/StremioCatalog.kt
@@ -0,0 +1,32 @@
+package com.streamvault.domain.model.stremio
+
+data class StremioMetaPreview(
+ val id: String,
+ val type: StremioMediaType,
+ val name: String,
+ val poster: String? = null,
+ val background: String? = null,
+ val logo: String? = null,
+ val description: String? = null,
+ val releaseInfo: String? = null,
+ val imdbRating: String? = null,
+ val genres: List<String> = emptyList(),
+ val runtime: String? = null
+)
+
+data class StremioCatalogPage(
+ val metas: List<StremioMetaPreview>,
+ val hasMore: Boolean = false
+)
+
+data class StremioCatalogQuery(
+ val search: String? = null,
+ val genre: String? = null,
+ val skip: Int? = null
+) {
+ fun toExtras(): List<Pair<String, String>> = buildList {
+ search?.trim()?.takeIf { it.isNotEmpty() }?.let { add("search" to it) }
+ genre?.trim()?.takeIf { it.isNotEmpty() }?.let { add("genre" to it) }
+ skip?.takeIf { it > 0 }?.let { add("skip" to it.toString()) }
+ }
+}
diff --git a/domain/src/main/java/com/streamvault/domain/model/stremio/StremioManifest.kt b/domain/src/main/java/com/streamvault/domain/model/stremio/StremioManifest.kt
new file mode 100644
index 00000000..210e9e67
--- /dev/null
+++ b/domain/src/main/java/com/streamvault/domain/model/stremio/StremioManifest.kt
@@ -0,0 +1,81 @@
+package com.streamvault.domain.model.stremio
+
+enum class StremioMediaType(val typeName: String) {
+ MOVIE("movie"),
+ SERIES("series"),
+ CHANNEL("channel"),
+ TV("tv"),
+ UNKNOWN("unknown");
+
+ companion object {
+ fun fromTypeName(value: String?): StremioMediaType {
+ val normalized = value?.trim().orEmpty()
+ return entries.firstOrNull { it.typeName.equals(normalized, ignoreCase = true) } ?: UNKNOWN
+ }
+ }
+}
+
+enum class StremioResourceKind(val resourceName: String) {
+ CATALOG("catalog"),
+ META("meta"),
+ STREAM("stream"),
+ SUBTITLES("subtitles"),
+ UNKNOWN("unknown");
+
+ companion object {
+ fun fromResourceName(value: String?): StremioResourceKind {
+ val normalized = value?.trim().orEmpty()
+ return entries.firstOrNull { it.resourceName.equals(normalized, ignoreCase = true) } ?: UNKNOWN
+ }
+ }
+}
+
+data class StremioManifestResource(
+ val kind: StremioResourceKind,
+ val types: List<StremioMediaType> = emptyList(),
+ val idPrefixes: List<String> = emptyList()
+)
+
+data class StremioCatalogExtraDef(
+ val name: String,
+ val isRequired: Boolean = false,
+ val options: List<String> = emptyList()
+)
+
+data class StremioCatalogRef(
+ val type: StremioMediaType,
+ val id: String,
+ val name: String? = null,
+ val genres: List<String> = emptyList(),
+ val extras: List<StremioCatalogExtraDef> = emptyList()
+) {
+ val settingsKey: String get() = "${type.typeName}:$id"
+ val supportsSearch: Boolean get() = extras.any { it.name.equals("search", ignoreCase = true) }
+ val supportsSkip: Boolean get() = extras.any { it.name.equals("skip", ignoreCase = true) }
+ val supportsGenre: Boolean
+ get() = genres.isNotEmpty() || extras.any { it.name.equals("genre", ignoreCase = true) }
+}
+
+data class StremioManifestBehaviorHints(
+ val configurable: Boolean = false,
+ val configurationRequired: Boolean = false
+)
+
+data class StremioManifest(
+ val id: String,
+ val name: String,
+ val version: String,
+ val description: String? = null,
+ val logo: String? = null,
+ val background: String? = null,
+ val types: List<StremioMediaType> = emptyList(),
+ val resources: List<StremioManifestResource> = emptyList(),
+ val catalogs: List<StremioCatalogRef> = emptyList(),
+ val idPrefixes: List<String> = emptyList(),
+ val behaviorHints: StremioManifestBehaviorHints = StremioManifestBehaviorHints()
+) {
+ fun supportsResource(kind: StremioResourceKind, type: StremioMediaType): Boolean =
+ resources.any { resource ->
+ resource.kind == kind && (resource.types.isEmpty() || type in resource.types)
+ }
+}
diff --git a/domain/src/main/java/com/streamvault/domain/model/stremio/StremioMeta.kt b/domain/src/main/java/com/streamvault/domain/model/stremio/StremioMeta.kt
new file mode 100644
index 00000000..b5bda628
--- /dev/null
+++ b/domain/src/main/java/com/streamvault/domain/model/stremio/StremioMeta.kt
@@ -0,0 +1,36 @@
+package com.streamvault.domain.model.stremio
+
+data class StremioVideo(
+ val id: String,
+ val title: String? = null,
+ val season: Int? = null,
+ val episode: Int? = null,
+ val released: String? = null,
+ val thumbnail: String? = null,
+ val overview: String? = null
+)
+
+data class StremioMetaDetail(
+ val id: String,
+ val type: StremioMediaType,
+ val name: String,
+ val poster: String? = null,
+ val background: String? = null,
+ val logo: String? = null,
+ val description: String? = null,
+ val releaseInfo: String? = null,
+ val imdbRating: String? = null,
+ val genres: List<String> = emptyList(),
+ val runtime: String? = null,
+ val cast: List<String> = emptyList(),
+ val director: List<String> = emptyList(),
+ val videos: List<StremioVideo> = emptyList()
+) {
+ fun seasons(): List<Int> = videos.mapNotNull { it.season }.distinct().sorted()
+
+ fun episodes(season: Int): List<StremioVideo> =
+ videos.filter { it.season == season }.sortedBy { it.episode ?: Int.MAX_VALUE }
+
+ fun episodeVideoId(season: Int, episode: Int): String? =
+ videos.firstOrNull { it.season == season && it.episode == episode }?.id
+}
diff --git a/domain/src/main/java/com/streamvault/domain/model/stremio/StremioStream.kt b/domain/src/main/java/com/streamvault/domain/model/stremio/StremioStream.kt
new file mode 100644
index 00000000..e29865f9
--- /dev/null
+++ b/domain/src/main/java/com/streamvault/domain/model/stremio/StremioStream.kt
@@ -0,0 +1,45 @@
+package com.streamvault.domain.model.stremio
+
+enum class StremioStreamKind {
+ DIRECT,
+ TORRENT,
+ YOUTUBE,
+ EXTERNAL,
+ UNKNOWN
+}
+
+data class StremioProxyHeaders(
+ val request: Map<String, String> = emptyMap(),
+ val response: Map<String, String> = emptyMap()
+)
+
+data class StremioStreamBehaviorHints(
+ val notWebReady: Boolean = false,
+ val bingeGroup: String? = null,
+ val filename: String? = null,
+ val videoSize: Long? = null,
+ val videoHash: String? = null,
+ val proxyHeaders: StremioProxyHeaders? = null
+)
+
+data class StremioStream(
+ val name: String? = null,
+ val title: String? = null,
+ val description: String? = null,
+ val url: String? = null,
+ val ytId: String? = null,
+ val infoHash: String? = null,
+ val fileIdx: Int? = null,
+ val externalUrl: String? = null,
+ val sources: List<String> = emptyList(),
+ val behaviorHints: StremioStreamBehaviorHints? = null
+) {
+ val kind: StremioStreamKind
+ get() = when {
+ !infoHash.isNullOrBlank() -> StremioStreamKind.TORRENT
+ !url.isNullOrBlank() -> StremioStreamKind.DIRECT
+ !ytId.isNullOrBlank() -> StremioStreamKind.YOUTUBE
+ !externalUrl.isNullOrBlank() -> StremioStreamKind.EXTERNAL
+ else -> StremioStreamKind.UNKNOWN
+ }
+}
diff --git a/domain/src/main/java/com/streamvault/domain/model/stremio/StremioSubtitle.kt b/domain/src/main/java/com/streamvault/domain/model/stremio/StremioSubtitle.kt
new file mode 100644
index 00000000..40c7176b
--- /dev/null
+++ b/domain/src/main/java/com/streamvault/domain/model/stremio/StremioSubtitle.kt
@@ -0,0 +1,7 @@
+package com.streamvault.domain.model.stremio
+
+data class StremioSubtitle(
+ val url: String,
+ val lang: String,
+ val id: String? = null
+)
diff --git a/domain/src/main/java/com/streamvault/domain/repository/StremioAddonRepository.kt b/domain/src/main/java/com/streamvault/domain/repository/StremioAddonRepository.kt
new file mode 100644
index 00000000..360ab8a8
--- /dev/null
+++ b/domain/src/main/java/com/streamvault/domain/repository/StremioAddonRepository.kt
@@ -0,0 +1,24 @@
+package com.streamvault.domain.repository
+
+import com.streamvault.domain.model.Result
+import com.streamvault.domain.model.stremio.StremioAddon
+import com.streamvault.domain.model.stremio.StremioManifest
+import kotlinx.coroutines.flow.Flow
+
+interface StremioAddonRepository {
+ fun observeAddons(): Flow<List<StremioAddon>>
+
+ suspend fun getAddon(id: Long): StremioAddon?
+
+ suspend fun getManifest(addonId: Long): StremioManifest?
+
+ suspend fun installAddon(installUrl: String): Result<StremioAddon>
+
+ suspend fun removeAddon(id: Long): Result<Unit>
+
+ suspend fun setAddonEnabled(id: Long, enabled: Boolean): Result<Unit>
+
+ suspend fun moveAddon(id: Long, offset: Int): Result<Unit>
+
+ suspend fun setCatalogEnabled(addonId: Long, catalogKey: String, enabled: Boolean): Result<Unit>
+}
diff --git a/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsPreferenceDialogs.kt b/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsPreferenceDialogs.kt
index 94f59dce..3c90eb0b 100644
--- a/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsPreferenceDialogs.kt
+++ b/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsPreferenceDialogs.kt
@@ -394,6 +394,7 @@ private fun AppLandingDestination.labelResId(): Int = when (this) {
AppLandingDestination.GUIDE -> R.string.nav_epg
AppLandingDestination.DOWNLOADS -> R.string.nav_downloads
AppLandingDestination.PLUGINS -> R.string.nav_plugins
+ AppLandingDestination.ADDONS -> R.string.nav_addons
AppLandingDestination.SETTINGS -> R.string.nav_settings
}
diff --git a/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsScreenState.kt b/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsScreenState.kt
index 251d3e31..16012508 100644
--- a/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsScreenState.kt
+++ b/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsScreenState.kt
@@ -236,6 +236,7 @@ private fun formatAppLandingDestinationLabel(
AppLandingDestination.GUIDE -> R.string.nav_epg
AppLandingDestination.DOWNLOADS -> R.string.nav_downloads
AppLandingDestination.PLUGINS -> R.string.nav_plugins
+ AppLandingDestination.ADDONS -> R.string.nav_addons
AppLandingDestination.SETTINGS -> R.string.nav_settings
}
)
diff --git a/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsViewModel.kt b/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsViewModel.kt
index 38331ff9..844919b1 100644
--- a/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsViewModel.kt
+++ b/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsViewModel.kt
@@ -1159,6 +1159,7 @@ class SettingsViewModel @Inject constructor(
AppLandingDestination.GUIDE -> R.string.nav_epg
AppLandingDestination.DOWNLOADS -> R.string.nav_downloads
AppLandingDestination.PLUGINS -> R.string.nav_plugins
+ AppLandingDestination.ADDONS -> R.string.nav_addons
AppLandingDestination.SETTINGS -> R.string.nav_settings
}
diff --git a/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/TopNavigationDialog.kt b/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/TopNavigationDialog.kt
index abd00ef5..e86d8777 100644
--- a/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/TopNavigationDialog.kt
+++ b/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/TopNavigationDialog.kt
@@ -244,5 +244,6 @@ private fun AppTopLevelDestination.labelResId(): Int = when (this) {
AppTopLevelDestination.GUIDE -> R.string.nav_epg
AppTopLevelDestination.SEARCH -> R.string.search_title
AppTopLevelDestination.PLUGINS -> R.string.nav_plugins
+ AppTopLevelDestination.ADDONS -> R.string.nav_addons
AppTopLevelDestination.SETTINGS -> R.string.nav_settings
}
diff --git a/feature/settings/src/main/res/values/strings.xml b/feature/settings/src/main/res/values/strings.xml
index 868ee14a..996da1df 100644
--- a/feature/settings/src/main/res/values/strings.xml
+++ b/feature/settings/src/main/res/values/strings.xml
@@ -545,6 +545,7 @@
<string name="nav_epg">Guide</string>
<string name="nav_downloads">Downloads</string>
<string name="nav_plugins">Plugins</string>
+ <string name="nav_addons">Addons</string>
<string name="nav_settings">Settings</string>
<string name="settings_overview_title">Control Center</string>
<string name="settings_overview_subtitle">Review your provider, protection, and playback setup at a glance.</string>
diff --git a/feature/stremio/build.gradle.kts b/feature/stremio/build.gradle.kts
new file mode 100644
index 00000000..93d17eb6
--- /dev/null
+++ b/feature/stremio/build.gradle.kts
@@ -0,0 +1,73 @@
+plugins {
+ alias(libs.plugins.android.library)
+ alias(libs.plugins.kotlin.android)
+ alias(libs.plugins.kotlin.compose)
+ alias(libs.plugins.ksp)
+ alias(libs.plugins.hilt)
+ alias(libs.plugins.kover)
+}
+
+android {
+ namespace = "com.streamvault.feature.stremio"
+ compileSdk = 36
+
+ defaultConfig {
+ minSdk = 25
+ testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
+ }
+
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
+ }
+
+ buildFeatures {
+ compose = true
+ }
+}
+
+kotlin {
+ compilerOptions {
+ jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
+ }
+}
+
+kover {
+ currentProject {
+ createVariant("ci") {
+ add("debug")
+ }
+ }
+}
+
+dependencies {
+ implementation(project(":core:navigation"))
+ implementation(project(":core:ui"))
+ implementation(project(":domain"))
+
+ implementation(platform(libs.compose.bom))
+ implementation(libs.compose.ui)
+ implementation(libs.compose.material3)
+ implementation(libs.compose.material.icons.extended)
+ implementation(libs.compose.tv.foundation)
+ implementation(libs.compose.tv.material)
+ implementation(libs.activity.compose)
+ implementation(libs.lifecycle.runtime.ktx)
+ implementation(libs.lifecycle.runtime.compose)
+ implementation(libs.lifecycle.viewmodel.compose)
+ implementation(libs.navigation.compose)
+ implementation(libs.hilt.android)
+ ksp(libs.hilt.compiler)
+ implementation(libs.hilt.navigation.compose)
+ implementation(libs.coroutines.core)
+ implementation(libs.coroutines.android)
+ implementation(libs.core.ktx)
+
+ testImplementation(libs.junit)
+ testImplementation(libs.truth)
+ testImplementation(libs.coroutines.test)
+
+ androidTestImplementation(libs.androidx.test.ext.junit)
+ androidTestImplementation(libs.androidx.test.runner)
+ androidTestImplementation(libs.truth)
+}
diff --git a/feature/stremio/src/main/java/com/streamvault/feature/stremio/api/StremioFeatureContracts.kt b/feature/stremio/src/main/java/com/streamvault/feature/stremio/api/StremioFeatureContracts.kt
new file mode 100644
index 00000000..bfd43d6b
--- /dev/null
+++ b/feature/stremio/src/main/java/com/streamvault/feature/stremio/api/StremioFeatureContracts.kt
@@ -0,0 +1,14 @@
+package com.streamvault.feature.stremio.api
+
+import androidx.compose.foundation.layout.ColumnScope
+import androidx.compose.runtime.Composable
+import com.streamvault.core.navigation.AppDestination
+
+typealias StremioScaffoldContent = @Composable (
+ currentDestination: AppDestination,
+ title: String,
+ subtitle: String?,
+ compactHeader: Boolean,
+ showScreenHeader: Boolean,
+ content: @Composable ColumnScope.() -> Unit,
+) -> Unit
diff --git a/feature/stremio/src/main/java/com/streamvault/feature/stremio/navigation/StremioGraph.kt b/feature/stremio/src/main/java/com/streamvault/feature/stremio/navigation/StremioGraph.kt
new file mode 100644
index 00000000..bfdadb89
--- /dev/null
+++ b/feature/stremio/src/main/java/com/streamvault/feature/stremio/navigation/StremioGraph.kt
@@ -0,0 +1,12 @@
+package com.streamvault.feature.stremio.navigation
+
+import androidx.navigation.NavGraphBuilder
+import androidx.navigation.compose.composable
+import com.streamvault.feature.stremio.api.StremioScaffoldContent
+import com.streamvault.feature.stremio.presentation.AddonsScreen
+
+fun NavGraphBuilder.registerStremioGraph(scaffold: StremioScaffoldContent) {
+ composable(StremioRoutePatterns.ADDONS) {
+ AddonsScreen(scaffold = scaffold)
+ }
+}
diff --git a/feature/stremio/src/main/java/com/streamvault/feature/stremio/navigation/StremioRoutePatterns.kt b/feature/stremio/src/main/java/com/streamvault/feature/stremio/navigation/StremioRoutePatterns.kt
new file mode 100644
index 00000000..10e34169
--- /dev/null
+++ b/feature/stremio/src/main/java/com/streamvault/feature/stremio/navigation/StremioRoutePatterns.kt
@@ -0,0 +1,5 @@
+package com.streamvault.feature.stremio.navigation
+
+object StremioRoutePatterns {
+ const val ADDONS = "addons"
+}
diff --git a/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/AddonsScreen.kt b/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/AddonsScreen.kt
new file mode 100644
index 00000000..964a7dea
--- /dev/null
+++ b/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/AddonsScreen.kt
@@ -0,0 +1,309 @@
+package com.streamvault.feature.stremio.presentation
+
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.itemsIndexed
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Add
+import androidx.compose.material.icons.filled.KeyboardArrowDown
+import androidx.compose.material.icons.filled.KeyboardArrowUp
+import androidx.compose.material3.AlertDialog
+import androidx.compose.material3.Button
+import androidx.compose.material3.Card
+import androidx.compose.material3.CircularProgressIndicator
+import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.OutlinedTextField
+import androidx.compose.material3.Switch
+import androidx.compose.material3.Text
+import androidx.compose.material3.TextButton
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.dp
+import androidx.hilt.navigation.compose.hiltViewModel
+import androidx.lifecycle.compose.collectAsStateWithLifecycle
+import com.streamvault.core.navigation.AppDestination
+import com.streamvault.feature.stremio.R
+import com.streamvault.feature.stremio.api.StremioScaffoldContent
+import kotlinx.coroutines.delay
+
+@Composable
+fun AddonsScreen(
+ scaffold: StremioScaffoldContent,
+ viewModel: AddonsViewModel = hiltViewModel()
+) {
+ val state by viewModel.state.collectAsStateWithLifecycle()
+
+ state.statusMessageRes?.let { messageRes ->
+ LaunchedEffect(messageRes) {
+ delay(3_000)
+ viewModel.consumeStatusMessage()
+ }
+ }
+
+ scaffold(
+ AppDestination.Addons,
+ stringResource(R.string.stremio_title),
+ stringResource(R.string.stremio_subtitle),
+ false,
+ true
+ ) {
+ Column(
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(horizontal = 24.dp, vertical = 8.dp),
+ verticalArrangement = Arrangement.spacedBy(12.dp)
+ ) {
+ Button(onClick = viewModel::showInstallDialog) {
+ Icon(imageVector = Icons.Default.Add, contentDescription = null)
+ Spacer(modifier = Modifier.size(8.dp))
+ Text(text = stringResource(R.string.stremio_add))
+ }
+ state.errorMessage?.let { message ->
+ MessageBanner(message = message, onClick = viewModel::consumeError)
+ }
+ state.statusMessageRes?.let { messageRes ->
+ MessageBanner(message = stringResource(messageRes), onClick = viewModel::consumeStatusMessage)
+ }
+ when {
+ state.loading -> Box(
+ modifier = Modifier.fillMaxSize(),
+ contentAlignment = Alignment.Center
+ ) {
+ CircularProgressIndicator()
+ }
+ state.addons.isEmpty() -> Text(
+ text = stringResource(R.string.stremio_empty),
+ style = MaterialTheme.typography.bodyLarge,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ else -> LazyColumn(
+ modifier = Modifier.fillMaxSize(),
+ verticalArrangement = Arrangement.spacedBy(12.dp)
+ ) {
+ itemsIndexed(
+ items = state.addons,
+ key = { _, entry -> entry.addon.id }
+ ) { index, entry ->
+ AddonCard(
+ entry = entry,
+ expanded = state.expandedAddonId == entry.addon.id,
+ canMoveUp = index > 0,
+ canMoveDown = index < state.addons.lastIndex,
+ onEnabledChange = { enabled -> viewModel.setEnabled(entry, enabled) },
+ onMoveUp = { viewModel.moveAddon(entry, -1) },
+ onMoveDown = { viewModel.moveAddon(entry, 1) },
+ onToggleExpanded = { viewModel.toggleExpanded(entry.addon.id) },
+ onCatalogEnabledChange = { catalogKey, enabled ->
+ viewModel.setCatalogEnabled(entry, catalogKey, enabled)
+ },
+ onRemove = { viewModel.removeAddon(entry) }
+ )
+ }
+ }
+ }
+ }
+ }
+
+ if (state.installDialogVisible) {
+ InstallAddonDialog(
+ url = state.installUrl,
+ installing = state.installing,
+ errorMessage = state.errorMessage,
+ onUrlChange = viewModel::updateInstallUrl,
+ onConfirm = viewModel::install,
+ onDismiss = viewModel::dismissInstallDialog
+ )
+ }
+}
+
+@Composable
+private fun AddonCard(
+ entry: AddonsViewModel.AddonEntry,
+ expanded: Boolean,
+ canMoveUp: Boolean,
+ canMoveDown: Boolean,
+ onEnabledChange: (Boolean) -> Unit,
+ onMoveUp: () -> Unit,
+ onMoveDown: () -> Unit,
+ onToggleExpanded: () -> Unit,
+ onCatalogEnabledChange: (String, Boolean) -> Unit,
+ onRemove: () -> Unit
+) {
+ val addon = entry.addon
+ Card(modifier = Modifier.fillMaxWidth()) {
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(16.dp),
+ verticalArrangement = Arrangement.spacedBy(8.dp)
+ ) {
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = addon.name, style = MaterialTheme.typography.titleMedium)
+ Text(
+ text = stringResource(R.string.stremio_version_format, addon.version),
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ Text(
+ text = addon.installUrl,
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ }
+ Switch(checked = addon.enabled, onCheckedChange = onEnabledChange)
+ }
+ Row(
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(8.dp)
+ ) {
+ IconButton(onClick = onMoveUp, enabled = canMoveUp) {
+ Icon(
+ imageVector = Icons.Default.KeyboardArrowUp,
+ contentDescription = stringResource(R.string.stremio_move_up)
+ )
+ }
+ IconButton(onClick = onMoveDown, enabled = canMoveDown) {
+ Icon(
+ imageVector = Icons.Default.KeyboardArrowDown,
+ contentDescription = stringResource(R.string.stremio_move_down)
+ )
+ }
+ TextButton(onClick = onToggleExpanded) {
+ Text(text = stringResource(R.string.stremio_catalogs))
+ }
+ Spacer(modifier = Modifier.weight(1f))
+ TextButton(onClick = onRemove) {
+ Text(
+ text = stringResource(R.string.stremio_remove),
+ color = MaterialTheme.colorScheme.error
+ )
+ }
+ }
+ if (expanded) {
+ if (entry.catalogs.isEmpty()) {
+ Text(
+ text = stringResource(R.string.stremio_no_catalogs),
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ } else {
+ entry.catalogs.forEach { catalog ->
+ Row(
+ verticalAlignment = Alignment.CenterVertically,
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Switch(
+ checked = addon.isCatalogEnabled(catalog.settingsKey),
+ onCheckedChange = { enabled ->
+ onCatalogEnabledChange(catalog.settingsKey, enabled)
+ }
+ )
+ Spacer(modifier = Modifier.size(12.dp))
+ Column {
+ Text(
+ text = catalog.name ?: catalog.id,
+ style = MaterialTheme.typography.bodyLarge
+ )
+ Text(
+ text = "${catalog.type.typeName} · ${catalog.id}",
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+@Composable
+private fun InstallAddonDialog(
+ url: String,
+ installing: Boolean,
+ errorMessage: String?,
+ onUrlChange: (String) -> Unit,
+ onConfirm: () -> Unit,
+ onDismiss: () -> Unit
+) {
+ AlertDialog(
+ onDismissRequest = { if (!installing) onDismiss() },
+ title = { Text(text = stringResource(R.string.stremio_install_title)) },
+ text = {
+ Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
+ OutlinedTextField(
+ value = url,
+ onValueChange = onUrlChange,
+ singleLine = true,
+ enabled = !installing,
+ placeholder = { Text(text = stringResource(R.string.stremio_install_hint)) },
+ modifier = Modifier.fillMaxWidth()
+ )
+ if (installing) {
+ Row(
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(12.dp)
+ ) {
+ CircularProgressIndicator(modifier = Modifier.size(20.dp))
+ Text(text = stringResource(R.string.stremio_installing))
+ }
+ }
+ errorMessage?.let { message ->
+ Text(
+ text = message,
+ color = MaterialTheme.colorScheme.error,
+ style = MaterialTheme.typography.bodyMedium
+ )
+ }
+ }
+ },
+ confirmButton = {
+ TextButton(
+ onClick = onConfirm,
+ enabled = url.isNotBlank() && !installing
+ ) {
+ Text(text = stringResource(R.string.stremio_install_confirm))
+ }
+ },
+ dismissButton = {
+ TextButton(onClick = onDismiss, enabled = !installing) {
+ Text(text = stringResource(R.string.stremio_cancel))
+ }
+ }
+ )
+}
+
+@Composable
+private fun MessageBanner(message: String, onClick: () -> Unit) {
+ Card(
+ modifier = Modifier
+ .fillMaxWidth()
+ .clickable(onClick = onClick)
+ ) {
+ Text(
+ text = message,
+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp),
+ style = MaterialTheme.typography.bodyMedium
+ )
+ }
+}
diff --git a/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/AddonsViewModel.kt b/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/AddonsViewModel.kt
new file mode 100644
index 00000000..a33c9713
--- /dev/null
+++ b/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/AddonsViewModel.kt
@@ -0,0 +1,140 @@
+package com.streamvault.feature.stremio.presentation
+
+import androidx.annotation.StringRes
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
+import com.streamvault.domain.model.Result
+import com.streamvault.domain.model.stremio.StremioAddon
+import com.streamvault.domain.model.stremio.StremioCatalogRef
+import com.streamvault.domain.repository.StremioAddonRepository
+import com.streamvault.feature.stremio.R
+import dagger.hilt.android.lifecycle.HiltViewModel
+import javax.inject.Inject
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.asStateFlow
+import kotlinx.coroutines.flow.update
+import kotlinx.coroutines.launch
+
+@HiltViewModel
+class AddonsViewModel @Inject constructor(
+ private val repository: StremioAddonRepository
+) : ViewModel() {
+
+ data class AddonEntry(
+ val addon: StremioAddon,
+ val catalogs: List<StremioCatalogRef>
+ )
+
+ data class UiState(
+ val loading: Boolean = true,
+ val addons: List<AddonEntry> = emptyList(),
+ val installDialogVisible: Boolean = false,
+ val installUrl: String = "",
+ val installing: Boolean = false,
+ val expandedAddonId: Long? = null,
+ @StringRes val statusMessageRes: Int? = null,
+ val errorMessage: String? = null
+ )
+
+ private val _state = MutableStateFlow(UiState())
+ val state: StateFlow<UiState> = _state.asStateFlow()
+
+ init {
+ viewModelScope.launch {
+ repository.observeAddons().collect { addons ->
+ val entries = addons.map { addon ->
+ AddonEntry(
+ addon = addon,
+ catalogs = repository.getManifest(addon.id)?.catalogs.orEmpty()
+ )
+ }
+ _state.update { it.copy(loading = false, addons = entries) }
+ }
+ }
+ }
+
+ fun showInstallDialog() {
+ _state.update { it.copy(installDialogVisible = true, errorMessage = null) }
+ }
+
+ fun dismissInstallDialog() {
+ _state.update { it.copy(installDialogVisible = false, installUrl = "", installing = false) }
+ }
+
+ fun updateInstallUrl(value: String) {
+ _state.update { it.copy(installUrl = value, errorMessage = null) }
+ }
+
+ fun install() {
+ val url = _state.value.installUrl.trim()
+ if (url.isEmpty() || _state.value.installing) return
+ _state.update { it.copy(installing = true, errorMessage = null) }
+ viewModelScope.launch {
+ when (val result = repository.installAddon(url)) {
+ is Result.Success -> _state.update {
+ it.copy(
+ installing = false,
+ installDialogVisible = false,
+ installUrl = "",
+ statusMessageRes = R.string.stremio_status_installed
+ )
+ }
+ is Result.Error -> _state.update {
+ it.copy(installing = false, errorMessage = result.message)
+ }
+ Result.Loading -> Unit
+ }
+ }
+ }
+
+ fun setEnabled(entry: AddonEntry, enabled: Boolean) {
+ viewModelScope.launch {
+ repository.setAddonEnabled(entry.addon.id, enabled).errorMessageOrNull()?.let { message ->
+ _state.update { it.copy(errorMessage = message) }
+ }
+ }
+ }
+
+ fun removeAddon(entry: AddonEntry) {
+ viewModelScope.launch {
+ repository.removeAddon(entry.addon.id).errorMessageOrNull()?.let { message ->
+ _state.update { it.copy(errorMessage = message) }
+ } ?: _state.update {
+ it.copy(
+ expandedAddonId = it.expandedAddonId.takeUnless { id -> id == entry.addon.id },
+ statusMessageRes = R.string.stremio_status_removed
+ )
+ }
+ }
+ }
+
+ fun moveAddon(entry: AddonEntry, offset: Int) {
+ viewModelScope.launch {
+ repository.moveAddon(entry.addon.id, offset).errorMessageOrNull()?.let { message ->
+ _state.update { it.copy(errorMessage = message) }
+ }
+ }
+ }
+
+ fun toggleExpanded(addonId: Long) {
+ _state.update {
+ it.copy(expandedAddonId = if (it.expandedAddonId == addonId) null else addonId)
+ }
+ }
+
+ fun setCatalogEnabled(entry: AddonEntry, catalogKey: String, enabled: Boolean) {
+ viewModelScope.launch {
+ repository.setCatalogEnabled(entry.addon.id, catalogKey, enabled).errorMessageOrNull()
+ ?.let { message -> _state.update { it.copy(errorMessage = message) } }
+ }
+ }
+
+ fun consumeStatusMessage() {
+ _state.update { it.copy(statusMessageRes = null) }
+ }
+
+ fun consumeError() {
+ _state.update { it.copy(errorMessage = null) }
+ }
+}
diff --git a/feature/stremio/src/main/res/values/strings.xml b/feature/stremio/src/main/res/values/strings.xml
new file mode 100644
index 00000000..d354e7c5
--- /dev/null
+++ b/feature/stremio/src/main/res/values/strings.xml
@@ -0,0 +1,20 @@
+<resources>
+ <string name="stremio_title">Addons</string>
+ <string name="stremio_subtitle">Stremio addons</string>
+ <string name="stremio_add">Add addon</string>
+ <string name="stremio_empty">No addons installed yet. Paste a Stremio addon manifest URL to get started.</string>
+ <string name="stremio_install_title">Add Stremio addon</string>
+ <string name="stremio_install_hint">https://example.com/manifest.json</string>
+ <string name="stremio_install_confirm">Add</string>
+ <string name="stremio_installing">Adding addon…</string>
+ <string name="stremio_cancel">Cancel</string>
+ <string name="stremio_enabled">Enabled</string>
+ <string name="stremio_move_up">Move up</string>
+ <string name="stremio_move_down">Move down</string>
+ <string name="stremio_catalogs">Catalogs</string>
+ <string name="stremio_remove">Remove</string>
+ <string name="stremio_status_installed">Addon installed</string>
+ <string name="stremio_status_removed">Addon removed</string>
+ <string name="stremio_no_catalogs">This addon exposes no browsable catalogs.</string>
+ <string name="stremio_version_format">Version %1$s</string>
+</resources>
diff --git a/feature/stremio/src/test/java/com/streamvault/feature/stremio/presentation/AddonsViewModelTest.kt b/feature/stremio/src/test/java/com/streamvault/feature/stremio/presentation/AddonsViewModelTest.kt
new file mode 100644
index 00000000..2422e6bd
--- /dev/null
+++ b/feature/stremio/src/test/java/com/streamvault/feature/stremio/presentation/AddonsViewModelTest.kt
@@ -0,0 +1,211 @@
+package com.streamvault.feature.stremio.presentation
+
+import com.google.common.truth.Truth.assertThat
+import com.streamvault.domain.model.Result
+import com.streamvault.domain.model.stremio.StremioAddon
+import com.streamvault.domain.model.stremio.StremioCatalogRef
+import com.streamvault.domain.model.stremio.StremioManifest
+import com.streamvault.domain.model.stremio.StremioManifestResource
+import com.streamvault.domain.model.stremio.StremioMediaType
+import com.streamvault.domain.model.stremio.StremioResourceKind
+import com.streamvault.domain.repository.StremioAddonRepository
+import com.streamvault.feature.stremio.R
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.test.StandardTestDispatcher
+import kotlinx.coroutines.test.advanceUntilIdle
+import kotlinx.coroutines.test.resetMain
+import kotlinx.coroutines.test.runTest
+import kotlinx.coroutines.test.setMain
+import org.junit.After
+import org.junit.Before
+import org.junit.Test
+
+@OptIn(ExperimentalCoroutinesApi::class)
+class AddonsViewModelTest {
+
+ private val dispatcher = StandardTestDispatcher()
+
+ @Before
+ fun setUp() {
+ Dispatchers.setMain(dispatcher)
+ }
+
+ @After
+ fun tearDown() {
+ Dispatchers.resetMain()
+ }
+
+ @Test
+ fun `addons load with their catalog snapshots`() = runTest(dispatcher) {
+ val repository = FakeStremioAddonRepository()
+ repository.addons.value = listOf(addon(id = 1L, name = "Cinemeta"))
+ repository.manifests[1L] = manifestWithOneCatalog()
+
+ val viewModel = AddonsViewModel(repository)
+ advanceUntilIdle()
+
+ val state = viewModel.state.value
+ assertThat(state.loading).isFalse()
+ assertThat(state.addons).hasSize(1)
+ assertThat(state.addons.first().addon.name).isEqualTo("Cinemeta")
+ assertThat(state.addons.first().catalogs.single().id).isEqualTo("top")
+ }
+
+ @Test
+ fun `install success closes the dialog and reports status`() = runTest(dispatcher) {
+ val repository = FakeStremioAddonRepository()
+ repository.installResult = Result.success(addon(id = 5L, name = "New Addon"))
+ val viewModel = AddonsViewModel(repository)
+ advanceUntilIdle()
+
+ viewModel.showInstallDialog()
+ viewModel.updateInstallUrl("https://example.test/manifest.json")
+ viewModel.install()
+ advanceUntilIdle()
+
+ val state = viewModel.state.value
+ assertThat(state.installDialogVisible).isFalse()
+ assertThat(state.installUrl).isEmpty()
+ assertThat(state.installing).isFalse()
+ assertThat(state.statusMessageRes).isEqualTo(R.string.stremio_status_installed)
+ assertThat(state.errorMessage).isNull()
+ }
+
+ @Test
+ fun `install failure keeps the dialog and shows the error`() = runTest(dispatcher) {
+ val repository = FakeStremioAddonRepository()
+ repository.installResult = Result.error("Addon request failed with HTTP 500")
+ val viewModel = AddonsViewModel(repository)
+ advanceUntilIdle()
+
+ viewModel.showInstallDialog()
+ viewModel.updateInstallUrl("https://example.test/manifest.json")
+ viewModel.install()
+ advanceUntilIdle()
+
+ val state = viewModel.state.value
+ assertThat(state.installDialogVisible).isTrue()
+ assertThat(state.installing).isFalse()
+ assertThat(state.errorMessage).contains("500")
+ }
+
+ @Test
+ fun `blank install urls are ignored`() = runTest(dispatcher) {
+ val repository = FakeStremioAddonRepository()
+ val viewModel = AddonsViewModel(repository)
+ advanceUntilIdle()
+
+ viewModel.showInstallDialog()
+ viewModel.updateInstallUrl(" ")
+ viewModel.install()
+ advanceUntilIdle()
+
+ assertThat(repository.installCalls).isEmpty()
+ assertThat(viewModel.state.value.installDialogVisible).isTrue()
+ }
+
+ @Test
+ fun `remove collapses the expanded card and reports status`() = runTest(dispatcher) {
+ val repository = FakeStremioAddonRepository()
+ repository.addons.value = listOf(addon(id = 3L, name = "Cinemeta"))
+ val viewModel = AddonsViewModel(repository)
+ advanceUntilIdle()
+
+ viewModel.toggleExpanded(3L)
+ viewModel.removeAddon(viewModel.state.value.addons.single())
+ advanceUntilIdle()
+
+ val state = viewModel.state.value
+ assertThat(repository.removedIds).containsExactly(3L)
+ assertThat(state.expandedAddonId).isNull()
+ assertThat(state.statusMessageRes).isEqualTo(R.string.stremio_status_removed)
+ }
+
+ @Test
+ fun `enabled move and catalog toggles reach the repository`() = runTest(dispatcher) {
+ val repository = FakeStremioAddonRepository()
+ repository.addons.value = listOf(addon(id = 7L, name = "Cinemeta"))
+ val viewModel = AddonsViewModel(repository)
+ advanceUntilIdle()
+ val entry = viewModel.state.value.addons.single()
+
+ viewModel.setEnabled(entry, enabled = false)
+ viewModel.moveAddon(entry, offset = -1)
+ viewModel.setCatalogEnabled(entry, "movie:top", enabled = false)
+ advanceUntilIdle()
+
+ assertThat(repository.lastEnabled).isEqualTo(7L to false)
+ assertThat(repository.lastMove).isEqualTo(7L to -1)
+ assertThat(repository.lastCatalogToggle).isEqualTo(Triple(7L, "movie:top", false))
+ }
+
+ private fun addon(id: Long, name: String): StremioAddon = StremioAddon(
+ id = id,
+ installUrl = "https://example.test/$id/manifest.json",
+ manifestId = "test.$id",
+ name = name,
+ version = "1.0.0"
+ )
+
+ private fun manifestWithOneCatalog(): StremioManifest = StremioManifest(
+ id = "test",
+ name = "Test",
+ version = "1.0.0",
+ types = listOf(StremioMediaType.MOVIE),
+ resources = listOf(StremioManifestResource(StremioResourceKind.CATALOG)),
+ catalogs = listOf(
+ StremioCatalogRef(type = StremioMediaType.MOVIE, id = "top", name = "Popular")
+ )
+ )
+}
+
+private class FakeStremioAddonRepository : StremioAddonRepository {
+ val addons = MutableStateFlow<List<StremioAddon>>(emptyList())
+ val manifests = mutableMapOf<Long, StremioManifest>()
+ val installCalls = mutableListOf<String>()
+ val removedIds = mutableListOf<Long>()
+ var installResult: Result<StremioAddon> = Result.error("not configured")
+ var lastEnabled: Pair<Long, Boolean>? = null
+ var lastMove: Pair<Long, Int>? = null
+ var lastCatalogToggle: Triple<Long, String, Boolean>? = null
+
+ override fun observeAddons(): Flow<List<StremioAddon>> = addons
+
+ override suspend fun getAddon(id: Long): StremioAddon? =
+ addons.value.firstOrNull { it.id == id }
+
+ override suspend fun getManifest(addonId: Long): StremioManifest? = manifests[addonId]
+
+ override suspend fun installAddon(installUrl: String): Result<StremioAddon> {
+ installCalls += installUrl
+ return installResult
+ }
+
+ override suspend fun removeAddon(id: Long): Result<Unit> {
+ removedIds += id
+ addons.value = addons.value.filterNot { it.id == id }
+ return Result.success(Unit)
+ }
+
+ override suspend fun setAddonEnabled(id: Long, enabled: Boolean): Result<Unit> {
+ lastEnabled = id to enabled
+ return Result.success(Unit)
+ }
+
+ override suspend fun moveAddon(id: Long, offset: Int): Result<Unit> {
+ lastMove = id to offset
+ return Result.success(Unit)
+ }
+
+ override suspend fun setCatalogEnabled(
+ addonId: Long,
+ catalogKey: String,
+ enabled: Boolean
+ ): Result<Unit> {
+ lastCatalogToggle = Triple(addonId, catalogKey, enabled)
+ return Result.success(Unit)
+ }
+}
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 6ca20243..989ce0aa 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -29,3 +29,4 @@ include(":feature:settings")
include(":feature:live")
include(":feature:catalog")
include(":feature:system")
+include(":feature:stremio")