Skip to content

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

Merge stalker-fix and inner bug fixes

David Nashash093592265b77
diff --cc app/src/main/java/com/streamvault/app/StreamVaultApp.kt
index da20a4d3,96096a72..f9355b85
--- a/app/src/main/java/com/streamvault/app/StreamVaultApp.kt
+++ b/app/src/main/java/com/streamvault/app/StreamVaultApp.kt
@@@ -42,19 -33,22 +41,25 @@@ class StreamVaultApp : Application(), S
private val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
@Inject
- lateinit var preferencesRepository: PreferencesRepository
+ lateinit var okHttpClient: OkHttpClient
@Inject
- lateinit var gitHubReleaseChecker: GitHubReleaseChecker
+ lateinit var jellyfinImageAuthInterceptor: JellyfinImageAuthInterceptor
+ @Inject
- lateinit var okHttpClient: OkHttpClient
++ lateinit var syncManager: SyncManager
+
@Inject
- lateinit var jellyfinImageAuthInterceptor: JellyfinImageAuthInterceptor
+ lateinit var downloadManager: DownloadManager
@Inject
- lateinit var syncManager: SyncManager
+ lateinit var streamVaultPluginManager: StreamVaultPluginManager
+
+ @Inject
+ lateinit var programReminderManager: ProgramReminderManager
+
+ @Inject
+ lateinit var startupWorkRegistry: StartupWorkRegistry
private val imageOkHttpClient: OkHttpClient by lazy {
okHttpClient.newBuilder()
@@@ -72,36 -66,16 +77,19 @@@
TimeshiftDiskManager(applicationContext).cleanupStaleDirectories(activeSessionDir = null)
}
applicationScope.launch {
- refreshCachedAppUpdateIfNeeded()
+ downloadManager.recoverInterruptedDownloads()
+ }
+ applicationScope.launch {
+ streamVaultPluginManager.reconcilePluginProviders()
+ }
+ applicationScope.launch {
+ programReminderManager.restoreScheduledReminders()
}
+ applicationScope.launch {
+ syncManager.reconcileStalkerIndexWorkAtStartup()
+ }
- // Schedule daily data maintenance: EPG pruning, stale-favorite cleanup, and DB compaction checks.
- // BLD-H02: Require network + device idle so the worker doesn't drain battery.
- val gcConstraints = Constraints.Builder()
- .setRequiredNetworkType(NetworkType.CONNECTED)
- .setRequiresBatteryNotLow(true)
- .setRequiresDeviceIdle(true)
- .build()
-
- val gcWorkRequest = PeriodicWorkRequestBuilder<com.streamvault.data.sync.SyncWorker>(24, java.util.concurrent.TimeUnit.HOURS)
- .setConstraints(gcConstraints)
- .build()
-
- WorkManager.getInstance(this).enqueueUniquePeriodicWork(
- "DataMaintenanceWorker",
- ExistingPeriodicWorkPolicy.KEEP,
- gcWorkRequest
- )
-
- ProviderSyncWorker.enqueuePeriodic(this)
- ProviderSyncWorker.enqueueLaunchStaleCheck(this)
- XtreamIndexWorker.enqueuePeriodic(this)
- XtreamIndexWorker.enqueueLaunchStaleCheck(this)
- RecordingReconcileWorker.enqueuePeriodic(this)
- RecordingReconcileWorker.enqueueOneShot(this)
+ startupWorkRegistry.register()
}
override fun onTerminate() {
diff --cc app/src/main/java/com/streamvault/app/di/DatabaseModule.kt
index 6b2f0c58,d7930b06..f75b897b
--- a/app/src/main/java/com/streamvault/app/di/DatabaseModule.kt
+++ b/app/src/main/java/com/streamvault/app/di/DatabaseModule.kt
@@@ -150,9 -154,10 +156,14 @@@ object DatabaseModule
@Provides fun provideXtreamContentIndexDao(db: StreamVaultDatabase): XtreamContentIndexDao = db.xtreamContentIndexDao()
@Provides fun provideXtreamIndexJobDao(db: StreamVaultDatabase): XtreamIndexJobDao = db.xtreamIndexJobDao()
@Provides fun provideXtreamLiveOnboardingDao(db: StreamVaultDatabase): XtreamLiveOnboardingDao = db.xtreamLiveOnboardingDao()
+ @Provides fun provideStalkerIndexJobDao(db: StreamVaultDatabase): StalkerIndexJobDao = db.stalkerIndexJobDao()
+ @Provides fun provideStalkerPortalStateDao(db: StreamVaultDatabase): StalkerPortalStateDao = db.stalkerPortalStateDao()
+ @Provides fun provideStalkerRemoteIdentityDao(db: StreamVaultDatabase): StalkerRemoteIdentityDao = db.stalkerRemoteIdentityDao()
+ @Provides fun provideStalkerDiscoveryStageDao(db: StreamVaultDatabase): StalkerDiscoveryStageDao = db.stalkerDiscoveryStageDao()
@Provides fun provideDownloadDao(db: StreamVaultDatabase): DownloadDao = db.downloadDao()
+ @Provides fun provideProviderDeletionCleanupDao(db: StreamVaultDatabase): ProviderDeletionCleanupDao = db.providerDeletionCleanupDao()
+ @Provides fun provideProviderConfigRevisionDao(db: StreamVaultDatabase): ProviderConfigRevisionDao = db.providerConfigRevisionDao()
+ @Provides fun provideBackupRestoreCheckpointDao(db: StreamVaultDatabase): BackupRestoreCheckpointDao = db.backupRestoreCheckpointDao()
+ @Provides fun provideProviderWorkflowDao(db: StreamVaultDatabase): ProviderWorkflowDao = db.providerWorkflowDao()
+ @Provides fun providePluginProviderOwnershipDao(db: StreamVaultDatabase): PluginProviderOwnershipDao = db.pluginProviderOwnershipDao()
}
diff --cc data/build.gradle.kts
index 010be2bd,a0b6ef13..6c10fe29
--- a/data/build.gradle.kts
+++ b/data/build.gradle.kts
@@@ -92,8 -92,8 +92,10 @@@ dependencies
testImplementation(libs.junit)
testImplementation(libs.truth)
testImplementation(libs.coroutines.test)
+ testImplementation(libs.okhttp.mockwebserver)
+ testImplementation(libs.okhttp.tls)
+ testImplementation(libs.room.testing)
+ testImplementation(libs.robolectric)
// kxml2: JVM XmlPullParser implementation needed for XmltvParser unit tests
// (Android platform provides its own impl; the JVM test runner needs an explicit one)
testImplementation(libs.kxml2)
diff --cc data/schemas/com.streamvault.data.local.StreamVaultDatabase/72.json
index 00000000,5d3878c9..4a1dba24
mode 000000,100644..100644
--- a/data/schemas/com.streamvault.data.local.StreamVaultDatabase/72.json
+++ b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/72.json
@@@ -1,0 -1,5977 +1,6753 @@@
+ {
+ "formatVersion": 1,
+ "database": {
+ "version": 72,
- "identityHash": "587ce50641fa03e4737b79b8c3d51d3c",
++ "identityHash": "b4312ae5bde8b8c44d399bad4b923a94",
+ "entities": [
+ {
+ "tableName": "providers",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `type` TEXT NOT NULL, `server_url` TEXT NOT NULL, `username` TEXT NOT NULL, `password` TEXT NOT NULL, `m3u_url` TEXT NOT NULL, `epg_url` TEXT NOT NULL, `http_user_agent` TEXT NOT NULL, `http_headers` TEXT NOT NULL, `stalker_mac_address` TEXT NOT NULL, `stalker_device_profile` TEXT NOT NULL, `stalker_device_timezone` TEXT NOT NULL, `stalker_device_locale` TEXT NOT NULL, `stalker_serial_number` TEXT NOT NULL, `stalker_device_id` TEXT NOT NULL, `stalker_device_id2` TEXT NOT NULL, `stalker_signature` TEXT NOT NULL, `stalker_advanced_options_json` TEXT NOT NULL, `stalker_auth_mode` TEXT NOT NULL, `stalker_portal_profile` TEXT NOT NULL, `stalker_portal_fingerprint` TEXT NOT NULL, `stalker_mag_preset` TEXT NOT NULL, `stalker_last_bootstrap_recipe` TEXT NOT NULL, `stalker_endpoint_preference` TEXT NOT NULL, `stalker_cookie_mode` TEXT NOT NULL, `stalker_playback_backend_hint` TEXT NOT NULL, `stalker_last_playback_mode` TEXT, `stalker_credentials_required` INTEGER NOT NULL, `stalker_mac_required` INTEGER NOT NULL, `stalker_uses_temp_links` INTEGER NOT NULL, `stalker_module_restricted` INTEGER NOT NULL, `stalker_strict_fingerprint_required` INTEGER NOT NULL, `stalker_recipe_fallback_used` INTEGER NOT NULL, `stalker_recipe_rediscovery_attempts` INTEGER NOT NULL, `is_active` INTEGER NOT NULL, `max_connections` INTEGER NOT NULL, `expiration_date` INTEGER, `api_version` TEXT, `allowed_output_formats_json` TEXT NOT NULL, `epg_sync_mode` TEXT NOT NULL, `guide_source_policy` TEXT NOT NULL, `channel_logo_source_policy` TEXT NOT NULL, `xtream_fast_sync_enabled` INTEGER NOT NULL, `xtream_live_sync_mode` TEXT NOT NULL, `m3u_vod_classification_enabled` INTEGER NOT NULL, `status` TEXT NOT NULL, `last_synced_at` INTEGER NOT NULL, `created_at` INTEGER NOT NULL)",
++ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `type` TEXT NOT NULL, `server_url` TEXT NOT NULL, `username` TEXT NOT NULL, `password` TEXT NOT NULL, `m3u_url` TEXT NOT NULL, `epg_url` TEXT NOT NULL, `http_user_agent` TEXT NOT NULL, `http_headers` TEXT NOT NULL, `stalker_mac_address` TEXT NOT NULL, `stalker_device_profile` TEXT NOT NULL, `stalker_device_timezone` TEXT NOT NULL, `stalker_device_locale` TEXT NOT NULL, `stalker_serial_number` TEXT NOT NULL, `stalker_device_id` TEXT NOT NULL, `stalker_device_id2` TEXT NOT NULL, `stalker_signature` TEXT NOT NULL, `stalker_advanced_options_json` TEXT NOT NULL, `stalker_auth_mode` TEXT NOT NULL, `stalker_portal_profile` TEXT NOT NULL, `stalker_portal_fingerprint` TEXT NOT NULL, `stalker_mag_preset` TEXT NOT NULL, `stalker_protocol_preference` TEXT NOT NULL, `stalker_transport_mode` TEXT NOT NULL, `stalker_transport_origin` TEXT NOT NULL, `stalker_tls_spki_sha256` TEXT NOT NULL, `stalker_transport_consent_at` INTEGER NOT NULL, `stalker_configuration_generation` INTEGER NOT NULL, `stalker_discovery_summary` TEXT NOT NULL, `stalker_capabilities_json` TEXT NOT NULL, `stalker_requested_profile_id` TEXT NOT NULL, `stalker_learned_profile_id` TEXT NOT NULL, `stalker_profile_revision` INTEGER NOT NULL, `stalker_profile_verification` TEXT NOT NULL, `stalker_protocol_family` TEXT NOT NULL, `stalker_last_bootstrap_recipe` TEXT NOT NULL, `stalker_endpoint_preference` TEXT NOT NULL, `stalker_cookie_mode` TEXT NOT NULL, `stalker_playback_backend_hint` TEXT NOT NULL, `stalker_last_playback_mode` TEXT, `stalker_credentials_required` INTEGER NOT NULL, `stalker_mac_required` INTEGER NOT NULL, `stalker_uses_temp_links` INTEGER NOT NULL, `stalker_module_restricted` INTEGER NOT NULL, `stalker_strict_fingerprint_required` INTEGER NOT NULL, `stalker_recipe_fallback_used` INTEGER NOT NULL, `stalker_recipe_rediscovery_attempts` INTEGER NOT NULL, `is_active` INTEGER NOT NULL, `max_connections` INTEGER NOT NULL, `expiration_date` INTEGER, `api_version` TEXT, `allowed_output_formats_json` TEXT NOT NULL, `epg_sync_mode` TEXT NOT NULL, `stalker_catalog_mode` TEXT NOT NULL, `guide_source_policy` TEXT NOT NULL, `channel_logo_source_policy` TEXT NOT NULL, `xtream_fast_sync_enabled` INTEGER NOT NULL, `xtream_live_sync_mode` TEXT NOT NULL, `m3u_vod_classification_enabled` INTEGER NOT NULL, `catalog_layout` TEXT NOT NULL, `catalog_layout_detection_version` INTEGER NOT NULL, `status` TEXT NOT NULL, `last_synced_at` INTEGER NOT NULL, `created_at` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "serverUrl",
+ "columnName": "server_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "username",
+ "columnName": "username",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "password",
+ "columnName": "password",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "m3uUrl",
+ "columnName": "m3u_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgUrl",
+ "columnName": "epg_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "httpUserAgent",
+ "columnName": "http_user_agent",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "httpHeaders",
+ "columnName": "http_headers",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerMacAddress",
+ "columnName": "stalker_mac_address",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceProfile",
+ "columnName": "stalker_device_profile",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceTimezone",
+ "columnName": "stalker_device_timezone",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceLocale",
+ "columnName": "stalker_device_locale",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerSerialNumber",
+ "columnName": "stalker_serial_number",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceId",
+ "columnName": "stalker_device_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceId2",
+ "columnName": "stalker_device_id2",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerSignature",
+ "columnName": "stalker_signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerAdvancedOptionsJson",
+ "columnName": "stalker_advanced_options_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerAuthMode",
+ "columnName": "stalker_auth_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerPortalProfile",
+ "columnName": "stalker_portal_profile",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerPortalFingerprint",
+ "columnName": "stalker_portal_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerMagPreset",
+ "columnName": "stalker_mag_preset",
+ "affinity": "TEXT",
+ "notNull": true
+ },
++ {
++ "fieldPath": "stalkerProtocolPreference",
++ "columnName": "stalker_protocol_preference",
++ "affinity": "TEXT",
++ "notNull": true
++ },
++ {
++ "fieldPath": "stalkerTransportMode",
++ "columnName": "stalker_transport_mode",
++ "affinity": "TEXT",
++ "notNull": true
++ },
++ {
++ "fieldPath": "stalkerTransportOrigin",
++ "columnName": "stalker_transport_origin",
++ "affinity": "TEXT",
++ "notNull": true
++ },
++ {
++ "fieldPath": "stalkerTlsSpkiSha256",
++ "columnName": "stalker_tls_spki_sha256",
++ "affinity": "TEXT",
++ "notNull": true
++ },
++ {
++ "fieldPath": "stalkerTransportConsentAt",
++ "columnName": "stalker_transport_consent_at",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "stalkerConfigurationGeneration",
++ "columnName": "stalker_configuration_generation",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "stalkerDiscoverySummary",
++ "columnName": "stalker_discovery_summary",
++ "affinity": "TEXT",
++ "notNull": true
++ },
++ {
++ "fieldPath": "stalkerCapabilitiesJson",
++ "columnName": "stalker_capabilities_json",
++ "affinity": "TEXT",
++ "notNull": true
++ },
++ {
++ "fieldPath": "stalkerRequestedProfileId",
++ "columnName": "stalker_requested_profile_id",
++ "affinity": "TEXT",
++ "notNull": true
++ },
++ {
++ "fieldPath": "stalkerLearnedProfileId",
++ "columnName": "stalker_learned_profile_id",
++ "affinity": "TEXT",
++ "notNull": true
++ },
++ {
++ "fieldPath": "stalkerProfileRevision",
++ "columnName": "stalker_profile_revision",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "stalkerProfileVerification",
++ "columnName": "stalker_profile_verification",
++ "affinity": "TEXT",
++ "notNull": true
++ },
++ {
++ "fieldPath": "stalkerProtocolFamily",
++ "columnName": "stalker_protocol_family",
++ "affinity": "TEXT",
++ "notNull": true
++ },
+ {
+ "fieldPath": "stalkerLastBootstrapRecipe",
+ "columnName": "stalker_last_bootstrap_recipe",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerEndpointPreference",
+ "columnName": "stalker_endpoint_preference",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerCookieMode",
+ "columnName": "stalker_cookie_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerPlaybackBackendHint",
+ "columnName": "stalker_playback_backend_hint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerLastPlaybackMode",
+ "columnName": "stalker_last_playback_mode",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "stalkerCredentialsRequired",
+ "columnName": "stalker_credentials_required",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerMacRequired",
+ "columnName": "stalker_mac_required",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerUsesTemporaryLinks",
+ "columnName": "stalker_uses_temp_links",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerModuleRestricted",
+ "columnName": "stalker_module_restricted",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerStrictFingerprintRequired",
+ "columnName": "stalker_strict_fingerprint_required",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerRecipeFallbackUsed",
+ "columnName": "stalker_recipe_fallback_used",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerRecipeRediscoveryAttempts",
+ "columnName": "stalker_recipe_rediscovery_attempts",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isActive",
+ "columnName": "is_active",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "maxConnections",
+ "columnName": "max_connections",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "expirationDate",
+ "columnName": "expiration_date",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "apiVersion",
+ "columnName": "api_version",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "allowedOutputFormatsJson",
+ "columnName": "allowed_output_formats_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSyncMode",
+ "columnName": "epg_sync_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
++ {
++ "fieldPath": "stalkerCatalogMode",
++ "columnName": "stalker_catalog_mode",
++ "affinity": "TEXT",
++ "notNull": true
++ },
+ {
+ "fieldPath": "guideSourcePolicy",
+ "columnName": "guide_source_policy",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelLogoSourcePolicy",
+ "columnName": "channel_logo_source_policy",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xtreamFastSyncEnabled",
+ "columnName": "xtream_fast_sync_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xtreamLiveSyncMode",
+ "columnName": "xtream_live_sync_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "m3uVodClassificationEnabled",
+ "columnName": "m3u_vod_classification_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
++ {
++ "fieldPath": "catalogLayout",
++ "columnName": "catalog_layout",
++ "affinity": "TEXT",
++ "notNull": true
++ },
++ {
++ "fieldPath": "catalogLayoutDetectionVersion",
++ "columnName": "catalog_layout_detection_version",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSyncedAt",
+ "columnName": "last_synced_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_providers_server_url_username_stalker_mac_address",
+ "unique": true,
+ "columnNames": [
+ "server_url",
+ "username",
+ "stalker_mac_address"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_providers_server_url_username_stalker_mac_address` ON `${TABLE_NAME}` (`server_url`, `username`, `stalker_mac_address`)"
+ }
+ ]
+ },
+ {
+ "tableName": "channels",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `logo_url` TEXT, `group_title` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `epg_channel_id` TEXT, `number` INTEGER NOT NULL, `catch_up_supported` INTEGER NOT NULL, `catch_up_days` INTEGER NOT NULL, `catchUpSource` TEXT, `provider_id` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `logical_group_id` TEXT NOT NULL, `error_count` INTEGER NOT NULL, `quality_options_json` TEXT, `sync_fingerprint` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logoUrl",
+ "columnName": "logo_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupTitle",
+ "columnName": "group_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgChannelId",
+ "columnName": "epg_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "number",
+ "columnName": "number",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSupported",
+ "columnName": "catch_up_supported",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpDays",
+ "columnName": "catch_up_days",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSource",
+ "columnName": "catchUpSource",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logicalGroupId",
+ "columnName": "logical_group_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "errorCount",
+ "columnName": "error_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "qualityOptionsJson",
+ "columnName": "quality_options_json",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channels_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_category_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id_category_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_stream_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "stream_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channels_provider_id_stream_id` ON `${TABLE_NAME}` (`provider_id`, `stream_id`)"
+ },
+ {
+ "name": "index_channels_logical_group_id",
+ "unique": false,
+ "columnNames": [
+ "logical_group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_logical_group_id` ON `${TABLE_NAME}` (`logical_group_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_category_id_logical_group_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id",
+ "logical_group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id_category_id_logical_group_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`, `logical_group_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channel_preferences",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `channel_id` INTEGER NOT NULL, `aspect_ratio` TEXT, `audio_video_offset_ms` INTEGER, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`channel_id`) REFERENCES `channels`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "aspectRatio",
+ "columnName": "aspect_ratio",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "audioVideoOffsetMs",
+ "columnName": "audio_video_offset_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_preferences_channel_id",
+ "unique": true,
+ "columnNames": [
+ "channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channel_preferences_channel_id` ON `${TABLE_NAME}` (`channel_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "channels",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "channel_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channels_fts",
+ "createSql": "CREATE VIRTUAL TABLE IF NOT EXISTS `${TABLE_NAME}` USING FTS4(`name` TEXT NOT NULL, content=`channels`)",
+ "fields": [
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": []
+ },
+ "ftsVersion": "FTS4",
+ "ftsOptions": {
+ "tokenizer": "simple",
+ "tokenizerArgs": [],
+ "contentTable": "channels",
+ "languageIdColumnName": "",
+ "matchInfo": "FTS4",
+ "notIndexedColumns": [],
+ "prefixSizes": [],
+ "preferredOrder": "ASC"
+ },
+ "contentSyncTriggers": [
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_BEFORE_UPDATE BEFORE UPDATE ON `channels` BEGIN DELETE FROM `channels_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_BEFORE_DELETE BEFORE DELETE ON `channels` BEGIN DELETE FROM `channels_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_AFTER_UPDATE AFTER UPDATE ON `channels` BEGIN INSERT INTO `channels_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_AFTER_INSERT AFTER INSERT ON `channels` BEGIN INSERT INTO `channels_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END"
+ ]
+ },
+ {
+ "tableName": "movies",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `container_extension` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `duration` TEXT, `duration_seconds` INTEGER NOT NULL, `rating` REAL NOT NULL, `year` TEXT, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `provider_id` INTEGER NOT NULL, `watch_progress` INTEGER NOT NULL, `watch_count` INTEGER NOT NULL, `last_watched_at` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, `added_at` INTEGER NOT NULL, `cache_state` TEXT NOT NULL, `detail_hydrated_at` INTEGER NOT NULL, `remote_stale_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "duration",
+ "columnName": "duration",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "durationSeconds",
+ "columnName": "duration_seconds",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "year",
+ "columnName": "year",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchProgress",
+ "columnName": "watch_progress",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchCount",
+ "columnName": "watch_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastWatchedAt",
+ "columnName": "last_watched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "cacheState",
+ "columnName": "cache_state",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "detailHydratedAt",
+ "columnName": "detail_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "remoteStaleAt",
+ "columnName": "remote_stale_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_movies_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movies_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_movies_provider_id_category_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movies_provider_id_category_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`)"
+ },
+ {
+ "name": "index_movies_provider_id_stream_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "stream_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_movies_provider_id_stream_id` ON `${TABLE_NAME}` (`provider_id`, `stream_id`)"
+ },
+ {
+ "name": "index_movies_provider_id_name_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "name",
+ "id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movies_provider_id_name_id` ON `${TABLE_NAME}` (`provider_id`, `name`, `id`)"
+ },
+ {
+ "name": "index_movies_provider_id_category_id_name_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id",
+ "name",
+ "id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movies_provider_id_category_id_name_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`, `name`, `id`)"
+ },
+ {
+ "name": "index_movies_provider_id_rating_name_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "rating",
+ "name",
+ "id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movies_provider_id_rating_name_id` ON `${TABLE_NAME}` (`provider_id`, `rating`, `name`, `id`)"
+ },
+ {
+ "name": "index_movies_provider_id_added_at_release_date_name_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "added_at",
+ "release_date",
+ "name",
+ "id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movies_provider_id_added_at_release_date_name_id` ON `${TABLE_NAME}` (`provider_id`, `added_at`, `release_date`, `name`, `id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "movies_fts",
+ "createSql": "CREATE VIRTUAL TABLE IF NOT EXISTS `${TABLE_NAME}` USING FTS4(`name` TEXT NOT NULL, content=`movies`)",
+ "fields": [
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": []
+ },
+ "ftsVersion": "FTS4",
+ "ftsOptions": {
+ "tokenizer": "simple",
+ "tokenizerArgs": [],
+ "contentTable": "movies",
+ "languageIdColumnName": "",
+ "matchInfo": "FTS4",
+ "notIndexedColumns": [],
+ "prefixSizes": [],
+ "preferredOrder": "ASC"
+ },
+ "contentSyncTriggers": [
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_movies_fts_BEFORE_UPDATE BEFORE UPDATE ON `movies` BEGIN DELETE FROM `movies_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_movies_fts_BEFORE_DELETE BEFORE DELETE ON `movies` BEGIN DELETE FROM `movies_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_movies_fts_AFTER_UPDATE AFTER UPDATE ON `movies` BEGIN INSERT INTO `movies_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_movies_fts_AFTER_INSERT AFTER INSERT ON `movies` BEGIN INSERT INTO `movies_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END"
+ ]
+ },
+ {
+ "tableName": "series",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `series_id` INTEGER NOT NULL, `provider_series_id` TEXT, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `rating` REAL NOT NULL, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `episode_run_time` TEXT, `last_modified` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, `cache_state` TEXT NOT NULL, `detail_hydrated_at` INTEGER NOT NULL, `remote_stale_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
++ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `series_id` INTEGER NOT NULL, `provider_series_id` TEXT, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `rating` REAL NOT NULL, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `episode_run_time` TEXT, `last_modified` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, `cache_state` TEXT NOT NULL, `detail_hydrated_at` INTEGER NOT NULL, `remote_stale_at` INTEGER NOT NULL, `catalog_origin` TEXT NOT NULL, `episode_playback_template_url` TEXT, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesId",
+ "columnName": "series_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerSeriesId",
+ "columnName": "provider_series_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "episodeRunTime",
+ "columnName": "episode_run_time",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastModified",
+ "columnName": "last_modified",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "cacheState",
+ "columnName": "cache_state",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "detailHydratedAt",
+ "columnName": "detail_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "remoteStaleAt",
+ "columnName": "remote_stale_at",
+ "affinity": "INTEGER",
+ "notNull": true
++ },
++ {
++ "fieldPath": "catalogOrigin",
++ "columnName": "catalog_origin",
++ "affinity": "TEXT",
++ "notNull": true
++ },
++ {
++ "fieldPath": "episodePlaybackTemplateUrl",
++ "columnName": "episode_playback_template_url",
++ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_series_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_series_provider_id_category_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_provider_id_category_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`)"
+ },
+ {
+ "name": "index_series_provider_id_series_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "series_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_series_provider_id_series_id` ON `${TABLE_NAME}` (`provider_id`, `series_id`)"
+ },
+ {
+ "name": "index_series_provider_id_name_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "name",
+ "id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_provider_id_name_id` ON `${TABLE_NAME}` (`provider_id`, `name`, `id`)"
+ },
+ {
+ "name": "index_series_provider_id_category_id_name_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id",
+ "name",
+ "id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_provider_id_category_id_name_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`, `name`, `id`)"
+ },
+ {
+ "name": "index_series_provider_id_rating_name_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "rating",
+ "name",
+ "id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_provider_id_rating_name_id` ON `${TABLE_NAME}` (`provider_id`, `rating`, `name`, `id`)"
+ },
+ {
+ "name": "index_series_provider_id_last_modified_name_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "last_modified",
+ "name",
+ "id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_provider_id_last_modified_name_id` ON `${TABLE_NAME}` (`provider_id`, `last_modified`, `name`, `id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "series_fts",
+ "createSql": "CREATE VIRTUAL TABLE IF NOT EXISTS `${TABLE_NAME}` USING FTS4(`name` TEXT NOT NULL, content=`series`)",
+ "fields": [
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": []
+ },
+ "ftsVersion": "FTS4",
+ "ftsOptions": {
+ "tokenizer": "simple",
+ "tokenizerArgs": [],
+ "contentTable": "series",
+ "languageIdColumnName": "",
+ "matchInfo": "FTS4",
+ "notIndexedColumns": [],
+ "prefixSizes": [],
+ "preferredOrder": "ASC"
+ },
+ "contentSyncTriggers": [
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_series_fts_BEFORE_UPDATE BEFORE UPDATE ON `series` BEGIN DELETE FROM `series_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_series_fts_BEFORE_DELETE BEFORE DELETE ON `series` BEGIN DELETE FROM `series_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_series_fts_AFTER_UPDATE AFTER UPDATE ON `series` BEGIN INSERT INTO `series_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_series_fts_AFTER_INSERT AFTER INSERT ON `series` BEGIN INSERT INTO `series_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END"
+ ]
+ },
+ {
+ "tableName": "episodes",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `episode_id` INTEGER NOT NULL, `title` TEXT NOT NULL, `episode_number` INTEGER NOT NULL, `season_number` INTEGER NOT NULL, `stream_url` TEXT NOT NULL, `container_extension` TEXT, `cover_url` TEXT, `plot` TEXT, `duration` TEXT, `duration_seconds` INTEGER NOT NULL, `rating` REAL NOT NULL, `release_date` TEXT, `series_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `watch_progress` INTEGER NOT NULL, `last_watched_at` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`series_id`) REFERENCES `series`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "episodeId",
+ "columnName": "episode_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "episodeNumber",
+ "columnName": "episode_number",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seasonNumber",
+ "columnName": "season_number",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "coverUrl",
+ "columnName": "cover_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "duration",
+ "columnName": "duration",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "durationSeconds",
+ "columnName": "duration_seconds",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "seriesId",
+ "columnName": "series_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchProgress",
+ "columnName": "watch_progress",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastWatchedAt",
+ "columnName": "last_watched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_episodes_series_id",
+ "unique": false,
+ "columnNames": [
+ "series_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_episodes_series_id` ON `${TABLE_NAME}` (`series_id`)"
+ },
+ {
+ "name": "index_episodes_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_episodes_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_episodes_provider_id_episode_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "episode_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_episodes_provider_id_episode_id` ON `${TABLE_NAME}` (`provider_id`, `episode_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "series",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "series_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "categories",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `category_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `parent_id` INTEGER, `type` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `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 )",
++ "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, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `stream_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logoUrl",
+ "columnName": "logo_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupTitle",
+ "columnName": "group_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgChannelId",
+ "columnName": "epg_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "number",
+ "columnName": "number",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSupported",
+ "columnName": "catch_up_supported",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpDays",
+ "columnName": "catch_up_days",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSource",
+ "columnName": "catchUpSource",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logicalGroupId",
+ "columnName": "logical_group_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "errorCount",
+ "columnName": "error_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "stream_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_channel_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "movie_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `container_extension` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `duration` TEXT, `duration_seconds` INTEGER NOT NULL, `rating` REAL NOT NULL, `year` TEXT, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, `added_at` INTEGER NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `stream_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "duration",
+ "columnName": "duration",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "durationSeconds",
+ "columnName": "duration_seconds",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "year",
+ "columnName": "year",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "stream_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_movie_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_movie_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "series_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `series_id` INTEGER NOT NULL, `provider_series_id` TEXT, `provider_series_key` TEXT NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `rating` REAL NOT NULL, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `episode_run_time` TEXT, `last_modified` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `provider_series_key`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesId",
+ "columnName": "series_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerSeriesId",
+ "columnName": "provider_series_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "providerSeriesKey",
+ "columnName": "provider_series_key",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "episodeRunTime",
+ "columnName": "episode_run_time",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastModified",
+ "columnName": "last_modified",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "provider_series_key"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_series_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_series_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "category_import_stage",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `parent_id` INTEGER, `type` TEXT NOT NULL, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `category_id`, `type`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
++ "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, `is_complete` INTEGER NOT NULL, `page_size` INTEGER NOT NULL, `retry_after_ms` INTEGER NOT NULL, `failure_count` INTEGER NOT NULL, `retry_budget_remaining` INTEGER NOT NULL, `last_page_fingerprint` TEXT, PRIMARY KEY(`provider_id`, `category_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastHydratedAt",
+ "columnName": "last_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemCount",
+ "columnName": "item_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastStatus",
+ "columnName": "last_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastLoadedPage",
+ "columnName": "last_loaded_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastAttemptedPage",
+ "columnName": "last_attempted_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSuccessfulPage",
+ "columnName": "last_successful_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalPages",
+ "columnName": "total_pages",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isComplete",
+ "columnName": "is_complete",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "pageSize",
+ "columnName": "page_size",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryAfterMs",
+ "columnName": "retry_after_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureCount",
+ "columnName": "failure_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryBudgetRemaining",
+ "columnName": "retry_budget_remaining",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastPageFingerprint",
+ "columnName": "last_page_fingerprint",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_movie_category_hydration_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_category_hydration_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "series_category_hydration",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `last_hydrated_at` INTEGER NOT NULL, `item_count` INTEGER NOT NULL, `last_status` TEXT NOT NULL, `last_error` TEXT, `last_loaded_page` INTEGER NOT NULL, `last_attempted_page` INTEGER NOT NULL, `last_successful_page` INTEGER NOT NULL, `total_pages` INTEGER NOT NULL, `is_complete` INTEGER NOT NULL, `page_size` INTEGER NOT NULL, `retry_after_ms` INTEGER NOT NULL, `failure_count` INTEGER NOT NULL, `retry_budget_remaining` INTEGER NOT NULL, `last_page_fingerprint` TEXT, PRIMARY KEY(`provider_id`, `category_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastHydratedAt",
+ "columnName": "last_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemCount",
+ "columnName": "item_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastStatus",
+ "columnName": "last_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastLoadedPage",
+ "columnName": "last_loaded_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastAttemptedPage",
+ "columnName": "last_attempted_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSuccessfulPage",
+ "columnName": "last_successful_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalPages",
+ "columnName": "total_pages",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isComplete",
+ "columnName": "is_complete",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "pageSize",
+ "columnName": "page_size",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryAfterMs",
+ "columnName": "retry_after_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureCount",
+ "columnName": "failure_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryBudgetRemaining",
+ "columnName": "retry_budget_remaining",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastPageFingerprint",
+ "columnName": "last_page_fingerprint",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_series_category_hydration_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_category_hydration_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
- "tableName": "epg_sources",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `url` TEXT NOT NULL, `enabled` INTEGER NOT NULL, `last_refresh_at` INTEGER NOT NULL, `last_success_at` INTEGER NOT NULL, `last_error` TEXT, `priority` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, `etag` TEXT, `last_modified_header` TEXT, `timezone_policy` TEXT NOT NULL, `timezone_id` TEXT)",
++ "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, `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": "id",
- "columnName": "id",
++ "fieldPath": "providerId",
++ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
- "fieldPath": "name",
- "columnName": "name",
- "affinity": "TEXT",
++ "fieldPath": "categoryId",
++ "columnName": "category_id",
++ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
- "fieldPath": "url",
- "columnName": "url",
- "affinity": "TEXT",
++ "fieldPath": "lastLoadedPage",
++ "columnName": "last_loaded_page",
++ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
- "fieldPath": "enabled",
- "columnName": "enabled",
++ "fieldPath": "lastAttemptedPage",
++ "columnName": "last_attempted_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
- "fieldPath": "lastRefreshAt",
- "columnName": "last_refresh_at",
++ "fieldPath": "lastSuccessfulPage",
++ "columnName": "last_successful_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
- "fieldPath": "lastSuccessAt",
- "columnName": "last_success_at",
++ "fieldPath": "totalPages",
++ "columnName": "total_pages",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
- "fieldPath": "lastError",
- "columnName": "last_error",
- "affinity": "TEXT"
++ "fieldPath": "pageSize",
++ "columnName": "page_size",
++ "affinity": "INTEGER",
++ "notNull": true
+ },
+ {
- "fieldPath": "priority",
- "columnName": "priority",
++ "fieldPath": "itemCount",
++ "columnName": "item_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
- "fieldPath": "createdAt",
- "columnName": "created_at",
++ "fieldPath": "isComplete",
++ "columnName": "is_complete",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
- "fieldPath": "updatedAt",
- "columnName": "updated_at",
++ "fieldPath": "hasMovies",
++ "columnName": "has_movies",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
- "fieldPath": "etag",
- "columnName": "etag",
- "affinity": "TEXT"
++ "fieldPath": "hasSeries",
++ "columnName": "has_series",
++ "affinity": "INTEGER",
++ "notNull": true
+ },
+ {
- "fieldPath": "lastModifiedHeader",
- "columnName": "last_modified_header",
- "affinity": "TEXT"
++ "fieldPath": "lastHydratedAt",
++ "columnName": "last_hydrated_at",
++ "affinity": "INTEGER",
++ "notNull": true
+ },
+ {
- "fieldPath": "timezonePolicy",
- "columnName": "timezone_policy",
++ "fieldPath": "lastStatus",
++ "columnName": "last_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
- "fieldPath": "timezoneId",
- "columnName": "timezone_id",
++ "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": true,
++ "autoGenerate": false,
+ "columnNames": [
- "id"
++ "provider_id",
++ "category_id"
+ ]
+ },
+ "indices": [
+ {
- "name": "index_epg_sources_url",
- "unique": true,
++ "name": "index_vod_category_hydration_provider_id",
++ "unique": false,
+ "columnNames": [
- "url"
++ "provider_id"
+ ],
+ "orders": [],
- "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_sources_url` ON `${TABLE_NAME}` (`url`)"
++ "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": "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 )",
++ "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": "id",
- "columnName": "id",
++ "fieldPath": "providerId",
++ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
- "fieldPath": "providerId",
- "columnName": "provider_id",
++ "fieldPath": "categoryId",
++ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
- "fieldPath": "epgSourceId",
- "columnName": "epg_source_id",
++ "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": "priority",
- "columnName": "priority",
++ "fieldPath": "rawPage",
++ "columnName": "raw_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
- "fieldPath": "enabled",
- "columnName": "enabled",
++ "fieldPath": "rawIndex",
++ "columnName": "raw_index",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
- "autoGenerate": true,
++ "autoGenerate": false,
+ "columnNames": [
- "id"
++ "provider_id",
++ "category_id",
++ "raw_item_id"
+ ]
+ },
+ "indices": [
+ {
- "name": "index_provider_epg_sources_provider_id_epg_source_id",
- "unique": true,
++ "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",
- "epg_source_id"
++ "category_id",
++ "raw_page",
++ "raw_index"
+ ],
+ "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`)"
++ "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_provider_epg_sources_epg_source_id",
++ "name": "index_vod_catalog_entries_provider_id_item_type_target_id",
+ "unique": false,
+ "columnNames": [
- "epg_source_id"
++ "provider_id",
++ "item_type",
++ "target_id"
+ ],
+ "orders": [],
- "createSql": "CREATE INDEX IF NOT EXISTS `index_provider_epg_sources_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
++ "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"
+ ]
- },
- {
- "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 )",
++ "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": "epgSourceId",
++ "fieldPath": "name",
++ "columnName": "name",
++ "affinity": "TEXT",
++ "notNull": true
++ },
++ {
++ "fieldPath": "url",
++ "columnName": "url",
++ "affinity": "TEXT",
++ "notNull": true
++ },
++ {
++ "fieldPath": "enabled",
++ "columnName": "enabled",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "lastRefreshAt",
++ "columnName": "last_refresh_at",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "lastSuccessAt",
++ "columnName": "last_success_at",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "lastError",
++ "columnName": "last_error",
++ "affinity": "TEXT"
++ },
++ {
++ "fieldPath": "priority",
++ "columnName": "priority",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "createdAt",
++ "columnName": "created_at",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "updatedAt",
++ "columnName": "updated_at",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "etag",
++ "columnName": "etag",
++ "affinity": "TEXT"
++ },
++ {
++ "fieldPath": "lastModifiedHeader",
++ "columnName": "last_modified_header",
++ "affinity": "TEXT"
++ },
++ {
++ "fieldPath": "timezonePolicy",
++ "columnName": "timezone_policy",
++ "affinity": "TEXT",
++ "notNull": true
++ },
++ {
++ "fieldPath": "timezoneId",
++ "columnName": "timezone_id",
++ "affinity": "TEXT"
++ }
++ ],
++ "primaryKey": {
++ "autoGenerate": true,
++ "columnNames": [
++ "id"
++ ]
++ },
++ "indices": [
++ {
++ "name": "index_epg_sources_url",
++ "unique": true,
++ "columnNames": [
++ "url"
++ ],
++ "orders": [],
++ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_sources_url` ON `${TABLE_NAME}` (`url`)"
++ }
++ ]
++ },
++ {
++ "tableName": "provider_epg_sources",
++ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `epg_source_id` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
++ "fields": [
++ {
++ "fieldPath": "id",
++ "columnName": "id",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "providerId",
++ "columnName": "provider_id",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "epgSourceId",
++ "columnName": "epg_source_id",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "priority",
++ "columnName": "priority",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "enabled",
++ "columnName": "enabled",
++ "affinity": "INTEGER",
++ "notNull": true
++ }
++ ],
++ "primaryKey": {
++ "autoGenerate": true,
++ "columnNames": [
++ "id"
++ ]
++ },
++ "indices": [
++ {
++ "name": "index_provider_epg_sources_provider_id_epg_source_id",
++ "unique": true,
++ "columnNames": [
++ "provider_id",
++ "epg_source_id"
++ ],
++ "orders": [],
++ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_provider_epg_sources_provider_id_epg_source_id` ON `${TABLE_NAME}` (`provider_id`, `epg_source_id`)"
++ },
++ {
++ "name": "index_provider_epg_sources_epg_source_id",
++ "unique": false,
++ "columnNames": [
++ "epg_source_id"
++ ],
++ "orders": [],
++ "createSql": "CREATE INDEX IF NOT EXISTS `index_provider_epg_sources_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
++ }
++ ],
++ "foreignKeys": [
++ {
++ "table": "providers",
++ "onDelete": "CASCADE",
++ "onUpdate": "NO ACTION",
++ "columns": [
++ "provider_id"
++ ],
++ "referencedColumns": [
++ "id"
++ ]
++ },
++ {
++ "table": "epg_sources",
++ "onDelete": "CASCADE",
++ "onUpdate": "NO ACTION",
++ "columns": [
++ "epg_source_id"
++ ],
++ "referencedColumns": [
++ "id"
++ ]
++ }
++ ]
++ },
++ {
++ "tableName": "epg_channels",
++ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `epg_source_id` INTEGER NOT NULL, `xmltv_channel_id` TEXT NOT NULL, `display_name` TEXT NOT NULL, `normalized_name` TEXT NOT NULL, `icon_url` TEXT, FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
++ "fields": [
++ {
++ "fieldPath": "id",
++ "columnName": "id",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "displayName",
+ "columnName": "display_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "normalizedName",
+ "columnName": "normalized_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "iconUrl",
+ "columnName": "icon_url",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_epg_channels_epg_source_id_xmltv_channel_id",
+ "unique": true,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_channels_epg_source_id_xmltv_channel_id` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`)"
+ },
+ {
+ "name": "index_epg_channels_epg_source_id",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_channels_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
+ },
+ {
+ "name": "index_epg_channels_normalized_name",
+ "unique": false,
+ "columnNames": [
+ "normalized_name"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_channels_normalized_name` ON `${TABLE_NAME}` (`normalized_name`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "epg_sources",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "epg_source_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "epg_programmes",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `epg_source_id` INTEGER NOT NULL, `xmltv_channel_id` TEXT NOT NULL, `start_time` INTEGER NOT NULL, `end_time` INTEGER NOT NULL, `title` TEXT NOT NULL, `subtitle` TEXT, `description` TEXT NOT NULL, `category` TEXT, `lang` TEXT NOT NULL, `rating` TEXT, `image_url` TEXT, `episode_info` TEXT, FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "startTime",
+ "columnName": "start_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "endTime",
+ "columnName": "end_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "subtitle",
+ "columnName": "subtitle",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "category",
+ "columnName": "category",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lang",
+ "columnName": "lang",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "imageUrl",
+ "columnName": "image_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "episodeInfo",
+ "columnName": "episode_info",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_epg_programmes_epg_source_id_xmltv_channel_id_start_time",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id",
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id_xmltv_channel_id_start_time` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`, `start_time`)"
+ },
+ {
+ "name": "index_epg_programmes_epg_source_id_xmltv_channel_id_start_time_end_time",
+ "unique": true,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id",
+ "start_time",
+ "end_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id_xmltv_channel_id_start_time_end_time` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`, `start_time`, `end_time`)"
+ },
+ {
+ "name": "index_epg_programmes_epg_source_id",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
+ },
+ {
+ "name": "index_epg_programmes_start_time",
+ "unique": false,
+ "columnNames": [
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_start_time` ON `${TABLE_NAME}` (`start_time`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "epg_sources",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "epg_source_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channel_epg_mappings",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_channel_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `source_type` TEXT NOT NULL, `epg_source_id` INTEGER, `xmltv_channel_id` TEXT, `match_type` TEXT, `confidence` REAL NOT NULL, `matched_at` INTEGER NOT NULL, `failed_attempts` INTEGER NOT NULL, `source` TEXT, `is_manual_override` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerChannelId",
+ "columnName": "provider_channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sourceType",
+ "columnName": "source_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "matchType",
+ "columnName": "match_type",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "confidence",
+ "columnName": "confidence",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "matchedAt",
+ "columnName": "matched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failedAttempts",
+ "columnName": "failed_attempts",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "source",
+ "columnName": "source",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isManualOverride",
+ "columnName": "is_manual_override",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_epg_mappings_provider_id_provider_channel_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "provider_channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channel_epg_mappings_provider_id_provider_channel_id` ON `${TABLE_NAME}` (`provider_id`, `provider_channel_id`)"
+ },
+ {
+ "name": "index_channel_epg_mappings_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_epg_mappings_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "combined_m3u_profiles",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `enabled` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ }
+ },
+ {
+ "tableName": "combined_m3u_profile_members",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `profile_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, FOREIGN KEY(`profile_id`) REFERENCES `combined_m3u_profiles`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profileId",
+ "columnName": "profile_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_combined_m3u_profile_members_profile_id",
+ "unique": false,
+ "columnNames": [
+ "profile_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_profile_id` ON `${TABLE_NAME}` (`profile_id`)"
+ },
+ {
+ "name": "index_combined_m3u_profile_members_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_combined_m3u_profile_members_profile_id_provider_id",
+ "unique": true,
+ "columnNames": [
+ "profile_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_profile_id_provider_id` ON `${TABLE_NAME}` (`profile_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "combined_m3u_profiles",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "profile_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_schedules",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` INTEGER NOT NULL, `channel_name` TEXT NOT NULL, `stream_url` TEXT NOT NULL, `program_title` TEXT, `requested_start_ms` INTEGER NOT NULL, `requested_end_ms` INTEGER NOT NULL, `recurrence` TEXT NOT NULL, `recurring_rule_id` TEXT, `enabled` INTEGER NOT NULL, `is_manual` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "requestedStartMs",
+ "columnName": "requested_start_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "requestedEndMs",
+ "columnName": "requested_end_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurrence",
+ "columnName": "recurrence",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurringRuleId",
+ "columnName": "recurring_rule_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isManual",
+ "columnName": "is_manual",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_recording_schedules_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_recording_schedules_enabled_requested_start_ms",
+ "unique": false,
+ "columnNames": [
+ "enabled",
+ "requested_start_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_enabled_requested_start_ms` ON `${TABLE_NAME}` (`enabled`, `requested_start_ms`)"
+ },
+ {
+ "name": "index_recording_schedules_recurring_rule_id",
+ "unique": false,
+ "columnNames": [
+ "recurring_rule_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_recurring_rule_id` ON `${TABLE_NAME}` (`recurring_rule_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_runs",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `schedule_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` INTEGER NOT NULL, `channel_name` TEXT NOT NULL, `stream_url` TEXT NOT NULL, `program_title` TEXT, `scheduled_start_ms` INTEGER NOT NULL, `scheduled_end_ms` INTEGER NOT NULL, `recurrence` TEXT NOT NULL, `recurring_rule_id` TEXT, `status` TEXT NOT NULL, `source_type` TEXT NOT NULL, `resolved_url` TEXT, `headers_json` TEXT NOT NULL, `user_agent` TEXT, `expiration_time` INTEGER, `provider_label` TEXT, `output_uri` TEXT, `output_display_path` TEXT, `bytes_written` INTEGER NOT NULL, `average_throughput_bps` INTEGER NOT NULL, `retry_count` INTEGER NOT NULL, `last_progress_at_ms` INTEGER, `failure_category` TEXT NOT NULL, `failure_reason` TEXT, `terminal_at_ms` INTEGER, `started_at_ms` INTEGER, `ended_at_ms` INTEGER, `schedule_enabled` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `alarm_start_at_ms` INTEGER, `alarm_stop_at_ms` INTEGER, `exact_alarm_armed` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`schedule_id`) REFERENCES `recording_schedules`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "scheduleId",
+ "columnName": "schedule_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "scheduledStartMs",
+ "columnName": "scheduled_start_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "scheduledEndMs",
+ "columnName": "scheduled_end_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurrence",
+ "columnName": "recurrence",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurringRuleId",
+ "columnName": "recurring_rule_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sourceType",
+ "columnName": "source_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "resolvedUrl",
+ "columnName": "resolved_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "headersJson",
+ "columnName": "headers_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userAgent",
+ "columnName": "user_agent",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "expirationTime",
+ "columnName": "expiration_time",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "providerLabel",
+ "columnName": "provider_label",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputUri",
+ "columnName": "output_uri",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputDisplayPath",
+ "columnName": "output_display_path",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "bytesWritten",
+ "columnName": "bytes_written",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "averageThroughputBytesPerSecond",
+ "columnName": "average_throughput_bps",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryCount",
+ "columnName": "retry_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastProgressAtMs",
+ "columnName": "last_progress_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "failureCategory",
+ "columnName": "failure_category",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failure_reason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "terminalAtMs",
+ "columnName": "terminal_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "startedAtMs",
+ "columnName": "started_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "endedAtMs",
+ "columnName": "ended_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "scheduleEnabled",
+ "columnName": "schedule_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "alarmStartAtMs",
+ "columnName": "alarm_start_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "alarmStopAtMs",
+ "columnName": "alarm_stop_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "exactAlarmArmed",
+ "columnName": "exact_alarm_armed",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_recording_runs_schedule_id",
+ "unique": false,
+ "columnNames": [
+ "schedule_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_schedule_id` ON `${TABLE_NAME}` (`schedule_id`)"
+ },
+ {
+ "name": "index_recording_runs_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_recording_runs_status_scheduled_start_ms",
+ "unique": false,
+ "columnNames": [
+ "status",
+ "scheduled_start_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_status_scheduled_start_ms` ON `${TABLE_NAME}` (`status`, `scheduled_start_ms`)"
+ },
+ {
+ "name": "index_recording_runs_alarm_start_at_ms",
+ "unique": false,
+ "columnNames": [
+ "alarm_start_at_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_alarm_start_at_ms` ON `${TABLE_NAME}` (`alarm_start_at_ms`)"
+ },
+ {
+ "name": "index_recording_runs_alarm_stop_at_ms",
+ "unique": false,
+ "columnNames": [
+ "alarm_stop_at_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_alarm_stop_at_ms` ON `${TABLE_NAME}` (`alarm_stop_at_ms`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "recording_schedules",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "schedule_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "program_reminders",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` TEXT NOT NULL, `channel_name` TEXT NOT NULL, `program_title` TEXT NOT NULL, `program_start_time` INTEGER NOT NULL, `remind_at` INTEGER NOT NULL, `lead_time_minutes` INTEGER NOT NULL, `is_dismissed` INTEGER NOT NULL, `notified_at` INTEGER, `exact_alarm_armed` INTEGER NOT NULL, `delivery_state` TEXT NOT NULL, `delivery_attempt_token` TEXT, `delivery_attempted_at` INTEGER, `delivery_attempt_count` INTEGER NOT NULL, `delivery_failure_reason` TEXT, `created_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programStartTime",
+ "columnName": "program_start_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "remindAt",
+ "columnName": "remind_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "leadTimeMinutes",
+ "columnName": "lead_time_minutes",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isDismissed",
+ "columnName": "is_dismissed",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "notifiedAt",
+ "columnName": "notified_at",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "exactAlarmArmed",
+ "columnName": "exact_alarm_armed",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deliveryState",
+ "columnName": "delivery_state",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deliveryAttemptToken",
+ "columnName": "delivery_attempt_token",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "deliveryAttemptedAt",
+ "columnName": "delivery_attempted_at",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deliveryAttemptCount",
+ "columnName": "delivery_attempt_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deliveryFailureReason",
+ "columnName": "delivery_failure_reason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_program_reminders_provider_id_remind_at",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "remind_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_provider_id_remind_at` ON `${TABLE_NAME}` (`provider_id`, `remind_at`)"
+ },
+ {
+ "name": "index_program_reminders_is_dismissed_notified_at_remind_at",
+ "unique": false,
+ "columnNames": [
+ "is_dismissed",
+ "notified_at",
+ "remind_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_is_dismissed_notified_at_remind_at` ON `${TABLE_NAME}` (`is_dismissed`, `notified_at`, `remind_at`)"
+ },
+ {
+ "name": "index_program_reminders_provider_id_channel_id_program_start_time",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "program_start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_provider_id_channel_id_program_start_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `program_start_time`)"
+ },
+ {
+ "name": "index_program_reminders_provider_id_channel_id_program_title_program_start_time",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "program_title",
+ "program_start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_program_reminders_provider_id_channel_id_program_title_program_start_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `program_title`, `program_start_time`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_storage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `tree_uri` TEXT, `display_name` TEXT, `output_directory` TEXT, `available_bytes` INTEGER, `is_writable` INTEGER NOT NULL, `file_name_pattern` TEXT NOT NULL, `retention_days` INTEGER, `max_simultaneous_recordings` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "treeUri",
+ "columnName": "tree_uri",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "displayName",
+ "columnName": "display_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputDirectory",
+ "columnName": "output_directory",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "availableBytes",
+ "columnName": "available_bytes",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "isWritable",
+ "columnName": "is_writable",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "fileNamePattern",
+ "columnName": "file_name_pattern",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retentionDays",
+ "columnName": "retention_days",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "maxSimultaneousRecordings",
+ "columnName": "max_simultaneous_recordings",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ }
+ },
+ {
+ "tableName": "playback_compatibility_records",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `device_fingerprint` TEXT NOT NULL, `device_model` TEXT NOT NULL, `android_sdk` INTEGER NOT NULL, `stream_type` TEXT NOT NULL, `video_mime_type` TEXT NOT NULL, `resolution_bucket` TEXT NOT NULL, `decoder_name` TEXT NOT NULL, `surface_type` TEXT NOT NULL, `failure_type` TEXT NOT NULL, `last_failed_at` INTEGER NOT NULL, `last_succeeded_at` INTEGER NOT NULL, `failure_count` INTEGER NOT NULL, `success_count` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deviceFingerprint",
+ "columnName": "device_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deviceModel",
+ "columnName": "device_model",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "androidSdk",
+ "columnName": "android_sdk",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamType",
+ "columnName": "stream_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "videoMimeType",
+ "columnName": "video_mime_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "resolutionBucket",
+ "columnName": "resolution_bucket",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "decoderName",
+ "columnName": "decoder_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "surfaceType",
+ "columnName": "surface_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureType",
+ "columnName": "failure_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastFailedAt",
+ "columnName": "last_failed_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSucceededAt",
+ "columnName": "last_succeeded_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureCount",
+ "columnName": "failure_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "successCount",
+ "columnName": "success_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket_decoder_name_surface_type",
+ "unique": true,
+ "columnNames": [
+ "device_fingerprint",
+ "stream_type",
+ "video_mime_type",
+ "resolution_bucket",
+ "decoder_name",
+ "surface_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket_decoder_name_surface_type` ON `${TABLE_NAME}` (`device_fingerprint`, `stream_type`, `video_mime_type`, `resolution_bucket`, `decoder_name`, `surface_type`)"
+ },
+ {
+ "name": "index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket",
+ "unique": false,
+ "columnNames": [
+ "device_fingerprint",
+ "stream_type",
+ "video_mime_type",
+ "resolution_bucket"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket` ON `${TABLE_NAME}` (`device_fingerprint`, `stream_type`, `video_mime_type`, `resolution_bucket`)"
+ },
+ {
+ "name": "index_playback_compatibility_records_last_failed_at",
+ "unique": false,
+ "columnNames": [
+ "last_failed_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_compatibility_records_last_failed_at` ON `${TABLE_NAME}` (`last_failed_at`)"
+ },
+ {
+ "name": "index_playback_compatibility_records_last_succeeded_at",
+ "unique": false,
+ "columnNames": [
+ "last_succeeded_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_compatibility_records_last_succeeded_at` ON `${TABLE_NAME}` (`last_succeeded_at`)"
+ }
+ ]
+ },
+ {
+ "tableName": "xtream_content_index",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `remote_id` TEXT NOT NULL, `local_content_id` INTEGER, `name` TEXT NOT NULL, `category_id` INTEGER, `category_name` TEXT, `image_url` TEXT, `container_extension` TEXT, `rating` REAL NOT NULL, `added_at` INTEGER NOT NULL, `remote_updated_at` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `indexed_at` INTEGER NOT NULL, `detail_hydrated_at` INTEGER NOT NULL, `stale_state` TEXT NOT NULL, `error_state` TEXT, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`provider_id`, `content_type`, `remote_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "remoteId",
+ "columnName": "remote_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "localContentId",
+ "columnName": "local_content_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "imageUrl",
+ "columnName": "image_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "remoteUpdatedAt",
+ "columnName": "remote_updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "indexedAt",
+ "columnName": "indexed_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "detailHydratedAt",
+ "columnName": "detail_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "staleState",
+ "columnName": "stale_state",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "errorState",
+ "columnName": "error_state",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "content_type",
+ "remote_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_xtream_content_index_provider_id_content_type",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_content_index_provider_id_content_type` ON `${TABLE_NAME}` (`provider_id`, `content_type`)"
+ },
+ {
+ "name": "index_xtream_content_index_provider_id_content_type_category_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type",
+ "category_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_content_index_provider_id_content_type_category_id` ON `${TABLE_NAME}` (`provider_id`, `content_type`, `category_id`)"
+ },
+ {
+ "name": "index_xtream_content_index_provider_id_content_type_name",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type",
+ "name"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_content_index_provider_id_content_type_name` ON `${TABLE_NAME}` (`provider_id`, `content_type`, `name`)"
+ },
+ {
+ "name": "index_xtream_content_index_provider_id_content_type_local_content_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type",
+ "local_content_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_content_index_provider_id_content_type_local_content_id` ON `${TABLE_NAME}` (`provider_id`, `content_type`, `local_content_id`)"
+ },
+ {
+ "name": "index_xtream_content_index_provider_id_indexed_at",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "indexed_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_content_index_provider_id_indexed_at` ON `${TABLE_NAME}` (`provider_id`, `indexed_at`)"
+ },
+ {
+ "name": "index_xtream_content_index_stale_state",
+ "unique": false,
+ "columnNames": [
+ "stale_state"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_content_index_stale_state` ON `${TABLE_NAME}` (`stale_state`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "xtream_index_jobs",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `section` TEXT NOT NULL, `state` TEXT NOT NULL, `total_categories` INTEGER NOT NULL, `completed_categories` INTEGER NOT NULL, `next_category_index` INTEGER NOT NULL, `failed_categories` INTEGER NOT NULL, `indexed_rows` INTEGER NOT NULL, `skipped_malformed_rows` INTEGER NOT NULL, `deleted_pruned_rows` INTEGER NOT NULL, `priority_category_id` INTEGER, `priority_requested_at` INTEGER NOT NULL, `last_error` TEXT, `last_attempt_at` INTEGER NOT NULL, `last_success_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`provider_id`, `section`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "section",
+ "columnName": "section",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "state",
+ "columnName": "state",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalCategories",
+ "columnName": "total_categories",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "completedCategories",
+ "columnName": "completed_categories",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nextCategoryIndex",
+ "columnName": "next_category_index",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failedCategories",
+ "columnName": "failed_categories",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "indexedRows",
+ "columnName": "indexed_rows",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "skippedMalformedRows",
+ "columnName": "skipped_malformed_rows",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedPrunedRows",
+ "columnName": "deleted_pruned_rows",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priorityCategoryId",
+ "columnName": "priority_category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "priorityRequestedAt",
+ "columnName": "priority_requested_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastAttemptAt",
+ "columnName": "last_attempt_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSuccessAt",
+ "columnName": "last_success_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "section"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_xtream_index_jobs_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_index_jobs_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_xtream_index_jobs_section",
+ "unique": false,
+ "columnNames": [
+ "section"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_index_jobs_section` ON `${TABLE_NAME}` (`section`)"
+ },
+ {
+ "name": "index_xtream_index_jobs_state",
+ "unique": false,
+ "columnNames": [
+ "state"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_index_jobs_state` ON `${TABLE_NAME}` (`state`)"
+ },
+ {
+ "name": "index_xtream_index_jobs_updated_at",
+ "unique": false,
+ "columnNames": [
+ "updated_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_index_jobs_updated_at` ON `${TABLE_NAME}` (`updated_at`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "xtream_live_onboarding_state",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `provider_type` TEXT NOT NULL, `content_type` TEXT NOT NULL, `phase` TEXT NOT NULL, `staged_session_id` INTEGER, `import_strategy` TEXT, `next_category_index` INTEGER NOT NULL, `accepted_row_count` INTEGER NOT NULL, `staged_flush_count` INTEGER NOT NULL, `sync_profile_tier` TEXT, `sync_profile_batch_size` INTEGER NOT NULL, `sync_profile_strategy` TEXT, `sync_profile_low_memory` INTEGER NOT NULL, `sync_profile_memory_class_mb` INTEGER NOT NULL, `sync_profile_available_mem_mb` INTEGER NOT NULL, `last_error` TEXT, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, `completed_at` INTEGER, PRIMARY KEY(`provider_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerType",
+ "columnName": "provider_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "phase",
+ "columnName": "phase",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stagedSessionId",
+ "columnName": "staged_session_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "importStrategy",
+ "columnName": "import_strategy",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nextCategoryIndex",
+ "columnName": "next_category_index",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "acceptedRowCount",
+ "columnName": "accepted_row_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stagedFlushCount",
+ "columnName": "staged_flush_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncProfileTier",
+ "columnName": "sync_profile_tier",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "syncProfileBatchSize",
+ "columnName": "sync_profile_batch_size",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncProfileStrategy",
+ "columnName": "sync_profile_strategy",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "syncProfileLowMemory",
+ "columnName": "sync_profile_low_memory",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncProfileMemoryClassMb",
+ "columnName": "sync_profile_memory_class_mb",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncProfileAvailableMemMb",
+ "columnName": "sync_profile_available_mem_mb",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "completedAt",
+ "columnName": "completed_at",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_xtream_live_onboarding_state_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_live_onboarding_state_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_xtream_live_onboarding_state_phase",
+ "unique": false,
+ "columnNames": [
+ "phase"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_live_onboarding_state_phase` ON `${TABLE_NAME}` (`phase`)"
+ },
+ {
+ "name": "index_xtream_live_onboarding_state_updated_at",
+ "unique": false,
+ "columnNames": [
+ "updated_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_live_onboarding_state_updated_at` ON `${TABLE_NAME}` (`updated_at`)"
+ },
+ {
+ "name": "index_xtream_live_onboarding_state_staged_session_id",
+ "unique": false,
+ "columnNames": [
+ "staged_session_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_xtream_live_onboarding_state_staged_session_id` ON `${TABLE_NAME}` (`staged_session_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
++ {
++ "tableName": "stalker_index_jobs",
++ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `section` TEXT NOT NULL, `state` TEXT NOT NULL, `total_categories` INTEGER NOT NULL, `completed_categories` INTEGER NOT NULL, `next_category_index` INTEGER NOT NULL, `failed_categories` INTEGER NOT NULL, `indexed_rows` INTEGER NOT NULL, `skipped_malformed_rows` INTEGER NOT NULL, `deleted_pruned_rows` INTEGER NOT NULL, `last_error` TEXT, `last_attempt_at` INTEGER NOT NULL, `last_success_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`provider_id`, `section`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
++ "fields": [
++ {
++ "fieldPath": "providerId",
++ "columnName": "provider_id",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "section",
++ "columnName": "section",
++ "affinity": "TEXT",
++ "notNull": true
++ },
++ {
++ "fieldPath": "state",
++ "columnName": "state",
++ "affinity": "TEXT",
++ "notNull": true
++ },
++ {
++ "fieldPath": "totalCategories",
++ "columnName": "total_categories",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "completedCategories",
++ "columnName": "completed_categories",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "nextCategoryIndex",
++ "columnName": "next_category_index",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "failedCategories",
++ "columnName": "failed_categories",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "indexedRows",
++ "columnName": "indexed_rows",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "skippedMalformedRows",
++ "columnName": "skipped_malformed_rows",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "deletedPrunedRows",
++ "columnName": "deleted_pruned_rows",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "lastError",
++ "columnName": "last_error",
++ "affinity": "TEXT"
++ },
++ {
++ "fieldPath": "lastAttemptAt",
++ "columnName": "last_attempt_at",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "lastSuccessAt",
++ "columnName": "last_success_at",
++ "affinity": "INTEGER",
++ "notNull": true
++ },
++ {
++ "fieldPath": "updatedAt",
++ "columnName": "updated_at",
++ "affinity": "INTEGER",
++ "notNull": true
++ }
++ ],
++ "primaryKey": {
++ "autoGenerate": false,
++ "columnNames": [
++ "provider_id",
++ "section"
++ ]
++ },
++ "indices": [
++ {
++ "name": "index_stalker_index_jobs_provider_id",
++ "unique": false,
++ "columnNames": [
++ "provider_id"
++ ],
++ "orders": [],
++ "createSql": "CREATE INDEX IF NOT EXISTS `index_stalker_index_jobs_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
++ },
++ {
++ "name": "index_stalker_index_jobs_state",
++ "unique": false,
++ "columnNames": [
++ "state"
++ ],
++ "orders": [],
++ "createSql": "CREATE INDEX IF NOT EXISTS `index_stalker_index_jobs_state` ON `${TABLE_NAME}` (`state`)"
++ },
++ {
++ "name": "index_stalker_index_jobs_updated_at",
++ "unique": false,
++ "columnNames": [
++ "updated_at"
++ ],
++ "orders": [],
++ "createSql": "CREATE INDEX IF NOT EXISTS `index_stalker_index_jobs_updated_at` ON `${TABLE_NAME}` (`updated_at`)"
++ }
++ ],
++ "foreignKeys": [
++ {
++ "table": "providers",
++ "onDelete": "CASCADE",
++ "onUpdate": "NO ACTION",
++ "columns": [
++ "provider_id"
++ ],
++ "referencedColumns": [
++ "id"
++ ]
++ }
++ ]
++ },
++ {
++ "tableName": "stalker_portal_state",
++ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `working_endpoint` TEXT, `bootstrap_recipe` TEXT, `bulk_live_supported` INTEGER, `bulk_live_category_fidelity` INTEGER, `movie_wildcard_supported` INTEGER, `series_wildcard_supported` INTEGER, `epg_supported` INTEGER, `safe_metadata_concurrency` INTEGER NOT NULL, `stress_cooldown_until` INTEGER NOT NULL, `endpoint_health_json` TEXT NOT NULL, `endpoint_failed_until` INTEGER NOT NULL, `validated_at` INTEGER NOT NULL, `schema_version` INTEGER NOT NULL, 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
++ }
++ ],
++ "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": "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"
+ ]
+ }
+ ]
+ }
+ ],
+ "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, '587ce50641fa03e4737b79b8c3d51d3c')"
++ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'b4312ae5bde8b8c44d399bad4b923a94')"
+ ]
+ }
+ }
diff --cc data/src/androidTest/java/com/streamvault/data/local/StreamVaultDatabaseMigrationTest.kt
index 9a51535c,7fe9bdfe..08d70c35
--- a/data/src/androidTest/java/com/streamvault/data/local/StreamVaultDatabaseMigrationTest.kt
+++ b/data/src/androidTest/java/com/streamvault/data/local/StreamVaultDatabaseMigrationTest.kt
@@@ -1521,6 -1542,46 +1521,47 @@@ class StreamVaultDatabaseMigrationTest
migratedDb.close()
}
+ @Test
- fun migrate71To72_addsDeterministicXmltvTimezonePolicy() {
- val databaseName = "streamvault-71-72-test"
- migrationTestHelper.createDatabase(databaseName, 71).apply {
- execSQL(
- """
- INSERT INTO epg_sources (
- id, name, url, enabled, last_refresh_at, last_success_at, last_error,
- priority, created_at, updated_at, etag, last_modified_header
- ) VALUES (
- 1, 'Existing guide', 'https://example.com/guide.xml', 1, 0, 0, NULL,
- 0, 100, 100, NULL, NULL
- )
- """.trimIndent()
- )
- close()
- }
++ fun migrate62To72_combinesStalkerAndInnerBugFixMigrations() {
++ migrationTestHelper.createDatabase("streamvault-62-72-combined-test", 62).close()
+
+ val migratedDb = migrationTestHelper.runMigrationsAndValidate(
- databaseName,
++ "streamvault-62-72-combined-test",
+ 72,
+ true,
++ StreamVaultDatabase.MIGRATION_62_63,
++ StreamVaultDatabase.MIGRATION_63_64,
++ StreamVaultDatabase.MIGRATION_64_65,
++ StreamVaultDatabase.MIGRATION_65_66,
++ StreamVaultDatabase.MIGRATION_66_67,
++ StreamVaultDatabase.MIGRATION_67_68,
++ StreamVaultDatabase.MIGRATION_68_69,
++ StreamVaultDatabase.MIGRATION_69_70,
++ StreamVaultDatabase.MIGRATION_70_71,
+ StreamVaultDatabase.MIGRATION_71_72
+ )
+
- assertEquals(
- 1,
- countRows(
- migratedDb,
- """
- SELECT COUNT(*) FROM epg_sources
- WHERE id = 1
- AND timezone_policy = 'REQUIRE_OFFSET'
- AND timezone_id IS NULL
- """.trimIndent()
- )
- )
++ listOf(
++ "stalker_index_jobs",
++ "stalker_portal_state",
++ "stalker_remote_identities",
++ "provider_deletion_cleanup",
++ "plugin_provider_ownership",
++ "stalker_discovery_staging",
++ "vod_category_hydration",
++ "vod_catalog_entries",
++ "provider_config_revisions",
++ "backup_restore_checkpoints",
++ "provider_workflows",
++ "provider_workflow_phases"
++ ).forEach { table ->
++ assertEquals(1, countRows(migratedDb, "SELECT COUNT(*) FROM sqlite_master WHERE type = 'table' AND name = '$table'"))
++ }
++ assertEquals(1, countRows(migratedDb, "SELECT COUNT(*) FROM pragma_table_info('recording_runs') WHERE name = 'exact_alarm_armed'"))
++ assertEquals(1, countRows(migratedDb, "SELECT COUNT(*) FROM pragma_table_info('providers') WHERE name = 'xmltv_timezone_policy'"))
+ migratedDb.close()
+ }
+
private fun countRows(db: androidx.sqlite.db.SupportSQLiteDatabase, sql: String): Int {
db.query(sql).use { cursor ->
if (!cursor.moveToFirst()) return 0
diff --cc data/src/main/java/com/streamvault/data/local/RoomEnumConverters.kt
index 664fa5b1,d1d02ee7..e695f7c6
--- a/data/src/main/java/com/streamvault/data/local/RoomEnumConverters.kt
+++ b/data/src/main/java/com/streamvault/data/local/RoomEnumConverters.kt
@@@ -1,17 -1,20 +1,23 @@@
package com.streamvault.data.local
import androidx.room.TypeConverter
+ import com.streamvault.data.local.entity.ProviderConfigRevisionState
+ import com.streamvault.data.local.entity.ProviderWorkflowPhase
+ import com.streamvault.data.local.entity.ProviderWorkflowPhaseState
+ import com.streamvault.data.local.entity.ProviderWorkflowReason
+ import com.streamvault.data.local.entity.ProviderWorkflowState
import com.streamvault.domain.model.ContentType
+import com.streamvault.domain.model.CatalogLayout
+import com.streamvault.domain.model.SeriesCatalogOrigin
import com.streamvault.domain.model.ChannelLogoSourcePolicy
import com.streamvault.domain.model.GuideSourcePolicy
import com.streamvault.domain.model.ProviderEpgSyncMode
import com.streamvault.domain.model.ProviderStatus
import com.streamvault.domain.model.ProviderType
import com.streamvault.domain.model.ProviderXtreamLiveSyncMode
+ import com.streamvault.domain.model.ProgramReminderDeliveryState
import com.streamvault.domain.model.StalkerAuthMode
+import com.streamvault.domain.model.StalkerCatalogMode
import com.streamvault.domain.model.StalkerBootstrapRecipe
import com.streamvault.domain.model.StalkerCookieMode
import com.streamvault.domain.model.StalkerEndpointPreference
@@@ -19,10 -22,7 +25,11 @@@ import com.streamvault.domain.model.Sta
import com.streamvault.domain.model.StalkerPlaybackBackendHint
import com.streamvault.domain.model.StalkerPortalFingerprint
import com.streamvault.domain.model.StalkerPortalProfile
+import com.streamvault.domain.model.StalkerProfileVerification
+import com.streamvault.domain.model.StalkerProtocolFamily
+import com.streamvault.domain.model.StalkerProtocolPreference
+import com.streamvault.domain.model.StalkerTransportMode
+ import com.streamvault.domain.model.XmltvTimezonePolicy
import java.util.logging.Logger
class RoomEnumConverters {
@@@ -169,20 -176,13 +218,27 @@@
fun toContentType(value: String?): ContentType? =
enumValueOrDefault(value, ContentType.LIVE, contentTypeAliases())
+ @TypeConverter
+ fun fromCatalogLayout(value: CatalogLayout?): String? = value?.name
+
+ @TypeConverter
+ fun toCatalogLayout(value: String?): CatalogLayout? =
+ enumValueOrDefault(value, CatalogLayout.SPLIT)
+
+ @TypeConverter
+ fun fromSeriesCatalogOrigin(value: SeriesCatalogOrigin?): String? = value?.name
+
+ @TypeConverter
+ fun toSeriesCatalogOrigin(value: String?): SeriesCatalogOrigin? =
+ enumValueOrDefault(value, SeriesCatalogOrigin.NATIVE)
+
+ @TypeConverter
+ fun fromXmltvTimezonePolicy(value: XmltvTimezonePolicy?): String? = value?.name
+
+ @TypeConverter
+ fun toXmltvTimezonePolicy(value: String?): XmltvTimezonePolicy? =
+ enumValueOrDefault(value, XmltvTimezonePolicy.REQUIRE_OFFSET)
+
private inline fun <reified T : Enum<T>> enumValueOrDefault(
value: String?,
defaultValue: T,
diff --cc data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt
index 7fa423df,44eafc17..41efe80d
--- a/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt
+++ b/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt
@@@ -50,13 -48,15 +50,19 @@@ import com.streamvault.data.local.entit
XtreamContentIndexEntity::class,
XtreamIndexJobEntity::class,
XtreamLiveOnboardingStateEntity::class,
+ StalkerIndexJobEntity::class,
+ StalkerPortalStateEntity::class,
+ StalkerRemoteIdentityEntity::class,
+ StalkerDiscoveryStageEntity::class,
- DownloadEntity::class
+ DownloadEntity::class,
+ ProviderDeletionCleanupEntity::class,
+ PluginProviderOwnershipEntity::class,
+ ProviderConfigRevisionEntity::class,
+ BackupRestoreCheckpointEntity::class,
+ ProviderWorkflowEntity::class,
+ ProviderWorkflowPhaseEntity::class
],
- version = 66,
+ version = 72,
exportSchema = true // ← was false; schema JSON now tracked in version control
)
@TypeConverters(RoomEnumConverters::class)
@@@ -96,11 -94,12 +102,16 @@@ abstract class StreamVaultDatabase : Ro
abstract fun xtreamContentIndexDao(): XtreamContentIndexDao
abstract fun xtreamIndexJobDao(): XtreamIndexJobDao
abstract fun xtreamLiveOnboardingDao(): XtreamLiveOnboardingDao
+ abstract fun stalkerIndexJobDao(): StalkerIndexJobDao
+ abstract fun stalkerPortalStateDao(): StalkerPortalStateDao
+ abstract fun stalkerRemoteIdentityDao(): StalkerRemoteIdentityDao
+ abstract fun stalkerDiscoveryStageDao(): StalkerDiscoveryStageDao
abstract fun downloadDao(): DownloadDao
+ abstract fun providerDeletionCleanupDao(): ProviderDeletionCleanupDao
+ abstract fun pluginProviderOwnershipDao(): PluginProviderOwnershipDao
+ abstract fun providerConfigRevisionDao(): ProviderConfigRevisionDao
+ abstract fun backupRestoreCheckpointDao(): BackupRestoreCheckpointDao
+ abstract fun providerWorkflowDao(): ProviderWorkflowDao
companion object {
/**
@@@ -2716,309 -2715,279 +2727,498 @@@
val MIGRATION_62_63 = object : Migration(62, 63) {
override fun migrate(database: SupportSQLiteDatabase) {
+ addColumnIfMissing(
+ database,
+ tableName = "providers",
+ columnName = "stalker_catalog_mode",
+ columnDefinition = "TEXT NOT NULL DEFAULT 'ON_DEMAND'"
+ )
+ database.execSQL(
+ """
+ CREATE TABLE IF NOT EXISTS stalker_index_jobs (
+ provider_id INTEGER NOT NULL,
+ section TEXT NOT NULL,
+ state TEXT NOT NULL DEFAULT 'DISABLED',
+ total_categories INTEGER NOT NULL DEFAULT 0,
+ completed_categories INTEGER NOT NULL DEFAULT 0,
+ next_category_index INTEGER NOT NULL DEFAULT 0,
+ failed_categories INTEGER NOT NULL DEFAULT 0,
+ indexed_rows INTEGER NOT NULL DEFAULT 0,
+ skipped_malformed_rows INTEGER NOT NULL DEFAULT 0,
+ deleted_pruned_rows INTEGER NOT NULL DEFAULT 0,
+ last_error TEXT,
+ last_attempt_at INTEGER NOT NULL DEFAULT 0,
+ last_success_at INTEGER NOT NULL DEFAULT 0,
+ updated_at INTEGER NOT NULL DEFAULT 0,
+ PRIMARY KEY(provider_id, section),
+ FOREIGN KEY(provider_id) REFERENCES providers(id) ON UPDATE NO ACTION ON DELETE CASCADE
+ )
+ """.trimIndent()
+ )
+ database.execSQL("CREATE INDEX IF NOT EXISTS index_stalker_index_jobs_provider_id ON stalker_index_jobs(provider_id)")
+ database.execSQL("CREATE INDEX IF NOT EXISTS index_stalker_index_jobs_state ON stalker_index_jobs(state)")
+ database.execSQL("CREATE INDEX IF NOT EXISTS index_stalker_index_jobs_updated_at ON stalker_index_jobs(updated_at)")
+ database.execSQL(
+ """
+ INSERT OR REPLACE INTO stalker_index_jobs (
+ provider_id, section, state, total_categories, completed_categories,
+ next_category_index, failed_categories, indexed_rows, skipped_malformed_rows,
+ deleted_pruned_rows, last_error,
+ last_attempt_at, last_success_at, updated_at
+ )
+ SELECT j.provider_id, j.section, 'DISABLED', j.total_categories, j.completed_categories,
+ j.next_category_index, j.failed_categories, j.indexed_rows, j.skipped_malformed_rows,
+ j.deleted_pruned_rows, j.last_error,
+ j.last_attempt_at, j.last_success_at, j.updated_at
+ FROM xtream_index_jobs j
+ INNER JOIN providers p ON p.id = j.provider_id
+ WHERE p.type = 'STALKER_PORTAL' AND j.section IN ('MOVIE', 'SERIES')
+ """.trimIndent()
+ )
+ database.execSQL(
+ "DELETE FROM xtream_index_jobs WHERE provider_id IN (SELECT id FROM providers WHERE type = 'STALKER_PORTAL')"
+ )
+ database.execSQL(
+ """
+ CREATE TABLE IF NOT EXISTS stalker_portal_state (
+ 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 DEFAULT 2,
+ stress_cooldown_until INTEGER NOT NULL DEFAULT 0,
+ endpoint_health_json TEXT NOT NULL DEFAULT '{}',
+ endpoint_failed_until INTEGER NOT NULL DEFAULT 0,
+ validated_at INTEGER NOT NULL DEFAULT 0,
+ schema_version INTEGER NOT NULL DEFAULT 1,
+ PRIMARY KEY(provider_id),
+ FOREIGN KEY(provider_id) REFERENCES providers(id) ON UPDATE NO ACTION ON DELETE CASCADE
+ )
+ """.trimIndent()
+ )
+ database.execSQL("CREATE UNIQUE INDEX IF NOT EXISTS index_stalker_portal_state_provider_id ON stalker_portal_state(provider_id)")
+ database.execSQL(
+ """
+ CREATE TABLE IF NOT EXISTS stalker_remote_identities (
+ 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
+ )
+ """.trimIndent()
+ )
+ database.execSQL("CREATE INDEX IF NOT EXISTS index_stalker_remote_identities_provider_id ON stalker_remote_identities(provider_id)")
+ database.execSQL("CREATE UNIQUE INDEX IF NOT EXISTS index_stalker_remote_identities_provider_id_content_type_surrogate_id ON stalker_remote_identities(provider_id, content_type, surrogate_id)")
+ database.execSQL("""CREATE TABLE IF NOT EXISTS provider_deletion_cleanup (
+ id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
+ provider_id INTEGER NOT NULL,
+ action TEXT NOT NULL,
+ target_id TEXT NOT NULL DEFAULT '',
+ created_at INTEGER NOT NULL,
+ attempt_count INTEGER NOT NULL DEFAULT 0,
+ last_error TEXT
+ )""")
+ database.execSQL("CREATE UNIQUE INDEX IF NOT EXISTS index_provider_deletion_cleanup_provider_id_action_target_id ON provider_deletion_cleanup(provider_id, action, target_id)")
+ validateForeignKeys(database, "providers", "stalker_index_jobs", "stalker_portal_state", "stalker_remote_identities")
}
}
- /** Migration 63 -> 64: records immutable ownership for plugin-created M3U providers. */
val MIGRATION_63_64 = object : Migration(63, 64) {
override fun migrate(database: SupportSQLiteDatabase) {
+ addColumnIfMissing(database, "providers", "stalker_protocol_preference", "TEXT NOT NULL DEFAULT 'AUTO'")
+ addColumnIfMissing(database, "providers", "stalker_requested_profile_id", "TEXT NOT NULL DEFAULT 'auto'")
+ addColumnIfMissing(database, "providers", "stalker_learned_profile_id", "TEXT NOT NULL DEFAULT ''")
+ addColumnIfMissing(database, "providers", "stalker_profile_revision", "INTEGER NOT NULL DEFAULT 0")
+ addColumnIfMissing(database, "providers", "stalker_profile_verification", "TEXT NOT NULL DEFAULT 'UNVERIFIED'")
+ addColumnIfMissing(database, "providers", "stalker_protocol_family", "TEXT NOT NULL DEFAULT 'CLASSIC_MAG'")
+ database.execSQL(
+ """
+ UPDATE providers SET stalker_requested_profile_id = CASE stalker_mag_preset
+ WHEN 'MAG250_LEGACY' THEN 'classic.mag250.legacy'
+ WHEN 'MAG254_STRICT' THEN 'classic.mag254.strict'
+ WHEN 'MINISTRA_MODERN' THEN 'classic.mag322.modern'
+ ELSE 'classic.mag250.generic'
+ END,
+ stalker_learned_profile_id = CASE stalker_mag_preset
+ WHEN 'MAG250_LEGACY' THEN 'classic.mag250.legacy'
+ WHEN 'MAG254_STRICT' THEN 'classic.mag254.strict'
+ WHEN 'MINISTRA_MODERN' THEN 'classic.mag322.modern'
+ ELSE 'classic.mag250.generic'
+ END,
+ stalker_profile_revision = 1,
+ stalker_profile_verification = 'VERIFIED'
+ WHERE type = 'STALKER_PORTAL'
+ """.trimIndent()
+ )
+ database.execSQL("""CREATE TABLE IF NOT EXISTS plugin_provider_ownership (
+ package_name TEXT NOT NULL,
+ service_class_name TEXT NOT NULL,
+ manifest_id TEXT NOT NULL,
+ provider_id INTEGER NOT NULL,
+ created_at INTEGER NOT NULL,
+ PRIMARY KEY(package_name, service_class_name, manifest_id),
+ FOREIGN KEY(provider_id) REFERENCES providers(id) ON UPDATE NO ACTION ON DELETE CASCADE
+ )""")
+ database.execSQL("CREATE UNIQUE INDEX IF NOT EXISTS index_plugin_provider_ownership_provider_id ON plugin_provider_ownership(provider_id)")
- validateForeignKeys(database, "plugin_provider_ownership")
+ validateForeignKeys(database, "providers")
}
}
- /** Migration 64 -> 65: make already-persisted Jellyfin image URLs account scoped. */
val MIGRATION_64_65 = object : Migration(64, 65) {
override fun migrate(database: SupportSQLiteDatabase) {
+ addColumnIfMissing(
+ database,
+ "providers",
+ "stalker_transport_mode",
+ "TEXT NOT NULL DEFAULT 'AUTO_STRICT'"
+ )
+ addColumnIfMissing(
+ database,
+ "providers",
+ "stalker_transport_origin",
+ "TEXT NOT NULL DEFAULT ''"
+ )
+ addColumnIfMissing(
+ database,
+ "providers",
+ "stalker_tls_spki_sha256",
+ "TEXT NOT NULL DEFAULT ''"
+ )
+ addColumnIfMissing(
+ database,
+ "providers",
+ "stalker_transport_consent_at",
+ "INTEGER NOT NULL DEFAULT 0"
+ )
+ addColumnIfMissing(
+ database,
+ "providers",
+ "stalker_configuration_generation",
+ "INTEGER NOT NULL DEFAULT 0"
+ )
+ addColumnIfMissing(
+ database,
+ "providers",
+ "stalker_discovery_summary",
+ "TEXT NOT NULL DEFAULT ''"
+ )
+ addColumnIfMissing(
+ database,
+ "providers",
+ "stalker_capabilities_json",
+ "TEXT NOT NULL DEFAULT ''"
+ )
+ database.execSQL(
+ """
+ CREATE TABLE IF NOT EXISTS stalker_discovery_staging (
+ discovery_id TEXT NOT NULL PRIMARY KEY,
+ 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
+ )
+ """.trimIndent()
+ )
+ database.execSQL(
+ "CREATE INDEX IF NOT EXISTS index_stalker_discovery_staging_provider_id ON stalker_discovery_staging(provider_id)"
+ )
+ database.execSQL(
+ "CREATE INDEX IF NOT EXISTS index_stalker_discovery_staging_created_at ON stalker_discovery_staging(created_at)"
+ )
+ // Existing installs used a global trust-all client. They deliberately migrate to
+ // strict verification and must consent in the foreground if their portal needs
+ // HTTP or invalid TLS.
+ database.execSQL(
+ """
+ UPDATE providers
+ SET stalker_transport_mode = 'AUTO_STRICT',
+ stalker_transport_origin = '',
+ stalker_tls_spki_sha256 = '',
+ stalker_transport_consent_at = 0
+ WHERE type = 'STALKER_PORTAL'
+ """.trimIndent()
+ )
+ database.execSQL(
+ """
+ UPDATE providers
+ SET status = 'PARTIAL',
+ is_active = 0
+ WHERE type = 'STALKER_PORTAL'
+ AND lower(server_url) LIKE 'http://%'
+ """.trimIndent()
+ )
+ listOf(
+ imageUrlMigrationSql("movies", "poster_url"),
+ imageUrlMigrationSql("movies", "backdrop_url"),
+ imageUrlMigrationSql("series", "poster_url"),
+ imageUrlMigrationSql("series", "backdrop_url"),
+ imageUrlMigrationSql("episodes", "cover_url")
+ ).forEach(database::execSQL)
+ validateForeignKeys(database, "providers")
}
}
- /** Migration 65 -> 66: distinguish schedules that exist from schedules armed in AlarmManager. */
val MIGRATION_65_66 = object : Migration(65, 66) {
override fun migrate(database: SupportSQLiteDatabase) {
+ addColumnIfMissing(
+ database,
+ "providers",
+ "catalog_layout",
+ "TEXT NOT NULL DEFAULT 'SPLIT'"
+ )
+ addColumnIfMissing(
+ database,
+ "providers",
+ "catalog_layout_detection_version",
+ "INTEGER NOT NULL DEFAULT 0"
+ )
+ addColumnIfMissing(
+ database,
+ "categories",
+ "provider_order",
+ "INTEGER NOT NULL DEFAULT 0"
+ )
+ addColumnIfMissing(
+ database,
+ "category_import_stage",
+ "provider_order",
+ "INTEGER NOT NULL DEFAULT 0"
+ )
+ addColumnIfMissing(
+ database,
+ "series",
+ "catalog_origin",
+ "TEXT NOT NULL DEFAULT 'NATIVE'"
+ )
+ addColumnIfMissing(
+ database,
+ "series",
+ "episode_playback_template_url",
+ "TEXT"
+ )
+ database.execSQL(
+ """
+ CREATE TABLE IF NOT EXISTS vod_category_hydration (
+ provider_id INTEGER NOT NULL,
+ category_id INTEGER NOT NULL,
+ last_loaded_page INTEGER NOT NULL DEFAULT 0,
+ last_attempted_page INTEGER NOT NULL DEFAULT 0,
+ last_successful_page INTEGER NOT NULL DEFAULT 0,
+ total_pages INTEGER NOT NULL DEFAULT 0,
+ page_size INTEGER NOT NULL DEFAULT 0,
+ item_count INTEGER NOT NULL DEFAULT 0,
+ is_complete INTEGER NOT NULL DEFAULT 0,
+ has_movies INTEGER NOT NULL DEFAULT 0,
+ has_series INTEGER NOT NULL DEFAULT 0,
+ last_hydrated_at INTEGER NOT NULL DEFAULT 0,
+ last_status TEXT NOT NULL DEFAULT 'IDLE',
+ last_error TEXT,
+ retry_after_ms INTEGER NOT NULL DEFAULT 0,
+ failure_count INTEGER NOT NULL DEFAULT 0,
+ retry_budget_remaining INTEGER NOT NULL DEFAULT 3,
+ last_page_fingerprint TEXT,
+ PRIMARY KEY(provider_id, category_id),
+ FOREIGN KEY(provider_id) REFERENCES providers(id) ON UPDATE NO ACTION ON DELETE CASCADE
+ )
+ """.trimIndent()
+ )
+ database.execSQL(
+ "CREATE INDEX IF NOT EXISTS index_vod_category_hydration_provider_id ON vod_category_hydration(provider_id)"
+ )
+ database.execSQL(
+ """
+ CREATE TABLE IF NOT EXISTS vod_catalog_entries (
+ 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
+ )
+ """.trimIndent()
+ )
+ database.execSQL("CREATE INDEX IF NOT EXISTS index_vod_catalog_entries_provider_id ON vod_catalog_entries(provider_id)")
+ database.execSQL("CREATE INDEX IF NOT EXISTS index_vod_catalog_entries_provider_id_category_id_raw_page_raw_index ON vod_catalog_entries(provider_id, category_id, raw_page, raw_index)")
+ database.execSQL("CREATE INDEX IF NOT EXISTS index_vod_catalog_entries_provider_id_item_type_target_id ON vod_catalog_entries(provider_id, item_type, target_id)")
+ addColumnIfMissing(
+ database,
+ tableName = "recording_runs",
+ columnName = "exact_alarm_armed",
+ columnDefinition = "INTEGER NOT NULL DEFAULT 1"
+ )
+ addColumnIfMissing(
+ database,
+ tableName = "program_reminders",
+ columnName = "exact_alarm_armed",
+ columnDefinition = "INTEGER NOT NULL DEFAULT 1"
+ )
+ validateForeignKeys(database, "providers", "vod_category_hydration", "vod_catalog_entries")
}
}
+ /** Migration 66 -> 67: retain candidate provider edits until they are atomically promoted. */
+ val MIGRATION_66_67 = object : Migration(66, 67) {
+ override fun migrate(database: SupportSQLiteDatabase) {
+ database.execSQL(
+ """
+ CREATE TABLE IF NOT EXISTS provider_config_revisions (
+ provider_id INTEGER NOT NULL,
+ revision INTEGER NOT NULL,
+ config_json TEXT NOT NULL,
+ state TEXT NOT NULL,
+ attempt_count INTEGER NOT NULL DEFAULT 0,
+ 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 DELETE CASCADE
+ )
+ """.trimIndent()
+ )
- database.execSQL(
- "CREATE INDEX IF NOT EXISTS index_provider_config_revisions_provider_id_state ON provider_config_revisions(provider_id, state)"
- )
++ database.execSQL("CREATE INDEX IF NOT EXISTS index_provider_config_revisions_provider_id_state ON provider_config_revisions(provider_id, state)")
+ validateForeignKeys(database, "provider_config_revisions")
+ }
+ }
+
+ /** Migration 67 -> 68: retain cross-store backup restore progress for safe retry. */
+ val MIGRATION_67_68 = object : Migration(67, 68) {
+ override fun migrate(database: SupportSQLiteDatabase) {
+ database.execSQL(
+ """
+ CREATE TABLE IF NOT EXISTS backup_restore_checkpoints (
+ restore_key TEXT NOT NULL,
+ room_complete INTEGER NOT NULL DEFAULT 0,
+ preferences_complete INTEGER NOT NULL DEFAULT 0,
+ presets_complete INTEGER NOT NULL DEFAULT 0,
+ schedules_complete INTEGER NOT NULL DEFAULT 0,
+ 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)
+ )
+ """.trimIndent()
+ )
+ }
+ }
+
+ /** Migration 68 -> 69: make active download ownership durable and reclaimable. */
+ val MIGRATION_68_69 = object : Migration(68, 69) {
+ override fun migrate(database: SupportSQLiteDatabase) {
- addColumnIfMissing(
- database,
- tableName = "downloads",
- columnName = "owner_id",
- columnDefinition = "TEXT"
- )
- addColumnIfMissing(
- database,
- tableName = "downloads",
- columnName = "owner_epoch",
- columnDefinition = "INTEGER NOT NULL DEFAULT 0"
- )
- addColumnIfMissing(
- database,
- tableName = "downloads",
- columnName = "heartbeat_at",
- columnDefinition = "INTEGER"
- )
++ addColumnIfMissing(database, "downloads", "owner_id", "TEXT")
++ addColumnIfMissing(database, "downloads", "owner_epoch", "INTEGER NOT NULL DEFAULT 0")
++ addColumnIfMissing(database, "downloads", "heartbeat_at", "INTEGER")
+ }
+ }
+
+ /** Migration 69 -> 70: make reminder delivery outcomes durable and recoverable. */
+ val MIGRATION_69_70 = object : Migration(69, 70) {
+ override fun migrate(database: SupportSQLiteDatabase) {
- addColumnIfMissing(
- database,
- tableName = "program_reminders",
- columnName = "delivery_state",
- columnDefinition = "TEXT NOT NULL DEFAULT 'PENDING'"
- )
- addColumnIfMissing(
- database,
- tableName = "program_reminders",
- columnName = "delivery_attempt_token",
- columnDefinition = "TEXT"
- )
- addColumnIfMissing(
- database,
- tableName = "program_reminders",
- columnName = "delivery_attempted_at",
- columnDefinition = "INTEGER"
- )
- addColumnIfMissing(
- database,
- tableName = "program_reminders",
- columnName = "delivery_attempt_count",
- columnDefinition = "INTEGER NOT NULL DEFAULT 0"
- )
- addColumnIfMissing(
- database,
- tableName = "program_reminders",
- columnName = "delivery_failure_reason",
- columnDefinition = "TEXT"
- )
++ addColumnIfMissing(database, "program_reminders", "delivery_state", "TEXT NOT NULL DEFAULT 'PENDING'")
++ addColumnIfMissing(database, "program_reminders", "delivery_attempt_token", "TEXT")
++ addColumnIfMissing(database, "program_reminders", "delivery_attempted_at", "INTEGER")
++ addColumnIfMissing(database, "program_reminders", "delivery_attempt_count", "INTEGER NOT NULL DEFAULT 0")
++ addColumnIfMissing(database, "program_reminders", "delivery_failure_reason", "TEXT")
+ database.execSQL(
+ """
+ UPDATE program_reminders
+ SET delivery_state = CASE
+ WHEN notified_at IS NOT NULL THEN 'DELIVERED'
+ WHEN is_dismissed = 1 THEN 'DISMISSED'
+ ELSE 'PENDING'
+ END
+ """.trimIndent()
+ )
+ }
+ }
+
+ /** Migration 70 -> 71: persist the provider workflow generation, lease, and phase ledger. */
+ val MIGRATION_70_71 = object : Migration(70, 71) {
+ override fun migrate(database: SupportSQLiteDatabase) {
+ database.execSQL(
+ """
+ CREATE TABLE IF NOT EXISTS provider_workflows (
+ 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
+ )
+ """.trimIndent()
+ )
- database.execSQL(
- "CREATE INDEX IF NOT EXISTS index_provider_workflows_state ON provider_workflows(state)"
- )
- database.execSQL(
- "CREATE INDEX IF NOT EXISTS index_provider_workflows_updated_at ON provider_workflows(updated_at)"
- )
- database.execSQL(
- "CREATE INDEX IF NOT EXISTS index_provider_workflows_lease_expires_at ON provider_workflows(lease_expires_at)"
- )
++ database.execSQL("CREATE INDEX IF NOT EXISTS index_provider_workflows_state ON provider_workflows(state)")
++ database.execSQL("CREATE INDEX IF NOT EXISTS index_provider_workflows_updated_at ON provider_workflows(updated_at)")
++ database.execSQL("CREATE INDEX IF NOT EXISTS index_provider_workflows_lease_expires_at ON provider_workflows(lease_expires_at)")
+ database.execSQL(
+ """
+ CREATE TABLE IF NOT EXISTS provider_workflow_phases (
+ 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
+ )
+ """.trimIndent()
+ )
- database.execSQL(
- "CREATE INDEX IF NOT EXISTS index_provider_workflow_phases_provider_id ON provider_workflow_phases(provider_id)"
- )
- database.execSQL(
- "CREATE INDEX IF NOT EXISTS index_provider_workflow_phases_state ON provider_workflow_phases(state)"
- )
- database.execSQL(
- "CREATE INDEX IF NOT EXISTS index_provider_workflow_phases_updated_at ON provider_workflow_phases(updated_at)"
- )
++ database.execSQL("CREATE INDEX IF NOT EXISTS index_provider_workflow_phases_provider_id ON provider_workflow_phases(provider_id)")
++ database.execSQL("CREATE INDEX IF NOT EXISTS index_provider_workflow_phases_state ON provider_workflow_phases(state)")
++ database.execSQL("CREATE INDEX IF NOT EXISTS index_provider_workflow_phases_updated_at ON provider_workflow_phases(updated_at)")
+ validateForeignKeys(database, "provider_workflows", "provider_workflow_phases")
+ }
+ }
+
- /**
- * Migration 71 -> 72: make the interpretation of offset-free XMLTV timestamps an
- * explicit property of the source. Existing sources require an offset until the user
- * deliberately selects UTC or an IANA timezone; they must never inherit device state.
- */
++ /** Migration 71 -> 72: make offset-free XMLTV timestamp handling explicit per source. */
+ val MIGRATION_71_72 = object : Migration(71, 72) {
+ override fun migrate(database: SupportSQLiteDatabase) {
- database.execSQL(
- "ALTER TABLE epg_sources ADD COLUMN timezone_policy TEXT NOT NULL DEFAULT 'REQUIRE_OFFSET'"
- )
- database.execSQL(
- "ALTER TABLE epg_sources ADD COLUMN timezone_id TEXT"
- )
++ addColumnIfMissing(database, "epg_sources", "timezone_policy", "TEXT NOT NULL DEFAULT 'REQUIRE_OFFSET'")
++ addColumnIfMissing(database, "epg_sources", "timezone_id", "TEXT")
+ }
+ }
+
+ private fun imageUrlMigrationSql(table: String, column: String): String = """
+ UPDATE $table SET $column = CASE
+ WHEN instr($column, 'streamvault_provider_id=') > 0 THEN $column
+ ELSE $column || CASE WHEN instr($column, '?') = 0 THEN '?streamvault_provider_id=' ELSE '&streamvault_provider_id=' END || provider_id
+ END
+ WHERE $column IS NOT NULL
+ AND provider_id IN (SELECT id FROM providers WHERE type = 'JELLYFIN')
+ """.trimIndent()
+
val MIGRATION_52_53 = object : Migration(52, 53) {
override fun migrate(database: SupportSQLiteDatabase) {
addStalkerHardeningColumns(database, "movie_category_hydration")
diff --cc data/src/main/java/com/streamvault/data/local/entity/Entities.kt
index ef2cc764,b1f988df..4dfb1454
--- a/data/src/main/java/com/streamvault/data/local/entity/Entities.kt
+++ b/data/src/main/java/com/streamvault/data/local/entity/Entities.kt
@@@ -23,12 -21,7 +23,13 @@@ import com.streamvault.domain.model.Sta
import com.streamvault.domain.model.StalkerPortalFingerprint
import com.streamvault.domain.model.StalkerPortalProfile
import com.streamvault.domain.model.ProviderXtreamLiveSyncMode
+import com.streamvault.domain.model.StalkerCatalogMode
+import com.streamvault.domain.model.StalkerCompatibilityProfileIds
+import com.streamvault.domain.model.StalkerProfileVerification
+import com.streamvault.domain.model.StalkerProtocolFamily
+import com.streamvault.domain.model.StalkerProtocolPreference
+import com.streamvault.domain.model.StalkerTransportMode
+ import com.streamvault.domain.model.XmltvTimezonePolicy
@Entity(
tableName = "providers",
diff --cc data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt
index 66a78000,c0167d53..774db35e
--- a/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt
+++ b/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt
@@@ -71,12 -79,13 +88,19 @@@ class ProviderRepositoryImpl @Inject co
private val recordingAlarmScheduler: RecordingAlarmScheduler,
private val programReminderAlarmScheduler: ProgramReminderAlarmScheduler,
private val jellyfinProvider: JellyfinProvider,
+ private val stalkerRemoteIdentityResolver: StalkerRemoteIdentityResolver,
+ private val stalkerIndexJobDao: StalkerIndexJobDao,
+ private val stalkerPortalStateStore: StalkerPortalStateStore,
+ private val movieCategoryHydrationDao: MovieCategoryHydrationDao,
+ private val seriesCategoryHydrationDao: SeriesCategoryHydrationDao,
- private val stalkerDiscoveryStageDao: StalkerDiscoveryStageDao? = null
++ private val stalkerDiscoveryStageDao: StalkerDiscoveryStageDao? = null,
+ private val providerDeletionCleanupDao: ProviderDeletionCleanupDao,
+ private val providerDeletionCleanupEnqueuer: ProviderDeletionCleanupEnqueuer,
+ private val providerConfigRevisionDao: ProviderConfigRevisionDao,
+ private val gson: Gson,
+ private val providerWorkflowRunner: ProviderWorkflowRunner,
+ private val providerWorkflowCommitFence: ProviderWorkflowCommitFence,
+ @param:ApplicationContext private val appContext: Context
) : ProviderRepository {
private companion object {
const val XTREAM_GUIDE_BATCH_CONCURRENCY = 4
@@@ -86,9 -95,8 +110,10 @@@
const val ALARM_STEP_WEIGHT = 5
const val PROVIDER_ROW_STEP_WEIGHT = 200
const val FINALIZE_STEP_WEIGHT = 200
+ const val STALKER_DISCOVERY_STAGE_TTL_MILLIS = 60L * 60L * 1000L
+ const val MANUAL_REFRESH_PRIORITY = 50
val logger: Logger = Logger.getLogger(ProviderRepositoryImpl::class.java.name)
+ val STALKER_URL_SCHEME_REGEX = Regex("^[a-zA-Z][a-zA-Z0-9+.-]*://")
}
private val repositoryScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
@@@ -344,8 -330,7 +391,8 @@@
)
return when (val authResult = provider.authenticate()) {
is Result.Success -> {
+ onProgress?.invoke("Profile accepted; catalog validated")
- val providerData = if (existingProvider != null) {
+ val onboardingTarget = if (existingProvider != null) {
onProgress?.invoke("Updating existing provider...")
val updated = authResult.data.copy(
id = existingProvider.id,
@@@ -382,23 -369,21 +431,26 @@@
status = ProviderStatus.PARTIAL
)
val newId = providerDao.insert(newData.toSecureEntity())
- newData.copy(id = newId).copy(password = "")
+ InitialOnboardingTarget(
+ providerData = newData.copy(id = newId, password = ""),
+ providerForSync = newData.copy(id = newId)
+ )
}
- if (providerData.stalkerCatalogMode == StalkerCatalogMode.ON_DEMAND) {
- stalkerIndexJobDao.disableForProvider(providerData.id, System.currentTimeMillis())
- syncManager.cancelStalkerIndexSync(providerData.id)
++ if (onboardingTarget.providerData.stalkerCatalogMode == StalkerCatalogMode.ON_DEMAND) {
++ stalkerIndexJobDao.disableForProvider(onboardingTarget.providerData.id, System.currentTimeMillis())
++ syncManager.cancelStalkerIndexSync(onboardingTarget.providerData.id)
+ }
+
handleInitialOnboardingSync(
- providerData = providerData,
- syncResult = syncManager.sync(
- providerData.id,
- force = false,
- onProgress = onProgress,
+ providerData = onboardingTarget.providerData,
+ syncResult = syncInitialOnboarding(
+ onboardingTarget,
+ onProgress,
trackInitialLiveOnboarding = true
),
- syncFailurePrefix = "Provider login succeeded, but initial sync failed. The provider was saved and can be retried from Settings"
+ syncFailurePrefix = "Provider login succeeded, but initial sync failed. The provider was saved and can be retried from Settings",
+ pendingEdit = onboardingTarget.pendingEdit
)
}
is Result.Error -> Result.error(authResult.message, authResult.exception)
@@@ -740,58 -705,14 +817,58 @@@
deviceId = normalizedDeviceId,
deviceId2 = normalizedDeviceId2,
signature = normalizedSignature,
- stalkerAdvancedOptionsJson = normalizedAdvancedOptionsJson
+ stalkerAdvancedOptionsJson = normalizedAdvancedOptionsJson,
+ protocolPreference = protocolPreference,
+ transportGrant = effectiveTransportGrant,
+ requestedProfileId = requestedProfileId,
+ requireCatalogValidation = requireLiveReadiness,
+ catalogLayoutHint = existingProvider?.catalogLayout
+ ?: com.streamvault.domain.model.CatalogLayout.UNKNOWN,
+ catalogLayoutDetectionVersionHint = 0,
+ onProgress = onProgress
)
- return when (val authResult = provider.authenticate()) {
+ var authenticatedProvider = discoveryProvider(requireLiveReadiness = true)
+ var authResult = authenticatedProvider.authenticate()
+ var acceptedWithoutVerification = false
+ val readinessWasInconclusive = (authResult as? Result.Error)?.exception
+ ?.let { failure ->
+ generateSequence(failure) { it.cause }
+ .filterIsInstance<StalkerApiError.ReadinessInconclusive>()
+ .firstOrNull()
+ }
+ if (saveWithoutVerification && readinessWasInconclusive != null) {
+ onProgress?.invoke("Authentication confirmed; saving with Live TV verification pending")
+ authenticatedProvider = discoveryProvider(requireLiveReadiness = false)
+ authResult = authenticatedProvider.authenticate()
+ acceptedWithoutVerification = authResult is Result.Success
+ }
+
+ return when (val finalAuthResult = authResult) {
is Result.Success -> {
+ val validatedSnapshot = authenticatedProvider.validatedAuthenticationSnapshot()
+ val discoverySummary = validatedSnapshot?.toSanitizedDiscoverySummary().orEmpty()
+ val capabilitySummary = validatedSnapshot?.second
+ ?.toSanitizedCapabilitySummary()
+ .orEmpty()
+ val discoveryId = UUID.randomUUID().toString()
+ val stagedAt = System.currentTimeMillis()
+ stalkerDiscoveryStageDao?.deleteOlderThan(
+ stagedAt - STALKER_DISCOVERY_STAGE_TTL_MILLIS
+ )
+ stalkerDiscoveryStageDao?.upsert(
+ StalkerDiscoveryStageEntity(
+ discoveryId = discoveryId,
+ providerId = existingProvider?.id,
+ configurationGeneration =
+ (existingProvider?.stalkerConfigurationGeneration ?: 0L) + 1L,
+ sanitizedSummary = discoverySummary,
+ createdAt = stagedAt
+ )
+ )
- val providerData = if (existingProvider != null) {
+ val onboardingTarget = if (existingProvider != null) {
onProgress?.invoke("Updating existing provider...")
- val updated = authResult.data.copy(
+ val updated = finalAuthResult.data.copy(
id = existingProvider.id,
name = normalizedName.ifBlank { existingProvider.name },
serverUrl = resolvedPortalUrl,
@@@ -833,21 -740,14 +910,22 @@@
lastSyncedAt = 0L,
createdAt = existingProvider.createdAt
)
- transactionRunner.inTransaction {
- providerDao.update(updated.toSecureEntity())
- validatedSnapshot?.let { (session, validatedProfile) ->
- stalkerPortalStateStore.recordAuthentication(
- providerId = updated.id,
- session = session,
- profile = validatedProfile
- )
- }
- stalkerDiscoveryStageDao?.delete(discoveryId)
++ validatedSnapshot?.let { (session, validatedProfile) ->
++ stalkerPortalStateStore.recordAuthentication(
++ providerId = updated.id,
++ session = session,
++ profile = validatedProfile
++ )
+ }
- updated.copy(password = "")
++ stalkerDiscoveryStageDao?.delete(discoveryId)
+ InitialOnboardingTarget(
+ providerData = updated.copy(password = ""),
+ providerForSync = updated,
+ pendingEdit = stageProviderEdit(updated)
+ )
} else {
- val newData = authResult.data.copy(
- name = normalizedName.ifBlank { authResult.data.name },
+ val newData = finalAuthResult.data.copy(
+ name = normalizedName.ifBlank { finalAuthResult.data.name },
serverUrl = resolvedPortalUrl,
username = normalizedUsername,
password = effectivePassword,
@@@ -883,93 -770,21 +961,98 @@@
isActive = false,
status = ProviderStatus.PARTIAL
)
- val newId = providerDao.insert(newData.toSecureEntity())
+ val newId = transactionRunner.inTransaction {
+ val insertedId = providerDao.insert(newData.toSecureEntity())
+ validatedSnapshot?.let { (session, validatedProfile) ->
+ stalkerPortalStateStore.recordAuthentication(
+ providerId = insertedId,
+ session = session,
+ profile = validatedProfile
+ )
+ }
+ stalkerDiscoveryStageDao?.delete(discoveryId)
+ insertedId
+ }
- newData.copy(id = newId).copy(password = "")
+ InitialOnboardingTarget(
+ providerData = newData.copy(id = newId, password = ""),
+ providerForSync = newData.copy(id = newId)
+ )
}
- handleInitialOnboardingSync(
- providerData = onboardingTarget.providerData,
- syncResult = syncInitialOnboarding(onboardingTarget, onProgress),
- syncFailurePrefix = "Provider login succeeded, but initial sync failed. The provider was saved and can be retried from Settings",
- pendingEdit = onboardingTarget.pendingEdit
- )
+ val onboardingResult = if (acceptedWithoutVerification) {
+ syncManager.scheduleProviderSyncResume(
- providerData.id,
- providerData.stalkerConfigurationGeneration
++ onboardingTarget.providerData.id,
++ onboardingTarget.providerData.stalkerConfigurationGeneration
+ )
+ val message =
+ "Provider saved with Live TV verification pending. It needs a successful sync before activation."
+ Result.error(
+ message,
+ ProviderSavedWithSyncErrorException(
- provider = providerData.copy(
++ provider = onboardingTarget.providerData.copy(
+ status = ProviderStatus.PARTIAL,
+ isActive = false
+ ),
+ message = message
+ )
+ )
+ } else {
+ handleInitialOnboardingSync(
- providerData = providerData,
- syncResult = syncManager.sync(providerData.id, force = false, onProgress = onProgress),
- syncFailurePrefix = "Provider login succeeded, but initial sync failed. The provider was saved and can be retried from Settings"
++ providerData = onboardingTarget.providerData,
++ syncResult = syncInitialOnboarding(onboardingTarget, onProgress),
++ syncFailurePrefix = "Provider login succeeded, but initial sync failed. The provider was saved and can be retried from Settings",
++ pendingEdit = onboardingTarget.pendingEdit
+ )
+ }
+ if (existingProvider != null && onboardingResult is Result.Error && !acceptedWithoutVerification) {
+ transactionRunner.inTransaction {
+ providerDao.update(existingProvider)
+ stalkerPortalStateStore.restore(existingProvider.id, previousPortalState)
+ }
+ Result.error(
+ "The new Stalker settings were not saved because initial readiness failed. The previous provider configuration is still active.",
+ onboardingResult.exception?.cause ?: onboardingResult.exception
+ )
+ } else {
+ onboardingResult
+ }
+ }
+ is Result.Error -> {
+ val consent = (finalAuthResult.exception as? StalkerApiError.TransportConsentRequired)
+ ?.let { StalkerTransportConsentRequiredException(it.challenge) }
+ if (consent != null) {
+ Result.error(consent.message.orEmpty(), consent)
+ } else if (finalAuthResult.exception is StalkerApiError.ReadinessInconclusive) {
+ val inconclusive = finalAuthResult.exception as StalkerApiError.ReadinessInconclusive
+ val required = StalkerReadinessInconclusiveException(
+ evidenceCode = inconclusive.evidenceCode,
+ message = "Authentication succeeded, but Live TV could not be verified. You can go back or save this provider with verification pending.",
+ cause = inconclusive
+ )
+ Result.error(required.message.orEmpty(), required)
+ } else if (!inputHasScheme && finalAuthResult.exception.isNonTlsTransportFailure()) {
+ val httpOrigin = "http://$normalizedPortalUrl".toStalkerOrigin()
+ if (httpOrigin != null) {
+ val challenge = StalkerTransportChallenge(
+ reason = StalkerTransportChallengeReason.CLEARTEXT_HTTP,
+ origin = httpOrigin,
+ displayHost = if (httpOrigin.port == 80) {
+ httpOrigin.host
+ } else {
+ "${httpOrigin.host}:${httpOrigin.port}"
+ },
+ detailCode = "HTTPS_UNAVAILABLE_HTTP_FALLBACK"
+ )
+ val required = StalkerTransportConsentRequiredException(challenge)
+ Result.error(required.message.orEmpty(), required)
+ } else {
+ Result.error(finalAuthResult.message, finalAuthResult.exception)
+ }
+ } else {
+ Result.error(finalAuthResult.message, finalAuthResult.exception)
+ }
++
}
- is Result.Error -> Result.error(authResult.message, authResult.exception)
is Result.Loading -> Result.error("Unexpected loading state")
}
}
@@@ -1054,12 -1015,16 +1288,20 @@@
epgSyncModeOverride: ProviderEpgSyncMode?,
onProgress: ((String) -> Unit)?
): Result<Unit> {
+ if (force && providerDao.getById(providerId)?.type == ProviderType.STALKER_PORTAL) {
+ stalkerPortalStateStore.invalidateCapabilities(providerId)
+ providerDao.invalidateCatalogLayoutDetection(providerId)
+ }
- return when (
- val syncResult = syncManager.sync(
+ var syncResult: Result<Unit>? = null
+ val disposition = providerWorkflowRunner.execute(
+ providerId = providerId,
+ phase = ProviderWorkflowPhase.PRIMARY_CATALOG,
+ reason = ProviderWorkflowReason.MANUAL,
+ force = force,
+ supersede = force,
+ priority = MANUAL_REFRESH_PRIORITY
+ ) {
+ val result = syncManager.sync(
providerId,
force = force,
movieFastSyncOverride = movieFastSyncOverride,
diff --cc data/src/main/java/com/streamvault/data/sync/StalkerIndexWorker.kt
index 8881ea84,4ac4b459..0861c4ac
--- a/data/src/main/java/com/streamvault/data/sync/StalkerIndexWorker.kt
+++ b/data/src/main/java/com/streamvault/data/sync/StalkerIndexWorker.kt
@@@ -25,14 -23,7 +24,13 @@@ import dagger.hilt.android.EntryPointAc
import dagger.hilt.components.SingletonComponent
import java.io.IOException
import java.util.concurrent.TimeUnit
- import kotlinx.coroutines.CancellationException
+internal fun stalkerIndexExistingWorkPolicy(force: Boolean, appendSuccessor: Boolean): ExistingWorkPolicy = when {
+ force -> ExistingWorkPolicy.REPLACE
+ appendSuccessor -> ExistingWorkPolicy.APPEND_OR_REPLACE
+ else -> ExistingWorkPolicy.KEEP
+}
+
class StalkerIndexWorker(
appContext: Context,
workerParams: WorkerParameters
@@@ -171,22 -155,12 +163,18 @@@
.build()
WorkManager.getInstance(context).enqueueUniqueWork(
- uniqueWorkName(providerId),
+ providerWorkUniqueName(providerId),
- providerWorkExistingPolicy(supersede = false),
+ stalkerIndexExistingWorkPolicy(force, appendSuccessor),
request
)
}
+ fun cancel(context: Context, providerId: Long) {
- if (providerId <= 0L) return
- val workManager = WorkManager.getInstance(context)
- workManager.cancelUniqueWork(uniqueWorkName(providerId))
- // Names used by older builds had a section suffix.
- workManager.cancelUniqueWork("$UNIQUE_WORK_PREFIX$providerId-")
- workManager.cancelUniqueWork("$UNIQUE_WORK_PREFIX$providerId-MOVIE")
- workManager.cancelUniqueWork("$UNIQUE_WORK_PREFIX$providerId-SERIES")
++ if (providerId > 0L) {
++ WorkManager.getInstance(context).cancelUniqueWork(providerWorkUniqueName(providerId))
++ }
+ }
+
private fun defaultConstraints(): Constraints = Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.setRequiresBatteryNotLow(true)
diff --cc data/src/main/java/com/streamvault/data/sync/SyncManager.kt
index a70a021b,f20eb611..2319a237
--- a/data/src/main/java/com/streamvault/data/sync/SyncManager.kt
+++ b/data/src/main/java/com/streamvault/data/sync/SyncManager.kt
@@@ -11,12 -11,10 +11,13 @@@ import com.streamvault.data.local.dao.M
import com.streamvault.data.local.dao.MovieDao
import com.streamvault.data.local.dao.ProgramDao
import com.streamvault.data.local.dao.ProviderDao
+ import com.streamvault.data.local.dao.ProviderWorkflowDao
import com.streamvault.data.local.dao.SeriesCategoryHydrationDao
import com.streamvault.data.local.dao.SeriesDao
+import com.streamvault.data.local.dao.StalkerIndexJobDao
import com.streamvault.data.local.dao.TmdbIdentityDao
+import com.streamvault.data.local.dao.VodCategoryHydrationDao
+import com.streamvault.data.local.dao.VodCatalogEntryDao
import com.streamvault.data.local.dao.XtreamContentIndexDao
import com.streamvault.data.local.dao.XtreamIndexJobDao
import com.streamvault.data.local.dao.XtreamLiveOnboardingDao
@@@ -37,19 -32,15 +38,23 @@@ import com.streamvault.data.parser.M3uP
import com.streamvault.data.remote.http.buildAppRequestProfile
import com.streamvault.data.remote.http.toGenericRequestProfile
import com.streamvault.data.remote.stalker.StalkerApiService
+import com.streamvault.data.remote.stalker.StalkerApiError
import com.streamvault.data.remote.stalker.StalkerPlaybackMode
import com.streamvault.data.remote.stalker.StalkerProvider
+import com.streamvault.data.remote.stalker.StalkerVodCatalogItem
+import com.streamvault.data.remote.stalker.StalkerRemoteIdentityResolver
+import com.streamvault.data.remote.stalker.StalkerRequestCoordinator
+import com.streamvault.data.remote.stalker.StalkerRequestDescriptor
+import com.streamvault.data.remote.stalker.StalkerResponseMetrics
+import com.streamvault.data.remote.stalker.StalkerPortalStateStore
import com.streamvault.data.remote.stalker.StalkerProviderProfile
import com.streamvault.data.remote.jellyfin.JellyfinProvider
+ import com.streamvault.data.remote.jellyfin.JellyfinCatalogLimitException
+ import com.streamvault.data.remote.jellyfin.JellyfinItemLimitException
+ import com.streamvault.data.remote.jellyfin.JellyfinPaginationException
+ import com.streamvault.data.remote.jellyfin.JellyfinResponseTooLargeException
import com.streamvault.data.remote.stalker.StalkerTrafficCoordinator
+import com.streamvault.data.remote.stalker.StalkerTelemetry
import com.streamvault.data.remote.dto.XtreamCategory
import com.streamvault.data.remote.dto.XtreamSeriesItem
import com.streamvault.data.remote.dto.XtreamStream
@@@ -64,9 -55,9 +69,10 @@@ import com.streamvault.data.remote.xtre
import com.streamvault.data.remote.xtream.XtreamUrlFactory
import com.streamvault.data.security.CredentialCrypto
import com.streamvault.data.util.AdultContentClassifier
+ import com.streamvault.data.util.runSuspendCatching
import com.streamvault.data.util.UrlSecurityPolicy
import com.streamvault.domain.model.Channel
+import com.streamvault.domain.model.CatalogLayout
import com.streamvault.domain.model.GuideSourcePolicy
import com.streamvault.domain.model.ContentType
import com.streamvault.domain.model.Movie
@@@ -94,18 -78,19 +100,20 @@@ import dagger.hilt.android.qualifiers.A
import kotlinx.coroutines.async
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.CancellationException
+ import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.isActive
+import kotlinx.coroutines.launch
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.withContext
+ import kotlin.coroutines.coroutineContext
import kotlinx.coroutines.sync.Mutex
-import kotlinx.coroutines.sync.Semaphore
import kotlinx.coroutines.sync.withLock
-import kotlinx.coroutines.sync.withPermit
import kotlinx.serialization.json.Json
import okhttp3.OkHttpClient
import okhttp3.Request
@@@ -235,10 -219,8 +259,12 @@@ class SyncManager @Inject constructor
private val transactionRunner: DatabaseTransactionRunner,
private val preferencesRepository: com.streamvault.data.preferences.PreferencesRepository,
private val syncProgressBus: SyncProgressBus,
+ private val stalkerRemoteIdentityResolver: StalkerRemoteIdentityResolver,
+ private val stalkerRequestCoordinator: StalkerRequestCoordinator,
+ private val stalkerPortalStateStore: StalkerPortalStateStore,
- private val stalkerReadinessTracker: StalkerReadinessTracker
++ private val stalkerReadinessTracker: StalkerReadinessTracker,
+ private val providerWorkflowCommitFence: ProviderWorkflowCommitFence,
+ private val providerWorkflowDao: ProviderWorkflowDao? = null
) {
private val syncStateTracker = SyncStateTracker()
private val syncErrorSanitizer = SyncErrorSanitizer()
@@@ -271,350 -254,9 +298,351 @@@
)
val syncState: StateFlow<SyncState> = syncStateTracker.aggregateState
val syncStatesByProvider: StateFlow<Map<Long, SyncState>> = syncStateTracker.statesByProvider
+ private val providerSyncMutexes = ConcurrentHashMap<Long, Mutex>()
+ private val providerStalkerSummaryMutexes = ConcurrentHashMap<Long, Mutex>()
+ private val providerStalkerIndexSectionMutexes = ConcurrentHashMap<String, Mutex>()
+ private val providerVodCategoryMutexes = ConcurrentHashMap<String, Mutex>()
+ private val providerEpgMutexes = ConcurrentHashMap<Long, Mutex>()
+ private val syncAdmissionMutex = Mutex()
+
+ suspend fun hydrateUnifiedVodCategory(
+ providerId: Long,
+ categoryId: Long,
+ request: com.streamvault.domain.model.VodCategoryHydrationRequest
+ ): Result<Unit> {
+ val requestedPage = if (request == com.streamvault.domain.model.VodCategoryHydrationRequest.NEXT_PAGE) {
+ ((vodCategoryHydrationDao.get(providerId, categoryId)?.lastSuccessfulPage ?: 0) + 1).coerceAtLeast(1)
+ } else {
+ null
+ }
+ val lock = providerVodCategoryMutexes.computeIfAbsent("$providerId:$categoryId") { Mutex() }
+ return lock.withLock {
+ val providerEntity = providerDao.getById(providerId)
+ ?: return@withLock Result.error("Provider not found")
+ if (providerEntity.type != ProviderType.STALKER_PORTAL) {
+ return@withLock Result.success(Unit)
+ }
+ val current = vodCategoryHydrationDao.get(providerId, categoryId)
+ if (current?.isComplete == true ||
+ (requestedPage != null && current != null && current.lastSuccessfulPage >= requestedPage) ||
+ (request == com.streamvault.domain.model.VodCategoryHydrationRequest.OPEN &&
+ (current?.lastSuccessfulPage ?: 0) > 0)
+ ) {
+ return@withLock Result.success(Unit)
+ }
+
+ val api = createStalkerSyncProvider(providerEntity.toDomain())
+ var hydration = current
+ var nextPage = ((current?.lastSuccessfulPage ?: 0) + 1).coerceAtLeast(1)
+ while (true) {
+ val attemptAt = System.currentTimeMillis()
+ vodCategoryHydrationDao.upsert(
+ (hydration ?: VodCategoryHydrationEntity(providerId, categoryId)).copy(
+ lastAttemptedPage = nextPage,
+ lastStatus = "RUNNING",
+ lastError = null
+ )
+ )
+ when (val pageResult = api.getUnifiedVodPage(categoryId, nextPage)) {
+ is Result.Success -> {
+ val page = pageResult.data
+ val category = categoryDao.getByProviderAndTypeSync(providerId, ContentType.VOD.name)
+ .firstOrNull { it.categoryId == categoryId }
+ val protected = category?.isUserProtected == true
+ val movies = page.items.mapNotNull { entry ->
+ (entry.item as? VodCatalogItem.MovieItem)?.movie
+ ?.copy(isUserProtected = protected)
+ ?.toEntity()
+ }
+ val series = page.items.mapNotNull { entry ->
+ (entry.item as? VodCatalogItem.SeriesItem)?.series
+ ?.copy(isUserProtected = protected)
+ ?.toEntity()
+ }
+ val entries = page.items.mapIndexed { rawIndex, entry ->
+ when (val item = entry.item) {
+ is VodCatalogItem.MovieItem -> VodCatalogEntryEntity(
+ providerId = providerId,
+ categoryId = categoryId,
+ rawItemId = entry.rawItemId,
+ itemType = ContentType.MOVIE,
+ targetId = item.movie.streamId,
+ rawPage = page.page,
+ rawIndex = rawIndex
+ )
+ is VodCatalogItem.SeriesItem -> VodCatalogEntryEntity(
+ providerId = providerId,
+ categoryId = categoryId,
+ rawItemId = entry.rawItemId,
+ itemType = ContentType.SERIES,
+ targetId = item.series.seriesId,
+ rawPage = page.page,
+ rawIndex = rawIndex
+ )
+ }
+ }
+ transactionRunner.inTransaction {
+ movieDao.upsertCategoryPage(providerId, movies)
+ seriesDao.upsertCategoryPage(providerId, series)
+ vodCatalogEntryDao.replacePage(providerId, categoryId, page.page, entries)
+ val persistedCount = vodCatalogEntryDao.countByCategory(providerId, categoryId)
+ hydration = VodCategoryHydrationEntity(
+ providerId = providerId,
+ categoryId = categoryId,
+ lastLoadedPage = page.page,
+ lastAttemptedPage = page.page,
+ lastSuccessfulPage = page.page,
+ totalPages = page.totalPages,
+ pageSize = page.pageSize,
+ itemCount = persistedCount,
+ isComplete = page.isComplete,
+ hasMovies = (hydration?.hasMovies == true) || movies.isNotEmpty(),
+ hasSeries = (hydration?.hasSeries == true) || series.isNotEmpty(),
+ lastHydratedAt = attemptAt,
+ lastStatus = if (page.isTruncated) "TRUNCATED" else "SUCCESS",
+ lastError = page.terminationReason,
+ retryAfterMs = 0L,
+ failureCount = 0,
+ retryBudgetRemaining = STALKER_CATEGORY_RETRY_BUDGET,
+ lastPageFingerprint = entries.joinToString("|") { it.rawItemId }.takeIf(String::isNotEmpty)
+ )
+ vodCategoryHydrationDao.upsert(hydration!!)
+ }
+ if (page.isTruncated) return@withLock Result.error(page.terminationReason ?: "VOD response was truncated")
+ if (page.isComplete) return@withLock Result.success(Unit)
+ if (request != com.streamvault.domain.model.VodCategoryHydrationRequest.COMPLETE) {
+ return@withLock Result.success(Unit)
+ }
+ nextPage = page.page + 1
+ }
+ is Result.Error -> {
+ val prior = hydration ?: VodCategoryHydrationEntity(providerId, categoryId)
+ hydration = prior.copy(
+ lastAttemptedPage = nextPage,
+ lastStatus = "FAILED_RETRYABLE",
+ lastError = pageResult.message,
+ failureCount = prior.failureCount + 1,
+ retryBudgetRemaining = (prior.retryBudgetRemaining - 1).coerceAtLeast(0)
+ )
+ vodCategoryHydrationDao.upsert(hydration!!)
+ return@withLock Result.error(pageResult.message, pageResult.exception)
+ }
+ Result.Loading -> return@withLock Result.error("VOD hydration did not complete")
+ }
+ }
+ @Suppress("UNREACHABLE_CODE")
+ Result.success(Unit)
+ }
+ }
+
+ suspend fun hydrateSplitVodCategory(
+ providerId: Long,
+ movieCategoryId: Long,
+ request: com.streamvault.domain.model.VodCategoryHydrationRequest,
+ requestedProjection: ContentType = ContentType.MOVIE
+ ): Result<Unit> {
+ val requestedPage = if (request == com.streamvault.domain.model.VodCategoryHydrationRequest.NEXT_PAGE) {
+ ((movieCategoryHydrationDao.get(providerId, movieCategoryId)?.lastSuccessfulPage ?: 0) + 1)
+ .coerceAtLeast(1)
+ } else {
+ null
+ }
+ val lock = providerVodCategoryMutexes.computeIfAbsent("split:$providerId:$movieCategoryId") { Mutex() }
+ return lock.withLock {
+ val providerEntity = providerDao.getById(providerId)
+ ?: return@withLock Result.error("Provider not found")
+ if (providerEntity.type != ProviderType.STALKER_PORTAL || providerEntity.catalogLayout != CatalogLayout.SPLIT) {
+ return@withLock Result.success(Unit)
+ }
+ var hydration = movieCategoryHydrationDao.get(providerId, movieCategoryId)
+ var movieCount = movieDao.getCountByCategory(providerId, movieCategoryId).first()
+ if (hydration?.isComplete == true ||
+ (requestedPage != null && hydration != null && hydration.lastSuccessfulPage >= requestedPage) ||
+ (request == com.streamvault.domain.model.VodCategoryHydrationRequest.OPEN &&
+ (hydration?.lastSuccessfulPage ?: 0) > 0)
+ ) {
+ return@withLock Result.success(Unit)
+ }
+ val api = createStalkerSyncProvider(providerEntity.toDomain())
+ val movieCategory = categoryDao.getByProviderAndTypeSync(providerId, ContentType.MOVIE.name)
+ .firstOrNull { it.categoryId == movieCategoryId }
+ ?: return@withLock Result.error("Movie category not found")
+ // Populate the provider's category identity cache before translating it to Series.
+ api.getVodCategories()
+ val seriesCategoryId = api.projectVodCategoryToSeries(movieCategoryId)
+ ?: return@withLock Result.error("Unable to resolve VOD-derived Series category")
+ val initialProjectionCount = when (requestedProjection) {
+ ContentType.SERIES -> seriesDao.getCountByCategory(providerId, seriesCategoryId).first()
+ else -> movieCount
+ }
+ var nextPage = ((hydration?.lastSuccessfulPage ?: 0) + 1).coerceAtLeast(1)
+ while (true) {
+ val attemptAt = System.currentTimeMillis()
+ movieCategoryHydrationDao.upsert(
+ (hydration ?: com.streamvault.data.local.entity.MovieCategoryHydrationEntity(
+ providerId,
+ movieCategoryId
+ )).copy(
+ lastAttemptedPage = nextPage,
+ lastStatus = "RUNNING",
+ lastError = null
+ )
+ )
+ seriesCategoryHydrationDao.get(providerId, seriesCategoryId)?.let { seriesHydration ->
+ seriesCategoryHydrationDao.upsert(
+ seriesHydration.copy(
+ lastAttemptedPage = nextPage,
+ lastStatus = "RUNNING",
+ lastError = null
+ )
+ )
+ }
+ when (val pageResult = api.getSplitVodPage(movieCategoryId, seriesCategoryId, nextPage)) {
+ is Result.Success -> {
+ val page = pageResult.data
+ val movies = page.items.mapNotNull { (it.item as? VodCatalogItem.MovieItem)?.movie?.toEntity() }
+ val incomingSeries = page.items.mapNotNull {
+ (it.item as? VodCatalogItem.SeriesItem)?.series
+ ?.copy(isUserProtected = movieCategory.isUserProtected)
+ ?.toEntity()
+ }
+ val now = attemptAt
+ val existingSeriesHydration = seriesCategoryHydrationDao.get(providerId, seriesCategoryId)
+ transactionRunner.inTransaction {
+ movieDao.upsertCategoryPage(providerId, movies)
+ if (incomingSeries.isNotEmpty()) {
+ categoryDao.insertAll(
+ listOf(
+ CategoryEntity(
+ providerId = providerId,
+ categoryId = seriesCategoryId,
+ name = movieCategory.name,
+ parentId = movieCategory.parentId,
+ type = ContentType.SERIES,
+ providerOrder = movieCategory.providerOrder,
+ isAdult = movieCategory.isAdult,
+ isUserProtected = movieCategory.isUserProtected
+ )
+ )
+ )
+ }
+ // Check inside the same transaction as the write so a concurrent
+ // native-Series refresh can never be replaced by derived VOD data.
+ val existingSeries = seriesDao.getBySeriesIds(
+ providerId,
+ incomingSeries.map { it.seriesId }
+ ).associateBy { it.seriesId }
+ val derivedSeries = incomingSeries.filter { incoming ->
+ existingSeries[incoming.seriesId]?.catalogOrigin !=
+ com.streamvault.domain.model.SeriesCatalogOrigin.NATIVE
+ }
+ seriesDao.upsertCategoryPage(providerId, derivedSeries)
+ movieCount = movieDao.getCountByCategory(providerId, movieCategoryId).first()
+ val seriesCount = seriesDao.getCountByCategory(providerId, seriesCategoryId).first()
+ hydration = com.streamvault.data.local.entity.MovieCategoryHydrationEntity(
+ providerId = providerId,
+ categoryId = movieCategoryId,
+ lastHydratedAt = now,
+ itemCount = movieCount,
+ lastStatus = if (page.isTruncated) "TRUNCATED" else "SUCCESS",
+ lastError = page.terminationReason,
+ lastLoadedPage = page.page,
+ lastAttemptedPage = page.page,
+ lastSuccessfulPage = page.page,
+ totalPages = page.totalPages,
+ isComplete = page.isComplete,
+ pageSize = page.pageSize,
+ retryBudgetRemaining = STALKER_CATEGORY_RETRY_BUDGET,
+ lastPageFingerprint = page.items.joinToString("|") { it.rawItemId }
+ .takeIf(String::isNotEmpty)
+ )
+ movieCategoryHydrationDao.upsert(hydration!!)
+ if (incomingSeries.isNotEmpty() || existingSeriesHydration != null) {
+ seriesCategoryHydrationDao.upsert(
+ com.streamvault.data.local.entity.SeriesCategoryHydrationEntity(
+ providerId = providerId,
+ categoryId = seriesCategoryId,
+ lastHydratedAt = now,
+ itemCount = seriesCount,
+ lastStatus = if (page.isTruncated) "TRUNCATED" else "SUCCESS",
+ lastError = page.terminationReason,
+ lastLoadedPage = page.page,
+ lastAttemptedPage = page.page,
+ lastSuccessfulPage = page.page,
+ totalPages = page.totalPages,
+ isComplete = page.isComplete,
+ pageSize = page.pageSize,
+ retryBudgetRemaining = STALKER_CATEGORY_RETRY_BUDGET,
+ lastPageFingerprint = page.items.joinToString("|") { it.rawItemId }
+ .takeIf(String::isNotEmpty)
+ )
+ )
+ }
+ }
+ if (page.isTruncated) return@withLock Result.error(page.terminationReason ?: "VOD response was truncated")
+ val projectionCount = when (requestedProjection) {
+ ContentType.SERIES -> seriesDao.getCountByCategory(providerId, seriesCategoryId).first()
+ else -> movieCount
+ }
+ if (page.isComplete ||
+ (request != com.streamvault.domain.model.VodCategoryHydrationRequest.COMPLETE &&
+ projectionCount > initialProjectionCount)
+ ) {
+ return@withLock Result.success(Unit)
+ }
+ nextPage = page.page + 1
+ }
+ is Result.Error -> {
+ val prior = hydration ?: com.streamvault.data.local.entity.MovieCategoryHydrationEntity(
+ providerId,
+ movieCategoryId
+ )
+ movieCategoryHydrationDao.upsert(
+ prior.copy(
+ lastAttemptedPage = nextPage,
+ lastStatus = "FAILED_RETRYABLE",
+ lastError = pageResult.message,
+ failureCount = prior.failureCount + 1,
+ retryBudgetRemaining = (prior.retryBudgetRemaining - 1).coerceAtLeast(0)
+ )
+ )
+ seriesCategoryHydrationDao.get(providerId, seriesCategoryId)?.let { seriesHydration ->
+ seriesCategoryHydrationDao.upsert(
+ seriesHydration.copy(
+ lastAttemptedPage = nextPage,
+ lastStatus = "FAILED_RETRYABLE",
+ lastError = pageResult.message,
+ failureCount = seriesHydration.failureCount + 1,
+ retryBudgetRemaining = (seriesHydration.retryBudgetRemaining - 1).coerceAtLeast(0)
+ )
+ )
+ }
+ return@withLock Result.error(pageResult.message, pageResult.exception)
+ }
+ Result.Loading -> return@withLock Result.error("Split VOD hydration did not complete")
+ }
+ }
+ @Suppress("UNREACHABLE_CODE")
+ Result.success(Unit)
+ }
+ }
+
+ suspend fun hydrateSplitVodSeriesCategory(
+ providerId: Long,
+ seriesCategoryId: Long,
+ request: com.streamvault.domain.model.VodCategoryHydrationRequest
+ ): Result<Unit> {
+ val providerEntity = providerDao.getById(providerId) ?: return Result.error("Provider not found")
+ if (providerEntity.type != ProviderType.STALKER_PORTAL || providerEntity.catalogLayout != CatalogLayout.SPLIT) {
+ return Result.success(Unit)
+ }
+ val api = createStalkerSyncProvider(providerEntity.toDomain())
+ api.getSeriesCategories()
+ val movieCategoryId = api.projectSeriesCategoryToVod(seriesCategoryId)
+ ?: return Result.error("Unable to resolve VOD category for derived Series")
+ return hydrateSplitVodCategory(providerId, movieCategoryId, request, ContentType.SERIES)
+ }
+ private val providerWorkLocks = ProviderWorkLockRegistry()
- private val providerStalkerFetchSemaphores = ConcurrentHashMap<Long, Semaphore>()
- private val stalkerFetchAdmissionMutex = Mutex()
private val xtreamCatalogHttpService: OkHttpXtreamApiService by lazy {
OkHttpXtreamApiService(
client = okHttpClient,
@@@ -669,121 -311,32 +697,117 @@@
syncStateTracker.current(providerId)
/** Returns true if any provider sync mutex is currently held (used by DatabaseMaintenanceManager). */
- fun isAnySyncActive(): Boolean = isAnySyncMutexLocked()
+ fun isAnySyncActive(): Boolean = providerWorkLocks.isAnyWorkActiveOrWaiting()
- private suspend fun <T> withProviderLock(providerId: Long, block: suspend () -> T): T =
- providerWorkLocks.withProviderLock(providerId, block)
+ private fun isAnySyncMutexLocked(): Boolean =
+ providerSyncMutexes.values.any { it.isLocked } ||
+ providerEpgMutexes.values.any { it.isLocked }
- private suspend fun <T> withStalkerFetchPermit(provider: Provider, block: suspend () -> T): T {
- val permitCount = minOf(
- provider.maxConnections.coerceAtLeast(1),
- STALKER_MAX_PARALLEL_CATEGORY_FETCHES
- ).coerceAtLeast(1)
- val semaphore = stalkerFetchAdmissionMutex.withLock {
- providerStalkerFetchSemaphores.computeIfAbsent(provider.id) { Semaphore(permitCount) }
+ private suspend fun <T> withProviderLock(providerId: Long, block: suspend () -> T): T {
- val mutex = syncAdmissionMutex.withLock {
- providerSyncMutexes.computeIfAbsent(providerId) { Mutex() }.also { providerMutex ->
- providerMutex.lock()
++ return providerWorkLocks.withProviderLock(providerId) {
++ val mutex = syncAdmissionMutex.withLock {
++ providerSyncMutexes.computeIfAbsent(providerId) { Mutex() }.also { providerMutex ->
++ providerMutex.lock()
++ }
++ }
++ try {
++ block()
++ } finally {
++ mutex.unlock()
+ }
- }
- try {
- return block()
- } finally {
- mutex.unlock()
+ }
+ }
+
+ private suspend fun <T> withProviderEpgLock(providerId: Long, block: suspend () -> T): T {
+ val mutex = syncAdmissionMutex.withLock {
+ providerEpgMutexes.computeIfAbsent(providerId) { Mutex() }.also { providerMutex ->
+ providerMutex.lock()
+ }
+ }
+ try {
+ return block()
+ } finally {
+ mutex.unlock()
}
- return semaphore.withPermit { block() }
}
+ private suspend fun <T> withStalkerIndexSectionLock(
+ providerId: Long,
+ section: ContentType,
+ block: suspend () -> T
+ ): T {
+ val lockKey = "$providerId:${section.name}"
+ val mutex = syncAdmissionMutex.withLock {
+ providerStalkerIndexSectionMutexes.computeIfAbsent(lockKey) { Mutex() }.also { sectionMutex ->
+ sectionMutex.lock()
+ }
+ }
+ try {
+ return block()
+ } finally {
+ mutex.unlock()
+ }
+ }
+
+ private suspend fun <T> withStalkerSummaryProviderLock(providerId: Long, block: suspend () -> T): T {
+ val mutex = syncAdmissionMutex.withLock {
+ providerStalkerSummaryMutexes.computeIfAbsent(providerId) { Mutex() }.also { providerMutex ->
+ providerMutex.lock()
+ }
+ }
+ try {
+ return block()
+ } finally {
+ mutex.unlock()
+ }
+ }
+
+ private suspend fun <T> withStalkerSummaryLock(
+ providerId: Long,
+ section: ContentType?,
+ block: suspend () -> T
+ ): T = when (section) {
+ ContentType.MOVIE,
+ ContentType.SERIES -> withStalkerSummaryProviderLock(providerId, block)
+ else -> withProviderLock(providerId, block)
+ }
+
+ private suspend fun <T> withStalkerFetchPermit(
+ provider: Provider,
+ contentType: ContentType,
+ categoryId: Long,
+ page: Int,
+ block: suspend () -> T
+ ): T = stalkerRequestCoordinator.execute(
+ providerId = provider.id,
+ priority = StalkerRequestPriority.BACKGROUND_INDEX,
+ descriptor = StalkerRequestDescriptor(
+ contentType = contentType.name,
+ action = "INDEX_PAGE",
+ categoryKey = categoryId.toString(),
+ page = page
+ )
+ ) { block() }
+
suspend fun runWhenNoSyncActive(block: suspend () -> Boolean): Boolean =
- syncAdmissionMutex.withLock {
- if (isAnySyncMutexLocked()) {
- false
- } else {
- block()
- }
- }
+ providerWorkLocks.runWhenNoWorkActive(block)
suspend fun onProviderDeleted(providerId: Long) {
- BackgroundEpgSyncWorker.cancel(applicationContext, providerId)
+ runCatching { BackgroundEpgSyncWorker.cancel(applicationContext, providerId) }
+ .onFailure { error -> Log.w(TAG, "Failed to cancel background EPG work: ${sanitizeThrowableMessage(error)}") }
+ runCatching { StalkerIndexWorker.cancel(applicationContext, providerId) }
+ .onFailure { error -> Log.w(TAG, "Failed to cancel Stalker index work: ${sanitizeThrowableMessage(error)}") }
withProviderLock(providerId) {
- syncStateTracker.reset(providerId)
- xtreamAdaptiveSyncPolicy.forgetProvider(providerId)
- syncCatalogStore.clearProviderStaging(providerId)
- epgRepository.onProviderDeleted(providerId)
+ withProviderEpgLock(providerId) {
+ syncStateTracker.reset(providerId)
+ stalkerReadinessTracker.clear(providerId)
+ xtreamAdaptiveSyncPolicy.forgetProvider(providerId)
+ syncCatalogStore.clearProviderStaging(providerId)
+ epgRepository.onProviderDeleted(providerId)
+ providerSyncMutexes.remove(providerId)
+ providerStalkerSummaryMutexes.remove(providerId)
+ providerEpgMutexes.remove(providerId)
+ }
}
}
@@@ -795,16 -348,9 +819,20 @@@
}
}
- fun scheduleProviderSyncResume(providerId: Long) {
+ fun scheduleProviderSyncResume(
+ providerId: Long,
+ configurationGeneration: Long? = null
+ ) {
runCatching {
- ProviderSyncWorker.enqueueProvider(
- applicationContext,
- providerId,
- configurationGeneration
- )
- ProviderSyncWorker.enqueueProvider(applicationContext, providerId)
++ if (configurationGeneration != null) {
++ ProviderSyncWorker.enqueueProviderConfigRevision(
++ applicationContext,
++ providerId,
++ configurationGeneration
++ )
++ } else {
++ ProviderSyncWorker.enqueueProvider(applicationContext, providerId)
++ }
}.onFailure { error ->
Log.w(TAG, "Failed to schedule provider resume work for provider $providerId: ${sanitizeThrowableMessage(error)}")
}
@@@ -1200,9 -808,11 +1257,11 @@@
} catch (e: Exception) {
val safeMessage = syncErrorSanitizer.userMessage(e, "Index rebuild failed")
Log.e(TAG, "Xtream index rebuild failed for provider $providerId: ${syncErrorSanitizer.throwableMessage(e)}")
- updateSyncStatusMetadata(providerId = providerId, status = "ERROR")
+ updateSyncStatusMetadata(providerId = providerId, status = syncFailureStatus(provider, e))
publishSyncState(providerId, SyncState.Error(safeMessage, e))
com.streamvault.domain.model.Result.error(safeMessage, e)
+ } finally {
+ finishProgressSession(progressSession)
}
}
@@@ -1957,7 -1524,18 +2023,18 @@@
maxCategoriesPerSection: Int? = null,
onProgress: ((String) -> Unit)? = null
): com.streamvault.domain.model.Result<Unit> {
- return withProviderLock(providerId) lock@{
- val playbackDelayMillis = StalkerTrafficCoordinator.deferCatalogFetchMillis(providerId)
+ return withStalkerSummaryLock(providerId, section) lock@{
++ val playbackDelayMillis = if (StalkerTrafficCoordinator.isPlaybackActive(providerId)) 2_000L else 0L
+ if (playbackDelayMillis > 0L) {
+ Log.i(TAG, "Deferring Stalker catalog work for provider $providerId because playback is active.")
+ scheduleStalkerIndexSync(
+ providerId = providerId,
+ section = null,
+ force = force,
+ initialDelaySeconds = ((playbackDelayMillis + 999L) / 1000L).coerceAtLeast(1L)
+ )
+ return@lock com.streamvault.domain.model.Result.success(Unit)
+ }
val providerEntity = providerDao.getById(providerId)
?: return@lock com.streamvault.domain.model.Result.error("Provider $providerId not found")
@@@ -4426,47 -3875,17 +4538,48 @@@
private suspend fun syncStalker(
provider: Provider,
force: Boolean,
- onProgress: ((String) -> Unit)?
+ onProgress: ((String) -> Unit)?,
+ afterCatalogApply: suspend () -> Unit = {}
): SyncOutcome {
val warnings = mutableListOf<String>()
+ stalkerReadinessTracker.start(provider.id)
UrlSecurityPolicy.validateStalkerPortalUrl(provider.serverUrl)?.let { message ->
throw IllegalStateException(message)
}
- emitCatalogSyncProgress(section = Section.LIVE)
+ emitCatalogSyncProgress(provider.id, section = Section.LIVE)
progress(provider.id, onProgress, "Connecting to portal...")
val api = createStalkerSyncProvider(provider)
- requireResult(api.authenticate(), "Failed to authenticate with portal")
+ val authenticatedProvider = requireResult(api.authenticate(), "Failed to authenticate with portal")
+ val effectiveCatalogLayout = authenticatedProvider.catalogLayout
+ .takeUnless { it == com.streamvault.domain.model.CatalogLayout.UNKNOWN }
+ ?: provider.catalogLayout
+ val catalogLayoutChanged =
+ authenticatedProvider.catalogLayout != com.streamvault.domain.model.CatalogLayout.UNKNOWN &&
+ authenticatedProvider.catalogLayout != provider.catalogLayout
+ if (
+ catalogLayoutChanged ||
+ authenticatedProvider.catalogLayoutDetectionVersion != provider.catalogLayoutDetectionVersion
+ ) {
+ transactionRunner.inTransaction {
+ if (authenticatedProvider.catalogLayout != com.streamvault.domain.model.CatalogLayout.UNKNOWN) {
+ providerDao.updateCatalogLayout(
+ provider.id,
+ authenticatedProvider.catalogLayout,
+ authenticatedProvider.catalogLayoutDetectionVersion
+ )
+ }
+ if (catalogLayoutChanged) {
+ categoryDao.deleteByProviderAndType(provider.id, ContentType.MOVIE.name)
+ categoryDao.deleteByProviderAndType(provider.id, ContentType.SERIES.name)
+ categoryDao.deleteByProviderAndType(provider.id, ContentType.VOD.name)
+ movieCategoryHydrationDao.deleteByProvider(provider.id)
+ seriesCategoryHydrationDao.deleteByProvider(provider.id)
+ vodCategoryHydrationDao.deleteByProvider(provider.id)
+ vodCatalogEntryDao.deleteByProvider(provider.id)
+ }
+ }
+ }
+ stalkerReadinessTracker.authenticated(provider.id)
var metadata = syncMetadataRepository.getMetadata(provider.id) ?: SyncMetadata(provider.id)
val now = System.currentTimeMillis()
@@@ -4477,9 -3896,25 +4590,15 @@@
var seriesCategoryCount = 0
if (force || ContentCachePolicy.shouldRefresh(metadata.lastLiveSuccess, ContentCachePolicy.CATALOG_TTL_MILLIS, now)) {
- upsertXtreamIndexJob(
- providerId = provider.id,
- section = ContentType.LIVE.name,
- state = "RUNNING",
- now = now,
- lastAttemptAt = now,
- lastError = null
- )
progress(provider.id, onProgress, "Downloading Live TV...")
val hiddenLiveCategoryIds = preferencesRepository.getHiddenCategoryIds(provider.id, ContentType.LIVE).first()
- val liveCatalogResult = syncStalkerLiveCatalogStaged(api, provider, hiddenLiveCategoryIds, onProgress)
+ val liveCatalogResult = syncStalkerLiveCatalogStaged(
+ api,
+ provider,
+ hiddenLiveCategoryIds,
+ onProgress,
+ afterCatalogApply
+ )
- val liveCategoryCount = categoryDao.getByProviderAndTypeSync(provider.id, ContentType.LIVE.name).size
- val liveFinishedAt = System.currentTimeMillis()
metadata = metadata.copy(
lastLiveSync = now,
lastLiveSuccess = now,
@@@ -5198,19 -4664,10 +5393,19 @@@
fallbackGuideRequests.forEachIndexed { index, request ->
if (ignorePerChannelGuide) return@forEachIndexed
progress(provider.id, onProgress, "Downloading portal EPG... ${index + 1} of ${fallbackGuideRequests.size}")
- runCatching {
+ runSuspendCatching {
var perChannelRecordCount = 0
val foreignChannelIds = HashSet<String>()
- val streamResult = api.streamEpg(request.channelKey) { program ->
+ val streamResult = stalkerRequestCoordinator.execute(
+ providerId = provider.id,
+ priority = StalkerRequestPriority.EPG,
+ descriptor = StalkerRequestDescriptor(
+ contentType = "EPG",
+ action = "CHANNEL_GUIDE",
+ itemKey = request.channelKey
+ )
+ ) {
+ api.streamEpg(request.channelKey) { program ->
if (program.endTime <= program.startTime) return@streamEpg
if (program.channelId != request.channelKey) {
foreignChannelIds += program.channelId
@@@ -5484,8 -4920,16 +5679,8 @@@
syncMetadataRepository.updateMetadata(metadata)
}
ProviderType.STALKER_PORTAL -> {
- emitCatalogSyncProgress(section = Section.LIVE)
+ emitCatalogSyncProgress(provider.id, section = Section.LIVE)
progress(provider.id, onProgress, "Retrying Live TV...")
- upsertXtreamIndexJob(
- providerId = provider.id,
- section = ContentType.LIVE.name,
- state = "RUNNING",
- now = now,
- lastAttemptAt = now,
- lastError = null
- )
val api = createStalkerSyncProvider(provider)
val hiddenLiveCategoryIds = preferencesRepository.getHiddenCategoryIds(provider.id, ContentType.LIVE).first()
val liveCatalogResult = syncStalkerLiveCatalogStaged(api, provider, hiddenLiveCategoryIds, onProgress)
@@@ -6337,19 -5750,22 +6553,24 @@@
.distinctBy { it.categoryId to it.type }
.takeIf { it.isNotEmpty() }
if (acceptedCount == 0 || sessionId == null) {
- syncCatalogStore.replaceLiveCatalog(
- providerId = provider.id,
- categories = categories,
- channels = emptyList()
- )
+ // An empty discovery result is not proof that a previously working
+ // catalog became empty. Keep the committed generation intact and
+ // discard only rows owned by this attempt.
+ sessionId?.let { syncCatalogStore.discardStagedImport(provider.id, it) }
return StagedStalkerLiveCatalogResult(
acceptedCount = 0,
- warnings = (warnings + "Live TV provider exposed no live channels; continuing with VOD and series only.").distinct()
+ warnings = (
+ warnings +
+ "Live TV returned no usable channels; keeping the last verified Live catalog."
+ ).distinct()
)
}
- syncCatalogStore.applyStagedLiveCatalog(provider.id, sessionId, categories)
+ syncCatalogStore.applyStagedLiveCatalog(
+ provider.id,
+ sessionId,
+ categories,
+ afterCatalogApply
+ )
return StagedStalkerLiveCatalogResult(acceptedCount, warnings)
}
diff --cc data/src/test/java/com/streamvault/data/manager/BackupManagerImplTest.kt
index 44e55d6a,096ff14d..e5105f50
--- a/data/src/test/java/com/streamvault/data/manager/BackupManagerImplTest.kt
+++ b/data/src/test/java/com/streamvault/data/manager/BackupManagerImplTest.kt
@@@ -26,24 -39,35 +39,37 @@@ import com.streamvault.domain.manager.S
import com.streamvault.domain.model.AppHomeDashboardShelf
import com.streamvault.domain.model.AppTopLevelDestination
import com.streamvault.domain.model.ContentType
+ import com.streamvault.domain.model.Category
import com.streamvault.domain.model.DecoderMode
import com.streamvault.domain.model.Favorite
+ import com.streamvault.domain.model.EpgSource
import com.streamvault.domain.model.PlaybackHistory
import com.streamvault.domain.model.Provider
+import com.streamvault.domain.model.ProviderStatus
import com.streamvault.domain.model.ProviderType
import com.streamvault.domain.model.RecordingItem
import com.streamvault.domain.model.RecordingRecurrence
import com.streamvault.domain.model.RecordingStatus
import com.streamvault.domain.model.Result
+import com.streamvault.domain.model.StalkerTransportMode
+ import com.streamvault.domain.model.XmltvTimezonePolicy
import com.streamvault.domain.repository.CategoryRepository
import java.io.ByteArrayInputStream
+ import java.io.File
+ import java.io.FileOutputStream
+ import java.io.InputStream
+ import kotlinx.coroutines.CancellationException
+ import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.runBlocking
+ import kotlin.system.measureTimeMillis
+ import org.junit.Assert.assertThrows
import org.junit.Test
import org.mockito.kotlin.any
+ import org.mockito.kotlin.anyOrNull
import org.mockito.kotlin.argThat
import org.mockito.kotlin.doAnswer
+ import org.mockito.kotlin.doThrow
+ import org.mockito.kotlin.eq
import org.mockito.kotlin.mock
import org.mockito.kotlin.never
import org.mockito.kotlin.verify
@@@ -90,81 -365,6 +367,82 @@@ class BackupManagerImplTest
verify(preferencesRepository, never()).setParentalControlLevel(any())
}
+ @Test
+ fun `import strips Stalker transport consent and requires attention for HTTP`() = runBlocking {
+ val context: Context = mock()
+ val contentResolver: ContentResolver = mock()
+ val providerDao: ProviderDao = mock()
+ val credentialCrypto: CredentialCrypto = mock()
+ val gson = Gson()
+ val backup = BackupData(
+ providers = listOf(
+ Provider(
+ id = 9L,
+ name = "MAG",
+ type = ProviderType.STALKER_PORTAL,
+ serverUrl = "http://portal.example.com/c/",
+ stalkerMacAddress = "00:1A:79:12:34:56",
+ stalkerTransportMode = StalkerTransportMode.USER_ACCEPTED_HTTP,
+ stalkerTransportOrigin = "http://portal.example.com",
+ stalkerTlsSpkiSha256 = "sha256/must-not-survive",
+ stalkerTransportConsentAt = 1234L,
+ isActive = true,
+ status = ProviderStatus.ACTIVE
+ )
+ )
+ )
+ whenever(context.contentResolver).thenReturn(contentResolver)
+ whenever(contentResolver.openInputStream(Uri.parse("content://stalker-backup"))).thenReturn(
+ ByteArrayInputStream(gson.toJson(backup).toByteArray())
+ )
+ whenever(providerDao.getAllSync()).thenReturn(emptyList())
+ whenever(credentialCrypto.encryptIfNeeded(any())).thenAnswer { invocation ->
+ invocation.arguments.first() as String
+ }
+ val manager = BackupManagerImpl(
+ context = context,
+ preferencesRepository = mock(),
+ credentialCrypto = credentialCrypto,
+ providerDao = providerDao,
+ favoriteDao = mock(),
+ virtualGroupDao = mock(),
+ playbackHistoryDao = mock(),
+ movieDao = mock(),
+ episodeDao = mock(),
++ channelDao = mock(),
+ categoryRepository = mock(),
+ recordingScheduleDao = mock(),
+ recordingManager = mock(),
+ transactionRunner = object : DatabaseTransactionRunner {
+ override suspend fun <T> inTransaction(block: suspend () -> T): T = block()
+ },
+ gson = gson
+ )
+
+ val result = manager.importConfig(
+ uriString = "content://stalker-backup",
+ plan = BackupImportPlan(
+ importPreferences = false,
+ importProviders = true,
+ importSavedLibrary = false,
+ importPlaybackHistory = false,
+ importMultiViewPresets = false,
+ importRecordingSchedules = false
+ )
+ )
+
+ assertThat(result).isInstanceOf(Result.Success::class.java)
+ val inserted = org.mockito.kotlin.argumentCaptor<ProviderEntity>()
+ verify(providerDao).insert(inserted.capture())
+ assertThat(inserted.firstValue.stalkerTransportMode)
+ .isEqualTo(StalkerTransportMode.AUTO_STRICT)
+ assertThat(inserted.firstValue.stalkerTransportOrigin).isEmpty()
+ assertThat(inserted.firstValue.stalkerTlsSpkiSha256).isEmpty()
+ assertThat(inserted.firstValue.stalkerTransportConsentAt).isEqualTo(0L)
+ assertThat(inserted.firstValue.isActive).isFalse()
+ assertThat(inserted.firstValue.status).isEqualTo(ProviderStatus.PARTIAL)
+ }
+
@Test
fun `importConfig replace history only deletes imported providers and resyncs them in transaction`() = runBlocking {
val context: Context = mock()
diff --cc data/src/test/java/com/streamvault/data/remote/stalker/OkHttpStalkerCancellationTest.kt
index 00000000,bec9cee7..580aed03
mode 000000,100644..100644
--- a/data/src/test/java/com/streamvault/data/remote/stalker/OkHttpStalkerCancellationTest.kt
+++ b/data/src/test/java/com/streamvault/data/remote/stalker/OkHttpStalkerCancellationTest.kt
@@@ -1,0 -1,98 +1,100 @@@
+ package com.streamvault.data.remote.stalker
+
+ import com.google.common.truth.Truth.assertThat
+ import com.streamvault.domain.model.Result
+ import com.streamvault.domain.model.StalkerAuthMode
++import com.streamvault.domain.model.DiscoveryBudget
+ import java.io.IOException
+ import java.util.concurrent.CopyOnWriteArrayList
+ import java.util.concurrent.CountDownLatch
+ import java.util.concurrent.TimeUnit
+ import kotlinx.coroutines.Dispatchers
+ import kotlinx.coroutines.cancelAndJoin
+ import kotlinx.coroutines.launch
+ import kotlinx.coroutines.runBlocking
+ import kotlinx.serialization.json.Json
+ import kotlin.system.measureTimeMillis
+ import okhttp3.MediaType.Companion.toMediaType
+ import okhttp3.OkHttpClient
+ import okhttp3.Protocol
+ import okhttp3.Response
+ import okhttp3.ResponseBody.Companion.toResponseBody
+ import org.junit.Test
+
+ class OkHttpStalkerCancellationTest {
+
+ @Test
+ fun `cancelling handshake prevents later recipe requests`(): Unit = runBlocking {
+ val started = CountDownLatch(1)
+ val actions = CopyOnWriteArrayList<String>()
+ val client = OkHttpClient.Builder().addInterceptor { chain ->
+ actions += chain.request().url.queryParameter("action").orEmpty()
+ started.countDown()
+ while (!chain.call().isCanceled()) Thread.sleep(5)
+ throw IOException("cancelled")
+ }.build()
- val service = service(client, StalkerDiscoveryBudget(10_000, 24))
++ val service = service(client)
+ val job = launch(Dispatchers.IO) {
- service.authenticate(profile())
++ service.authenticate(profile(DiscoveryBudget(10_000, 24)))
+ }
+
+ assertThat(started.await(5, TimeUnit.SECONDS)).isTrue()
+ job.cancelAndJoin()
+
+ assertThat(actions).containsExactly("handshake")
+ }
+
+ @Test
+ fun `request budget prevents an additional outbound request`(): Unit = runBlocking {
+ val actions = CopyOnWriteArrayList<String>()
+ val client = OkHttpClient.Builder().addInterceptor { chain ->
+ val action = chain.request().url.queryParameter("action").orEmpty()
+ actions += action
+ Response.Builder()
+ .request(chain.request())
+ .protocol(Protocol.HTTP_1_1)
+ .code(200)
+ .message("OK")
+ .body("""{"js":{"token":"token-123"}}""".toResponseBody("application/json".toMediaType()))
+ .build()
+ }.build()
+
- val result = service(client, StalkerDiscoveryBudget(10_000, 1)).authenticate(profile())
++ val result = service(client).authenticate(profile(DiscoveryBudget(10_000, 1)))
+
+ assertThat(result).isInstanceOf(Result.Error::class.java)
+ assertThat(actions).containsExactly("handshake")
+ }
+
+ @Test
+ fun `overall discovery deadline cancels the active request`(): Unit = runBlocking {
+ val cancelled = CountDownLatch(1)
+ val client = OkHttpClient.Builder().addInterceptor { chain ->
+ while (!chain.call().isCanceled()) Thread.sleep(5)
+ cancelled.countDown()
+ throw IOException("cancelled")
+ }.build()
+ lateinit var result: Result<Pair<StalkerSession, StalkerProviderProfile>>
+
+ val elapsedMillis = measureTimeMillis {
- result = service(client, StalkerDiscoveryBudget(100, 24)).authenticate(profile())
++ result = service(client).authenticate(profile(DiscoveryBudget(100, 24)))
+ }
+
+ assertThat(result).isInstanceOf(Result.Error::class.java)
+ assertThat((result as Result.Error).message).contains("exceeded")
+ assertThat(cancelled.await(5, TimeUnit.SECONDS)).isTrue()
+ assertThat(elapsedMillis).isLessThan(5_000L)
+ }
+
- private fun service(client: OkHttpClient, budget: StalkerDiscoveryBudget) =
- OkHttpStalkerApiService(client, Json { ignoreUnknownKeys = true }, budget)
++ private fun service(client: OkHttpClient) =
++ OkHttpStalkerApiService(client, Json { ignoreUnknownKeys = true })
+
- private fun profile() = buildStalkerDeviceProfile(
++ private fun profile(budget: DiscoveryBudget = DiscoveryBudget()) = buildStalkerDeviceProfile(
+ portalUrl = "https://portal.example.com/c",
+ macAddress = "00:1A:79:12:34:56",
+ authMode = StalkerAuthMode.AUTO,
+ deviceProfile = "MAG250",
+ timezone = "UTC",
- locale = "en"
++ locale = "en",
++ discoveryBudget = budget
+ )
+ }
diff --cc data/src/test/java/com/streamvault/data/repository/ProviderRepositoryImplTest.kt
index 9542acf5,2e9ff687..5c610f58
--- a/data/src/test/java/com/streamvault/data/repository/ProviderRepositoryImplTest.kt
+++ b/data/src/test/java/com/streamvault/data/repository/ProviderRepositoryImplTest.kt
@@@ -9,13 -10,15 +11,16 @@@ import com.streamvault.data.local.dao.M
import com.streamvault.data.local.dao.ProgramDao
import com.streamvault.data.local.dao.ProgramReminderDao
import com.streamvault.data.local.dao.ProviderDao
+ import com.streamvault.data.local.dao.ProviderConfigRevisionDao
++import com.streamvault.data.local.dao.ProviderDeletionCleanupDao
import com.streamvault.data.local.dao.RecordingRunDao
import com.streamvault.data.local.dao.SeriesDao
-import com.streamvault.data.local.dao.ProviderDeletionCleanupDao
+import com.streamvault.data.local.dao.SeriesCategoryHydrationDao
+import com.streamvault.data.local.dao.StalkerIndexJobDao
import com.streamvault.data.local.entity.ProviderEntity
+ import com.streamvault.data.local.entity.ProviderConfigRevisionState
import com.streamvault.data.local.entity.CategoryEntity
-import com.streamvault.data.local.entity.ProviderWorkflowPhase
-import com.streamvault.data.local.entity.ProviderWorkflowReason
+import com.streamvault.data.local.entity.StalkerIndexJobEntity
import com.streamvault.data.manager.recording.RecordingAlarmScheduler
import com.streamvault.data.manager.reminder.ProgramReminderAlarmScheduler
import com.streamvault.data.preferences.PreferencesRepository
@@@ -80,9 -79,12 +89,15 @@@ class ProviderRepositoryImplTest
private val recordingAlarmScheduler: RecordingAlarmScheduler = mock()
private val programReminderAlarmScheduler: ProgramReminderAlarmScheduler = mock()
private val jellyfinProvider: JellyfinProvider = mock()
+ private val stalkerIndexJobDao: StalkerIndexJobDao = mock()
+ private val movieCategoryHydrationDao: MovieCategoryHydrationDao = mock()
+ private val seriesCategoryHydrationDao: SeriesCategoryHydrationDao = mock()
+ private val providerDeletionCleanupDao: ProviderDeletionCleanupDao = mock()
+ private val providerDeletionCleanupEnqueuer: ProviderDeletionCleanupEnqueuer = mock()
+ private val providerConfigRevisionDao: ProviderConfigRevisionDao = mock()
+ private val providerWorkflowRunner: ProviderWorkflowRunner = mock()
+ private val gson = Gson()
+ private val appContext: Context = mock()
private val transactionRunner = object : DatabaseTransactionRunner {
override suspend fun <T> inTransaction(block: suspend () -> T): T = block()
}
@@@ -108,11 -110,13 +123,18 @@@
recordingAlarmScheduler = recordingAlarmScheduler,
programReminderAlarmScheduler = programReminderAlarmScheduler,
jellyfinProvider = jellyfinProvider,
+ stalkerRemoteIdentityResolver = mock(),
+ stalkerIndexJobDao = stalkerIndexJobDao,
+ stalkerPortalStateStore = mock(),
+ movieCategoryHydrationDao = movieCategoryHydrationDao,
- seriesCategoryHydrationDao = seriesCategoryHydrationDao
++ seriesCategoryHydrationDao = seriesCategoryHydrationDao,
+ providerDeletionCleanupDao = providerDeletionCleanupDao,
+ providerDeletionCleanupEnqueuer = providerDeletionCleanupEnqueuer,
+ providerConfigRevisionDao = providerConfigRevisionDao,
+ gson = gson,
+ providerWorkflowRunner = providerWorkflowRunner,
+ providerWorkflowCommitFence = ProviderWorkflowCommitFence(),
+ appContext = appContext
)
private val repository = createRepository()
@@@ -120,6 -124,41 +142,28 @@@
init {
whenever(preferencesRepository.xtreamBase64TextCompatibility).thenReturn(flowOf(false))
runBlocking {
- whenever(credentialCrypto.encryptIfNeeded(any())).thenAnswer { invocation ->
- invocation.getArgument<String>(0)
- }
+ whenever(providerConfigRevisionDao.latestRevision(any())).thenReturn(0L)
+ whenever(providerConfigRevisionDao.claimForSync(any(), any(), any())).thenReturn(1)
+ whenever(providerConfigRevisionDao.getState(any(), any()))
+ .thenReturn(ProviderConfigRevisionState.COMMITTED)
+ whenever(
- providerWorkflowRunner.execute(
- any(),
- any(),
- any(),
- any(),
- any(),
- any(),
- any()
- )
++ providerWorkflowRunner.execute(any(), any(), any(), any(), any(), any(), any())
+ ).thenAnswer { invocation ->
+ val block = invocation.getArgument<suspend () -> ProviderWorkflowOutcome>(6)
+ when (val outcome = runBlocking { block() }) {
+ is ProviderWorkflowOutcome.Success -> ProviderWorkflowDisposition.SUCCEEDED
- is ProviderWorkflowOutcome.Failure -> {
- if (outcome.retryable) {
- ProviderWorkflowDisposition.RETRY
- } else {
- ProviderWorkflowDisposition.FAILED
- }
++ is ProviderWorkflowOutcome.Failure -> if (outcome.retryable) {
++ ProviderWorkflowDisposition.RETRY
++ } else {
++ ProviderWorkflowDisposition.FAILED
+ }
+ }
+ }
+ whenever(
+ syncManager.syncWithProviderOverride(
+ any(), any(), anyOrNull(), anyOrNull(), anyOrNull(), any(), anyOrNull(), anyOrNull()
+ )
+ ).thenReturn(Result.success(Unit))
whenever(categoryDao.getByProviderAndTypeSync(any(), any())).thenReturn(emptyList())
whenever(programDao.countByProvider(any())).thenReturn(0)
whenever(channelDao.countByProvider(any())).thenReturn(0)
diff --cc data/src/test/java/com/streamvault/data/sync/SyncManagerTest.kt
index e946a55f,4b0a990c..507e32f5
--- a/data/src/test/java/com/streamvault/data/sync/SyncManagerTest.kt
+++ b/data/src/test/java/com/streamvault/data/sync/SyncManagerTest.kt
@@@ -466,10 -389,7 +484,11 @@@ class SyncManagerTest
transactionRunner = transactionRunner,
preferencesRepository = preferencesRepo,
syncProgressBus = SyncProgressBus(),
+ stalkerRemoteIdentityResolver = mock(),
+ stalkerRequestCoordinator = com.streamvault.data.remote.stalker.StalkerRequestCoordinator(),
+ stalkerPortalStateStore = portalStateStore,
- stalkerReadinessTracker = readinessTracker
++ stalkerReadinessTracker = readinessTracker,
+ providerWorkflowCommitFence = ProviderWorkflowCommitFence()
)
// ── Initial state ───────────────────────────────────────────────