Skip to content

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

Improve Stremio browsing and extension UX

David Nashashb60bd843c97c
diff --git a/app/src/main/java/com/streamvault/app/plugins/StreamVaultPluginManager.kt b/app/src/main/java/com/streamvault/app/plugins/StreamVaultPluginManager.kt
index 502156eb..6cddbc41 100644
--- a/app/src/main/java/com/streamvault/app/plugins/StreamVaultPluginManager.kt
+++ b/app/src/main/java/com/streamvault/app/plugins/StreamVaultPluginManager.kt
@@ -483,6 +483,20 @@ class StreamVaultPluginManager @Inject constructor(
suspend fun preparePlaybackUrl(url: String): Result<Unit> =
preparePlaybackStreamInfo(StreamInfo(url = url)).map { Unit }
+ suspend fun hasEnabledMagnetPlaybackPlugin(): Boolean = try {
+ withPluginPlaybackDeadline(PLAYBACK_TOTAL_TIMEOUT_MILLIS) {
+ playbackCandidates(
+ discoverPlugins(),
+ "magnet:?xt=urn:btih:0000000000000000000000000000000000000000",
+ StreamVaultPluginContract.CAPABILITY_PLAYBACK_PREPARE
+ ).isNotEmpty()
+ } ?: false
+ } catch (cancelled: CancellationException) {
+ throw cancelled
+ } catch (_: Exception) {
+ false
+ }
+
suspend fun preparePlaybackStreamInfo(streamInfo: StreamInfo): Result<StreamInfo> = withContext(Dispatchers.IO) {
val url = streamInfo.url
if (url.isBlank()) return@withContext Result.success(streamInfo)
diff --git a/app/src/main/java/com/streamvault/app/stremio/AppStremioBindings.kt b/app/src/main/java/com/streamvault/app/stremio/AppStremioBindings.kt
new file mode 100644
index 00000000..f3ab8b99
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/stremio/AppStremioBindings.kt
@@ -0,0 +1,18 @@
+package com.streamvault.app.stremio
+
+import com.streamvault.feature.stremio.api.StremioTorrentPlaybackAvailability
+import dagger.Binds
+import dagger.Module
+import dagger.hilt.InstallIn
+import dagger.hilt.components.SingletonComponent
+import javax.inject.Singleton
+
+@Module
+@InstallIn(SingletonComponent::class)
+abstract class AppStremioBindings {
+ @Binds
+ @Singleton
+ abstract fun bindStremioTorrentPlaybackAvailability(
+ impl: AppStremioTorrentPlaybackAvailability
+ ): StremioTorrentPlaybackAvailability
+}
diff --git a/app/src/main/java/com/streamvault/app/stremio/AppStremioTorrentPlaybackAvailability.kt b/app/src/main/java/com/streamvault/app/stremio/AppStremioTorrentPlaybackAvailability.kt
new file mode 100644
index 00000000..62fc2a0d
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/stremio/AppStremioTorrentPlaybackAvailability.kt
@@ -0,0 +1,14 @@
+package com.streamvault.app.stremio
+
+import com.streamvault.app.plugins.StreamVaultPluginManager
+import com.streamvault.feature.stremio.api.StremioTorrentPlaybackAvailability
+import javax.inject.Inject
+import javax.inject.Singleton
+
+@Singleton
+class AppStremioTorrentPlaybackAvailability @Inject constructor(
+ private val pluginManager: StreamVaultPluginManager
+) : StremioTorrentPlaybackAvailability {
+ override suspend fun hasEnabledMagnetPlugin(): Boolean =
+ pluginManager.hasEnabledMagnetPlaybackPlugin()
+}
diff --git a/core/ui/src/main/java/com/streamvault/core/ui/components/SearchInput.kt b/core/ui/src/main/java/com/streamvault/core/ui/components/SearchInput.kt
index d0ab0ab0..e659cb7a 100644
--- a/core/ui/src/main/java/com/streamvault/core/ui/components/SearchInput.kt
+++ b/core/ui/src/main/java/com/streamvault/core/ui/components/SearchInput.kt
@@ -84,7 +84,7 @@ fun SearchInput(
val isTelevisionDevice = rememberIsTelevisionDevice()
var hasContainerFocus by remember { mutableStateOf(false) }
var hasInputFocus by remember { mutableStateOf(false) }
- var acceptsInput by remember(isTelevisionDevice) { mutableStateOf(!isTelevisionDevice) }
+ var acceptsInput by remember { mutableStateOf(false) }
var pendingInputActivation by remember { mutableStateOf(false) }
var textFieldValue by remember {
mutableStateOf(TextFieldValue(text = value, selection = TextRange(value.length)))
@@ -153,7 +153,7 @@ fun SearchInput(
pendingInputActivation = false
}
- BackHandler(enabled = shouldConsumeSearchInputBack(isTelevisionDevice, acceptsInput)) {
+ BackHandler(enabled = shouldConsumeSearchInputBack(acceptsInput)) {
pendingInputActivation = false
acceptsInput = false
keyboardController?.hide()
@@ -217,7 +217,7 @@ fun SearchInput(
.fillMaxWidth()
.focusRequester(inputFocusRequester)
.focusProperties {
- canFocus = enabled && (!isTelevisionDevice || acceptsInput)
+ canFocus = enabled && acceptsInput
if (isTelevisionDevice && acceptsInput) {
left = FocusRequester.Cancel
right = FocusRequester.Cancel
@@ -228,9 +228,7 @@ fun SearchInput(
if (it.hasFocus) {
requestBringIntoView(120)
} else {
- if (isTelevisionDevice) {
- acceptsInput = false
- }
+ acceptsInput = false
keyboardController?.hide()
}
}
@@ -257,7 +255,7 @@ fun SearchInput(
singleLine = true,
cursorBrush = SolidColor(Primary),
enabled = enabled,
- readOnly = isTelevisionDevice && !acceptsInput,
+ readOnly = !acceptsInput,
keyboardOptions = KeyboardOptions(imeAction = imeAction),
keyboardActions = KeyboardActions(
onSearch = {
@@ -293,7 +291,4 @@ fun SearchInput(
}
}
-internal fun shouldConsumeSearchInputBack(
- isTelevisionDevice: Boolean,
- acceptsInput: Boolean,
-): Boolean = isTelevisionDevice && acceptsInput
+internal fun shouldConsumeSearchInputBack(acceptsInput: Boolean): Boolean = acceptsInput
diff --git a/core/ui/src/test/java/com/streamvault/core/ui/components/SearchInputBehaviorTest.kt b/core/ui/src/test/java/com/streamvault/core/ui/components/SearchInputBehaviorTest.kt
index 77a90129..c4d2ccf5 100644
--- a/core/ui/src/test/java/com/streamvault/core/ui/components/SearchInputBehaviorTest.kt
+++ b/core/ui/src/test/java/com/streamvault/core/ui/components/SearchInputBehaviorTest.kt
@@ -5,13 +5,8 @@ import org.junit.Test
class SearchInputBehaviorTest {
@Test
- fun `TV Back is consumed only while the field is editing`() {
- assertThat(shouldConsumeSearchInputBack(isTelevisionDevice = true, acceptsInput = true)).isTrue()
- assertThat(shouldConsumeSearchInputBack(isTelevisionDevice = true, acceptsInput = false)).isFalse()
- }
-
- @Test
- fun `touch search leaves Back ownership with the enclosing surface`() {
- assertThat(shouldConsumeSearchInputBack(isTelevisionDevice = false, acceptsInput = true)).isFalse()
+ fun `Back is consumed only while the field is explicitly editing`() {
+ assertThat(shouldConsumeSearchInputBack(acceptsInput = true)).isTrue()
+ assertThat(shouldConsumeSearchInputBack(acceptsInput = false)).isFalse()
}
}
diff --git a/data/schemas/com.streamvault.data.local.StreamVaultDatabase/84.json b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/84.json
new file mode 100644
index 00000000..428aea3d
--- /dev/null
+++ b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/84.json
@@ -0,0 +1,7385 @@
+{
+ "formatVersion": 1,
+ "database": {
+ "version": 84,
+ "identityHash": "ded848d29a3eb630bdeefe50eb889180",
+ "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_series_id_episode_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "series_id",
+ "episode_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_episodes_provider_id_series_id_episode_id` ON `${TABLE_NAME}` (`provider_id`, `series_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, `output_credentials_encrypted` 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": "outputCredentialsEncrypted",
+ "columnName": "output_credentials_encrypted",
+ "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, `smb_url` TEXT, `smb_credentials_encrypted` 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": "smbUrl",
+ "columnName": "smb_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "smbCredentialsEncrypted",
+ "columnName": "smb_credentials_encrypted",
+ "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, `sealed_session_id` INTEGER, `sealed_row_count` INTEGER NOT NULL DEFAULT 0, `sealed_configuration_generation` INTEGER, `sealed_mapping_profile` TEXT, `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": "sealedSessionId",
+ "columnName": "sealed_session_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "sealedRowCount",
+ "columnName": "sealed_row_count",
+ "affinity": "INTEGER",
+ "notNull": true,
+ "defaultValue": "0"
+ },
+ {
+ "fieldPath": "sealedConfigurationGeneration",
+ "columnName": "sealed_configuration_generation",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "sealedMappingProfile",
+ "columnName": "sealed_mapping_profile",
+ "affinity": "TEXT"
+ },
+ {
+ "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_live_category_retries",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `category_name` TEXT NOT NULL, `configuration_generation` INTEGER NOT NULL, `attempt_count` INTEGER NOT NULL, `last_attempt_at` INTEGER NOT NULL, `last_error` 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": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "configurationGeneration",
+ "columnName": "configuration_generation",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "attemptCount",
+ "columnName": "attempt_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastAttemptAt",
+ "columnName": "last_attempt_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_stalker_live_category_retries_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_stalker_live_category_retries_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "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`)"
+ }
+ ]
+ },
+ {
+ "tableName": "stremio_playback_history",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`content_key` TEXT NOT NULL, `media_type` TEXT NOT NULL, `exact_video_id` TEXT NOT NULL, `parent_series_id` TEXT, `title` TEXT NOT NULL, `poster_url` TEXT, `resume_position_ms` INTEGER NOT NULL, `total_duration_ms` INTEGER NOT NULL, `is_watched` INTEGER NOT NULL, `last_watched_at` INTEGER NOT NULL, `catalog_origin_key` TEXT NOT NULL, `stream_origin_key_hint` TEXT, PRIMARY KEY(`content_key`))",
+ "fields": [
+ {
+ "fieldPath": "contentKey",
+ "columnName": "content_key",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "mediaType",
+ "columnName": "media_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "exactVideoId",
+ "columnName": "exact_video_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "parentSeriesId",
+ "columnName": "parent_series_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "resumePositionMs",
+ "columnName": "resume_position_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalDurationMs",
+ "columnName": "total_duration_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isWatched",
+ "columnName": "is_watched",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastWatchedAt",
+ "columnName": "last_watched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catalogOriginKey",
+ "columnName": "catalog_origin_key",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamOriginKeyHint",
+ "columnName": "stream_origin_key_hint",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "content_key"
+ ]
+ }
+ }
+ ],
+ "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, 'ded848d29a3eb630bdeefe50eb889180')"
+ ]
+ }
+}
\ 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 3bcb48bc..ee2dfc53 100644
--- a/data/src/androidTest/java/com/streamvault/data/local/StreamVaultDatabaseMigrationTest.kt
+++ b/data/src/androidTest/java/com/streamvault/data/local/StreamVaultDatabaseMigrationTest.kt
@@ -2121,6 +2121,92 @@ class StreamVaultDatabaseMigrationTest {
migrated.close()
}
+ @Test
+ fun migratePreMergeStremioV80To84_repairsSchemaAndPreservesUserData() {
+ val name = "streamvault-premerge-stremio-v80-84"
+ migrationTestHelper.createDatabase(name, 80).apply {
+ execSQL("DROP INDEX `index_episodes_provider_id_series_id_episode_id`")
+ execSQL(
+ "CREATE UNIQUE INDEX `index_episodes_provider_id_episode_id` " +
+ "ON `episodes` (`provider_id`, `episode_id`)"
+ )
+ listOf(
+ "sealed_session_id",
+ "sealed_row_count",
+ "sealed_configuration_generation",
+ "sealed_mapping_profile"
+ ).forEach { column ->
+ execSQL("ALTER TABLE `xtream_live_onboarding_state` DROP COLUMN `$column`")
+ }
+
+ insertProvider78(1, "Synthetic Xtream", "XTREAM_CODES")
+ execSQL(
+ """
+ INSERT INTO xtream_live_onboarding_state (
+ provider_id, provider_type, content_type, phase, staged_session_id,
+ import_strategy, next_category_index, accepted_row_count, staged_flush_count,
+ sync_profile_tier, sync_profile_batch_size, sync_profile_strategy,
+ sync_profile_low_memory, sync_profile_memory_class_mb,
+ sync_profile_available_mem_mb, last_error, created_at, updated_at, completed_at
+ ) VALUES (1, 'XTREAM_CODES', 'LIVE', 'STAGED', 123, 'full', 2, 7, 1,
+ 'MID', 250, 'STREAM_ALL', 0, 192, 512, NULL, 100, 200, NULL)
+ """.trimIndent()
+ )
+ insertSeries78(30, 3001, 1, "First Series", 555)
+ insertSeries78(31, 3002, 1, "Second Series", 666)
+ insertEpisode78(40, 10001, 30, 1, "First S01E01")
+
+ // The earlier Stremio schema already contained these tables at v80.
+ FeatureMigrationsV82To83.MIGRATION_82_83.migrate(this)
+ execSQL(
+ """
+ INSERT INTO stremio_addons (
+ id, install_url, manifest_id, name, version, manifest_json, enabled,
+ sort_order, catalog_settings_json, created_at, updated_at
+ ) VALUES (1, 'https://addon.example/manifest.json', 'fixture.addon', 'Fixture Add-on',
+ '1.2.3', '{}', 1, 0, '{}', 100, 200)
+ """.trimIndent()
+ )
+ execSQL(
+ """
+ INSERT INTO stremio_playback_history (
+ content_key, media_type, exact_video_id, parent_series_id, title, poster_url,
+ resume_position_ms, total_duration_ms, is_watched, last_watched_at,
+ catalog_origin_key, stream_origin_key_hint
+ ) VALUES ('movie:fixture', 'movie', 'fixture', NULL, 'Saved Movie', NULL,
+ 12000, 90000, 0, 300, 'fixture.addon', NULL)
+ """.trimIndent()
+ )
+ close()
+ }
+
+ val migrationPath = StreamVaultDatabaseMigrationRegistry.all
+ .filter { it.startVersion >= 80 }
+ val migrated = migrationTestHelper.runMigrationsAndValidate(
+ name,
+ 84,
+ true,
+ *migrationPath.toTypedArray()
+ )
+
+ assertEquals(1, countRows(migrated, "SELECT COUNT(*) FROM providers WHERE id=1 AND name='Synthetic Xtream'"))
+ assertEquals(1, countRows(migrated, """
+ SELECT COUNT(*) FROM xtream_live_onboarding_state
+ WHERE provider_id=1 AND staged_session_id=123 AND next_category_index=2
+ AND accepted_row_count=7 AND sealed_session_id IS NULL AND sealed_row_count=0
+ AND sealed_configuration_generation IS NULL AND sealed_mapping_profile IS NULL
+ """.trimIndent()))
+ assertEquals(0, countRows(migrated, "SELECT COUNT(*) FROM pragma_index_list('episodes') WHERE name='index_episodes_provider_id_episode_id'"))
+ assertEquals(1, countRows(migrated, "SELECT COUNT(*) FROM pragma_index_list('episodes') WHERE name='index_episodes_provider_id_series_id_episode_id' AND `unique`=1"))
+ assertEquals(2, countRows(migrated, "SELECT COUNT(*) FROM series WHERE provider_id=1 AND detail_hydrated_at=1"))
+ migrated.insertEpisode78(41, 10001, 31, 1, "Second S01E01")
+ assertEquals(2, countRows(migrated, "SELECT COUNT(*) FROM episodes WHERE provider_id=1 AND episode_id=10001"))
+ assertEquals(1, countRows(migrated, "SELECT COUNT(*) FROM stremio_addons WHERE id=1 AND name='Fixture Add-on' AND enabled=1"))
+ assertEquals(1, countRows(migrated, "SELECT COUNT(*) FROM stremio_playback_history WHERE content_key='movie:fixture' AND resume_position_ms=12000"))
+ assertEquals(0, countRows(migrated, "SELECT COUNT(*) FROM pragma_foreign_key_check"))
+ migrated.close()
+ }
+
private fun SupportSQLiteDatabase.insertProvider78(id: Long, name: String, type: String) {
execSQL(
"INSERT INTO providers (id,name,type,is_active,status,last_synced_at,created_at) VALUES (?,?,?,1,'UNKNOWN',0,0)",
diff --git a/data/src/main/java/com/streamvault/data/local/FeatureMigrationsV83To84.kt b/data/src/main/java/com/streamvault/data/local/FeatureMigrationsV83To84.kt
new file mode 100644
index 00000000..72169e65
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/local/FeatureMigrationsV83To84.kt
@@ -0,0 +1,54 @@
+package com.streamvault.data.local
+
+import androidx.room.migration.Migration
+import androidx.sqlite.db.SupportSQLiteDatabase
+
+/** Repairs schema variants produced by the pre-merge Stremio branch at versions 79-80. */
+internal object FeatureMigrationsV83To84 {
+ val MIGRATION_83_84 = object : Migration(83, 84) {
+ override fun migrate(db: SupportSQLiteDatabase) {
+ val receiptColumns = listOf(
+ "sealed_session_id" to "INTEGER",
+ "sealed_row_count" to "INTEGER NOT NULL DEFAULT 0",
+ "sealed_configuration_generation" to "INTEGER",
+ "sealed_mapping_profile" to "TEXT"
+ )
+ val missingReceiptColumns = receiptColumns.filter { (name, _) ->
+ !tableHasColumn(db, "xtream_live_onboarding_state", name)
+ }
+ val hasLegacyEpisodeIndex = hasIndex(db, "episodes", "index_episodes_provider_id_episode_id")
+ val isPreMergeStremioSchema = missingReceiptColumns.isNotEmpty() || hasLegacyEpisodeIndex
+
+ missingReceiptColumns.forEach { (name, declaration) ->
+ db.execSQL(
+ "ALTER TABLE `xtream_live_onboarding_state` " +
+ "ADD COLUMN `$name` $declaration"
+ )
+ }
+
+ db.execSQL("DROP INDEX IF EXISTS `index_episodes_provider_id_episode_id`")
+ db.execSQL(
+ "CREATE UNIQUE INDEX IF NOT EXISTS " +
+ "`index_episodes_provider_id_series_id_episode_id` " +
+ "ON `episodes` (`provider_id`, `series_id`, `episode_id`)"
+ )
+
+ if (isPreMergeStremioSchema) {
+ // Version 78→79 also expired these caches when it repaired the old episode key.
+ db.execSQL("UPDATE `series` SET `detail_hydrated_at` = 1 WHERE `detail_hydrated_at` > 0")
+ }
+
+ validateForeignKeys(db, "xtream_live_onboarding_state", "episodes")
+ }
+ }
+
+ private fun hasIndex(db: SupportSQLiteDatabase, tableName: String, indexName: String): Boolean =
+ db.query("PRAGMA index_list(`$tableName`)").use { cursor ->
+ val nameIndex = cursor.getColumnIndexOrThrow("name")
+ var found = false
+ while (cursor.moveToNext()) {
+ if (cursor.getString(nameIndex) == indexName) found = true
+ }
+ found
+ }
+}
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 25be2211..591060b5 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 = 83
+internal const val STREAM_VAULT_DATABASE_VERSION = 84
@Database(
entities = [
@@ -217,5 +217,6 @@ abstract class StreamVaultDatabase : RoomDatabase() {
val MIGRATION_80_81 = FeatureMigrationsV80To81.MIGRATION_80_81
val MIGRATION_81_82 = FeatureMigrationsV81To82.MIGRATION_81_82
val MIGRATION_82_83 = FeatureMigrationsV82To83.MIGRATION_82_83
+ val MIGRATION_83_84 = FeatureMigrationsV83To84.MIGRATION_83_84
}
}
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 9fd432c1..1dbb33fd 100644
--- a/data/src/main/java/com/streamvault/data/local/StreamVaultDatabaseMigrationRegistry.kt
+++ b/data/src/main/java/com/streamvault/data/local/StreamVaultDatabaseMigrationRegistry.kt
@@ -20,7 +20,8 @@ object StreamVaultDatabaseMigrationRegistry {
val v80To81: List<Migration> = listOf(FeatureMigrationsV80To81.MIGRATION_80_81)
val v81To82: List<Migration> = listOf(FeatureMigrationsV81To82.MIGRATION_81_82)
val v82To83: List<Migration> = listOf(FeatureMigrationsV82To83.MIGRATION_82_83)
- val all: List<Migration> = (v1To24 + v24To49 + v49To75 + v75To76 + v76To77 + v77To78 + v78To79 + v79To80 + v80To81 + v81To82 + v82To83).also(::validate)
+ val v83To84: List<Migration> = listOf(FeatureMigrationsV83To84.MIGRATION_83_84)
+ val all: List<Migration> = (v1To24 + v24To49 + v49To75 + v75To76 + v76To77 + v77To78 + v78To79 + v79To80 + v80To81 + v81To82 + v82To83 + v83To84).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
index 989504ab..12133564 100644
--- a/data/src/main/java/com/streamvault/data/local/dao/StremioAddonDao.kt
+++ b/data/src/main/java/com/streamvault/data/local/dao/StremioAddonDao.kt
@@ -27,6 +27,12 @@ interface StremioAddonDao {
@Insert
suspend fun insert(entity: StremioAddonEntity): Long
+ @Query(
+ "UPDATE stremio_addons SET manifest_id = :manifestId, name = :name, version = :version, " +
+ "manifest_json = :manifestJson, updated_at = :updatedAt WHERE id = :id"
+ )
+ suspend fun updateManifest(id: Long, manifestId: String, name: String, version: String, manifestJson: String, updatedAt: Long)
+
@Query("UPDATE stremio_addons SET enabled = :enabled, updated_at = :updatedAt WHERE id = :id")
suspend fun setEnabled(id: Long, enabled: Boolean, updatedAt: Long)
diff --git a/data/src/main/java/com/streamvault/data/repository/StremioAddonRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/StremioAddonRepositoryImpl.kt
index f57727ec..b208ba12 100644
--- a/data/src/main/java/com/streamvault/data/repository/StremioAddonRepositoryImpl.kt
+++ b/data/src/main/java/com/streamvault/data/repository/StremioAddonRepositoryImpl.kt
@@ -102,6 +102,13 @@ class StremioAddonRepositoryImpl @Inject constructor(
type: StremioMediaType,
exactId: String,
addonIds: Set<Long>?
+ ): StremioResourceResolution<StremioStream> = resolveStreamsProgressively(type, exactId, addonIds) {}
+
+ override suspend fun resolveStreamsProgressively(
+ type: StremioMediaType,
+ exactId: String,
+ addonIds: Set<Long>?,
+ onProgress: suspend (StremioResourceResolution<StremioStream>) -> Unit
): StremioResourceResolution<StremioStream> {
val eligible = resourceResolver.candidates(
addons = resourceCandidates(),
@@ -110,9 +117,9 @@ class StremioAddonRepositoryImpl @Inject constructor(
exactId = exactId,
addonIds = addonIds
)
- return resourceResolver.resolveMany(eligible) { addon ->
+ return resourceResolver.resolveMany(eligible, request = { addon ->
client.fetchStreams(addon.installUrl, type, exactId)
- }
+ }, onProgress = onProgress)
}
override suspend fun resolveSubtitles(
@@ -130,7 +137,7 @@ class StremioAddonRepositoryImpl @Inject constructor(
exactId = exactVideoId,
addonIds = addonIds
)
- return resourceResolver.resolveMany(eligible) { addon ->
+ return resourceResolver.resolveMany(eligible, request = { addon ->
client.fetchSubtitles(
addon.installUrl,
type,
@@ -139,7 +146,7 @@ class StremioAddonRepositoryImpl @Inject constructor(
videoSize,
filename
)
- }
+ })
}
private suspend fun resourceCandidates(): List<StremioInstalledAddon> = dao.getAll().asSequence()
@@ -181,6 +188,29 @@ class StremioAddonRepositoryImpl @Inject constructor(
return Result.success(entity.copy(id = id).toDomain())
}
+ override suspend fun refreshAddon(id: Long): Result<StremioAddon> {
+ val existing = dao.getById(id) ?: return Result.error("Addon is not installed")
+ val snapshotResult = client.fetchManifestSnapshot(existing.installUrl)
+ val snapshot = snapshotResult.getOrNull() ?: return Result.error(
+ snapshotResult.errorMessageOrNull() ?: "Addon manifest could not be refreshed",
+ (snapshotResult as? Result.Error)?.exception
+ )
+ if (snapshot.manifest.behaviorHints.configurationRequired) {
+ return Result.error("This addon still requires configuration in its browser setup.")
+ }
+ val now = System.currentTimeMillis()
+ dao.updateManifest(
+ id = id,
+ manifestId = snapshot.manifest.id,
+ name = snapshot.manifest.name,
+ version = snapshot.manifest.version,
+ manifestJson = snapshot.manifestJson,
+ updatedAt = now
+ )
+ val refreshed = dao.getById(id) ?: return Result.error("Addon disappeared during refresh")
+ return Result.success(refreshed.toDomain())
+ }
+
override suspend fun removeAddon(id: Long): Result<Unit> {
dao.delete(id)
return Result.success(Unit)
diff --git a/data/src/test/java/com/streamvault/data/local/StreamVaultDatabaseMigrationRegistryTest.kt b/data/src/test/java/com/streamvault/data/local/StreamVaultDatabaseMigrationRegistryTest.kt
index ab916306..8c4a56ec 100644
--- a/data/src/test/java/com/streamvault/data/local/StreamVaultDatabaseMigrationRegistryTest.kt
+++ b/data/src/test/java/com/streamvault/data/local/StreamVaultDatabaseMigrationRegistryTest.kt
@@ -32,5 +32,6 @@ class StreamVaultDatabaseMigrationRegistryTest {
assertThat(StreamVaultDatabaseMigrationRegistry.v80To81.single().endVersion).isEqualTo(81)
assertThat(StreamVaultDatabaseMigrationRegistry.v81To82.single().endVersion).isEqualTo(82)
assertThat(StreamVaultDatabaseMigrationRegistry.v82To83.single().endVersion).isEqualTo(83)
+ assertThat(StreamVaultDatabaseMigrationRegistry.v83To84.single().endVersion).isEqualTo(84)
}
}
diff --git a/data/src/test/java/com/streamvault/data/repository/StremioAddonRepositoryImplTest.kt b/data/src/test/java/com/streamvault/data/repository/StremioAddonRepositoryImplTest.kt
index 221bf388..7a477e7d 100644
--- a/data/src/test/java/com/streamvault/data/repository/StremioAddonRepositoryImplTest.kt
+++ b/data/src/test/java/com/streamvault/data/repository/StremioAddonRepositoryImplTest.kt
@@ -99,6 +99,39 @@ class StremioAddonRepositoryImplTest {
assertThat(addons.map { it.name }).containsExactly("One", "Two").inOrder()
}
+ @Test
+ fun `refresh updates manifest while preserving install choices and ordering`() = runTest {
+ server.enqueue(manifestResponse("com.one", "One"))
+ val installed = repository.installAddon("${baseUrl()}/one").getOrNull()!!
+ dao.setEnabled(installed.id, false, 250)
+ dao.setSortOrder(installed.id, 4, 250)
+ dao.setCatalogSettings(installed.id, "{\"movie:top\":false}", 250)
+ server.enqueue(manifestResponse("com.one", "Renamed One"))
+
+ val refreshed = repository.refreshAddon(installed.id).getOrNull()!!
+
+ assertThat(refreshed.id).isEqualTo(installed.id)
+ assertThat(refreshed.installUrl).isEqualTo(installed.installUrl)
+ assertThat(refreshed.name).isEqualTo("Renamed One")
+ assertThat(refreshed.enabled).isFalse()
+ assertThat(refreshed.sortOrder).isEqualTo(4)
+ assertThat(refreshed.isCatalogEnabled("movie:top")).isFalse()
+ assertThat(refreshed.createdAt).isEqualTo(installed.createdAt)
+ }
+
+ @Test
+ fun `refresh failure keeps the saved manifest`() = runTest {
+ server.enqueue(manifestResponse("com.one", "One"))
+ val installed = repository.installAddon("${baseUrl()}/one").getOrNull()!!
+ server.enqueue(MockResponse().setResponseCode(503).setBody("temporary outage"))
+
+ val refreshed = repository.refreshAddon(installed.id)
+
+ assertThat(refreshed.isError).isTrue()
+ assertThat(dao.getById(installed.id)?.manifestJson).isEqualTo(installed.manifestJson)
+ assertThat(dao.getById(installed.id)?.name).isEqualTo(installed.name)
+ }
+
@Test
fun `manifest failures surface the addon error`() = runTest {
server.enqueue(MockResponse().setResponseCode(500).setBody("boom"))
@@ -454,6 +487,25 @@ private class FakeStremioAddonDao : StremioAddonDao {
return id
}
+ override suspend fun updateManifest(
+ id: Long,
+ manifestId: String,
+ name: String,
+ version: String,
+ manifestJson: String,
+ updatedAt: Long
+ ) {
+ addons.value = addons.value.map { entity ->
+ if (entity.id == id) entity.copy(
+ manifestId = manifestId,
+ name = name,
+ version = version,
+ manifestJson = manifestJson,
+ updatedAt = updatedAt
+ ) else entity
+ }
+ }
+
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
diff --git a/docs/DATABASE_MIGRATION_INVARIANTS.md b/docs/DATABASE_MIGRATION_INVARIANTS.md
index bf8535e4..3948505f 100644
--- a/docs/DATABASE_MIGRATION_INVARIANTS.md
+++ b/docs/DATABASE_MIGRATION_INVARIANTS.md
@@ -14,14 +14,16 @@ Every schema change must satisfy this checklist before the database version is a
## Current verification requirements
-- Current schema: v81.
-- Exported historical origins: v1 and v3-v80; v2 has no committed Room schema export.
-- Required migration coverage: `StreamVaultDatabaseMigrationTest` must validate exported origins through v81 plus populated direct/multi-hop preservation fixtures.
+- Current schema: v84.
+- Exported historical origins: v1 and v3-v83; v2 has no committed Room schema export.
+- Required migration coverage: `StreamVaultDatabaseMigrationTest` must validate exported origins through v84 plus populated direct/multi-hop preservation fixtures and the legacy Stremio schema fixture described below.
- Migration 78 → 79 scopes episode uniqueness to the owning series and expires hydrated series detail timestamps.
- Migration 79 → 80 adds the four Xtream live receipt columns; migration 80 → 81 creates the durable Stalker live-category retry table and its provider index.
-- Versions 79 and 80 were reordered during branch integration. The discarded branch schemas have no upgrade users and are not supported migration origins; their episode-index repair is intentionally omitted.
+- Versions 79 and 80 were reordered during branch integration. The discarded non-Stremio branch schemas have no upgrade users and are not supported migration origins; their episode-index repair is intentionally omitted.
+- The pre-merge Stremio branch independently exported schema v80 with the same version number but no Xtream receipt columns, the old `(provider_id, episode_id)` episode index, and Stremio add-on/history tables. `FeatureMigrationsV83To84` repairs that known variant after its multi-hop path, preserving Stremio rows and invalidating affected hydrated-series cache timestamps. A populated migration fixture exercises this variant; do not treat it as one of the unsupported discarded non-Stremio schemas.
## Validation (2026-10-10)
-- All 45 `StreamVaultDatabaseMigrationTest` tests passed on `Television_4K_2(AVD) - 16` using `:data:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.streamvault.data.local.StreamVaultDatabaseMigrationTest`.
+- All 45 `StreamVaultDatabaseMigrationTest` tests passed on `Television_4K_2(AVD) - 16` using `:data:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.streamvault.data.local.StreamVaultDatabaseMigrationTest` on 2026-10-10, against schema v81.
- Coverage includes every committed historical schema to v81, populated v78 → v80 → v81 receipt preservation, and direct v80 → v81 Stalker retry creation with episode/timestamp preservation and provider-delete cascade checks.
+- Current Stremio worktree validation on 2026-10-16: all 47 `StreamVaultDatabaseMigrationTest` tests passed on `emulator-5558` against schema v84, including a populated synthetic fixture for the pre-merge Stremio v80 schema and preservation of provider, add-on, playback-history, and episode data.
diff --git a/docs/STREMIO_UX_AND_FUNCTIONALITY_PLAN.md b/docs/STREMIO_UX_AND_FUNCTIONALITY_PLAN.md
index 168c90f3..bbe7cb6b 100644
--- a/docs/STREMIO_UX_AND_FUNCTIONALITY_PLAN.md
+++ b/docs/STREMIO_UX_AND_FUNCTIONALITY_PLAN.md
@@ -1,7 +1,7 @@
# Stremio and Extensions UX and functionality improvement plan
- Date: 2026-10-16.
-- Status: Planning only; implementation has not started.
+- Status: Implementation in progress; debug APK is installed on the requested emulator; manual UX and real-torrent acceptance remain pending.
- Reviewed baseline: `f1ac7d3d` on `feature/stremio-addons`.
- Worktree: `D:\antigravity-scratch\iptv-player\.worktrees\stremio-addons`.
@@ -172,11 +172,11 @@ through a real torrent session or an emulator database upgrade during this revie
Addresses R1-R2.
-- [ ] Repair magnet handoff without applying the direct-HTTP header requirement
+- [x] Repair magnet handoff without applying the direct-HTTP header requirement
to the original magnet URI; preserve meaningful plugin failures.
-- [ ] Audit supported upgrade origins against the historical Stremio and develop
+- [x] Audit supported upgrade origins against the historical Stremio and develop
schemas, including the episode index and four Xtream receipt columns.
-- [ ] Add an appropriate forward compatibility migration for supported legacy
+- [x] Add an appropriate forward compatibility migration for supported legacy
variants and the already-installed current schema. Follow the database
invariants, export the final schema, and preserve providers, add-on settings,
recordings, and playback history.
@@ -190,21 +190,23 @@ final Room schema and foreign keys, and a current debug APK builds.
Addresses UI decisions 1-3 and 5; R3, R6, R9, R11, and R12.
-- [ ] Separate management and dedicated browse routes with explicit Back targets.
-- [ ] Replace the installed-state hero with the compact header and add-on rows.
-- [ ] Apply the same compact installed-state hierarchy to Plugins: put URL/APK
+- [x] Separate management and dedicated browse routes with explicit Back targets.
+- [x] Replace the installed-state hero with the compact header and add-on rows.
+- [x] Apply the same compact installed-state hierarchy to Plugins: put URL/APK
installation behind Add plugin, retain refresh, and make its list the primary
vertical content area.
-- [ ] Keep Extensions as a full-screen shell destination with compact section
+- [x] Keep Extensions as a full-screen shell destination with compact section
tabs; make plugin configuration a nested page with a Back-to-Plugins header
and no duplicate section tabs.
-- [ ] Add capability-aware details, catalog settings, ordering, and removal
- confirmation. Make repeated actions safe and restore focus after a row changes
- or is removed.
-- [ ] Add manifest refresh preserving install identity, enabled state, catalog
+- [x] Add capability-aware details, catalog settings, ordering, and removal
+ confirmation. Make repeated actions safe.
+- [ ] Verify explicit remote-focus restoration after a row is reordered or
+ removed; stable row keys are in place, but this needs targeted testing on the
+ installed TV emulator.
+- [x] Add manifest refresh preserving install identity, enabled state, catalog
choices, ordering, and history. Keep the saved manifest if refresh fails.
Invalidate affected browse data after successful refresh.
-- [ ] Preserve the larger empty-install introduction and compact install dialog.
+- [x] Preserve the larger empty-install introduction and compact install dialog.
Gate: management state/action tests pass; the user can inspect the refreshed
management screen and its empty, disabled, and streams-only states.
@@ -213,15 +215,15 @@ management screen and its empty, disabled, and streams-only states.
Addresses UI decisions 2, 4, and 5; R3-R4 and the catalog portion of R7-R8.
-- [ ] Use the established browsing grid/components with a compact toolbar.
-- [ ] Implement capability-aware catalog selection, search, and filter pickers.
-- [ ] Use shared click/OK-to-edit search and retain the draft/query on exit.
-- [ ] Fetch the selected catalog on demand and cancel obsolete work.
-- [ ] Preserve results during replacement requests and show distinct loading,
+- [x] Use the established browsing grid/components with a compact toolbar.
+- [x] Implement capability-aware catalog selection, search, and filter pickers.
+- [x] Use shared click/OK-to-edit search and retain the draft/query on exit.
+- [x] Fetch the selected catalog on demand and cancel obsolete work.
+- [x] Preserve results during replacement requests and show distinct loading,
empty, required-input, unsupported, and failed states.
-- [ ] Retry a failed page at its original offset while retaining prior pages.
+- [x] Retry a failed page at its original offset while retaining prior pages.
Distinguish retry from an explicit refresh; refresh must bypass stale cache.
-- [ ] Restore grid position and focus after returning from details.
+- [x] Restore grid position and focus after returning from details.
Gate: request/state regressions pass; user acceptance confirms complete poster
cards and titles are visible on entry and D-pad focus never opens the keyboard.
@@ -230,12 +232,14 @@ cards and titles are visible on entry and D-pad focus never opens the keyboard.
Addresses R5-R7 and the playback-facing portion of R1.
-- [ ] Add season/episode selection and an immediate source picker.
-- [ ] Publish provider outcomes progressively with stable attribution/order.
-- [ ] Preserve successful sources on partial failure and retry only the failed
+- [x] Add season/episode selection and an immediate source picker.
+- [x] Publish provider outcomes progressively with stable attribution/order.
+- [x] Preserve successful sources on partial failure and retry only the failed
provider. Cancel stale episode lookups.
-- [ ] Add torrent capability feedback and clear unsupported-source behavior.
-- [ ] Return from the player to the selected title/episode context, then restore
+- [x] Add torrent capability feedback and clear unsupported-source behavior.
+ Check enabled magnet-capable plugins before enabling Play, and offer Plugins
+ when none is available.
+- [x] Return from the player to the selected title/episode context, then restore
the browse catalog, query, filters, position, and focused poster on Back.
- [ ] Cover history/resume and subtitle behavior across the new flow.
@@ -246,15 +250,16 @@ subtitle tests pass; user acceptance covers a long series and multiple providers
Addresses R8-R10 and verifies all five UI decisions.
-- [ ] Ensure install, refresh, toggles, ordering, removal, metadata, catalog, and
+- [x] Ensure install, refresh, toggles, ordering, removal, metadata, catalog, and
source operations handle expected/unexpected errors and clear loading state.
-- [ ] Separate an actual empty result, no eligible provider, unsupported resource,
+- [x] Separate an actual empty result, no eligible provider, unsupported resource,
and request failure. Keep retry actions tied to the failed operation.
- [ ] Handle an add-on/catalog being disabled or removed while its content is
selected, with a valid next selection and useful explanation.
-- [ ] Retain URL/token sanitization in UI errors, logs, and stored history.
-- [ ] Run relevant state, resolver, repository, playback, and migration checks;
- build and install `com.streamvault.app.debug` on `emulator-5558` with app data
+- [x] Retain URL/token sanitization in UI errors, logs, and stored history.
+- [ ] Obtain a clean run of the relevant repository checks; other targeted
+ state, resolver, playback, migration, build, and install checks have passed.
+ `com.streamvault.app.debug` is installed on `emulator-5558` with app data
retained for the user's manual acceptance.
- [ ] Record build/test evidence separately from user UI and real-playback
acceptance. Close acceptance items only when supported by that evidence.
@@ -263,10 +268,15 @@ Gate: required code checks pass and user-owned acceptance results are recorded.
## Verification baseline and acceptance matrix
-The review ran 107 existing tests with no failures: 30 Stremio feature/state,
-17 Stremio domain, 48 Stremio data, and 12 targeted playback tests. These passing
-tests do not establish visual quality or cover the newly identified handoff and
-historical-schema integration failures.
+The review baseline ran 107 existing tests with no failures: 30 Stremio
+feature/state, 17 Stremio domain, 48 Stremio data, and 12 targeted playback
+tests. Implementation verification has since passed the Stremio feature, system,
+shared UI, domain, and playback unit suites, plus the Room migration
+instrumentation suite. The focused Stremio data repository run exposed
+intermittent MockWebServer connection timeouts; one previously failing install
+case passed when run alone. The debug APK has built and is installed on
+`emulator-5558`. These checks do not establish visual quality or real torrent
+playback.
| Area | Required evidence after implementation |
| --- | --- |
diff --git a/domain/src/main/java/com/streamvault/domain/model/stremio/StremioResourceResolution.kt b/domain/src/main/java/com/streamvault/domain/model/stremio/StremioResourceResolution.kt
index 60b62636..0398c13c 100644
--- a/domain/src/main/java/com/streamvault/domain/model/stremio/StremioResourceResolution.kt
+++ b/domain/src/main/java/com/streamvault/domain/model/stremio/StremioResourceResolution.kt
@@ -31,5 +31,7 @@ data class StremioMetaResolution(
data class StremioResourceResolution<T>(
val results: List<StremioAttributedResource<T>> = emptyList(),
val failures: List<StremioAddonResourceFailure> = emptyList(),
- val candidateCount: Int = 0
+ val candidateCount: Int = 0,
+ /** Completed providers in configured add-on order, including providers that returned no resources. */
+ val completedAddonIds: List<Long> = emptyList()
)
diff --git a/domain/src/main/java/com/streamvault/domain/repository/StremioAddonRepository.kt b/domain/src/main/java/com/streamvault/domain/repository/StremioAddonRepository.kt
index 89584f24..db1b7100 100644
--- a/domain/src/main/java/com/streamvault/domain/repository/StremioAddonRepository.kt
+++ b/domain/src/main/java/com/streamvault/domain/repository/StremioAddonRepository.kt
@@ -49,6 +49,21 @@ interface StremioAddonRepository {
suspend fun installAddon(installUrl: String): Result<StremioAddon>
+ suspend fun refreshAddon(id: Long): Result<StremioAddon> =
+ Result.error("Addon refresh is not supported")
+
+ /** Emits each completed provider batch while retaining deterministic install order. */
+ suspend fun resolveStreamsProgressively(
+ type: StremioMediaType,
+ exactId: String,
+ addonIds: Set<Long>? = null,
+ onProgress: suspend (StremioResourceResolution<StremioStream>) -> Unit
+ ): StremioResourceResolution<StremioStream> {
+ val result = resolveStreams(type, exactId, addonIds)
+ onProgress(result)
+ return result
+ }
+
suspend fun removeAddon(id: Long): Result<Unit>
suspend fun setAddonEnabled(id: Long, enabled: Boolean): Result<Unit>
diff --git a/domain/src/main/java/com/streamvault/domain/repository/StremioResourceResolver.kt b/domain/src/main/java/com/streamvault/domain/repository/StremioResourceResolver.kt
index 8f136007..2673b3da 100644
--- a/domain/src/main/java/com/streamvault/domain/repository/StremioResourceResolver.kt
+++ b/domain/src/main/java/com/streamvault/domain/repository/StremioResourceResolver.kt
@@ -18,6 +18,8 @@ import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.sync.Semaphore
+import kotlinx.coroutines.sync.Mutex
+import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.sync.withPermit
/** Selects eligible addon resources and coordinates deterministic, bounded requests. */
@@ -90,11 +92,18 @@ class StremioResourceResolver @Inject constructor() {
suspend fun <T> resolveMany(
candidates: List<StremioInstalledAddon>,
+ onProgress: suspend (StremioResourceResolution<T>) -> Unit = {},
request: suspend (StremioAddon) -> Result<List<T>>
): StremioResourceResolution<T> {
- if (candidates.isEmpty()) return StremioResourceResolution()
+ if (candidates.isEmpty()) {
+ val empty = StremioResourceResolution<T>()
+ onProgress(empty)
+ return empty
+ }
val semaphore = Semaphore(MAX_CONCURRENT_REQUESTS)
- val outcomes = coroutineScope {
+ val completed = linkedMapOf<Long, Result<List<T>>>()
+ val completedMutex = Mutex()
+ coroutineScope {
candidates.map { candidate ->
async {
semaphore.withPermit {
@@ -105,14 +114,25 @@ class StremioResourceResolver @Inject constructor() {
} catch (_: Exception) {
Result.error("Addon request failed")
}
- candidate to result
+ completedMutex.withLock {
+ completed[candidate.addon.id] = result
+ onProgress(buildResolution(candidates, completed))
+ }
}
}
}.awaitAll()
}
+ return buildResolution(candidates, completed)
+ }
+
+ private fun <T> buildResolution(
+ candidates: List<StremioInstalledAddon>,
+ outcomes: Map<Long, Result<List<T>>>
+ ): StremioResourceResolution<T> {
val results = mutableListOf<StremioAttributedResource<T>>()
val failures = mutableListOf<StremioAddonResourceFailure>()
- outcomes.forEach { (candidate, result) ->
+ candidates.forEach { candidate ->
+ val result = outcomes[candidate.addon.id] ?: return@forEach
when (result) {
is Result.Success -> result.data.forEach { resource ->
results += StremioAttributedResource(candidate.addon.toSource(), resource)
@@ -121,7 +141,12 @@ class StremioResourceResolver @Inject constructor() {
Result.Loading -> failures += failure(candidate.addon, "Addon request did not complete")
}
}
- return StremioResourceResolution(results, failures, candidates.size)
+ return StremioResourceResolution(
+ results = results,
+ failures = failures,
+ candidateCount = candidates.size,
+ completedAddonIds = candidates.mapNotNull { it.addon.id.takeIf(outcomes::containsKey) }
+ )
}
private fun failure(addon: StremioAddon, rawMessage: String): StremioAddonResourceFailure {
diff --git a/domain/src/test/java/com/streamvault/domain/repository/StremioResourceResolverTest.kt b/domain/src/test/java/com/streamvault/domain/repository/StremioResourceResolverTest.kt
index 09fc2d2a..36d96393 100644
--- a/domain/src/test/java/com/streamvault/domain/repository/StremioResourceResolverTest.kt
+++ b/domain/src/test/java/com/streamvault/domain/repository/StremioResourceResolverTest.kt
@@ -195,6 +195,39 @@ class StremioResourceResolverTest {
assertThat(result.candidateCount).isEqualTo(7)
}
+ @Test
+ fun `fanout publishes completed providers progressively in configured order`() = runTest {
+ val candidates = (1L..3L).map { id ->
+ installed(
+ id,
+ types = listOf(StremioMediaType.MOVIE),
+ resources = listOf(StremioManifestResource(StremioResourceKind.STREAM))
+ )
+ }
+ val snapshots = mutableListOf<List<Long>>()
+ val result = resolver.resolveMany(
+ candidates,
+ request = { addon ->
+ delay(when (addon.id) {
+ 1L -> 30L
+ 2L -> 10L
+ else -> 20L
+ })
+ Result.success(listOf(addon.id))
+ },
+ onProgress = { progress ->
+ snapshots += progress.results.map { it.resource }
+ }
+ )
+
+ assertThat(snapshots).hasSize(3)
+ assertThat(snapshots.first()).containsExactly(2L)
+ snapshots.forEach { snapshot ->
+ assertThat(snapshot).containsExactlyElementsIn(snapshot.sorted()).inOrder()
+ }
+ assertThat(result.results.map { it.resource }).containsExactly(1L, 2L, 3L).inOrder()
+ }
+
@Test
fun `cancelling fanout cancels outstanding addon requests`() = runTest {
val started = CompletableDeferred<Unit>()
diff --git a/feature/playback/src/main/java/com/streamvault/feature/playback/player/PlayerViewModel.kt b/feature/playback/src/main/java/com/streamvault/feature/playback/player/PlayerViewModel.kt
index ac2ba978..b98296ea 100644
--- a/feature/playback/src/main/java/com/streamvault/feature/playback/player/PlayerViewModel.kt
+++ b/feature/playback/src/main/java/com/streamvault/feature/playback/player/PlayerViewModel.kt
@@ -30,7 +30,6 @@ import com.streamvault.domain.model.StreamInfo
import com.streamvault.domain.model.stremio.StremioPlaybackHistory
import com.streamvault.domain.model.stremio.StremioMediaType
import com.streamvault.domain.model.stremio.stremioPlaybackContentKey
-import com.streamvault.domain.model.stremio.stremioMediaRequestHeaders as validateStremioMediaRequestHeaders
import com.streamvault.domain.repository.StremioAddonRepository
import com.streamvault.domain.model.VirtualCategoryIds
import com.streamvault.domain.model.VideoFormat
@@ -1591,14 +1590,17 @@ class PlayerViewModel @Inject constructor(
if (!isActivePlaybackSession(requestVersion, streamUrl)) return@launch
val resolvedStreamInfo = resolution.streamInfo
val scopedHeaders = if (stremioPlaybackReference != null) {
- validateStremioMediaRequestHeaders(streamUrl, stremioMediaRequestHeaders)
+ when (val headerPolicy = stremioMediaHeaderPolicy(streamUrl, stremioMediaRequestHeaders)) {
+ StremioMediaHeaderPolicy.NotApplicable -> null
+ StremioMediaHeaderPolicy.Invalid -> {
+ _playbackResolutionUiState.value = PlaybackResolutionUiState.Failure(
+ "The selected addon stream supplied invalid media request headers."
+ )
+ return@launch
+ }
+ is StremioMediaHeaderPolicy.Scoped -> headerPolicy.value
+ }
} else null
- if (stremioPlaybackReference != null && scopedHeaders == null) {
- _playbackResolutionUiState.value = PlaybackResolutionUiState.Failure(
- "The selected addon stream supplied invalid media request headers."
- )
- return@launch
- }
val streamInfo = resolvedStreamInfo?.let { resolved ->
scopedHeaders?.let { validated ->
resolved.copy(
diff --git a/feature/playback/src/main/java/com/streamvault/feature/playback/player/StremioMediaHeaderPolicy.kt b/feature/playback/src/main/java/com/streamvault/feature/playback/player/StremioMediaHeaderPolicy.kt
new file mode 100644
index 00000000..759b90b0
--- /dev/null
+++ b/feature/playback/src/main/java/com/streamvault/feature/playback/player/StremioMediaHeaderPolicy.kt
@@ -0,0 +1,24 @@
+package com.streamvault.feature.playback.player
+
+import com.streamvault.domain.model.stremio.StremioMediaRequestHeaders
+import com.streamvault.domain.model.stremio.stremioMediaRequestHeaders
+import java.net.URI
+
+internal sealed interface StremioMediaHeaderPolicy {
+ data object NotApplicable : StremioMediaHeaderPolicy
+ data object Invalid : StremioMediaHeaderPolicy
+ data class Scoped(val value: StremioMediaRequestHeaders) : StremioMediaHeaderPolicy
+}
+
+/** Add-on request headers are scoped to the original direct HTTP media URL only. */
+internal fun stremioMediaHeaderPolicy(
+ mediaUrl: String,
+ suppliedHeaders: Map<String, String>?
+): StremioMediaHeaderPolicy {
+ val scheme = runCatching { URI(mediaUrl).scheme?.lowercase() }.getOrNull()
+ if (scheme != "http" && scheme != "https") return StremioMediaHeaderPolicy.NotApplicable
+
+ val scoped = stremioMediaRequestHeaders(mediaUrl, suppliedHeaders)
+ ?: return StremioMediaHeaderPolicy.Invalid
+ return StremioMediaHeaderPolicy.Scoped(scoped)
+}
diff --git a/feature/playback/src/test/java/com/streamvault/feature/playback/player/StremioMediaHeaderPolicyTest.kt b/feature/playback/src/test/java/com/streamvault/feature/playback/player/StremioMediaHeaderPolicyTest.kt
new file mode 100644
index 00000000..c56e69e5
--- /dev/null
+++ b/feature/playback/src/test/java/com/streamvault/feature/playback/player/StremioMediaHeaderPolicyTest.kt
@@ -0,0 +1,38 @@
+package com.streamvault.feature.playback.player
+
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+
+class StremioMediaHeaderPolicyTest {
+ @Test
+ fun magnetUrlsDoNotRunDirectHttpHeaderValidation() {
+ val result = stremioMediaHeaderPolicy(
+ mediaUrl = "magnet:?xt=urn:btih:0123456789abcdef",
+ suppliedHeaders = mapOf("Host" to "untrusted.example")
+ )
+
+ assertThat(result).isEqualTo(StremioMediaHeaderPolicy.NotApplicable)
+ }
+
+ @Test
+ fun validDirectHttpHeadersRemainScopedToTheirOrigin() {
+ val result = stremioMediaHeaderPolicy(
+ mediaUrl = "https://media.example.com/video.m3u8",
+ suppliedHeaders = mapOf("Authorization" to "Bearer token")
+ )
+
+ assertThat(result).isInstanceOf(StremioMediaHeaderPolicy.Scoped::class.java)
+ assertThat((result as StremioMediaHeaderPolicy.Scoped).value.origin)
+ .isEqualTo("https://media.example.com:443")
+ }
+
+ @Test
+ fun invalidDirectHttpHeadersAreRejected() {
+ val result = stremioMediaHeaderPolicy(
+ mediaUrl = "https://media.example.com/video.m3u8",
+ suppliedHeaders = mapOf("Host" to "other.example.com")
+ )
+
+ assertThat(result).isEqualTo(StremioMediaHeaderPolicy.Invalid)
+ }
+}
diff --git a/feature/stremio/src/main/java/com/streamvault/feature/stremio/api/StremioTorrentPlaybackAvailability.kt b/feature/stremio/src/main/java/com/streamvault/feature/stremio/api/StremioTorrentPlaybackAvailability.kt
new file mode 100644
index 00000000..142a0522
--- /dev/null
+++ b/feature/stremio/src/main/java/com/streamvault/feature/stremio/api/StremioTorrentPlaybackAvailability.kt
@@ -0,0 +1,6 @@
+package com.streamvault.feature.stremio.api
+
+/** Reports whether an enabled app plugin can prepare magnet playback URLs. */
+fun interface StremioTorrentPlaybackAvailability {
+ suspend fun hasEnabledMagnetPlugin(): Boolean
+}
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
index 7339a600..64f827e5 100644
--- 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
@@ -4,6 +4,8 @@ import androidx.navigation.NavHostController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavType
import androidx.navigation.compose.composable
+import androidx.compose.runtime.remember
+import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.navArgument
import androidx.compose.ui.res.stringResource
import com.streamvault.core.navigation.AppDestination
@@ -13,6 +15,9 @@ import com.streamvault.feature.stremio.api.StremioScaffoldContent
import com.streamvault.feature.stremio.presentation.AddonsScreen
import com.streamvault.feature.stremio.presentation.StremioItemDetailScreen
import com.streamvault.feature.stremio.presentation.StremioVisibilityHost
+import com.streamvault.feature.stremio.presentation.StremioBrowseScreen
+import com.streamvault.feature.stremio.presentation.AddonsViewModel
+import com.streamvault.feature.stremio.presentation.StremioCatalogBrowseViewModel
import com.streamvault.feature.stremio.R
fun NavGraphBuilder.registerStremioGraph(
@@ -28,11 +33,32 @@ fun NavGraphBuilder.registerStremioGraph(
title = stringResource(R.string.extensions_title),
showExtensionsTabs = true,
onNavigateToPlugins = { onTopLevelDestinationRequested(AppDestination.Plugins) },
- content = { accessState ->
+ content = {
AddonsScreen(
scaffold = scaffold,
- showContinueWatching = accessState.showContinueWatching,
onNavigateToPlugins = { onTopLevelDestinationRequested(AppDestination.Plugins) },
+ onOpenBrowse = { navController.navigate(StremioRoutePatterns.BROWSE) }
+ )
+ }
+ )
+ }
+ composable(StremioRoutePatterns.BROWSE) { backStackEntry ->
+ val addonsEntry = remember(backStackEntry) {
+ navController.getBackStackEntry(StremioRoutePatterns.ADDONS)
+ }
+ val addonsViewModel: AddonsViewModel = hiltViewModel(viewModelStoreOwner = addonsEntry)
+ val browseViewModel: StremioCatalogBrowseViewModel = hiltViewModel(viewModelStoreOwner = addonsEntry)
+ StremioVisibilityHost(
+ scaffold = scaffold,
+ onOpenSettings = { actions.navigate(AppDestination.Settings()) },
+ title = stringResource(R.string.stremio_browse_title),
+ content = { accessState ->
+ StremioBrowseScreen(
+ scaffold = scaffold,
+ showContinueWatching = accessState.showContinueWatching,
+ addonsViewModel = addonsViewModel,
+ browseViewModel = browseViewModel,
+ onManageAddons = { navController.popBackStack(StremioRoutePatterns.ADDONS, false) },
onOpenItem = { addonId, preview ->
navController.navigate(StremioRoutePatterns.itemRoute(addonId, preview))
},
@@ -65,6 +91,7 @@ fun NavGraphBuilder.registerStremioGraph(
content = {
StremioItemDetailScreen(
scaffold = scaffold,
+ onManagePlugins = { onTopLevelDestinationRequested(AppDestination.Plugins) },
onPlay = { handoff ->
actions.openPlayer(
PlayerNavigationRequest(
@@ -72,7 +99,7 @@ fun NavGraphBuilder.registerStremioGraph(
title = handoff.title,
contentType = handoff.contentType,
artworkUrl = handoff.artworkUrl,
- returnDestination = AppDestination.Addons,
+ returnDestination = null,
stremioPlaybackReference = handoff.reference,
stremioMediaRequestHeaders = handoff.mediaRequestHeaders,
stremioInlineSubtitles = handoff.inlineSubtitles
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
index 448b4ed5..4ffed66c 100644
--- 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
@@ -5,6 +5,7 @@ import com.streamvault.domain.model.stremio.StremioMetaPreview
object StremioRoutePatterns {
const val ADDONS = "addons"
+ const val BROWSE = "addons/browse"
const val ITEM = "addons/item/{originAddonId}/{type}/{exactId}?name={name}&poster={poster}&description={description}&releaseInfo={releaseInfo}&replayVideoId={replayVideoId}&replayOriginKey={replayOriginKey}&replayRequiresOrigin={replayRequiresOrigin}"
fun itemRoute(
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
index f82e16bf..d90360a8 100644
--- 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
@@ -32,7 +32,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
-import androidx.compose.runtime.mutableIntStateOf
+import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
@@ -53,8 +53,6 @@ import coil3.compose.AsyncImage
import com.streamvault.core.navigation.AppDestination
import com.streamvault.core.ui.components.dialogs.PremiumDialog
import com.streamvault.core.ui.components.dialogs.PremiumDialogFooterButton
-import com.streamvault.core.ui.components.shell.AppHeroHeader
-import com.streamvault.core.ui.components.shell.AppSectionHeader
import com.streamvault.core.ui.components.shell.ExtensionsEmptyState
import com.streamvault.core.ui.components.shell.StatusPill
import com.streamvault.core.ui.design.BrowseColors as AppColors
@@ -71,6 +69,7 @@ import com.streamvault.core.ui.interaction.TvClickableSurface
import com.streamvault.core.ui.components.shell.ExtensionsSectionTabs
import com.streamvault.domain.model.stremio.StremioMetaPreview
import com.streamvault.domain.model.stremio.StremioPlaybackHistory
+import com.streamvault.domain.model.stremio.StremioResourceKind
import com.streamvault.domain.model.stremio.installFingerprint
import com.streamvault.feature.stremio.R
import com.streamvault.feature.stremio.api.StremioScaffoldContent
@@ -79,14 +78,12 @@ import kotlinx.coroutines.delay
@Composable
fun AddonsScreen(
scaffold: StremioScaffoldContent,
- showContinueWatching: Boolean = true,
onNavigateToPlugins: () -> Unit = {},
- onOpenItem: (Long, StremioMetaPreview) -> Unit = { _, _ -> },
- onOpenHistory: (StremioPlaybackHistory, Long) -> Unit = { _, _ -> },
+ onOpenBrowse: () -> Unit = {},
viewModel: AddonsViewModel = hiltViewModel()
) {
val state by viewModel.state.collectAsStateWithLifecycle()
- var selectedTab by rememberSaveable { mutableIntStateOf(0) }
+ var pendingRemoval by remember { mutableStateOf<AddonsViewModel.AddonEntry?>(null) }
state.statusMessageRes?.let { messageRes ->
LaunchedEffect(messageRes) {
@@ -102,11 +99,7 @@ fun AddonsScreen(
false,
true
) {
- Column(
- modifier = Modifier
- .fillMaxSize(),
- verticalArrangement = Arrangement.spacedBy(16.dp)
- ) {
+ Column(modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.spacedBy(12.dp)) {
ExtensionsSectionTabs(
selectedIndex = 1,
pluginsLabel = stringResource(R.string.extensions_tab_plugins),
@@ -115,27 +108,18 @@ fun AddonsScreen(
if (selectedIndex == 0) onNavigateToPlugins()
}
)
- AppHeroHeader(
- title = stringResource(R.string.stremio_title),
- subtitle = stringResource(R.string.stremio_section_description),
- eyebrow = stringResource(R.string.extensions_title),
- modifier = Modifier.fillMaxWidth(),
- actions = {
- TvPrimaryButton(onClick = viewModel::showInstallDialog) {
- Icon(imageVector = Icons.Default.Add, contentDescription = null)
- Spacer(Modifier.size(8.dp))
- 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)
}
- if (!state.loading && state.addons.isEmpty()) {
- ExtensionsEmptyState(
+ when {
+ state.loading && state.addons.isEmpty() -> Box(
+ modifier = Modifier.weight(1f).fillMaxWidth(),
+ contentAlignment = Alignment.Center
+ ) { CircularProgressIndicator(color = AppColors.Brand) }
+ state.addons.isEmpty() -> ExtensionsEmptyState(
title = stringResource(R.string.stremio_empty_title),
description = stringResource(R.string.stremio_empty_description),
modifier = Modifier.weight(1f),
@@ -147,69 +131,50 @@ fun AddonsScreen(
}
}
)
- } else {
- StremioViewTabs(
- selectedIndex = selectedTab,
- onTabSelected = { selectedTab = it }
- )
- if (selectedTab == 0) {
- if (showContinueWatching && state.continueWatching.isNotEmpty()) {
- Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
- AppSectionHeader(title = stringResource(R.string.stremio_continue_watching))
- LazyRow(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
- items(state.continueWatching, key = { it.contentKey }) { item ->
- val originAddonId = state.addons.firstOrNull {
- it.addon.installFingerprint() == item.catalogOriginKey
- }?.addon?.id ?: 0L
- ContinueWatchingCard(
- item = item,
- onClick = { onOpenHistory(item, originAddonId) }
- )
- }
- }
+ else -> {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(10.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Text(
+ text = stringResource(R.string.stremio_installed_count, state.addons.size),
+ modifier = Modifier.weight(1f),
+ style = MaterialTheme.typography.titleMedium,
+ color = AppColors.TextPrimary
+ )
+ TvPrimaryButton(onClick = viewModel::showInstallDialog) {
+ Icon(imageVector = Icons.Default.Add, contentDescription = null)
+ Spacer(Modifier.size(8.dp))
+ Text(stringResource(R.string.stremio_add))
}
- }
- StremioCatalogBrowseContent(
- modifier = Modifier.weight(1f),
- onOpenItem = onOpenItem
- )
- } else {
- when {
- state.loading -> Box(
- modifier = Modifier.weight(1f).fillMaxWidth(),
- contentAlignment = Alignment.Center
- ) {
- CircularProgressIndicator()
+ TvButton(onClick = onOpenBrowse) {
+ Text(stringResource(R.string.stremio_browse))
}
- state.addons.isEmpty() -> Text(
- text = stringResource(R.string.stremio_empty),
- style = MaterialTheme.typography.bodyLarge,
- color = MaterialTheme.colorScheme.onSurfaceVariant
- )
- else -> LazyColumn(
- modifier = Modifier.weight(1f).fillMaxWidth(),
- verticalArrangement = Arrangement.spacedBy(14.dp),
- contentPadding = androidx.compose.foundation.layout.PaddingValues(bottom = 20.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) }
- )
- }
+ }
+ LazyColumn(
+ modifier = Modifier.weight(1f).fillMaxWidth(),
+ verticalArrangement = Arrangement.spacedBy(10.dp),
+ contentPadding = androidx.compose.foundation.layout.PaddingValues(bottom = 20.dp)
+ ) {
+ itemsIndexed(items = state.addons, key = { _, entry -> entry.addon.id }) { index, entry ->
+ AddonCard(
+ entry = entry,
+ expanded = state.expandedAddonId == entry.addon.id,
+ refreshing = state.refreshingAddonId == entry.addon.id,
+ busy = entry.addon.id in state.busyAddonIds,
+ 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)
+ },
+ onRefresh = { viewModel.refreshAddon(entry) },
+ onRemove = { pendingRemoval = entry }
+ )
}
}
}
@@ -227,6 +192,30 @@ fun AddonsScreen(
onDismiss = viewModel::dismissInstallDialog
)
}
+
+ pendingRemoval?.let { entry ->
+ PremiumDialog(
+ title = stringResource(R.string.stremio_remove_confirm_title),
+ subtitle = stringResource(R.string.stremio_remove_confirm_body, entry.addon.name),
+ onDismissRequest = { pendingRemoval = null },
+ heightFraction = null,
+ content = {},
+ footer = {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.stremio_cancel),
+ onClick = { pendingRemoval = null }
+ )
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.stremio_remove),
+ onClick = {
+ pendingRemoval = null
+ viewModel.removeAddon(entry)
+ },
+ emphasized = true
+ )
+ }
+ )
+ }
}
@Composable
@@ -281,6 +270,8 @@ private fun ContinueWatchingCard(item: StremioPlaybackHistory, onClick: () -> Un
private fun AddonCard(
entry: AddonsViewModel.AddonEntry,
expanded: Boolean,
+ refreshing: Boolean,
+ busy: Boolean,
canMoveUp: Boolean,
canMoveDown: Boolean,
onEnabledChange: (Boolean) -> Unit,
@@ -288,70 +279,63 @@ private fun AddonCard(
onMoveDown: () -> Unit,
onToggleExpanded: () -> Unit,
onCatalogEnabledChange: (String, Boolean) -> Unit,
+ onRefresh: () -> Unit,
onRemove: () -> Unit
) {
val addon = entry.addon
+ val manifest = entry.manifest
+ val hasStreams = manifest?.resources?.any { it.kind == StremioResourceKind.STREAM } == true
+ val hasSubtitles = manifest?.resources?.any { it.kind == StremioResourceKind.SUBTITLES } == true
Column(
- modifier = Modifier.fillMaxWidth().browsePanel(BrowseShapes.Panel).padding(18.dp),
- verticalArrangement = Arrangement.spacedBy(14.dp)
+ modifier = Modifier.fillMaxWidth().browsePanel(BrowseShapes.Panel).padding(12.dp),
+ verticalArrangement = Arrangement.spacedBy(8.dp)
) {
Row(
modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.spacedBy(20.dp),
+ horizontalArrangement = Arrangement.spacedBy(12.dp),
verticalAlignment = Alignment.CenterVertically
) {
- Column(
- modifier = Modifier.weight(1f),
- verticalArrangement = Arrangement.spacedBy(5.dp)
- ) {
- Row(horizontalArrangement = Arrangement.spacedBy(10.dp), verticalAlignment = Alignment.CenterVertically) {
- Text(
- text = addon.name,
- style = MaterialTheme.typography.titleMedium,
- color = AppColors.TextPrimary,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis
- )
- StatusPill(
- label = stringResource(if (addon.enabled) R.string.stremio_enabled else R.string.stremio_disabled),
- containerColor = if (addon.enabled) AppColors.Success else AppColors.SurfaceEmphasis
- )
- }
+ Box(
+ modifier = Modifier.size(46.dp).clip(BrowseShapes.Artwork).background(AppColors.SurfaceEmphasis),
+ contentAlignment = Alignment.Center
+ ) {
Text(
- text = stringResource(R.string.stremio_version_format, addon.version),
- style = MaterialTheme.typography.bodySmall,
- color = AppColors.TextSecondary
+ text = addon.name.take(1).uppercase(),
+ style = MaterialTheme.typography.titleMedium,
+ color = AppColors.BrandStrong
)
+ manifest?.logo?.takeIf(String::isNotBlank)?.let { logo ->
+ AsyncImage(
+ model = logo,
+ contentDescription = null,
+ modifier = Modifier.fillMaxSize(),
+ contentScale = ContentScale.Crop
+ )
+ }
+ }
+ Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(5.dp)) {
Text(
- text = stringResource(
- R.string.stremio_addon_server_format,
- stremioAddonOriginLabel(addon.installUrl)
- ?: stringResource(R.string.stremio_addon_server_unknown)
- ),
- style = MaterialTheme.typography.bodySmall,
- color = AppColors.TextTertiary,
+ text = addon.name,
+ style = MaterialTheme.typography.titleMedium,
+ color = AppColors.TextPrimary,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
+ Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {
+ if (entry.catalogs.isNotEmpty()) StatusPill(label = stringResource(R.string.stremio_catalogs_capability))
+ if (hasStreams) StatusPill(label = stringResource(R.string.stremio_streams_capability))
+ if (hasSubtitles) StatusPill(label = stringResource(R.string.stremio_subtitles_capability))
+ }
}
Switch(
checked = addon.enabled,
onCheckedChange = onEnabledChange,
+ enabled = !busy,
colors = stremioSwitchColors()
)
}
- Row(
- modifier = Modifier.fillMaxWidth(),
- verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.spacedBy(8.dp)
- ) {
- TvIconButton(onClick = onMoveUp, enabled = canMoveUp) {
- Icon(Icons.Default.KeyboardArrowUp, contentDescription = stringResource(R.string.stremio_move_up))
- }
- TvIconButton(onClick = onMoveDown, enabled = canMoveDown) {
- Icon(Icons.Default.KeyboardArrowDown, contentDescription = stringResource(R.string.stremio_move_down))
- }
+ Row(modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
TvButton(
onClick = onToggleExpanded,
modifier = Modifier.heightIn(min = 44.dp),
@@ -362,34 +346,66 @@ private fun AddonCard(
focusedContentColor = AppColors.TextPrimary
)
) {
- Text(
- text = stringResource(R.string.stremio_catalogs),
- modifier = Modifier.padding(horizontal = 6.dp)
- )
+ Text(stringResource(if (expanded) R.string.stremio_hide_details else R.string.stremio_details))
}
Spacer(modifier = Modifier.weight(1f))
- TvButton(
- onClick = onRemove,
- modifier = Modifier.heightIn(min = 44.dp),
- colors = androidx.tv.material3.ButtonDefaults.colors(
- containerColor = AppColors.Live.copy(alpha = 0.12f),
- contentColor = AppColors.Live,
- focusedContainerColor = AppColors.Live.copy(alpha = 0.22f),
- focusedContentColor = AppColors.Live
- )
- ) {
- Text(stringResource(R.string.stremio_remove), modifier = Modifier.padding(horizontal = 6.dp))
- }
}
if (expanded) {
+ Text(
+ text = stringResource(R.string.stremio_version_and_server_format,
+ addon.version,
+ stremioAddonOriginLabel(addon.installUrl)
+ ?: stringResource(R.string.stremio_addon_server_unknown)
+ ),
+ style = MaterialTheme.typography.bodySmall,
+ color = AppColors.TextTertiary,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ manifest?.description?.takeIf(String::isNotBlank)?.let { description ->
+ Text(description, style = MaterialTheme.typography.bodySmall, color = AppColors.TextSecondary)
+ }
if (entry.catalogs.isEmpty()) {
+ val capabilityHint = when {
+ hasStreams && hasSubtitles -> R.string.stremio_streams_and_subtitles_only_hint
+ hasStreams -> R.string.stremio_streams_only_hint
+ hasSubtitles -> R.string.stremio_subtitles_only_hint
+ else -> null
+ }
+ capabilityHint?.let { hint ->
+ Text(
+ text = stringResource(hint),
+ style = MaterialTheme.typography.bodySmall,
+ color = AppColors.TextSecondary
+ )
+ }
+ }
+ Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically) {
+ TvButton(onClick = onRefresh, enabled = !refreshing && !busy) {
+ if (refreshing) {
+ CircularProgressIndicator(modifier = Modifier.size(16.dp), strokeWidth = 2.dp, color = AppColors.Brand)
+ Spacer(Modifier.width(6.dp))
+ }
+ Text(stringResource(R.string.stremio_refresh_manifest))
+ }
+ TvIconButton(onClick = onMoveUp, enabled = canMoveUp && !busy) {
+ Icon(Icons.Default.KeyboardArrowUp, contentDescription = stringResource(R.string.stremio_move_up))
+ }
+ TvIconButton(onClick = onMoveDown, enabled = canMoveDown && !busy) {
+ Icon(Icons.Default.KeyboardArrowDown, contentDescription = stringResource(R.string.stremio_move_down))
+ }
+ Spacer(Modifier.weight(1f))
+ TvButton(onClick = onRemove, enabled = !busy) {
+ Text(stringResource(R.string.stremio_remove))
+ }
+ }
+ if (entry.catalogs.isNotEmpty()) {
Text(
- text = stringResource(R.string.stremio_no_catalogs),
- style = MaterialTheme.typography.bodyMedium,
- color = AppColors.TextSecondary
+ text = stringResource(R.string.stremio_catalogs_capability),
+ style = MaterialTheme.typography.titleSmall,
+ color = AppColors.TextPrimary
)
- } else {
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
entry.catalogs.forEach { catalog ->
Row(
@@ -416,6 +432,7 @@ private fun AddonCard(
onCheckedChange = { enabled ->
onCatalogEnabledChange(catalog.settingsKey, enabled)
},
+ enabled = !busy,
colors = stremioSwitchColors()
)
}
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
index 18a94280..eba42122 100644
--- 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
@@ -7,6 +7,8 @@ import com.streamvault.domain.model.Result
import com.streamvault.domain.model.stremio.StremioAddon
import com.streamvault.domain.model.stremio.StremioPlaybackHistory
import com.streamvault.domain.model.stremio.StremioCatalogRef
+import com.streamvault.domain.model.stremio.StremioManifest
+import com.streamvault.domain.model.stremio.StremioResourceKind
import com.streamvault.domain.repository.StremioAddonRepository
import com.streamvault.domain.repository.StremioPlaybackHistoryRepository
import com.streamvault.feature.stremio.R
@@ -15,6 +17,7 @@ import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
+import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
@@ -27,7 +30,8 @@ class AddonsViewModel @Inject constructor(
data class AddonEntry(
val addon: StremioAddon,
- val catalogs: List<StremioCatalogRef>
+ val catalogs: List<StremioCatalogRef>,
+ val manifest: StremioManifest? = null
)
data class UiState(
@@ -38,6 +42,8 @@ class AddonsViewModel @Inject constructor(
val installUrl: String = "",
val installing: Boolean = false,
val expandedAddonId: Long? = null,
+ val refreshingAddonId: Long? = null,
+ val busyAddonIds: Set<Long> = emptySet(),
@param:StringRes val statusMessageRes: Int? = null,
val errorMessage: String? = null
)
@@ -47,20 +53,31 @@ class AddonsViewModel @Inject constructor(
init {
viewModelScope.launch {
- repository.observeAddons().collect { addons ->
- val entries = addons.map { addon ->
- AddonEntry(
- addon = addon,
- catalogs = repository.getManifest(addon.id)?.catalogs.orEmpty()
- )
+ repository.observeAddons()
+ .catch { error ->
+ _state.update {
+ it.copy(loading = false, errorMessage = safeAddonError(error.message ?: "Add-ons could not be loaded"))
+ }
+ }
+ .collect { addons ->
+ val entries = addons.map { addon ->
+ val manifest = try {
+ repository.getManifest(addon.id)
+ } catch (cancellation: kotlinx.coroutines.CancellationException) {
+ throw cancellation
+ } catch (error: Exception) {
+ _state.update { it.copy(errorMessage = safeAddonError(error.message ?: "Add-on details could not be loaded")) }
+ null
+ }
+ AddonEntry(addon, manifest?.catalogs.orEmpty(), manifest)
+ }
+ _state.update { it.copy(loading = false, addons = entries) }
}
- _state.update { it.copy(loading = false, addons = entries) }
- }
}
viewModelScope.launch {
- historyRepository.observeContinueWatching().collect { history ->
- _state.update { it.copy(continueWatching = history) }
- }
+ historyRepository.observeContinueWatching()
+ .catch { _state.update { state -> state.copy(errorMessage = safeAddonError(it.message ?: "History could not be loaded")) } }
+ .collect { history -> _state.update { it.copy(continueWatching = history) } }
}
}
@@ -87,7 +104,8 @@ class AddonsViewModel @Inject constructor(
_state.update { it.copy(installing = false) }
return@launch
}
- when (val result = repository.installAddon(url)) {
+ try {
+ when (val result = repository.installAddon(url)) {
is Result.Success -> _state.update {
it.copy(
installing = false,
@@ -97,40 +115,64 @@ class AddonsViewModel @Inject constructor(
)
}
is Result.Error -> _state.update {
- it.copy(installing = false, errorMessage = result.message)
+ it.copy(installing = false, errorMessage = safeAddonError(result.message, url))
+ }
+ Result.Loading -> _state.update { it.copy(installing = false, errorMessage = "Addon installation did not complete") }
+ }
+ } catch (cancellation: kotlinx.coroutines.CancellationException) {
+ throw cancellation
+ } catch (error: Exception) {
+ _state.update {
+ it.copy(installing = false, errorMessage = safeAddonError(error.message ?: "Addon could not be installed", url))
}
- Result.Loading -> Unit
}
}
}
- fun setEnabled(entry: AddonEntry, enabled: Boolean) {
+ fun refreshAddon(entry: AddonEntry) {
+ val id = entry.addon.id
+ if (id in _state.value.busyAddonIds) return
+ _state.update {
+ it.copy(refreshingAddonId = id, busyAddonIds = it.busyAddonIds + id, errorMessage = null)
+ }
viewModelScope.launch {
- repository.setAddonEnabled(entry.addon.id, enabled).errorMessageOrNull()?.let { message ->
- _state.update { it.copy(errorMessage = message) }
+ try {
+ when (val result = repository.refreshAddon(id)) {
+ is Result.Success -> _state.update { it.copy(statusMessageRes = R.string.stremio_status_refreshed) }
+ is Result.Error -> _state.update { it.copy(errorMessage = safeAddonError(result.message, entry.addon.installUrl)) }
+ Result.Loading -> _state.update { it.copy(errorMessage = "Add-on refresh did not complete") }
+ }
+ } catch (cancellation: kotlinx.coroutines.CancellationException) {
+ throw cancellation
+ } catch (error: Exception) {
+ _state.update {
+ it.copy(errorMessage = safeAddonError(error.message ?: "Add-on manifest could not be refreshed", entry.addon.installUrl))
+ }
+ } finally {
+ _state.update { it.copy(refreshingAddonId = null, busyAddonIds = it.busyAddonIds - id) }
}
}
}
+ fun setEnabled(entry: AddonEntry, enabled: Boolean) {
+ performAddonAction(entry, action = { repository.setAddonEnabled(entry.addon.id, enabled) })
+ }
+
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 },
+ performAddonAction(
+ entry = entry,
+ action = { repository.removeAddon(entry.addon.id) },
+ onSuccess = { state ->
+ state.copy(
+ expandedAddonId = state.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) }
- }
- }
+ performAddonAction(entry, action = { repository.moveAddon(entry.addon.id, offset) })
}
fun toggleExpanded(addonId: Long) {
@@ -140,10 +182,10 @@ class AddonsViewModel @Inject constructor(
}
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) } }
- }
+ performAddonAction(
+ entry,
+ action = { repository.setCatalogEnabled(entry.addon.id, catalogKey, enabled) }
+ )
}
fun consumeStatusMessage() {
@@ -153,4 +195,42 @@ class AddonsViewModel @Inject constructor(
fun consumeError() {
_state.update { it.copy(errorMessage = null) }
}
+
+ private fun <T> performAddonAction(
+ entry: AddonEntry,
+ action: suspend () -> Result<T>,
+ onSuccess: (UiState) -> UiState = { it }
+ ) {
+ val id = entry.addon.id
+ if (id in _state.value.busyAddonIds) return
+ _state.update { it.copy(busyAddonIds = it.busyAddonIds + id, errorMessage = null) }
+ viewModelScope.launch {
+ try {
+ when (val result = action()) {
+ is Result.Success -> _state.update(onSuccess)
+ is Result.Error -> _state.update { it.copy(errorMessage = safeAddonError(result.message, entry.addon.installUrl)) }
+ Result.Loading -> _state.update { it.copy(errorMessage = "Add-on action did not complete") }
+ }
+ } catch (cancellation: kotlinx.coroutines.CancellationException) {
+ throw cancellation
+ } catch (error: Exception) {
+ _state.update {
+ it.copy(errorMessage = safeAddonError(error.message ?: "Add-on action failed", entry.addon.installUrl))
+ }
+ } finally {
+ _state.update { it.copy(busyAddonIds = it.busyAddonIds - id) }
+ }
+ }
+ }
+
+ private fun safeAddonError(message: String, installUrl: String? = null): String {
+ val withoutInstallUrl = installUrl?.takeIf(String::isNotEmpty)
+ ?.let { message.replace(it, "add-on endpoint", ignoreCase = true) }
+ ?: message
+ return withoutInstallUrl
+ .replace(Regex("(?i)(?:https?://[^\\s\\\"']+|magnet:\\?[^\\s\\\"']+)"), "add-on endpoint")
+ .replace(Regex("(?i)([?&](username|password|token|auth|key)=)[^&\\s]+"), "\$1<redacted>")
+ .take(220)
+ .ifBlank { "Add-on action failed" }
+ }
}
diff --git a/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioBrowseScreen.kt b/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioBrowseScreen.kt
new file mode 100644
index 00000000..0149c25f
--- /dev/null
+++ b/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioBrowseScreen.kt
@@ -0,0 +1,108 @@
+package com.streamvault.feature.stremio.presentation
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.heightIn
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.items
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.saveable.rememberSaveable
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.lifecycle.compose.collectAsStateWithLifecycle
+import androidx.tv.material3.Text
+import com.streamvault.core.navigation.AppDestination
+import com.streamvault.core.ui.components.dialogs.PremiumDialog
+import com.streamvault.core.ui.components.dialogs.PremiumDialogFooterButton
+import com.streamvault.core.ui.interaction.TvButton
+import com.streamvault.feature.stremio.R
+import com.streamvault.feature.stremio.api.StremioScaffoldContent
+import com.streamvault.domain.model.stremio.StremioPlaybackHistory
+import com.streamvault.domain.model.stremio.StremioMetaPreview
+import com.streamvault.domain.model.stremio.installFingerprint
+
+@Composable
+internal fun StremioBrowseScreen(
+ scaffold: StremioScaffoldContent,
+ showContinueWatching: Boolean,
+ addonsViewModel: AddonsViewModel,
+ browseViewModel: StremioCatalogBrowseViewModel,
+ onManageAddons: () -> Unit,
+ onOpenItem: (Long, StremioMetaPreview) -> Unit,
+ onOpenHistory: (StremioPlaybackHistory, Long) -> Unit
+) {
+ val addonsState = addonsViewModel.state.collectAsStateWithLifecycle().value
+ var showContinueWatchingDialog by rememberSaveable { mutableStateOf(false) }
+ scaffold(
+ AppDestination.Addons,
+ stringResource(R.string.stremio_browse_title),
+ null,
+ false,
+ true
+ ) {
+ Column(modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.spacedBy(10.dp)) {
+ androidx.compose.foundation.layout.Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.End,
+ verticalAlignment = androidx.compose.ui.Alignment.CenterVertically
+ ) {
+ if (showContinueWatching && addonsState.continueWatching.isNotEmpty()) {
+ TvButton(onClick = { showContinueWatchingDialog = true }) {
+ Text(stringResource(R.string.stremio_continue_watching))
+ }
+ }
+ TvButton(onClick = onManageAddons) {
+ Text(stringResource(R.string.stremio_manage_addons))
+ }
+ }
+ StremioCatalogBrowseContent(
+ modifier = Modifier.weight(1f),
+ viewModel = browseViewModel,
+ onOpenItem = onOpenItem,
+ onManageAddons = onManageAddons
+ )
+ }
+ }
+
+ if (showContinueWatchingDialog && addonsState.continueWatching.isNotEmpty()) {
+ PremiumDialog(
+ title = stringResource(R.string.stremio_continue_watching),
+ onDismissRequest = { showContinueWatchingDialog = false },
+ heightFraction = null,
+ content = {
+ LazyColumn(
+ modifier = Modifier.fillMaxWidth().heightIn(max = 460.dp),
+ verticalArrangement = Arrangement.spacedBy(8.dp)
+ ) {
+ items(addonsState.continueWatching, key = { it.contentKey }) { item ->
+ val originAddonId = addonsState.addons.firstOrNull {
+ it.addon.installFingerprint() == item.catalogOriginKey
+ }?.addon?.id ?: 0L
+ TvButton(
+ onClick = {
+ showContinueWatchingDialog = false
+ onOpenHistory(item, originAddonId)
+ },
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Text(item.title, maxLines = 1)
+ }
+ }
+ }
+ },
+ footer = {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.stremio_cancel),
+ onClick = { showContinueWatchingDialog = false }
+ )
+ }
+ )
+ }
+}
diff --git a/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioCatalogBrowseContent.kt b/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioCatalogBrowseContent.kt
index 3dd76d26..ff334ab8 100644
--- a/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioCatalogBrowseContent.kt
+++ b/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioCatalogBrowseContent.kt
@@ -1,6 +1,5 @@
package com.streamvault.feature.stremio.presentation
-import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@@ -10,37 +9,47 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
-import androidx.compose.foundation.lazy.LazyColumn
-import androidx.compose.foundation.lazy.LazyRow
-import androidx.compose.foundation.lazy.items
-import androidx.compose.material3.OutlinedTextFieldDefaults
+import androidx.compose.foundation.lazy.grid.GridCells
+import androidx.compose.foundation.lazy.grid.GridItemSpan
+import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
+import androidx.compose.foundation.lazy.grid.items
+import androidx.compose.foundation.lazy.grid.rememberLazyGridState
import androidx.compose.ui.draw.clip
+import androidx.compose.ui.layout.ContentScale
+import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
-import androidx.tv.material3.Border
-import androidx.tv.material3.ButtonDefaults
import androidx.tv.material3.ClickableSurfaceDefaults
import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.Text
import androidx.compose.material3.CircularProgressIndicator
-import androidx.compose.material3.OutlinedTextField
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
-import androidx.compose.ui.layout.ContentScale
+import androidx.compose.ui.focus.FocusRequester
+import androidx.compose.ui.focus.focusRequester
+import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
+import androidx.compose.runtime.saveable.rememberSaveable
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import coil3.compose.AsyncImage
import com.streamvault.core.ui.components.shell.AppSectionHeader
+import com.streamvault.core.ui.components.SearchInput
+import com.streamvault.core.ui.components.dialogs.PremiumDialog
+import com.streamvault.core.ui.components.dialogs.PremiumDialogFooterButton
import com.streamvault.core.ui.design.BrowseColors as AppColors
import com.streamvault.core.ui.design.BrowseShapes
import com.streamvault.core.ui.design.browsePanel
@@ -49,169 +58,284 @@ import com.streamvault.core.ui.interaction.TvClickableSurface
import com.streamvault.core.ui.interaction.TvPrimaryButton
import com.streamvault.feature.stremio.R
import com.streamvault.domain.model.stremio.StremioMetaPreview
+import kotlinx.coroutines.yield
@Composable
internal fun StremioCatalogBrowseContent(
modifier: Modifier = Modifier,
viewModel: StremioCatalogBrowseViewModel = hiltViewModel(),
- onOpenItem: (Long, StremioMetaPreview) -> Unit = { _, _ -> }
+ onOpenItem: (Long, StremioMetaPreview) -> Unit = { _, _ -> },
+ onManageAddons: () -> Unit = {}
) {
val state = viewModel.state.collectAsStateWithLifecycle().value
- when {
- state.loading && state.rows.isEmpty() -> Box(modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
- CircularProgressIndicator(color = AppColors.Brand)
- }
- state.rows.isEmpty() -> Box(
- modifier = modifier.fillMaxSize().padding(24.dp),
- contentAlignment = Alignment.Center
+ val selected = state.rows.firstOrNull { it.key == state.selectedCatalogKey }
+ var showCatalogPicker by remember { mutableStateOf(false) }
+ var showGenrePicker by remember { mutableStateOf(false) }
+ val gridState = rememberLazyGridState()
+ var lastFocusedMetaId by rememberSaveable { mutableStateOf<String?>(null) }
+ var lastGridQueryKey by rememberSaveable { mutableStateOf<String?>(null) }
+ val itemFocusRequesters = remember { mutableMapOf<String, FocusRequester>() }
+
+ if (state.rows.isEmpty()) {
+ Column(
+ modifier = modifier.fillMaxSize(),
+ horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.Center
) {
- Text(
- text = stringResource(R.string.stremio_browse_empty),
- style = MaterialTheme.typography.bodyLarge,
- color = AppColors.TextSecondary
- )
+ val message = when (state.emptyReason) {
+ StremioBrowseEmptyReason.NO_INSTALLED_ADDONS -> R.string.stremio_browse_no_installed_addons
+ StremioBrowseEmptyReason.NO_ENABLED_ADDONS -> R.string.stremio_browse_no_enabled_addons
+ StremioBrowseEmptyReason.NO_ENABLED_CATALOGS -> R.string.stremio_browse_no_enabled_catalogs
+ null -> R.string.stremio_browse_empty
+ }
+ Text(stringResource(message), style = MaterialTheme.typography.bodyLarge, color = AppColors.TextSecondary)
+ Spacer(Modifier.height(12.dp))
+ TvButton(onClick = onManageAddons) { Text(stringResource(R.string.stremio_manage_addons)) }
}
- else -> LazyColumn(
+ return
+ }
+ if (selected == null) {
+ Column(
modifier = modifier.fillMaxSize(),
- verticalArrangement = Arrangement.spacedBy(14.dp),
- contentPadding = androidx.compose.foundation.layout.PaddingValues(bottom = 20.dp)
+ horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.Center
) {
- items(items = state.rows, key = { "${it.key.addonId}:${it.key.catalogKey}" }) { row ->
- CatalogRow(row, viewModel, onOpenItem)
- }
+ Text(stringResource(R.string.stremio_no_supported_catalogs), color = AppColors.TextSecondary)
+ Spacer(Modifier.height(12.dp))
+ TvButton(onClick = onManageAddons) { Text(stringResource(R.string.stremio_manage_addons)) }
}
+ return
}
-}
-@Composable
-private fun CatalogRow(
- row: StremioCatalogRowState,
- viewModel: StremioCatalogBrowseViewModel,
- onOpenItem: (Long, StremioMetaPreview) -> Unit
-) {
- Column(
- modifier = Modifier.fillMaxWidth().browsePanel(BrowseShapes.Panel).padding(18.dp),
- verticalArrangement = Arrangement.spacedBy(12.dp)
- ) {
- AppSectionHeader(
- title = row.catalog.name?.takeIf { it.isNotBlank() } ?: row.catalog.id,
- subtitle = "${row.addonName} · ${row.catalog.type.typeName}"
- )
-
- if (row.supportsSearch) {
- OutlinedTextField(
- value = row.search,
- onValueChange = { viewModel.setSearch(row.key, it) },
- modifier = Modifier.fillMaxWidth(),
- label = { Text(stringResource(R.string.stremio_search_catalog)) },
- singleLine = true,
- enabled = row.blockedReason == null,
- colors = browseTextFieldColors()
- )
- }
+ val gridQueryKey = "${selected.key.addonId}:${selected.key.catalogKey}:${selected.search.trim()}:${selected.genre.trim()}"
+ LaunchedEffect(gridQueryKey) {
+ if (lastGridQueryKey != null && lastGridQueryKey != gridQueryKey) gridState.scrollToItem(0)
+ lastGridQueryKey = gridQueryKey
+ }
+ LaunchedEffect(selected.key, lastFocusedMetaId, selected.metas) {
+ val focusedId = lastFocusedMetaId ?: return@LaunchedEffect
+ val focusedIndex = selected.metas.indexOfFirst { it.id == focusedId }
+ if (focusedIndex < 0) return@LaunchedEffect
+ gridState.scrollToItem(focusedIndex)
+ yield()
+ itemFocusRequesters[focusedId]?.let { requester -> runCatching { requester.requestFocus() } }
+ }
- if (row.supportsGenre) {
- if (row.genreOptions.isNotEmpty()) {
- LazyRow(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
- if (!row.genreRequired) {
- item(key = "all") {
- CatalogFilterChip(
- label = stringResource(R.string.stremio_all_genres),
- selected = row.genre.isBlank(),
- onClick = { viewModel.setGenre(row.key, "") }
- )
- }
- }
- items(row.genreOptions, key = { it }) { genre ->
- CatalogFilterChip(
- label = genre,
- selected = row.genre == genre,
- onClick = { viewModel.setGenre(row.key, genre) }
- )
- }
- }
- } else {
- OutlinedTextField(
- value = row.genre,
- onValueChange = { viewModel.setGenre(row.key, it) },
- modifier = Modifier.fillMaxWidth(),
- label = { Text(stringResource(R.string.stremio_filter_genre)) },
- singleLine = true,
- enabled = row.blockedReason == null,
- colors = browseTextFieldColors()
+ Column(modifier = modifier.fillMaxSize(), verticalArrangement = Arrangement.spacedBy(10.dp)) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(10.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ AppSectionHeader(
+ title = selected.catalog.name?.takeIf(String::isNotBlank) ?: selected.catalog.id,
+ subtitle = "${selected.addonName} · ${selected.catalog.type.typeName}"
)
}
+ TvButton(onClick = { showCatalogPicker = true }) {
+ Text(stringResource(R.string.stremio_choose_catalog))
+ }
+ if (selected.supportsGenre && selected.genreOptions.isNotEmpty()) {
+ TvButton(onClick = { showGenrePicker = true }) {
+ Text(selected.genre.ifBlank { stringResource(R.string.stremio_all_genres) })
+ }
+ }
+ if (selected.pageCount > 0 || selected.error != null) {
+ TvButton(onClick = { viewModel.refresh(selected.key) }, enabled = !selected.loading) {
+ Text(stringResource(R.string.stremio_refresh))
+ }
+ }
}
- row.blockedReason?.let { reason ->
- CatalogMessage(message = reason, error = true)
+ if (selected.supportsSearch) {
+ SearchInput(
+ value = selected.search,
+ onValueChange = { viewModel.setSearch(selected.key, it) },
+ placeholder = stringResource(R.string.stremio_search_catalog),
+ enabled = selected.blockedReason == null,
+ modifier = Modifier.fillMaxWidth()
+ )
+ }
+ if (selected.supportsGenre && selected.genreOptions.isEmpty()) {
+ SearchInput(
+ value = selected.genre,
+ onValueChange = { viewModel.setGenre(selected.key, it) },
+ placeholder = stringResource(R.string.stremio_filter_genre),
+ enabled = selected.blockedReason == null,
+ modifier = Modifier.fillMaxWidth()
+ )
}
- row.waitingForInput?.let {
+
+ selected.blockedReason?.let { CatalogMessage(message = it, error = true) }
+ selected.waitingForInput?.let {
val waiting = when {
- row.searchRequired && row.search.isBlank() -> stringResource(R.string.stremio_catalog_waiting_search)
- row.genreRequired && row.genre.isBlank() -> stringResource(R.string.stremio_catalog_waiting_genre)
+ selected.searchRequired && selected.search.isBlank() -> stringResource(R.string.stremio_catalog_waiting_search)
+ selected.genreRequired && selected.genre.isBlank() -> stringResource(R.string.stremio_catalog_waiting_genre)
else -> it
}
CatalogMessage(message = waiting)
}
- row.error?.let { error ->
+ selected.error?.let { error ->
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(10.dp)
) {
- Text(
- error,
- modifier = Modifier.weight(1f),
- color = AppColors.Live,
- style = MaterialTheme.typography.bodySmall
- )
- TvButton(onClick = { viewModel.retry(row.key) }) {
- Text(stringResource(R.string.stremio_retry))
- }
+ Text(error, modifier = Modifier.weight(1f), color = AppColors.Live, style = MaterialTheme.typography.bodySmall)
+ TvButton(onClick = { viewModel.retry(selected.key) }) { Text(stringResource(R.string.stremio_retry)) }
}
}
-
- if (row.loading && row.metas.isEmpty()) {
- Box(Modifier.fillMaxWidth().height(156.dp), contentAlignment = Alignment.Center) {
+ val showingPreviousResults = selected.metas.isNotEmpty() &&
+ (selected.loadedSearch != selected.search.trim() || selected.loadedGenre != selected.genre.trim())
+ if (showingPreviousResults) {
+ CatalogMessage(
+ message = stringResource(
+ if (selected.loading) R.string.stremio_catalog_updating_previous_results
+ else R.string.stremio_catalog_previous_results_label
+ )
+ )
+ } else if (selected.loading && selected.metas.isNotEmpty()) {
+ CatalogMessage(message = stringResource(R.string.stremio_catalog_refreshing_previous_results))
+ }
+ if (selected.loading && selected.metas.isEmpty()) {
+ Box(Modifier.weight(1f).fillMaxWidth(), contentAlignment = Alignment.Center) {
CircularProgressIndicator(color = AppColors.Brand)
}
- } else if (row.metas.isEmpty() && row.blockedReason == null &&
- row.waitingForInput == null && row.error == null
- ) {
- Text(
- text = stringResource(R.string.stremio_empty_catalog),
- color = AppColors.TextSecondary,
- style = MaterialTheme.typography.bodyMedium
- )
- } else if (row.metas.isNotEmpty()) {
- LazyRow(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
- items(
- items = row.metas,
- key = { "${it.type.typeName}:${it.id}" }
- ) { meta ->
- CatalogMetaCard(meta) { onOpenItem(row.key.addonId, meta) }
+ } else if (selected.metas.isEmpty()) {
+ Box(Modifier.weight(1f).fillMaxWidth(), contentAlignment = Alignment.Center) {
+ if (selected.blockedReason == null && selected.waitingForInput == null && selected.error == null) {
+ Text(stringResource(R.string.stremio_empty_catalog), color = AppColors.TextSecondary)
}
}
- }
-
- if (row.canLoadMore || row.loadingMore) {
- TvPrimaryButton(
- onClick = { viewModel.loadMore(row.key) },
- enabled = !row.loadingMore && !row.loading
+ } else {
+ LazyVerticalGrid(
+ columns = GridCells.Adaptive(minSize = 156.dp),
+ state = gridState,
+ modifier = Modifier.weight(1f).fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(12.dp),
+ verticalArrangement = Arrangement.spacedBy(14.dp),
+ contentPadding = androidx.compose.foundation.layout.PaddingValues(bottom = 20.dp)
) {
- if (row.loadingMore) {
- CircularProgressIndicator(modifier = Modifier.size(18.dp), strokeWidth = 2.dp, color = AppColors.OnPrimary)
- Spacer(Modifier.width(8.dp))
+ items(selected.metas, key = { "${it.type.typeName}:${it.id}" }) { meta ->
+ val focusRequester = itemFocusRequesters.getOrPut(meta.id) { FocusRequester() }
+ CatalogMetaCard(
+ meta = meta,
+ focusRequester = focusRequester,
+ onFocused = { lastFocusedMetaId = meta.id },
+ onClick = { onOpenItem(selected.key.addonId, meta) }
+ )
+ }
+ if ((selected.canLoadMore || selected.loadingMore) && selected.failedPageSkip == null) {
+ item(span = { GridItemSpan(maxLineSpan) }) {
+ TvPrimaryButton(
+ onClick = { viewModel.loadMore(selected.key) },
+ enabled = !selected.loadingMore && !selected.loading,
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ if (selected.loadingMore) {
+ CircularProgressIndicator(modifier = Modifier.size(18.dp), strokeWidth = 2.dp, color = AppColors.OnPrimary)
+ Spacer(Modifier.width(8.dp))
+ }
+ Text(stringResource(R.string.stremio_load_more))
+ }
+ }
}
- Text(stringResource(R.string.stremio_load_more))
}
}
}
+
+ if (showCatalogPicker) {
+ CatalogPickerDialog(
+ rows = state.rows,
+ selectedKey = selected.key,
+ onSelect = { viewModel.selectCatalog(it); showCatalogPicker = false },
+ onDismiss = { showCatalogPicker = false }
+ )
+ }
+ if (showGenrePicker) {
+ GenrePickerDialog(
+ row = selected,
+ onSelect = { viewModel.setGenre(selected.key, it); showGenrePicker = false },
+ onDismiss = { showGenrePicker = false }
+ )
+ }
+}
+@Composable
+private fun CatalogPickerDialog(
+ rows: List<StremioCatalogRowState>,
+ selectedKey: StremioCatalogRowKey,
+ onSelect: (StremioCatalogRowKey) -> Unit,
+ onDismiss: () -> Unit
+) {
+ PremiumDialog(
+ title = stringResource(R.string.stremio_choose_catalog),
+ onDismissRequest = onDismiss,
+ heightFraction = null,
+ content = {
+ Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
+ rows.forEach { row ->
+ TvButton(
+ onClick = { onSelect(row.key) },
+ modifier = Modifier.fillMaxWidth(),
+ enabled = row.blockedReason == null
+ ) {
+ Text(
+ text = listOf(
+ row.catalog.name?.takeIf(String::isNotBlank) ?: row.catalog.id,
+ row.addonName,
+ row.catalog.type.typeName,
+ if (row.key == selectedKey) "✓" else null
+ ).filterNotNull().joinToString(" · "),
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ }
+ }
+ }
+ },
+ footer = {
+ PremiumDialogFooterButton(label = stringResource(R.string.stremio_cancel), onClick = onDismiss)
+ }
+ )
+}
+@Composable
+private fun GenrePickerDialog(
+ row: StremioCatalogRowState,
+ onSelect: (String) -> Unit,
+ onDismiss: () -> Unit
+) {
+ PremiumDialog(
+ title = stringResource(R.string.stremio_filter_genre),
+ onDismissRequest = onDismiss,
+ heightFraction = null,
+ content = {
+ Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
+ if (!row.genreRequired) {
+ TvButton(onClick = { onSelect("") }, modifier = Modifier.fillMaxWidth()) {
+ Text(stringResource(R.string.stremio_all_genres))
+ }
+ }
+ row.genreOptions.forEach { genre ->
+ TvButton(onClick = { onSelect(genre) }, modifier = Modifier.fillMaxWidth()) {
+ Text(if (genre == row.genre) "$genre ✓" else genre)
+ }
+ }
+ }
+ },
+ footer = {
+ PremiumDialogFooterButton(label = stringResource(R.string.stremio_cancel), onClick = onDismiss)
+ }
+ )
}
@Composable
-private fun CatalogMetaCard(meta: StremioMetaPreview, onClick: () -> Unit) {
+private fun CatalogMetaCard(
+ meta: StremioMetaPreview,
+ focusRequester: FocusRequester,
+ onFocused: () -> Unit,
+ onClick: () -> Unit
+) {
val description = stringResource(
R.string.stremio_catalog_item_a11y,
meta.name,
@@ -220,13 +344,15 @@ private fun CatalogMetaCard(meta: StremioMetaPreview, onClick: () -> Unit) {
TvClickableSurface(
onClick = onClick,
modifier = Modifier
- .width(152.dp)
+ .fillMaxWidth()
+ .focusRequester(focusRequester)
+ .onFocusChanged { if (it.isFocused) onFocused() }
.semantics { contentDescription = description },
shape = ClickableSurfaceDefaults.shape(BrowseShapes.Artwork)
) {
Column(modifier = Modifier.fillMaxWidth().clip(BrowseShapes.Artwork)) {
Box(
- modifier = Modifier.fillMaxWidth().height(210.dp).clip(BrowseShapes.Artwork)
+ modifier = Modifier.fillMaxWidth().aspectRatio(2f / 3f).clip(BrowseShapes.Artwork)
.background(AppColors.SurfaceEmphasis),
contentAlignment = Alignment.Center
) {
@@ -236,12 +362,14 @@ private fun CatalogMetaCard(meta: StremioMetaPreview, onClick: () -> Unit) {
style = MaterialTheme.typography.displaySmall,
fontWeight = FontWeight.Bold
)
- AsyncImage(
- model = meta.poster,
- contentDescription = null,
- modifier = Modifier.fillMaxSize(),
- contentScale = ContentScale.Crop
- )
+ meta.poster?.takeIf(String::isNotBlank)?.let { poster ->
+ AsyncImage(
+ model = poster,
+ contentDescription = null,
+ modifier = Modifier.fillMaxSize(),
+ contentScale = ContentScale.Crop
+ )
+ }
}
Column(
modifier = Modifier.fillMaxWidth().padding(horizontal = 10.dp, vertical = 10.dp),
@@ -268,28 +396,6 @@ private fun CatalogMetaCard(meta: StremioMetaPreview, onClick: () -> Unit) {
}
}
-@Composable
-private fun CatalogFilterChip(label: String, selected: Boolean, onClick: () -> Unit) {
- val shape = BrowseShapes.Control
- TvButton(
- onClick = onClick,
- modifier = Modifier.heightIn(min = 40.dp),
- shape = ButtonDefaults.shape(shape),
- border = ButtonDefaults.border(
- border = if (selected) Border(BorderStroke(1.dp, AppColors.Brand.copy(alpha = 0.7f)), shape = shape) else Border.None,
- focusedBorder = Border(BorderStroke(2.dp, AppColors.Focus), shape = shape)
- ),
- colors = ButtonDefaults.colors(
- containerColor = if (selected) AppColors.BrandMuted else AppColors.Surface,
- contentColor = if (selected) AppColors.TextPrimary else AppColors.TextSecondary,
- focusedContainerColor = if (selected) AppColors.BrandMuted else AppColors.SurfaceEmphasis,
- focusedContentColor = AppColors.TextPrimary
- )
- ) {
- Text(label, modifier = Modifier.padding(horizontal = 6.dp))
- }
-}
-
@Composable
private fun CatalogMessage(message: String, error: Boolean = false) {
Row(
@@ -303,17 +409,3 @@ private fun CatalogMessage(message: String, error: Boolean = false) {
)
}
}
-
-@Composable
-private fun browseTextFieldColors() = OutlinedTextFieldDefaults.colors(
- focusedTextColor = AppColors.TextPrimary,
- unfocusedTextColor = AppColors.TextPrimary,
- disabledTextColor = AppColors.TextSecondary,
- focusedBorderColor = AppColors.Brand,
- unfocusedBorderColor = AppColors.Outline,
- disabledBorderColor = AppColors.Outline.copy(alpha = 0.4f),
- focusedLabelColor = AppColors.Brand,
- unfocusedLabelColor = AppColors.TextSecondary,
- disabledLabelColor = AppColors.TextTertiary,
- cursorColor = AppColors.Brand
-)
diff --git a/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioCatalogBrowseViewModel.kt b/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioCatalogBrowseViewModel.kt
index 08b07697..dc6e6888 100644
--- a/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioCatalogBrowseViewModel.kt
+++ b/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioCatalogBrowseViewModel.kt
@@ -30,12 +30,17 @@ data class StremioCatalogRowState(
val key: StremioCatalogRowKey,
val addonName: String,
val addonFingerprint: String,
+ val addonUpdatedAt: Long,
val catalog: StremioCatalogRef,
val metas: List<StremioMetaPreview> = emptyList(),
val search: String = "",
val genre: String = "",
+ val loadedSearch: String? = null,
+ val loadedGenre: String? = null,
val loading: Boolean = false,
val loadingMore: Boolean = false,
+ val failedPageSkip: Int? = null,
+ val failedRequestBypassCache: Boolean = false,
val nextSkip: Int = 0,
val pageCount: Int = 0,
val canLoadMore: Boolean = false,
@@ -61,9 +66,14 @@ data class StremioCatalogRowState(
?: catalog.genres
}
+enum class StremioBrowseEmptyReason { NO_INSTALLED_ADDONS, NO_ENABLED_ADDONS, NO_ENABLED_CATALOGS }
+
data class StremioCatalogBrowseState(
val loading: Boolean = true,
- val rows: List<StremioCatalogRowState> = emptyList()
+ val rows: List<StremioCatalogRowState> = emptyList(),
+ val selectedCatalogKey: StremioCatalogRowKey? = null,
+ val emptyReason: StremioBrowseEmptyReason? = null,
+ val loadError: String? = null
)
@HiltViewModel
@@ -91,7 +101,13 @@ class StremioCatalogBrowseViewModel @Inject constructor(
val oldRows = _state.value.rows.associateBy { it.key }
val rows = buildList {
addons.asSequence().filter { it.enabled }.forEach addonLoop@{ addon ->
- val manifest = repository.getManifest(addon.id) ?: return@addonLoop
+ val manifest = try {
+ repository.getManifest(addon.id)
+ } catch (cancellation: CancellationException) {
+ throw cancellation
+ } catch (_: Exception) {
+ null
+ } ?: return@addonLoop
manifest.catalogs.forEach catalogLoop@{ catalog ->
if (!addon.isCatalogEnabled(catalog.settingsKey)) return@catalogLoop
val key = StremioCatalogRowKey(addon.id, catalog.settingsKey)
@@ -103,16 +119,43 @@ class StremioCatalogBrowseViewModel @Inject constructor(
}?.let { "Requires unsupported '${it.name}' filter" }
else -> "${catalog.type.typeName} catalogs are not supported yet"
}
+ val old = oldRows[key]?.takeIf { it.addonFingerprint == addonFingerprint }
add(
- oldRows[key]?.takeIf { it.addonFingerprint == addonFingerprint }?.copy(
- addonName = addon.name,
- addonFingerprint = addonFingerprint,
- catalog = catalog,
- blockedReason = blockedReason
- ) ?: StremioCatalogRowState(
+ old?.let { previous ->
+ if (previous.addonUpdatedAt == addon.updatedAt) {
+ previous.copy(
+ addonName = addon.name,
+ addonFingerprint = addonFingerprint,
+ addonUpdatedAt = addon.updatedAt,
+ catalog = catalog,
+ blockedReason = blockedReason
+ )
+ } else {
+ previous.copy(
+ addonName = addon.name,
+ addonFingerprint = addonFingerprint,
+ addonUpdatedAt = addon.updatedAt,
+ catalog = catalog,
+ metas = emptyList(),
+ loadedSearch = null,
+ loadedGenre = null,
+ loading = false,
+ loadingMore = false,
+ failedPageSkip = null,
+ failedRequestBypassCache = false,
+ nextSkip = 0,
+ pageCount = 0,
+ canLoadMore = false,
+ error = null,
+ blockedReason = blockedReason,
+ waitingForInput = null
+ )
+ }
+ } ?: StremioCatalogRowState(
key = key,
addonName = addon.name,
addonFingerprint = addonFingerprint,
+ addonUpdatedAt = addon.updatedAt,
catalog = catalog,
blockedReason = blockedReason
)
@@ -129,7 +172,11 @@ class StremioCatalogBrowseViewModel @Inject constructor(
pageCache.removeCatalog(row.addonFingerprint, row.catalog.settingsKey)
}
val refreshedKeys = rows.mapNotNull { row ->
- row.key.takeIf { oldRows[it]?.addonFingerprint?.let { old -> old != row.addonFingerprint } == true }
+ row.key.takeIf {
+ oldRows[it]?.let { old ->
+ old.addonFingerprint != row.addonFingerprint || old.addonUpdatedAt != row.addonUpdatedAt
+ } == true
+ }
}.toSet()
rows.forEach { row ->
oldRows[row.key]?.takeIf { row.key in refreshedKeys }?.let { old ->
@@ -138,12 +185,37 @@ class StremioCatalogBrowseViewModel @Inject constructor(
pageCache.removeCatalog(old.addonFingerprint, old.catalog.settingsKey)
}
}
- val isFirstLoad = _state.value.loading
- _state.value = StremioCatalogBrowseState(loading = false, rows = rows)
- rows.filter { (it.key !in oldRows || it.key in refreshedKeys) && it.blockedReason == null }.forEach { row ->
- startRequest(row.key, reset = true, debounceMs = 0L)
+ val selectedKey = _state.value.selectedCatalogKey
+ ?.takeIf { key -> rows.any { it.key == key } }
+ ?: rows.firstOrNull { it.blockedReason == null }?.key
+ val emptyReason = when {
+ addons.isEmpty() -> StremioBrowseEmptyReason.NO_INSTALLED_ADDONS
+ addons.none { it.enabled } -> StremioBrowseEmptyReason.NO_ENABLED_ADDONS
+ rows.isEmpty() -> StremioBrowseEmptyReason.NO_ENABLED_CATALOGS
+ else -> null
+ }
+ _state.value = StremioCatalogBrowseState(
+ loading = false,
+ rows = rows,
+ selectedCatalogKey = selectedKey,
+ emptyReason = emptyReason
+ )
+ selectedKey?.let { key ->
+ val selected = rows.firstOrNull { it.key == key } ?: return@let
+ if (selected.blockedReason == null && selected.pageCount == 0 &&
+ !selected.loading && selected.error == null && selected.waitingForInput == null
+ ) {
+ startRequest(key, reset = true, debounceMs = 0L)
+ }
+ }
+ }
+
+ fun selectCatalog(key: StremioCatalogRowKey) {
+ val row = _state.value.rows.firstOrNull { it.key == key } ?: return
+ _state.update { it.copy(selectedCatalogKey = key) }
+ if (row.blockedReason == null && row.pageCount == 0 && !row.loading && row.error == null) {
+ startRequest(key, reset = true, debounceMs = 0L)
}
- if (isFirstLoad && rows.isEmpty()) _state.update { it.copy(loading = false) }
}
fun setSearch(key: StremioCatalogRowKey, search: String) {
@@ -159,7 +231,18 @@ class StremioCatalogBrowseViewModel @Inject constructor(
}
fun retry(key: StremioCatalogRowKey) {
- startRequest(key, reset = true, debounceMs = 0L)
+ val row = _state.value.rows.firstOrNull { it.key == key } ?: return
+ val failedSkip = row.failedPageSkip
+ val bypassCache = row.failedRequestBypassCache
+ if (failedSkip != null && failedSkip > 0) {
+ startRequest(key, reset = false, debounceMs = 0L, bypassCache = bypassCache, skipOverride = failedSkip)
+ } else {
+ startRequest(key, reset = true, debounceMs = 0L, bypassCache = bypassCache)
+ }
+ }
+
+ fun refresh(key: StremioCatalogRowKey) {
+ startRequest(key, reset = true, debounceMs = 0L, bypassCache = true)
}
fun loadMore(key: StremioCatalogRowKey) {
@@ -168,7 +251,13 @@ class StremioCatalogBrowseViewModel @Inject constructor(
startRequest(key, reset = false, debounceMs = 0L)
}
- private fun startRequest(key: StremioCatalogRowKey, reset: Boolean, debounceMs: Long) {
+ private fun startRequest(
+ key: StremioCatalogRowKey,
+ reset: Boolean,
+ debounceMs: Long,
+ bypassCache: Boolean = false,
+ skipOverride: Int? = null
+ ) {
if (!contentAccess.canAccessContentNow()) return
val row = _state.value.rows.firstOrNull { it.key == key } ?: return
if (row.blockedReason != null) return
@@ -179,34 +268,38 @@ class StremioCatalogBrowseViewModel @Inject constructor(
seenPageFingerprints[key] = mutableSetOf()
updateRow(key) {
it.copy(
- metas = emptyList(),
+ metas = if (rowCanRequest(it)) it.metas else emptyList(),
loading = rowCanRequest(it),
loadingMore = false,
nextSkip = 0,
pageCount = 0,
canLoadMore = false,
error = null,
+ failedPageSkip = null,
+ failedRequestBypassCache = false,
waitingForInput = missingRequiredInput(it)
)
}
} else {
- updateRow(key) { it.copy(loadingMore = true, error = null) }
+ updateRow(key) { it.copy(loadingMore = true, error = null, failedPageSkip = null, failedRequestBypassCache = false) }
}
if (!rowCanRequest(_state.value.rows.first { it.key == key })) return
jobs[key] = viewModelScope.launch {
if (debounceMs > 0L) delay(debounceMs)
- requestPage(key, generation, reset)
+ requestPage(key, generation, reset, bypassCache, skipOverride)
}
}
private suspend fun requestPage(
key: StremioCatalogRowKey,
generation: Long,
- reset: Boolean
+ reset: Boolean,
+ bypassCache: Boolean,
+ skipOverride: Int?
) {
if (!contentAccess.canAccessContentNow()) return
val row = _state.value.rows.firstOrNull { it.key == key } ?: return
- val skip = if (row.supportsSkip) row.nextSkip else null
+ val skip = if (row.supportsSkip) (skipOverride ?: row.nextSkip) else null
val query = StremioCatalogQuery(
search = row.search.trim().takeIf { it.isNotEmpty() },
genre = row.genre.trim().takeIf { it.isNotEmpty() },
@@ -220,7 +313,7 @@ class StremioCatalogBrowseViewModel @Inject constructor(
skip = skip
)
try {
- val cachedPage = pageCache.get(cacheKey)
+ val cachedPage = if (bypassCache) null else pageCache.get(cacheKey)
val result = if (cachedPage != null) {
null
} else {
@@ -234,7 +327,14 @@ class StremioCatalogBrowseViewModel @Inject constructor(
if (page == null) {
val error = result?.errorMessageOrNull() ?: "Catalog could not be loaded"
updateRow(key) {
- it.copy(loading = false, loadingMore = false, error = error, canLoadMore = false)
+ it.copy(
+ loading = false,
+ loadingMore = false,
+ error = error,
+ failedPageSkip = skip ?: 0,
+ failedRequestBypassCache = bypassCache,
+ canLoadMore = (skip ?: 0) > 0 || it.canLoadMore
+ )
}
return
}
@@ -248,7 +348,9 @@ class StremioCatalogBrowseViewModel @Inject constructor(
loading = false,
loadingMore = false,
error = error.message ?: "Catalog could not be loaded",
- canLoadMore = false
+ failedPageSkip = skip ?: 0,
+ failedRequestBypassCache = bypassCache,
+ canLoadMore = (skip ?: 0) > 0 || it.canLoadMore
)
}
}
@@ -279,11 +381,15 @@ class StremioCatalogBrowseViewModel @Inject constructor(
updateRow(key) {
it.copy(
metas = if (reset) uniqueNew else it.metas + uniqueNew,
+ loadedSearch = requestedRow.search.trim(),
+ loadedGenre = requestedRow.genre.trim(),
loading = false,
loadingMore = false,
nextSkip = nextSkip,
pageCount = if (reset) 1 else it.pageCount + 1,
canLoadMore = canLoadMore,
+ failedPageSkip = null,
+ failedRequestBypassCache = false,
error = when {
repeated -> "The addon repeated a page; loading stopped."
rawHasMore && !canLoadMore && page.rawItemCount > 0 &&
diff --git a/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioItemDetailContent.kt b/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioItemDetailContent.kt
index 1e040313..84757c27 100644
--- a/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioItemDetailContent.kt
+++ b/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioItemDetailContent.kt
@@ -13,12 +13,18 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.foundation.background
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.DisposableEffect
+import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.saveable.rememberSaveable
+import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
@@ -28,6 +34,9 @@ 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.Lifecycle
+import androidx.lifecycle.LifecycleEventObserver
+import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import coil3.compose.AsyncImage
import androidx.tv.material3.ClickableSurfaceDefaults
@@ -57,9 +66,18 @@ import com.streamvault.feature.stremio.api.StremioScaffoldContent
internal fun StremioItemDetailScreen(
scaffold: StremioScaffoldContent,
onPlay: (StremioPlayerHandoff) -> Unit,
+ onManagePlugins: () -> Unit = {},
viewModel: StremioItemDetailViewModel = hiltViewModel()
) {
val state by viewModel.state.collectAsStateWithLifecycle()
+ val lifecycleOwner = LocalLifecycleOwner.current
+ DisposableEffect(lifecycleOwner, viewModel) {
+ val observer = LifecycleEventObserver { _, event ->
+ if (event == Lifecycle.Event.ON_RESUME) viewModel.refreshTorrentPlaybackAvailability()
+ }
+ lifecycleOwner.lifecycle.addObserver(observer)
+ onDispose { lifecycleOwner.lifecycle.removeObserver(observer) }
+ }
scaffold(
AppDestination.Addons,
state.displayName,
@@ -71,8 +89,11 @@ internal fun StremioItemDetailScreen(
state = state,
onLoadMovieStreams = { viewModel.loadStreams(state.preview.id) },
onLoadEpisodeStreams = viewModel::loadStreams,
+ onClearSelectedEpisode = viewModel::clearSelectedEpisode,
+ onRetryAllStreams = { videoId -> viewModel.loadStreams(videoId) },
onRetryMetadata = viewModel::retryMetadata,
onRetryAddon = viewModel::retryStreamsForAddon,
+ onManagePlugins = onManagePlugins,
onPlay = onPlay
)
}
@@ -83,10 +104,18 @@ private fun StremioItemDetailContent(
state: StremioItemDetailState,
onLoadMovieStreams: () -> Unit,
onLoadEpisodeStreams: (String) -> Unit,
+ onClearSelectedEpisode: () -> Unit,
+ onRetryAllStreams: (String) -> Unit,
onRetryMetadata: () -> Unit,
onRetryAddon: (Long) -> Unit,
+ onManagePlugins: () -> Unit,
onPlay: (StremioPlayerHandoff) -> Unit
) {
+ var selectedSeason by rememberSaveable(state.preview.id) { mutableStateOf<Int?>(null) }
+ val seasons = state.videos.mapNotNull { it.season }.distinct().sorted()
+ LaunchedEffect(seasons) {
+ if (selectedSeason !in seasons) selectedSeason = seasons.firstOrNull()
+ }
LazyColumn(
modifier = Modifier.fillMaxSize().padding(horizontal = 20.dp, vertical = 8.dp),
verticalArrangement = Arrangement.spacedBy(14.dp),
@@ -162,8 +191,25 @@ private fun StremioItemDetailContent(
item(key = "episodes-empty") {
StremioDetailMessage(stringResource(R.string.stremio_item_no_episode_ids))
}
- } else {
- items(state.videos, key = { "episode:${it.id}" }) { video ->
+ } else if (state.requestedVideoId == null) {
+ if (seasons.size > 1) {
+ item(key = "season-picker") {
+ LazyRow(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
+ items(seasons, key = { "season:$it" }) { season ->
+ TvButton(onClick = { selectedSeason = season }) {
+ Text(
+ text = stringResource(R.string.stremio_item_season_number, season),
+ color = if (season == selectedSeason) AppColors.TextPrimary else AppColors.TextSecondary
+ )
+ }
+ }
+ }
+ }
+ }
+ items(
+ state.videos.filter { selectedSeason == null || it.season == selectedSeason },
+ key = { "episode:${it.id}" }
+ ) { video ->
TvClickableSurface(
onClick = { onLoadEpisodeStreams(video.id) },
enabled = !state.replayOriginUnavailable,
@@ -197,6 +243,28 @@ private fun StremioItemDetailContent(
}
}
}
+ } else {
+ item(key = "selected-episode") {
+ Row(
+ modifier = Modifier.fillMaxWidth().browsePanel(BrowseShapes.Control).padding(12.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(12.dp)
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(
+ state.selectedVideo?.let(::episodeLabel)
+ ?: state.selectedVideo?.title
+ ?: "Episode ${state.requestedVideoId}",
+ style = MaterialTheme.typography.titleSmall,
+ color = AppColors.TextPrimary
+ )
+ }
+ TvButton(onClick = {
+ selectedSeason = state.selectedVideo?.season ?: selectedSeason
+ onClearSelectedEpisode()
+ }) { Text(stringResource(R.string.stremio_item_change_episode)) }
+ }
+ }
}
}
@@ -217,6 +285,34 @@ private fun StremioItemDetailContent(
}
}
}
+ if (state.streamsLoading && state.streams.isNotEmpty()) {
+ val settledProviders = (state.streams.map { it.source.addonId } + state.streamFailures.map { it.source.addonId })
+ .distinct().size
+ val remaining = (state.streamCandidateCount - settledProviders).coerceAtLeast(0)
+ item(key = "streams-progress") {
+ StremioDetailMessage(
+ if (remaining > 0) {
+ stringResource(R.string.stremio_item_sources_remaining, remaining)
+ } else {
+ stringResource(R.string.stremio_item_sources_loading)
+ }
+ )
+ }
+ }
+ state.streamError?.let { message ->
+ item(key = "streams-operation-error") {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ Text(message, modifier = Modifier.weight(1f), color = AppColors.Live)
+ TvButton(onClick = { onRetryAllStreams(requestedVideoId) }) {
+ Text(stringResource(R.string.stremio_retry))
+ }
+ }
+ }
+ }
if (!state.streamsLoading && state.streams.isEmpty() &&
state.streamFailures.isEmpty() && state.streamCandidateCount == 0
) {
@@ -241,7 +337,8 @@ private fun StremioItemDetailContent(
} == true
val canPlay = when (stream.kind) {
StremioStreamKind.DIRECT -> mediaHeaders != null && isHttpUrl
- StremioStreamKind.TORRENT -> stream.toMagnetUri() != null
+ StremioStreamKind.TORRENT ->
+ stream.toMagnetUri() != null && state.torrentPluginAvailable == true
else -> false
}
Column(
@@ -271,7 +368,10 @@ private fun StremioItemDetailContent(
}
if (!canPlay) {
Text(
- unsupportedStreamLabel(stream),
+ unsupportedStreamLabel(
+ stream,
+ checkingTorrentPlugin = state.torrentPluginCheckLoading
+ ),
style = MaterialTheme.typography.bodySmall,
color = AppColors.TextSecondary
)
@@ -282,6 +382,13 @@ private fun StremioItemDetailContent(
color = AppColors.TextSecondary
)
}
+ if (stream.kind == StremioStreamKind.TORRENT &&
+ stream.toMagnetUri() != null && state.torrentPluginAvailable == false
+ ) {
+ TvButton(onClick = onManagePlugins) {
+ Text(stringResource(R.string.stremio_item_manage_plugins))
+ }
+ }
}
if (canPlay) {
TvPrimaryButton(
@@ -365,6 +472,16 @@ private fun StremioMetadataContent(
}
} else if (state.metadata == null) {
StremioDetailMessage(stringResource(R.string.stremio_item_preview_only))
+ state.metadataError?.let { message ->
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ Text(message, modifier = Modifier.weight(1f), color = AppColors.Live)
+ TvButton(onClick = onRetryMetadata) { Text(stringResource(R.string.stremio_retry)) }
+ }
+ }
state.metadataFailures.forEach { failure ->
Row(
modifier = Modifier.fillMaxWidth(),
@@ -409,15 +526,18 @@ private fun episodeLabel(video: com.streamvault.domain.model.stremio.StremioVide
}
@Composable
-private fun unsupportedStreamLabel(stream: StremioStream): String {
+private fun unsupportedStreamLabel(
+ stream: StremioStream,
+ checkingTorrentPlugin: Boolean
+): String {
val stringRes = when {
stream.kind == StremioStreamKind.DIRECT && stream.url?.let {
stremioMediaRequestHeaders(it, stream.behaviorHints?.proxyHeaders?.request)
} == null -> R.string.stremio_item_headers_unavailable
- stream.kind == StremioStreamKind.TORRENT -> if (stream.toMagnetUri() == null) {
- R.string.stremio_item_torrent_invalid
- } else {
- R.string.stremio_item_torrent_unavailable
+ stream.kind == StremioStreamKind.TORRENT -> when {
+ stream.toMagnetUri() == null -> R.string.stremio_item_torrent_invalid
+ checkingTorrentPlugin -> R.string.stremio_item_torrent_checking
+ else -> R.string.stremio_item_torrent_unavailable
}
stream.kind == StremioStreamKind.UNKNOWN -> R.string.stremio_item_unsupported_stream
stream.kind == StremioStreamKind.YOUTUBE || stream.kind == StremioStreamKind.EXTERNAL ->
diff --git a/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioItemDetailViewModel.kt b/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioItemDetailViewModel.kt
index 692e6270..4d5e17cb 100644
--- a/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioItemDetailViewModel.kt
+++ b/feature/stremio/src/main/java/com/streamvault/feature/stremio/presentation/StremioItemDetailViewModel.kt
@@ -9,10 +9,12 @@ 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.StremioStream
+import com.streamvault.domain.model.stremio.StremioStreamKind
import com.streamvault.domain.model.stremio.StremioSubtitle
import com.streamvault.domain.model.stremio.StremioVideo
import com.streamvault.domain.model.stremio.installFingerprint
import com.streamvault.domain.repository.StremioAddonRepository
+import com.streamvault.feature.stremio.api.StremioTorrentPlaybackAvailability
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.CancellationException
@@ -32,12 +34,17 @@ data class StremioItemDetailState(
val metaOrigin: StremioAddonSource? = null,
val metadataLoading: Boolean = true,
val metadataFailures: List<StremioAddonResourceFailure> = emptyList(),
+ val metadataError: String? = null,
val requestedVideoId: String? = null,
val selectedVideo: StremioVideo? = null,
val streamsLoading: Boolean = false,
+ val streamError: String? = null,
val streams: List<com.streamvault.domain.model.stremio.StremioAttributedResource<StremioStream>> = emptyList(),
val streamFailures: List<StremioAddonResourceFailure> = emptyList(),
val streamCandidateCount: Int = 0,
+ val streamProviderOrder: List<Long> = emptyList(),
+ val torrentPluginAvailable: Boolean? = null,
+ val torrentPluginCheckLoading: Boolean = false,
val subtitles: List<com.streamvault.domain.model.stremio.StremioAttributedResource<StremioSubtitle>> = emptyList(),
val subtitleFailures: List<StremioAddonResourceFailure> = emptyList()
) {
@@ -52,7 +59,8 @@ data class StremioItemDetailState(
class StremioItemDetailViewModel @Inject constructor(
savedStateHandle: SavedStateHandle,
private val repository: StremioAddonRepository,
- private val contentAccess: StremioContentAccess
+ private val contentAccess: StremioContentAccess,
+ private val torrentPlaybackAvailability: StremioTorrentPlaybackAvailability
) : ViewModel() {
private val originAddonId = savedStateHandle.get<Long>(ARG_ORIGIN_ADDON_ID) ?: -1L
@@ -81,7 +89,9 @@ class StremioItemDetailViewModel @Inject constructor(
private var metadataJob: Job? = null
private var streamJob: Job? = null
+ private var torrentAvailabilityJob: Job? = null
private var streamGeneration = 0L
+ private var torrentAvailabilityGeneration = 0L
init {
loadMetadata()
@@ -104,15 +114,21 @@ class StremioItemDetailViewModel @Inject constructor(
else -> return
}
streamJob?.cancel()
+ torrentAvailabilityJob?.cancel()
+ torrentAvailabilityGeneration++
val generation = ++streamGeneration
_state.update {
it.copy(
requestedVideoId = videoId,
selectedVideo = selectedVideo,
streamsLoading = true,
+ streamError = null,
streams = emptyList(),
streamFailures = emptyList(),
streamCandidateCount = 0,
+ streamProviderOrder = emptyList(),
+ torrentPluginAvailable = null,
+ torrentPluginCheckLoading = false,
subtitles = emptyList(),
subtitleFailures = emptyList()
)
@@ -120,14 +136,28 @@ class StremioItemDetailViewModel @Inject constructor(
streamJob = viewModelScope.launch {
try {
if (!contentAccess.canAccessContentNow()) return@launch
- val result = repository.resolveStreams(type, videoId)
+ val result = repository.resolveStreamsProgressively(type, videoId) { progress ->
+ if (generation == streamGeneration) {
+ checkTorrentPlaybackAvailability(progress.results)
+ _state.update {
+ it.copy(
+ streams = progress.results,
+ streamFailures = progress.failures,
+ streamCandidateCount = progress.candidateCount,
+ streamProviderOrder = progress.completedAddonIds
+ )
+ }
+ }
+ }
if (generation == streamGeneration) {
+ checkTorrentPlaybackAvailability(result.results)
_state.update {
it.copy(
streamsLoading = false,
streams = result.results,
streamFailures = result.failures,
- streamCandidateCount = result.candidateCount
+ streamCandidateCount = result.candidateCount,
+ streamProviderOrder = result.completedAddonIds
)
}
}
@@ -135,30 +165,83 @@ class StremioItemDetailViewModel @Inject constructor(
throw cancellation
} catch (_: Exception) {
if (generation == streamGeneration) {
- _state.update { it.copy(streamsLoading = false) }
+ _state.update {
+ it.copy(streamsLoading = false, streamError = "Sources could not be loaded. Try again.")
+ }
}
}
}
}
+ fun clearSelectedEpisode() {
+ streamJob?.cancel()
+ torrentAvailabilityJob?.cancel()
+ torrentAvailabilityGeneration++
+ streamGeneration++
+ _state.update {
+ it.copy(
+ requestedVideoId = null,
+ selectedVideo = null,
+ streamsLoading = false,
+ streamError = null,
+ streams = emptyList(),
+ streamFailures = emptyList(),
+ streamCandidateCount = 0,
+ streamProviderOrder = emptyList(),
+ torrentPluginAvailable = null,
+ torrentPluginCheckLoading = false,
+ subtitles = emptyList(),
+ subtitleFailures = emptyList()
+ )
+ }
+ }
+
fun retryStreamsForAddon(addonId: Long) {
if (!contentAccess.canAccessContentNow()) return
val current = _state.value
val videoId = current.requestedVideoId ?: return
val generation = ++streamGeneration
streamJob?.cancel()
- _state.update { it.copy(streamsLoading = true) }
+ _state.update { it.copy(streamsLoading = true, streamError = null) }
streamJob = viewModelScope.launch {
try {
if (!contentAccess.canAccessContentNow()) return@launch
- val result = repository.resolveStreams(type, videoId, setOf(addonId))
+ val result = repository.resolveStreamsProgressively(type, videoId, setOf(addonId)) { progress ->
+ if (generation == streamGeneration) {
+ checkTorrentPlaybackAvailability(progress.results)
+ _state.update { state ->
+ val providerOrder = state.streamProviderOrder.ifEmpty { progress.completedAddonIds }
+ state.copy(
+ streams = orderResourcesByProvider(
+ state.streams.filterNot { it.source.addonId == addonId } + progress.results,
+ providerOrder
+ ),
+ streamFailures = orderFailuresByProvider(
+ state.streamFailures.filterNot { it.source.addonId == addonId } + progress.failures,
+ providerOrder
+ ),
+ streamCandidateCount = maxOf(state.streamCandidateCount, progress.candidateCount),
+ streamProviderOrder = providerOrder
+ )
+ }
+ }
+ }
if (generation == streamGeneration) {
+ checkTorrentPlaybackAvailability(result.results)
_state.update { state ->
+ val providerOrder = state.streamProviderOrder.ifEmpty { result.completedAddonIds }
state.copy(
streamsLoading = false,
- streams = state.streams.filterNot { it.source.addonId == addonId } + result.results,
- streamFailures = state.streamFailures.filterNot { it.source.addonId == addonId } + result.failures,
- streamCandidateCount = maxOf(state.streamCandidateCount, result.candidateCount)
+ streams = orderResourcesByProvider(
+ state.streams.filterNot { it.source.addonId == addonId } + result.results,
+ providerOrder
+ ),
+ streamFailures = orderFailuresByProvider(
+ state.streamFailures.filterNot { it.source.addonId == addonId } + result.failures,
+ providerOrder
+ ),
+ streamCandidateCount = maxOf(state.streamCandidateCount, result.candidateCount),
+ streamProviderOrder = providerOrder
)
}
}
@@ -166,7 +249,40 @@ class StremioItemDetailViewModel @Inject constructor(
throw cancellation
} catch (_: Exception) {
if (generation == streamGeneration) {
- _state.update { it.copy(streamsLoading = false) }
+ _state.update {
+ it.copy(streamsLoading = false, streamError = "This provider could not be retried.")
+ }
+ }
+ }
+ }
+ }
+
+ /** Recheck when returning from Plugins so installing/enabling the torrent plugin is reflected. */
+ fun refreshTorrentPlaybackAvailability() {
+ checkTorrentPlaybackAvailability(_state.value.streams, force = true)
+ }
+
+ private fun checkTorrentPlaybackAvailability(
+ streams: List<com.streamvault.domain.model.stremio.StremioAttributedResource<StremioStream>>,
+ force: Boolean = false
+ ) {
+ if (streams.none { it.resource.kind == StremioStreamKind.TORRENT }) return
+ val current = _state.value
+ if (!force && (current.torrentPluginCheckLoading || current.torrentPluginAvailable != null)) return
+ torrentAvailabilityJob?.cancel()
+ val generation = ++torrentAvailabilityGeneration
+ _state.update { it.copy(torrentPluginAvailable = null, torrentPluginCheckLoading = true) }
+ torrentAvailabilityJob = viewModelScope.launch {
+ val available = try {
+ torrentPlaybackAvailability.hasEnabledMagnetPlugin()
+ } catch (cancellation: CancellationException) {
+ throw cancellation
+ } catch (_: Exception) {
+ false
+ }
+ if (generation == torrentAvailabilityGeneration) {
+ _state.update {
+ it.copy(torrentPluginAvailable = available, torrentPluginCheckLoading = false)
}
}
}
@@ -179,12 +295,13 @@ class StremioItemDetailViewModel @Inject constructor(
return
}
metadataJob?.cancel()
- _state.update { it.copy(metadataLoading = true, metadataFailures = emptyList()) }
+ _state.update { it.copy(metadataLoading = true, metadataFailures = emptyList(), metadataError = null) }
metadataJob = viewModelScope.launch {
if (!contentAccess.canAccessContentNow()) {
_state.update { it.copy(metadataLoading = false) }
return@launch
}
+ try {
val origin = repository.getAddon(originAddonId)
val originKey = origin?.installFingerprint()
if (replayRequiresOrigin && (origin == null || !origin.enabled || originKey != replayOriginKey)) {
@@ -198,7 +315,6 @@ class StremioItemDetailViewModel @Inject constructor(
return@launch
}
_state.update { it.copy(catalogOriginKey = replayOriginKey ?: originKey) }
- try {
val result = repository.resolveMeta(originAddonId, type, exactId)
_state.update {
it.copy(
@@ -212,11 +328,23 @@ class StremioItemDetailViewModel @Inject constructor(
} catch (cancellation: CancellationException) {
throw cancellation
} catch (_: Exception) {
- _state.update { it.copy(metadataLoading = false) }
+ _state.update {
+ it.copy(metadataLoading = false, metadataError = "Title details could not be loaded. Try again.")
+ }
}
}
}
+ private fun <T> orderResourcesByProvider(
+ values: List<com.streamvault.domain.model.stremio.StremioAttributedResource<T>>,
+ providerOrder: List<Long>
+ ) = values.sortedBy { value -> providerOrder.indexOf(value.source.addonId).let { if (it < 0) Int.MAX_VALUE else it } }
+
+ private fun orderFailuresByProvider(
+ values: List<StremioAddonResourceFailure>,
+ providerOrder: List<Long>
+ ) = values.sortedBy { value -> providerOrder.indexOf(value.source.addonId).let { if (it < 0) Int.MAX_VALUE else it } }
+
companion object {
const val ARG_ORIGIN_ADDON_ID = "originAddonId"
const val ARG_TYPE = "type"
diff --git a/feature/stremio/src/main/res/values/strings.xml b/feature/stremio/src/main/res/values/strings.xml
index df0bc687..6c90a6d4 100644
--- a/feature/stremio/src/main/res/values/strings.xml
+++ b/feature/stremio/src/main/res/values/strings.xml
@@ -18,6 +18,23 @@
<string name="stremio_remove">Remove</string>
<string name="stremio_status_installed">Add-on installed</string>
<string name="stremio_status_removed">Add-on removed</string>
+ <string name="stremio_status_refreshed">Add-on details refreshed</string>
+ <string name="stremio_installed_count">Stremio add-ons · %1$d installed</string>
+ <string name="stremio_browse">Browse</string>
+ <string name="stremio_browse_title">Browse Stremio catalogs</string>
+ <string name="stremio_manage_addons">Manage add-ons</string>
+ <string name="stremio_details">Details</string>
+ <string name="stremio_hide_details">Hide details</string>
+ <string name="stremio_refresh_manifest">Refresh manifest</string>
+ <string name="stremio_version_and_server_format">Version %1$s · %2$s</string>
+ <string name="stremio_remove_confirm_title">Remove add-on?</string>
+ <string name="stremio_remove_confirm_body">%1$s will be removed. Its saved playback history remains available.</string>
+ <string name="stremio_catalogs_capability">Catalogs</string>
+ <string name="stremio_streams_capability">Streams</string>
+ <string name="stremio_subtitles_capability">Subtitles</string>
+ <string name="stremio_streams_only_hint">This add-on provides sources for matching titles from other catalogs.</string>
+ <string name="stremio_subtitles_only_hint">This add-on provides subtitles for compatible titles from other catalogs.</string>
+ <string name="stremio_streams_and_subtitles_only_hint">This add-on provides sources and subtitles for matching titles from other catalogs.</string>
<string name="stremio_addon_server_format">Server: %1$s</string>
<string name="stremio_addon_server_unknown">Custom endpoint</string>
<string name="stremio_no_catalogs">This add-on exposes no browsable catalogs.</string>
@@ -29,6 +46,15 @@
<string name="extensions_tab_plugins">Plugins</string>
<string name="extensions_tab_stremio_addons">Stremio-compatible Add-ons</string>
<string name="stremio_browse_empty">Enable a catalog or install a compatible add-on to browse Stremio titles.</string>
+ <string name="stremio_browse_no_installed_addons">No Stremio add-ons are installed yet.</string>
+ <string name="stremio_browse_no_enabled_addons">All Stremio add-ons are disabled. Enable one to browse its catalogs.</string>
+ <string name="stremio_browse_no_enabled_catalogs">There are no enabled catalogs. Enable a catalog in add-on details to browse.</string>
+ <string name="stremio_catalog_updating_previous_results">Updating this catalog. Showing the previous results until the new search finishes.</string>
+ <string name="stremio_catalog_previous_results_label">Showing results for the previous search.</string>
+ <string name="stremio_catalog_refreshing_previous_results">Refreshing this catalog. Showing the current results until refresh finishes.</string>
+ <string name="stremio_no_supported_catalogs">No supported catalogs are available. Check the add-on details or enable a catalog.</string>
+ <string name="stremio_choose_catalog">Choose catalog</string>
+ <string name="stremio_refresh">Refresh</string>
<string name="stremio_browse_manage_hint">Manage installed add-ons</string>
<string name="stremio_search_catalog">Search this catalog</string>
<string name="stremio_filter_genre">Genre</string>
@@ -48,6 +74,10 @@
<string name="stremio_item_find_streams">Find streams</string>
<string name="stremio_item_streams">Streams</string>
<string name="stremio_item_streams_for">Streams for %1$s</string>
+ <string name="stremio_item_season_number">Season %1$d</string>
+ <string name="stremio_item_change_episode">Change episode</string>
+ <string name="stremio_item_sources_loading">Checking sources…</string>
+ <string name="stremio_item_sources_remaining">Checking sources · %1$d providers remaining</string>
<string name="stremio_item_no_stream_addons">No enabled add-on supports streams for this item ID.</string>
<string name="stremio_item_no_streams">No streams were found.</string>
<string name="stremio_item_stream_failed">%1$s: %2$s</string>
@@ -55,6 +85,8 @@
<string name="stremio_item_torrent_unavailable">Magnet playback requires the StreamVault Torrent plugin.</string>
<string name="stremio_item_torrent_invalid">This torrent stream has no valid info hash or magnet link.</string>
<string name="stremio_item_torrent_plugin_hint">Magnet links are resolved by an installed StreamVault plugin that supports magnet playback.</string>
+ <string name="stremio_item_torrent_checking">Checking whether an enabled torrent playback plugin is available…</string>
+ <string name="stremio_item_manage_plugins">Manage plugins</string>
<string name="stremio_item_unsupported_stream">Unsupported stream format</string>
<string name="stremio_item_external_unavailable">This stream type is not supported yet</string>
<string name="stremio_item_headers_unavailable">This stream has invalid or unsupported add-on request headers.</string>
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
index 2813bb76..8ef4a8d1 100644
--- 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
@@ -159,7 +159,9 @@ class AddonsViewModelTest {
val entry = viewModel.state.value.addons.single()
viewModel.setEnabled(entry, enabled = false)
+ advanceUntilIdle()
viewModel.moveAddon(entry, offset = -1)
+ advanceUntilIdle()
viewModel.setCatalogEnabled(entry, "movie:top", enabled = false)
advanceUntilIdle()
diff --git a/feature/stremio/src/test/java/com/streamvault/feature/stremio/presentation/StremioCatalogBrowseViewModelTest.kt b/feature/stremio/src/test/java/com/streamvault/feature/stremio/presentation/StremioCatalogBrowseViewModelTest.kt
index 52099e79..55972b7e 100644
--- a/feature/stremio/src/test/java/com/streamvault/feature/stremio/presentation/StremioCatalogBrowseViewModelTest.kt
+++ b/feature/stremio/src/test/java/com/streamvault/feature/stremio/presentation/StremioCatalogBrowseViewModelTest.kt
@@ -142,6 +142,128 @@ class StremioCatalogBrowseViewModelTest {
.containsExactly("after-refresh")
}
+ @Test
+ fun `successful refresh invalidates cached catalog data when manifest is unchanged`() = runTest(dispatcher) {
+ val repository = CatalogRepositoryFake(catalogWithSkip())
+ repository.pages += StremioCatalogPage(listOf(preview("before-refresh")), rawItemCount = 1)
+ repository.pages += StremioCatalogPage(listOf(preview("after-refresh")), rawItemCount = 1)
+ val viewModel = StremioCatalogBrowseViewModel(repository, FakeStremioContentAccess())
+ advanceUntilIdle()
+
+ repository.addons.value = repository.addons.value.map { it.copy(updatedAt = 1L) }
+ advanceUntilIdle()
+
+ assertThat(repository.calls).hasSize(2)
+ assertThat(viewModel.state.value.rows.single().metas.map { it.id })
+ .containsExactly("after-refresh")
+ }
+
+ @Test
+ fun `only selected catalog loads until another catalog is selected`() = runTest(dispatcher) {
+ val firstCatalog = catalogWithSkip()
+ val secondCatalog = firstCatalog.copy(id = "recent", name = "Recently Added")
+ val repository = CatalogRepositoryFake(firstCatalog)
+ repository.manifests[1L] = manifest(firstCatalog).copy(catalogs = listOf(firstCatalog, secondCatalog))
+ repository.pages += StremioCatalogPage(listOf(preview("first")), rawItemCount = 1)
+ repository.pages += StremioCatalogPage(listOf(preview("second")), rawItemCount = 1)
+ val viewModel = StremioCatalogBrowseViewModel(repository, FakeStremioContentAccess())
+ advanceUntilIdle()
+
+ assertThat(repository.calls.map { it.addonId }).containsExactly(1L)
+ assertThat(viewModel.state.value.rows).hasSize(2)
+ val secondKey = viewModel.state.value.rows.single { it.catalog.id == "recent" }.key
+ viewModel.selectCatalog(secondKey)
+ advanceUntilIdle()
+
+ assertThat(repository.calls).hasSize(2)
+ assertThat(viewModel.state.value.rows.single { it.key == secondKey }.metas.map { it.id })
+ .containsExactly("second")
+ }
+
+ @Test
+ fun `failed pagination retries its offset without dropping prior results`() = runTest(dispatcher) {
+ val repository = CatalogRepositoryFake(catalogWithSkip())
+ val attemptsBySkip = mutableMapOf<Int?, Int>()
+ repository.fetchResponder = { call ->
+ val attempt = (attemptsBySkip[call.query.skip] ?: 0) + 1
+ attemptsBySkip[call.query.skip] = attempt
+ when (call.query.skip) {
+ 0 -> Result.success(StremioCatalogPage((0 until 100).map { preview("first-$it") }, rawItemCount = 100))
+ 100 -> if (attempt == 1) Result.error("temporary failure") else Result.success(
+ StremioCatalogPage(listOf(preview("second-page")), rawItemCount = 1)
+ )
+ else -> Result.error("unexpected offset")
+ }
+ }
+ val viewModel = StremioCatalogBrowseViewModel(repository, FakeStremioContentAccess())
+ advanceUntilIdle()
+ val key = viewModel.state.value.rows.single().key
+
+ viewModel.loadMore(key)
+ advanceUntilIdle()
+ val failed = viewModel.state.value.rows.single()
+ assertThat(failed.metas).hasSize(100)
+ assertThat(failed.failedPageSkip).isEqualTo(100)
+
+ viewModel.retry(key)
+ advanceUntilIdle()
+
+ assertThat(repository.calls.map { it.query.skip }).containsExactly(0, 100, 100).inOrder()
+ assertThat(viewModel.state.value.rows.single().metas).hasSize(101)
+ assertThat(viewModel.state.value.rows.single().metas.last().id).isEqualTo("second-page")
+ }
+
+ @Test
+ fun `explicit refresh bypasses the page cache`() = runTest(dispatcher) {
+ val repository = CatalogRepositoryFake(catalogWithSkip())
+ repository.pages += StremioCatalogPage(listOf(preview("cached")), rawItemCount = 1)
+ repository.pages += StremioCatalogPage(listOf(preview("fresh")), rawItemCount = 1)
+ val viewModel = StremioCatalogBrowseViewModel(repository, FakeStremioContentAccess())
+ advanceUntilIdle()
+ val key = viewModel.state.value.rows.single().key
+
+ viewModel.refresh(key)
+ advanceUntilIdle()
+
+ assertThat(repository.calls).hasSize(2)
+ assertThat(viewModel.state.value.rows.single().metas.map { it.id }).containsExactly("fresh")
+ }
+
+ @Test
+ fun `search replacement keeps current posters visible until new results arrive`() = runTest(dispatcher) {
+ val catalog = catalogWithSkip(
+ extras = listOf(StremioCatalogExtraDef("search"), StremioCatalogExtraDef("skip"))
+ )
+ val repository = CatalogRepositoryFake(catalog)
+ val replacement = CompletableDeferred<StremioCatalogPage>()
+ val replacementStarted = CompletableDeferred<Unit>()
+ repository.fetchResponder = { call ->
+ if (call.query.search == null) {
+ Result.success(StremioCatalogPage(listOf(preview("old-result")), rawItemCount = 1))
+ } else {
+ replacementStarted.complete(Unit)
+ Result.success(replacement.await())
+ }
+ }
+ val viewModel = StremioCatalogBrowseViewModel(repository, FakeStremioContentAccess())
+ advanceUntilIdle()
+ val key = viewModel.state.value.rows.single().key
+
+ viewModel.setSearch(key, "new query")
+ advanceTimeBy(350)
+ runCurrent()
+ replacementStarted.await()
+
+ val loading = viewModel.state.value.rows.single()
+ assertThat(loading.loading).isTrue()
+ assertThat(loading.metas.map { it.id }).containsExactly("old-result")
+ assertThat(loading.loadedSearch).isEqualTo("")
+
+ replacement.complete(StremioCatalogPage(listOf(preview("new-result")), rawItemCount = 1))
+ advanceUntilIdle()
+ assertThat(viewModel.state.value.rows.single().metas.map { it.id }).containsExactly("new-result")
+ }
+
@Test
fun `changing search cancels the stale catalog request`() = runTest(dispatcher) {
val catalog = catalogWithSkip(
diff --git a/feature/stremio/src/test/java/com/streamvault/feature/stremio/presentation/StremioItemDetailViewModelTest.kt b/feature/stremio/src/test/java/com/streamvault/feature/stremio/presentation/StremioItemDetailViewModelTest.kt
index 25c51a62..fa4d306d 100644
--- a/feature/stremio/src/test/java/com/streamvault/feature/stremio/presentation/StremioItemDetailViewModelTest.kt
+++ b/feature/stremio/src/test/java/com/streamvault/feature/stremio/presentation/StremioItemDetailViewModelTest.kt
@@ -19,6 +19,7 @@ import com.streamvault.domain.model.stremio.StremioSubtitle
import com.streamvault.domain.model.stremio.StremioVideo
import com.streamvault.domain.model.stremio.installFingerprint
import com.streamvault.domain.repository.StremioAddonRepository
+import com.streamvault.feature.stremio.api.StremioTorrentPlaybackAvailability
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -77,6 +78,37 @@ class StremioItemDetailViewModelTest {
assertThat(viewModel.state.value.streams.single().source.addonId).isEqualTo(21L)
}
+ @Test
+ fun `torrent sources check enabled plugin availability before playback`() = runTest(dispatcher) {
+ val repository = ItemRepositoryFake(addon(11L)).apply {
+ streamResponder = { _, _ ->
+ StremioResourceResolution(
+ results = listOf(
+ StremioAttributedResource(
+ source(21L),
+ StremioStream(title = "Torrent", infoHash = "a".repeat(40))
+ )
+ )
+ )
+ }
+ }
+ val viewModel = viewModel(
+ repository = repository,
+ type = "movie",
+ exactId = "tt123",
+ torrentPlaybackAvailability = FakeTorrentPlaybackAvailability(available = false)
+ )
+ advanceUntilIdle()
+
+ viewModel.loadStreams("tt123")
+ advanceUntilIdle()
+
+ assertThat(viewModel.state.value.streams.single().resource.kind)
+ .isEqualTo(com.streamvault.domain.model.stremio.StremioStreamKind.TORRENT)
+ assertThat(viewModel.state.value.torrentPluginAvailable).isFalse()
+ assertThat(viewModel.state.value.torrentPluginCheckLoading).isFalse()
+ }
+
@Test
fun `history replay resolves fresh streams for the saved exact episode id`() = runTest(dispatcher) {
val exactVideoId = "tt12345:1:2"
@@ -103,7 +135,8 @@ class StremioItemDetailViewModelTest {
)
),
repository = repository,
- contentAccess = FakeStremioContentAccess()
+ contentAccess = FakeStremioContentAccess(),
+ torrentPlaybackAvailability = FakeTorrentPlaybackAvailability()
)
advanceUntilIdle()
@@ -129,7 +162,8 @@ class StremioItemDetailViewModelTest {
)
),
repository = repository,
- contentAccess = FakeStremioContentAccess()
+ contentAccess = FakeStremioContentAccess(),
+ torrentPlaybackAvailability = FakeTorrentPlaybackAvailability()
)
advanceUntilIdle()
@@ -260,7 +294,8 @@ class StremioItemDetailViewModelTest {
type: String,
exactId: String,
name: String = "Preview",
- contentAccess: StremioContentAccess = FakeStremioContentAccess()
+ contentAccess: StremioContentAccess = FakeStremioContentAccess(),
+ torrentPlaybackAvailability: StremioTorrentPlaybackAvailability = FakeTorrentPlaybackAvailability()
) = StremioItemDetailViewModel(
savedStateHandle = SavedStateHandle(
mapOf(
@@ -272,9 +307,16 @@ class StremioItemDetailViewModelTest {
)
),
repository = repository,
- contentAccess = contentAccess
+ contentAccess = contentAccess,
+ torrentPlaybackAvailability = torrentPlaybackAvailability
)
+ private class FakeTorrentPlaybackAvailability(
+ private val available: Boolean = true
+ ) : StremioTorrentPlaybackAvailability {
+ override suspend fun hasEnabledMagnetPlugin(): Boolean = available
+ }
+
private fun addon(id: Long) = StremioAddon(
id = id,
installUrl = "https://example.test/$id/manifest.json",
diff --git a/feature/system/src/main/java/com/streamvault/feature/system/presentation/plugins/PluginsScreen.kt b/feature/system/src/main/java/com/streamvault/feature/system/presentation/plugins/PluginsScreen.kt
index 6502ac25..fe9d585c 100644
--- a/feature/system/src/main/java/com/streamvault/feature/system/presentation/plugins/PluginsScreen.kt
+++ b/feature/system/src/main/java/com/streamvault/feature/system/presentation/plugins/PluginsScreen.kt
@@ -10,6 +10,7 @@ import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
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.RowScope
@@ -34,6 +35,7 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
+import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -85,6 +87,7 @@ fun PluginsScreen(
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
val snackbarHostState = remember { SnackbarHostState() }
var showInstallUrlDialog by remember { mutableStateOf(false) }
+ var showInstallOptionsDialog by remember { mutableStateOf(false) }
val actions = PluginsActions(
onUpdateInstallUrl = viewModel::updateInstallUrl,
onInstallFromLocalUri = viewModel::installFromLocalUri,
@@ -118,9 +121,17 @@ fun PluginsScreen(
scaffold = scaffold,
onNavigateToStremioAddons = onNavigateToStremioAddons,
showInstallUrlDialog = showInstallUrlDialog,
+ showInstallOptionsDialog = showInstallOptionsDialog,
+ onShowInstallOptionsDialog = { showInstallOptionsDialog = true },
+ onDismissInstallOptionsDialog = { showInstallOptionsDialog = false },
+ onChooseInstallFromUrl = {
+ showInstallOptionsDialog = false
+ showInstallUrlDialog = true
+ },
onShowInstallUrlDialog = { showInstallUrlDialog = true },
onDismissInstallUrlDialog = { showInstallUrlDialog = false },
onInstallFromFile = {
+ showInstallOptionsDialog = false
apkPicker.launch(
arrayOf(
"application/vnd.android.package-archive",
@@ -156,6 +167,10 @@ internal fun PluginsContent(
scaffold: SystemScaffoldContent,
onNavigateToStremioAddons: () -> Unit = {},
showInstallUrlDialog: Boolean,
+ showInstallOptionsDialog: Boolean = false,
+ onShowInstallOptionsDialog: () -> Unit = {},
+ onDismissInstallOptionsDialog: () -> Unit = {},
+ onChooseInstallFromUrl: () -> Unit = {},
onShowInstallUrlDialog: () -> Unit,
onDismissInstallUrlDialog: () -> Unit,
onInstallFromFile: () -> Unit,
@@ -163,6 +178,7 @@ internal fun PluginsContent(
modifier: Modifier = Modifier,
snackbarHostState: SnackbarHostState? = null,
) {
+ var expandedPluginKey by rememberSaveable { mutableStateOf<String?>(null) }
scaffold(
AppDestination.Plugins,
stringResource(R.string.extensions_title),
@@ -174,14 +190,6 @@ internal fun PluginsContent(
modifier = modifier.fillMaxSize(),
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
- ExtensionsSectionTabs(
- selectedIndex = 0,
- pluginsLabel = stringResource(R.string.extensions_tab_plugins),
- stremioAddonsLabel = stringResource(R.string.extensions_tab_stremio_addons),
- onTabSelected = { selectedIndex ->
- if (selectedIndex == 1) onNavigateToStremioAddons()
- }
- )
val configuration = uiState.configuration
if (configuration != null) {
PluginConfigurationPanel(
@@ -193,17 +201,110 @@ internal fun PluginsContent(
onRunAction = actions.onRunConfigurationAction
)
} else {
- Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
- Text(stringResource(R.string.extensions_tab_plugins), style = MaterialTheme.typography.titleLarge, color = AppColors.TextPrimary)
- Text(stringResource(R.string.plugins_section_description), style = MaterialTheme.typography.bodyMedium, color = AppColors.TextSecondary)
- }
- PluginInstallPanel(
- isInstalling = uiState.isInstalling,
- onInstallFromUrl = onShowInstallUrlDialog,
- onInstallFromFile = onInstallFromFile,
- onRefresh = actions.onRefreshPlugins
+ ExtensionsSectionTabs(
+ selectedIndex = 0,
+ pluginsLabel = stringResource(R.string.extensions_tab_plugins),
+ stremioAddonsLabel = stringResource(R.string.extensions_tab_stremio_addons),
+ onTabSelected = { selectedIndex ->
+ if (selectedIndex == 1) onNavigateToStremioAddons()
+ }
)
+ when {
+ uiState.isLoading && uiState.plugins.isEmpty() -> Box(
+ modifier = Modifier.weight(1f).fillMaxWidth(),
+ contentAlignment = Alignment.Center
+ ) {
+ androidx.compose.material3.CircularProgressIndicator(color = AppColors.Brand)
+ }
+ uiState.plugins.isEmpty() -> {
+ Column(
+ modifier = Modifier.fillMaxWidth().weight(1f),
+ verticalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ ExtensionsEmptyState(
+ title = stringResource(R.string.plugins_empty_title),
+ description = stringResource(R.string.plugins_empty_description),
+ modifier = Modifier.weight(1f),
+ action = {
+ Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
+ PluginButton(
+ enabled = !uiState.isInstalling,
+ onClick = onShowInstallUrlDialog,
+ tone = PluginButtonTone.Primary
+ ) { Text(stringResource(R.string.plugins_install_url)) }
+ PluginButton(
+ enabled = !uiState.isInstalling,
+ onClick = onInstallFromFile
+ ) { Text(stringResource(R.string.plugins_install_file)) }
+ }
+ }
+ )
+ PluginButton(
+ onClick = actions.onRefreshPlugins,
+ modifier = Modifier.align(Alignment.CenterHorizontally)
+ ) { Text(stringResource(R.string.plugins_refresh)) }
+ }
+ }
+ else -> {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(10.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Text(
+ text = stringResource(R.string.plugins_installed_count, uiState.plugins.size),
+ modifier = Modifier.weight(1f),
+ style = MaterialTheme.typography.titleMedium,
+ color = AppColors.TextPrimary
+ )
+ PluginButton(onClick = onShowInstallOptionsDialog, tone = PluginButtonTone.Primary) {
+ Text(stringResource(R.string.plugins_add))
+ }
+ PluginButton(
+ onClick = actions.onRefreshPlugins,
+ enabled = !uiState.isLoading
+ ) { Text(stringResource(R.string.plugins_refresh)) }
+ }
+ uiState.providerSources.takeIf { it.isNotEmpty() }?.let { sources ->
+ Text(
+ text = stringResource(R.string.plugins_provider_sources_count, sources.size),
+ style = MaterialTheme.typography.bodySmall,
+ color = AppColors.TextTertiary
+ )
+ }
+ uiState.syncProgress?.let {
+ Text(text = it, style = MaterialTheme.typography.bodySmall, color = AppColors.Brand)
+ }
+ LazyColumn(
+ modifier = Modifier.weight(1f).fillMaxWidth(),
+ verticalArrangement = Arrangement.spacedBy(10.dp)
+ ) {
+ items(uiState.plugins, key = { it.owner.toBundleSafeKey() }) { plugin ->
+ PluginCard(
+ plugin = plugin,
+ busy = uiState.activePluginOwner == plugin.owner,
+ expanded = expandedPluginKey == plugin.owner.toBundleSafeKey(),
+ onToggleDetails = {
+ val key = plugin.owner.toBundleSafeKey()
+ expandedPluginKey = if (expandedPluginKey == key) null else key
+ },
+ onEnabledChange = { enabled -> actions.onSetPluginEnabled(plugin, enabled) },
+ onOpenConfiguration = { actions.onOpenPluginConfiguration(plugin) }
+ )
+ }
+ item { Spacer(modifier = Modifier.height(20.dp)) }
+ }
+ }
+ }
+
+ if (showInstallOptionsDialog) {
+ PluginInstallOptionsDialog(
+ onInstallFromUrl = onChooseInstallFromUrl,
+ onInstallFromFile = onInstallFromFile,
+ onDismiss = onDismissInstallOptionsDialog
+ )
+ }
if (showInstallUrlDialog) {
PluginInstallUrlDialog(
installUrl = uiState.installUrl,
@@ -213,43 +314,6 @@ internal fun PluginsContent(
onInstall = actions.onInstallFromUrl
)
}
-
- uiState.syncProgress?.let {
- Text(
- text = it,
- style = MaterialTheme.typography.bodySmall,
- color = AppColors.Brand
- )
- }
-
- if (uiState.providerSources.isNotEmpty()) {
- Text(
- text = "${uiState.providerSources.size} plugin provider source(s) available",
- style = MaterialTheme.typography.bodySmall,
- color = AppColors.TextSecondary
- )
- }
-
- if (uiState.plugins.isEmpty() && !uiState.isLoading) {
- ExtensionsEmptyState(
- title = stringResource(R.string.plugins_empty_title),
- description = stringResource(R.string.plugins_empty_description),
- modifier = Modifier.weight(1f)
- )
- } else LazyColumn(
- modifier = Modifier.weight(1f).fillMaxWidth(),
- verticalArrangement = Arrangement.spacedBy(10.dp)
- ) {
- items(uiState.plugins, key = { it.owner.toBundleSafeKey() }) { plugin ->
- PluginCard(
- plugin = plugin,
- busy = uiState.activePluginOwner == plugin.owner,
- onEnabledChange = { enabled -> actions.onSetPluginEnabled(plugin, enabled) },
- onOpenConfiguration = { actions.onOpenPluginConfiguration(plugin) }
- )
- }
- item { Spacer(modifier = Modifier.height(20.dp)) }
- }
}
}
snackbarHostState?.let { hostState ->
@@ -258,6 +322,40 @@ internal fun PluginsContent(
}
}
+@Composable
+private fun PluginInstallOptionsDialog(
+ onInstallFromUrl: () -> Unit,
+ onInstallFromFile: () -> Unit,
+ onDismiss: () -> Unit
+) {
+ PremiumDialog(
+ title = stringResource(R.string.plugins_add),
+ subtitle = stringResource(R.string.plugins_install_hint),
+ onDismissRequest = onDismiss,
+ heightFraction = null,
+ content = {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(10.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ PluginButton(onClick = onInstallFromUrl, tone = PluginButtonTone.Primary) {
+ Text(stringResource(R.string.plugins_install_url))
+ }
+ PluginButton(onClick = onInstallFromFile) {
+ Text(stringResource(R.string.plugins_install_file))
+ }
+ }
+ },
+ footer = {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ }
+ )
+}
+
private enum class PluginButtonTone {
Primary,
Secondary
@@ -312,50 +410,6 @@ private fun PluginButton(
)
}
-@Composable
-private fun PluginInstallPanel(
- isInstalling: Boolean,
- onInstallFromUrl: () -> Unit,
- onInstallFromFile: () -> Unit,
- onRefresh: () -> Unit
-) {
- Column(
- modifier = Modifier
- .fillMaxWidth()
- .browsePanel()
- .padding(12.dp),
- verticalArrangement = Arrangement.spacedBy(10.dp)
- ) {
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.spacedBy(10.dp),
- verticalAlignment = Alignment.CenterVertically
- ) {
- PluginButton(
- enabled = !isInstalling,
- onClick = onInstallFromUrl,
- tone = PluginButtonTone.Primary
- ) {
- Text(stringResource(R.string.plugins_install_url))
- }
- PluginButton(
- enabled = !isInstalling,
- onClick = onInstallFromFile
- ) {
- Text(stringResource(R.string.plugins_install_file))
- }
- PluginButton(onClick = onRefresh) {
- Text(stringResource(R.string.plugins_refresh))
- }
- }
- Text(
- text = stringResource(R.string.plugins_install_hint),
- style = MaterialTheme.typography.bodySmall,
- color = AppColors.TextTertiary
- )
- }
-}
-
@Composable
private fun PluginInstallUrlDialog(
installUrl: String,
@@ -441,6 +495,8 @@ private fun PluginInstallUrlDialog(
private fun PluginCard(
plugin: InstalledStreamVaultPlugin,
busy: Boolean,
+ expanded: Boolean,
+ onToggleDetails: () -> Unit,
onEnabledChange: (Boolean) -> Unit,
onOpenConfiguration: () -> Unit
) {
@@ -465,45 +521,26 @@ private fun PluginCard(
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
- StatusPill(
- label = if (plugin.enabled) "Enabled" else "Disabled",
- containerColor = if (plugin.enabled) AppColors.BrandMuted else AppColors.SurfaceEmphasis,
- contentColor = if (plugin.enabled) AppColors.Brand else AppColors.TextSecondary
- )
}
Text(
text = plugin.manifest.description.ifBlank { plugin.packageName },
style = MaterialTheme.typography.bodySmall,
color = AppColors.TextSecondary,
- maxLines = 2,
- overflow = TextOverflow.Ellipsis
- )
- val version = plugin.manifest.versionName.ifBlank { "unknown" }
- Text(
- text = "${plugin.packageName} · v$version",
- style = MaterialTheme.typography.bodySmall,
- color = AppColors.TextTertiary,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
- if (plugin.statusLabel.isNotBlank() || plugin.lastMessage.isNotBlank()) {
- Text(
- text = listOf(plugin.statusLabel, plugin.lastMessage)
- .filter { it.isNotBlank() }
- .joinToString(" · "),
- style = MaterialTheme.typography.bodySmall,
- color = AppColors.TextTertiary,
- maxLines = 2,
- overflow = TextOverflow.Ellipsis
- )
- }
}
Row(horizontalArrangement = Arrangement.spacedBy(10.dp), verticalAlignment = Alignment.CenterVertically) {
- PluginButton(
- enabled = !busy && plugin.manifest.canConfigure,
- onClick = onOpenConfiguration
- ) {
- Text("Configure")
+ PluginButton(onClick = onToggleDetails) {
+ Text(stringResource(if (expanded) R.string.plugins_hide_details else R.string.plugins_details))
+ }
+ if (plugin.manifest.canConfigure) {
+ PluginButton(
+ enabled = !busy,
+ onClick = onOpenConfiguration
+ ) {
+ Text("Configure")
+ }
}
Switch(
checked = plugin.enabled,
@@ -521,6 +558,19 @@ private fun PluginCard(
)
}
}
+ if (expanded) {
+ val version = plugin.manifest.versionName.ifBlank { "unknown" }
+ val details = listOf("${plugin.packageName} · v$version", plugin.statusLabel, plugin.lastMessage)
+ .filter { it.isNotBlank() }
+ .joinToString(" · ")
+ Text(
+ text = details,
+ style = MaterialTheme.typography.bodySmall,
+ color = AppColors.TextTertiary,
+ maxLines = 2,
+ overflow = TextOverflow.Ellipsis
+ )
+ }
}
}
@@ -602,12 +652,23 @@ private fun PluginConfigurationHeader(
verticalArrangement = Arrangement.spacedBy(4.dp)
) {
Text(
- text = configuration.schema.title.ifBlank { configuration.plugin.displayName },
+ text = configuration.plugin.displayName,
style = MaterialTheme.typography.titleMedium,
color = AppColors.TextPrimary,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
+ configuration.schema.title
+ .takeIf { it.isNotBlank() && it != configuration.plugin.displayName }
+ ?.let { title ->
+ Text(
+ text = title,
+ style = MaterialTheme.typography.bodySmall,
+ color = AppColors.TextSecondary,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ }
val description = configuration.schema.description
.ifBlank { configuration.plugin.manifest.description }
if (description.isNotBlank()) {
@@ -624,13 +685,13 @@ private fun PluginConfigurationHeader(
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically
) {
- PluginButton(enabled = !busy, onClick = onBack) { Text("Back") }
- PluginButton(enabled = !busy, onClick = onRefresh) { Text("Refresh") }
+ PluginButton(enabled = !busy, onClick = onBack) { Text(stringResource(R.string.plugins_back_to_plugins)) }
+ PluginButton(enabled = !busy, onClick = onRefresh) { Text(stringResource(R.string.plugins_refresh_configuration)) }
PluginButton(
enabled = !busy && configuration.isDirty,
onClick = onSave,
tone = PluginButtonTone.Primary
- ) { Text("Save") }
+ ) { Text(stringResource(R.string.plugins_save_configuration)) }
}
}
if (configuration.validationErrors.isNotEmpty()) {
diff --git a/feature/system/src/main/res/values/strings.xml b/feature/system/src/main/res/values/strings.xml
index 2c027385..d98e1dfa 100644
--- a/feature/system/src/main/res/values/strings.xml
+++ b/feature/system/src/main/res/values/strings.xml
@@ -7,7 +7,15 @@
<string name="plugins_refresh">Check installed plugins</string>
<string name="plugins_install_hint">Use an APK file or a direct APK download link. For Stremio-compatible add-on manifest URLs, use the Stremio-compatible Add-ons tab.</string>
<string name="plugins_empty_title">No plugins installed</string>
- <string name="plugins_empty_description">Install a compatible StreamVault plugin using the buttons above. Already installed one outside the app? Choose Check installed plugins.</string>
+ <string name="plugins_empty_description">Install a compatible StreamVault companion app, or check again for a plugin you installed outside StreamVault.</string>
+ <string name="plugins_add">Add plugin</string>
+ <string name="plugins_installed_count">Plugins · %1$d installed</string>
+ <string name="plugins_provider_sources_count">%1$d provider sources available</string>
+ <string name="plugins_details">Details</string>
+ <string name="plugins_hide_details">Hide details</string>
+ <string name="plugins_back_to_plugins">Back to Plugins</string>
+ <string name="plugins_refresh_configuration">Refresh</string>
+ <string name="plugins_save_configuration">Save</string>
<string name="app_name">StreamVault</string>
<string name="welcome_setup_provider">Setup Provider</string>
<string name="welcome_setup_later">Set up later</string>