StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.
Kotlin iptv-player
Prepare production release
David Nashash338ceed32e5d
diff --git a/.gitignore b/.gitignoreindex 9f624c0d..b99d9823 100644--- a/.gitignore+++ b/.gitignore@@ -20,8 +20,12 @@ captures/.cxxlocal.propertieskeystore.properties+keystore/*.jks*.keystore+*.p12+*.pfx+*.pem# Build outputbuild_output_*.txtdiff --git a/PROJECT_SUMMARY.md b/PROJECT_SUMMARY.mddeleted file mode 100644index a4fb0fb0..00000000--- a/PROJECT_SUMMARY.md+++ /dev/null@@ -1,59 +0,0 @@-# StreamVault Development Summary: Phases 1 to 7--This document summarizes the research, decisions, and development milestones achieved during the first 7 phases of building the StreamVault IPTV application.--## Phase 1: Data Structuring & Repository Scaffolding-- **Objective**: Establish the core data layer for providers, channels, and VOD.-- **Added/Changed**:- - Designed local SQLite persistence using Android Room.- - Created `ProviderDao`, `ChannelDao`, `MovieDao` and `SeriesDao` focusing on the Xtream API schema.- - Implemented the `ProviderRepository` to orchestrate network fetches and local persistence.-- **Research**: Investigated the ideal local caching strategy for massive IPTV databases (handling up to 100k+ channels) prioritizing fast read times and paginated loading.--## Phase 2: M3U Support & Initial UI Prototyping-- **Objective**: Add support for traditional M3U playlists and build the first navigation skeleton.-- **Added/Changed**:- - Implemented an `M3uParser` using coroutines to traverse multi-megabyte M3U/M3U8 text files.- - Constructed the first Android TV layout using Compose for TV (`TvMaterial3`).- - Implemented the main left-side `TopNavBar` (later moved to the top in Phase 4) and fundamental screens (`HomeScreen`, `SettingsScreen`).--## Phase 3: Favorites & Advanced VOD Layouts-- **Objective**: Implement user favorites logic and improve the Video-on-Demand (VOD) catalog presentation.-- **Added/Changed**:- - Engineered `FavoritesRepository` crossing references across Channels, Movies, and Series.- - Upgraded VOD screens to use pagination and category filtering rows.- - Added "Continue Watching" history tracking logic.--## Phase 4: Media3 Playback & EPG Data Layer-- **Objective**: Integrate a robust player engine and establish background loading for the Electronic Program Guide (EPG).-- **Added/Changed**:- - Interfaced with `androidx.media3:media3-exoplayer` encapsulating playback, buffering, and track selection logic inside `Media3PlayerEngine`.- - Upgraded parser systems to fetch `xmltv` payloads for EPG parsing.- - Built the `EpgRepository` tying timeline occurrences to their respective `Channel` entities based on ID references.--## Phase 5: Cinematic Player & Localization-- **Objective**: Polish the main streaming UI and translate the app.-- **Added/Changed**:- - Implemented a premium cinematic overlay on `PlayerScreen` featuring animated gradients, system clocks, and intuitive transport controls.- - Re-mapped the application routing for complete Right-to-Left (RTL) matrix support (`he`, `ar`).- - Handled automated locale switching in `MainActivity` based on user-preference bypassing system settings.-- **Research**: Researched standard TV interaction patterns (DPAD navigation limits, focus trapping limits) ensuring RTL mirrored playback seeks.--## Phase 6: Sync Optimization & Testing Checkpoint-- **Objective**: Move heavy DB transactions off the UI thread and cement regressions.-- **Added/Changed**:- - Implemented AndroidX `WorkManager` initializing the `SyncWorker` allowing non-blocking daily background syncs.- - Rewrote DAO schemas to utilize compound SQL indexes making list lookups drastically faster.- - Introduced the Unit-Testing framework using Mockito and configured a GitHub Actions CI `.yml` for automated `assembleDebug` builds.-- **Research**: Investigated Catch-Up TV schemas spanning Xtream parameters and generalized M3U template tags (`{start}`, `{duration}`).--## Phase 7: UI/UX Master Polish & Bug Eradication-- **Objective**: Finalize the "Netflix Style" aesthetic and eliminate lingering interaction regressions.-- **Added/Changed**:- - Bypassed generic welcome screens if users already have saved providers.- - Rewrote the `MoviesScreen` and `SeriesScreen` to feature giant featured `HeroBanner` components with gradients and play actions.- - Hooked Live TV channels into DPAD extensions (`Left` opens the Channel List HUD overlay, `Right` opens the split EPG overlay).- - Squashed elusive `FocusRequester` state-loss issues in the Top Navigation bar which reset user positions during upward directional clicks.--## Next Up-Phase 8 opens the floor for feature expansion. The `feature/improvements` branch is live and the application is structurally sound.diff --git a/README.md b/README.mdindex 007d77f9..3f12fdb3 100644--- a/README.md+++ b/README.md@@ -1,101 +1,68 @@-# ๐บ StreamVault โ Android TV IPTV Player+# StreamVault-## ๐ Overview-**StreamVault** is a fast, modern, and production-grade **Android TV IPTV Player** built with **Jetpack Compose for TV**. It is designed to replace aging, clunky IPTV apps with a fluid, "console-like" user experience.+StreamVault is an Android TV IPTV player built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.-The app supports **Xtream Codes** API and standard **M3U** playlists. It features Live TV, Movies (VOD), Series, comprehensive EPG (Electronic Program Guide), and a robust Favorites system.+It is designed for large catalogs, remote-friendly navigation, and a polished TV-first playback experience. The app supports common IPTV provider formats, full library browsing, TV playback, and modern Android TV integrations.-### ๐ฏ Core Philosophy-- **Performance First**: Zero frame drops on standard Android TV hardware (Fire TV Stick 4K, Chromecast with Google TV).-- **TV-Native**: Designed strictly for D-Pad navigation. No "touch emulation". Focus management is explicit and deterministic.-- **Clean Architecture**: Strict separation of concerns (Domain, Data, Player, UI) to ensure scalability and maintainability.+## What It Does----+- Connects to IPTV providers using `M3U` playlists or `Xtream Codes`+- Syncs and organizes `Live TV`, `Movies`, and `Series`+- Provides a dedicated Android TV experience with Leanback launcher support+- Plays streams with Media3-based playback controls and track selection-## ๐ Architecture & Modules+## Supported Features-The project follows **Clean Architecture** principles with a multi-module Gradle setup:+- Provider setup for `M3U` and `Xtream Codes`+- Live TV with categories, channel search, favorites,custom categories and recent channels+- Movies and series libraries with category browsing and search+- Full EPG and now-playing data+- Global search across live channels, movies, and series+- Favorites and custom favorite groups+- Continue watching and playback history+- Multi-view playback for watching multiple streams+- Parental controls with PIN-protected categories+- Subtitle, audio-track, playback-speed, and video-track controls+- Cast integration+- Android TV home integrations such as launcher entry points and TV input support-### 1. `:app` (UI & Presentation)-- **Tech**: Jetpack Compose for TV, ViewModel, Hilt.-- **Responsibility**: Renders the UI, manages focus state, and handles user input.-- **Key Pattern**: "Screens" observe `UiState` flows from ViewModels. No business logic in Composables.+## Screenshots-### 2. `:domain` (Business Logic)-- **Tech**: Pure Kotlin.-- **Responsibility**: Defines core models (`Channel`, `Program`, `Provider`), Repository interfaces, and Use Cases (`GetChannelsUseCase`, `SyncEpgUseCase`).-- **Dependency**: Zero Android dependencies.+Add screenshots to `docs/images/` and update this section when assets are available.-### 3. `:data` (Data Layer)-- **Tech**: Room, Retrofit, OkHttp.-- **Responsibility**: Implements Repositories. Handles data synchronization, offline caching (Room), and API communication (Xtream Codes / M3U parsing).-- **Key Feature**: "Offline-First" capability using Room as the single source of truth.+Suggested files:-### 4. `:player` (Media Engine)-- **Tech**: Media3 (ExoPlayer).-- **Responsibility**: Encapsulates all playback logic. Handles adaptive streaming (HLS/DASH), track selection, and Zapping (channel switching).+- `docs/images/dashboard.png`+- `docs/images/live-tv.png`+- `docs/images/player.png`+- `docs/images/movies.png`+- `docs/images/series.png`+- `docs/images/search.png`+- `docs/images/multiview.png`----+## Project Structure-## ๐ Technology Stack+- `app/` Android app UI, navigation, DI, Android TV integrations+- `data/` Room database, sync, parsers, repositories, provider implementations+- `domain/` models, repository contracts, use cases, managers+- `player/` playback abstraction and Media3 player implementation-| Layer | Technology | Notes |-|-------|------------|-------|-| **Language** | Kotlin 2.0+ | Modern syntax, Coroutines, Flow. |-| **UI** | Jetpack Compose for TV | Specially designed for 10-foot interfaces. |-| **Media** | Media3 (ExoPlayer) | Robust playback for HLS, DASH, TS. |-| **DI** | Hilt | Standard dependency injection. |-| **Database** | Room | Local persistence for Channels, EPG, Favorites. |-| **Network** | Retrofit + OkHttp | Xtream Codes API client. |-| **Async** | Coroutines + Flow | All data streams are reactive. |-| **Image** | Coil | Optimized image loading with caching. |+## Build----+Requirements:-## โก Key Implementation Details (For Future Agents)+- Android Studio+- Android SDK+- JDK 17 or compatible Gradle-supported JDK-### ๐ฎ Focus & Input Handling (Crucial)-Android TV requires **explicit focus management**. Compose for TV handles much of this, but we use specific patterns for stability:-- **Search Bar**: Uses a custom `Box` + `BasicTextField` pattern. Standard `OutlinedTextField` causes keyboard focus issues on TV. The outer Box handles the D-Pad focus and click, then requests focus for the inner text field.-- **Long Press**: We use a **Top-Level Boolean Lock** (`ignoreNextClick`) in `HomeScreen` to handle the "Release after Long Press" event. This prevents the dialog from closing immediately when the user releases the select button.+Useful commands:-### ๐บ Playback & Zapping-- **Zapping**: Channel switching (Up/Down in player) is handled by passing `internalChannelId` to the player. The player uses this ID to query the database for the *next/previous* channel in the *current category context*.--### ๐ Favorites & Groups-- **Favorites**: Stored locally in Room. Toggling a favorite is optimistic and instant in the UI.-- **Custom Groups**: Users can create custom "Virtual Categories" to organize channels.--### ๐ฆ TV Compose And Accessibility Tracking-- `androidx.tv:tv-material` is intentionally pinned in `gradle/libs.versions.toml`.-- The library is now stable, but `SearchScreen` still uses `FilterChip` APIs behind `ExperimentalTvMaterial3Api`.-- Reduced-motion handling now respects Android's animator duration scale for shimmer and image crossfades.-- See `docs/audit/tv-compose-accessibility.md` for the current migration risk and accessibility checklist.-------## ๐ Getting Started--### Prerequisites-- Android Studio Koala or later.-- JDK 17+.-- Android TV Emulator (API 34) or physical device (Enabled Developer Options).--### Build Instructions-1. **Clone the repo**.-2. **Sync Gradle**.-3. **Run**: Select `app` configuration and run on an Android TV device.--### Project Structure-```text-streamvault/-โโโ app/ # UI, Navigation, DI-โโโ data/ # Database, API, Repository Impls-โโโ domain/ # Models, Use Cases, Interfaces-โโโ player/ # Media3/ExoPlayer Wrapper-โโโ gradle/ # Version Catalog (libs.versions.toml)+```bash+./gradlew assembleDebug+./gradlew testDebugUnitTest```----+## Notes-*Documentation maintained by Antigravity Agents.*+- StreamVault is an IPTV client, not a content provider.+- You are responsible for using playlist sources and streams you are authorized to access.diff --git a/app/build.gradle.kts b/app/build.gradle.ktsindex 8ecbb23e..ef501154 100644--- a/app/build.gradle.kts+++ b/app/build.gradle.kts@@ -13,7 +13,7 @@ plugins {val keystorePropertiesFile = rootProject.file("keystore.properties")val keystoreProperties = Properties()if (keystorePropertiesFile.exists()) {- keystoreProperties.load(FileInputStream(keystorePropertiesFile))+ FileInputStream(keystorePropertiesFile).use(keystoreProperties::load)}android {@@ -32,10 +32,10 @@ android {signingConfigs {if (keystorePropertiesFile.exists()) {create("release") {- storeFile = file(keystoreProperties["storeFile"] as String)- storePassword = keystoreProperties["storePassword"] as String- keyAlias = keystoreProperties["keyAlias"] as String- keyPassword = keystoreProperties["keyPassword"] as String+ storeFile = rootProject.file(keystoreProperties.getProperty("storeFile"))+ storePassword = keystoreProperties.getProperty("storePassword")+ keyAlias = keystoreProperties.getProperty("keyAlias")+ keyPassword = keystoreProperties.getProperty("keyPassword")}}}diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xmlindex 3a1e1435..d348456f 100644--- a/app/src/main/AndroidManifest.xml+++ b/app/src/main/AndroidManifest.xml@@ -4,7 +4,8 @@<uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />- <uses-permission android:name="com.google.android.tv.permission.WRITE_EPG_DATA" />+ <uses-permission android:name="com.android.providers.tv.permission.READ_EPG_DATA" />+ <uses-permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA" /><uses-permission android:name="android.permission.BIND_TV_INPUT" /><uses-featurediff --git a/app/src/main/java/com/streamvault/app/di/DatabaseModule.kt b/app/src/main/java/com/streamvault/app/di/DatabaseModule.ktindex 5c1d9b0f..b882b056 100644--- a/app/src/main/java/com/streamvault/app/di/DatabaseModule.kt+++ b/app/src/main/java/com/streamvault/app/di/DatabaseModule.kt@@ -39,7 +39,8 @@ object DatabaseModule {StreamVaultDatabase.MIGRATION_11_12,StreamVaultDatabase.MIGRATION_12_13,StreamVaultDatabase.MIGRATION_13_14,- StreamVaultDatabase.MIGRATION_14_15+ StreamVaultDatabase.MIGRATION_14_15,+ StreamVaultDatabase.MIGRATION_15_16)// NOTE: fallbackToDestructiveMigration() intentionally removed.// All future schema changes MUST add a corresponding Migration in StreamVaultDatabase.diff --git a/app/src/main/java/com/streamvault/app/tvinput/TvInputChannelSyncManager.kt b/app/src/main/java/com/streamvault/app/tvinput/TvInputChannelSyncManager.ktindex 715590a3..f52c19d8 100644--- a/app/src/main/java/com/streamvault/app/tvinput/TvInputChannelSyncManager.kt+++ b/app/src/main/java/com/streamvault/app/tvinput/TvInputChannelSyncManager.kt@@ -165,7 +165,6 @@ class TvInputChannelSyncManager @Inject constructor(put(CHANNEL_COLUMN_DISPLAY_NUMBER, channel.number.toString())put(CHANNEL_COLUMN_DISPLAY_NAME, channel.name)put(CHANNEL_COLUMN_DESCRIPTION, channel.categoryName ?: "IPTV")- put(CHANNEL_COLUMN_BROWSABLE, 1)put(CHANNEL_COLUMN_INTERNAL_PROVIDER_ID, channelKey(channel))put(CHANNEL_COLUMN_INTERNAL_PROVIDER_DATA, encodeChannelData(providerId, channel))put(CHANNEL_COLUMN_APP_LINK_INTENT_URI, buildChannelIntent(channel).toUri(Intent.URI_INTENT_SCHEME))diff --git a/app/src/main/java/com/streamvault/app/ui/model/LiveTvChannelMode.kt b/app/src/main/java/com/streamvault/app/ui/model/LiveTvChannelMode.ktindex 777d8866..a49397ef 100644--- a/app/src/main/java/com/streamvault/app/ui/model/LiveTvChannelMode.kt+++ b/app/src/main/java/com/streamvault/app/ui/model/LiveTvChannelMode.kt@@ -7,6 +7,6 @@ enum class LiveTvChannelMode {companion object {fun fromStorage(value: String?): LiveTvChannelMode =- entries.firstOrNull { it.name == value } ?: COMFORTABLE+ entries.firstOrNull { it.name == value } ?: COMPACT}}diff --git a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.ktindex 17d5a003..9426d7e3 100644--- a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt+++ b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt@@ -354,19 +354,20 @@ fun HomeScreen((category.isAdult || category.isUserProtected) && uiState.parentalControlLevel == 1}}+ val unlockedVisibleCategories = remember(visibleCategories, uiState.parentalControlLevel) {+ visibleCategories.filterNot(isCategoryLocked)+ }var lastFocusedCategoryId by rememberSaveable { mutableStateOf<Long?>(null) }var lastFocusedChannelId by rememberSaveable { mutableStateOf<Long?>(null) }var preferredRestoreTarget by rememberSaveable { mutableStateOf(FocusRestoreTarget.CHANNEL.name) }var shouldRestoreCategoryFocus by remember { mutableStateOf(false) }var shouldRestoreChannelFocus by remember { mutableStateOf(false) }- val visibleCategoryIds = remember(visibleCategories) {- visibleCategories.mapTo(mutableSetOf()) { it.id }- }- val displayedCategory = uiState.selectedCategory?.takeIf {- it.id in visibleCategoryIds && !isCategoryLocked(it)- } ?: visibleCategories.firstOrNull { !isCategoryLocked(it) }- val hasBlockedCategorySearch = displayedCategory == null && visibleCategories.isNotEmpty()+ val displayedCategory = uiState.selectedCategory?.takeIf { !isCategoryLocked(it) }+ val hasBlockedCategorySearch =+ uiState.categorySearchQuery.isNotBlank() &&+ visibleCategories.isNotEmpty() &&+ unlockedVisibleCategories.isEmpty()LaunchedEffect(uiState.categories) {val validIds = uiState.categories.mapTo(mutableSetOf()) { it.id }@@ -378,15 +379,16 @@ fun HomeScreen(channelFocusRequesters.keys.retainAll(validIds)}- LaunchedEffect(uiState.categorySearchQuery, displayedCategory?.id, isReorderMode, hasBlockedCategorySearch) {+ LaunchedEffect(uiState.categories, uiState.selectedCategory?.id, uiState.parentalControlLevel, isReorderMode) {if (isReorderMode) return@LaunchedEffect- if (displayedCategory == null) {- viewModel.clearVisibleChannelsForFilteredCategories()+ val selectedCategory = uiState.selectedCategory ?: return@LaunchedEffect+ if (!isCategoryLocked(selectedCategory)) {return@LaunchedEffect}- val selectedCategory = uiState.selectedCategory- if (selectedCategory?.id == displayedCategory.id) return@LaunchedEffect- viewModel.selectCategory(displayedCategory)+ val fallbackCategory = uiState.categories.firstOrNull { !isCategoryLocked(it) } ?: return@LaunchedEffect+ if (fallbackCategory.id != selectedCategory.id) {+ viewModel.selectCategory(fallbackCategory)+ }}LaunchedEffect(@@ -1107,6 +1109,9 @@ private fun LivePreviewPane(resizeMode = PlayerSurfaceResizeMode.FIT)},+ onRelease = { renderView ->+ playerEngine.releaseRenderView(renderView)+ },modifier = Modifier.fillMaxSize())} else {diff --git a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeViewModel.kt b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeViewModel.ktindex 06f54e5f..257c2185 100644--- a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeViewModel.kt+++ b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeViewModel.kt@@ -545,11 +545,9 @@ class HomeViewModel @Inject constructor(epgJob = viewModelScope.launch {val freshProgramMap = if (epgIds.isNotEmpty()) {- epgRepository.getNowPlayingForChannels(providerId, epgIds)- .firstOrNull()- ?.mapNotNull { (epgId, program) -> program?.let { epgId to it } }- ?.toMap()- ?: emptyMap()+ epgRepository.getNowPlayingForChannelsSnapshot(providerId, epgIds)+ .mapNotNull { (epgId, program) -> program?.let { epgId to it } }+ .toMap()} else {emptyMap()}diff --git a/app/src/main/java/com/streamvault/app/ui/screens/multiview/MultiViewScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/multiview/MultiViewScreen.ktindex d7bccf25..44983ffb 100644--- a/app/src/main/java/com/streamvault/app/ui/screens/multiview/MultiViewScreen.kt+++ b/app/src/main/java/com/streamvault/app/ui/screens/multiview/MultiViewScreen.kt@@ -352,6 +352,9 @@ private fun PlayerCell(resizeMode = PlayerSurfaceResizeMode.FILL)},+ onRelease = { renderView ->+ engine.releaseRenderView(renderView)+ },modifier = Modifier.fillMaxSize())}diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerScreen.ktindex 121d8371..e458071b 100644--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerScreen.kt+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerScreen.kt@@ -602,11 +602,18 @@ fun PlayerScreen()},update = { renderView ->+ // Only re-runs when aspectRatio changes (Compose tracks+ // the read of aspectRatio above). PlayerView's internal+ // AspectRatioFrameLayout handles video-size changes on+ // its own โ no need to rebind on every format change.viewModel.playerEngine.bindRenderView(renderView = renderView,resizeMode = aspectRatio.toPlayerSurfaceResizeMode())},+ onRelease = { renderView ->+ viewModel.playerEngine.releaseRenderView(renderView)+ },modifier = Modifier.fillMaxSize())@@ -922,10 +929,10 @@ private fun buildResolutionBadgeLabel(): String? {if (videoFormat.isEmpty) return nullval selectedTrack = videoTracks.firstOrNull(PlayerTrack::isSelected)- return if (selectedTrack?.id == PLAYER_TRACK_AUTO_ID) {+ return if (selectedTrack == null || selectedTrack.id == PLAYER_TRACK_AUTO_ID) {autoResolutionLabel} else {- videoFormat.resolutionLabel+ selectedTrack.name}}diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsViewModel.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsViewModel.ktindex 3d4f3b55..bf4ecfeb 100644--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsViewModel.kt+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsViewModel.kt@@ -116,7 +116,7 @@ class SettingsViewModel @Inject constructor(lastSpeedTestRecommendedHeight = null,lastSpeedTestEstimated = false,isIncognitoMode = false,- liveTvChannelMode = LiveTvChannelMode.COMFORTABLE+ liveTvChannelMode = LiveTvChannelMode.COMPACT)}.combine(preferencesRepository.appLanguage) { snapshot, language ->snapshot.copy(appLanguage = language)diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xmlindex 9708e7f7..8c504b66 100644--- a/app/src/main/res/values/strings.xml+++ b/app/src/main/res/values/strings.xml@@ -616,7 +616,7 @@<string name="player_track_off">Off</string><string name="player_video_quality">Video Quality</string><string name="player_aspect_ratio_label">Aspect %1$s</string>- <string name="player_resolution_auto_label">Auto: %1$s</string>+ <string name="player_resolution_auto_label">AUTO:%1$s</string><string name="player_channel_not_found">Channel not found</string><string name="player_type_channel_number">Type channel number</string><string name="player_selected">Selected</string>diff --git a/data/schemas/com.streamvault.data.local.StreamVaultDatabase/16.json b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/16.jsonnew file mode 100644index 00000000..dad25863--- /dev/null+++ b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/16.json@@ -0,0 +1,1638 @@+{+ "formatVersion": 1,+ "database": {+ "version": 16,+ "identityHash": "0b4b53fb18e665b6a09e8fba58397ffb",+ "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, `is_active` INTEGER NOT NULL, `max_connections` INTEGER NOT NULL, `expiration_date` INTEGER, `api_version` TEXT, `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": "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": "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",+ "unique": true,+ "columnNames": [+ "server_url",+ "username"+ ],+ "orders": [],+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_providers_server_url_username` ON `${TABLE_NAME}` (`server_url`, `username`)"+ }+ ]+ },+ {+ "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, 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"+ }+ ],+ "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, `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": "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, `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 )",+ "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": "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_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`)"+ }+ ],+ "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, `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, 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": "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+ }+ ],+ "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`)"+ }+ ],+ "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, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",+ "fields": [+ {+ "fieldPath": "id",+ "columnName": "id",+ "affinity": "INTEGER",+ "notNull": true+ },+ {+ "fieldPath": "categoryId",+ "columnName": "category_id",+ "affinity": "INTEGER",+ "notNull": true+ },+ {+ "fieldPath": "name",+ "columnName": "name",+ "affinity": "TEXT",+ "notNull": true+ },+ {+ "fieldPath": "parentId",+ "columnName": "parent_id",+ "affinity": "INTEGER"+ },+ {+ "fieldPath": "type",+ "columnName": "type",+ "affinity": "TEXT",+ "notNull": true+ },+ {+ "fieldPath": "providerId",+ "columnName": "provider_id",+ "affinity": "INTEGER",+ "notNull": true+ },+ {+ "fieldPath": "isAdult",+ "columnName": "is_adult",+ "affinity": "INTEGER",+ "notNull": true+ },+ {+ "fieldPath": "isUserProtected",+ "columnName": "is_user_protected",+ "affinity": "INTEGER",+ "notNull": true+ }+ ],+ "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": "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_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, `content_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `position` INTEGER NOT NULL, `group_id` INTEGER, `added_at` INTEGER NOT NULL, 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": "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": "addedAt",+ "columnName": "added_at",+ "affinity": "INTEGER",+ "notNull": true+ }+ ],+ "primaryKey": {+ "autoGenerate": true,+ "columnNames": [+ "id"+ ]+ },+ "indices": [+ {+ "name": "index_favorites_content_id_content_type_group_id",+ "unique": true,+ "columnNames": [+ "content_id",+ "content_type",+ "group_id"+ ],+ "orders": [],+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_favorites_content_id_content_type_group_id` ON `${TABLE_NAME}` (`content_id`, `content_type`, `group_id`)"+ },+ {+ "name": "index_favorites_content_type_group_id",+ "unique": false,+ "columnNames": [+ "content_type",+ "group_id"+ ],+ "orders": [],+ "createSql": "CREATE INDEX IF NOT EXISTS `index_favorites_content_type_group_id` ON `${TABLE_NAME}` (`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": "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, `name` TEXT NOT NULL, `icon_emoji` TEXT, `position` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `content_type` TEXT NOT NULL)",+ "fields": [+ {+ "fieldPath": "id",+ "columnName": "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_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`)"+ }+ ]+ },+ {+ "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`)"+ }+ ],+ "foreignKeys": [+ {+ "table": "providers",+ "onDelete": "CASCADE",+ "onUpdate": "NO ACTION",+ "columns": [+ "provider_id"+ ],+ "referencedColumns": [+ "id"+ ]+ }+ ]+ },+ {+ "tableName": "sync_metadata",+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `last_live_sync` INTEGER NOT NULL, `last_movie_sync` INTEGER NOT NULL, `last_series_sync` INTEGER NOT NULL, `last_epg_sync` 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, 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": "lastMovieSync",+ "columnName": "last_movie_sync",+ "affinity": "INTEGER",+ "notNull": true+ },+ {+ "fieldPath": "lastSeriesSync",+ "columnName": "last_series_sync",+ "affinity": "INTEGER",+ "notNull": true+ },+ {+ "fieldPath": "lastEpgSync",+ "columnName": "last_epg_sync",+ "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+ }+ ],+ "primaryKey": {+ "autoGenerate": false,+ "columnNames": [+ "provider_id"+ ]+ },+ "foreignKeys": [+ {+ "table": "providers",+ "onDelete": "CASCADE",+ "onUpdate": "NO ACTION",+ "columns": [+ "provider_id"+ ],+ "referencedColumns": [+ "id"+ ]+ }+ ]+ }+ ],+ "setupQueries": [+ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '0b4b53fb18e665b6a09e8fba58397ffb')"+ ]+ }+}\ No newline at end of filediff --git a/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt b/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.ktindex 97896f75..7b5a423a 100644--- a/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt+++ b/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt@@ -26,7 +26,7 @@ import com.streamvault.data.local.entity.*PlaybackHistoryEntity::class,SyncMetadataEntity::class],- version = 15,+ version = 16,exportSchema = true // โ was false; schema JSON now tracked in version control)@TypeConverters(RoomEnumConverters::class)@@ -959,5 +959,14 @@ abstract class StreamVaultDatabase : RoomDatabase() {database.execSQL("ALTER TABLE playback_history ADD COLUMN watched_status TEXT NOT NULL DEFAULT 'IN_PROGRESS'")}}++ val MIGRATION_15_16 = object : Migration(15, 16) {+ override fun migrate(database: SupportSQLiteDatabase) {+ database.execSQL(+ "CREATE INDEX IF NOT EXISTS index_channels_provider_id_category_id_logical_group_id " ++ "ON channels(provider_id, category_id, logical_group_id)"+ )+ }+ }}-}\ No newline at end of file+}diff --git a/data/src/main/java/com/streamvault/data/local/dao/Daos.kt b/data/src/main/java/com/streamvault/data/local/dao/Daos.ktindex 89dc279c..ce118e73 100644--- a/data/src/main/java/com/streamvault/data/local/dao/Daos.kt+++ b/data/src/main/java/com/streamvault/data/local/dao/Daos.kt@@ -79,9 +79,10 @@ interface ChannelDao {WHERE c.provider_id = :providerIdAND channels_fts MATCH :queryORDER BY c.name ASC+ LIMIT :limit""")- fun search(providerId: Long, query: String): Flow<List<ChannelEntity>>+ fun search(providerId: Long, query: String, limit: Int): Flow<List<ChannelEntity>>@Query("""@@ -91,9 +92,10 @@ interface ChannelDao {AND c.category_id = :categoryIdAND channels_fts MATCH :queryORDER BY c.name ASC+ LIMIT :limit""")- fun searchByCategory(providerId: Long, categoryId: Long, query: String): Flow<List<ChannelEntity>>+ fun searchByCategory(providerId: Long, categoryId: Long, query: String, limit: Int): Flow<List<ChannelEntity>>@Query("SELECT * FROM channels WHERE id = :id")suspend fun getById(id: Long): ChannelEntity?@@ -126,6 +128,24 @@ interface ChannelDao {@Query("SELECT category_id, COUNT(*) as item_count FROM channels WHERE provider_id = :providerId AND category_id IS NOT NULL GROUP BY category_id")fun getCategoryCounts(providerId: Long): Flow<List<CategoryCount>>+ @Query(+ """+ SELECT+ category_id,+ COUNT(+ DISTINCT CASE+ WHEN logical_group_id IS NOT NULL AND logical_group_id != '' THEN logical_group_id+ ELSE CAST(id AS TEXT)+ END+ ) AS item_count+ FROM channels+ WHERE provider_id = :providerId+ AND category_id IS NOT NULL+ GROUP BY category_id+ """+ )+ fun getGroupedCategoryCounts(providerId: Long): Flow<List<CategoryCount>>+@Query("SELECT COUNT(*) FROM channels WHERE provider_id = :providerId")fun getCount(providerId: Long): Flow<Int>@@ -189,9 +209,10 @@ interface MovieDao {WHERE m.provider_id = :providerIdAND movies_fts MATCH :queryORDER BY m.name ASC+ LIMIT :limit""")- fun search(providerId: Long, query: String): Flow<List<MovieEntity>>+ fun search(providerId: Long, query: String, limit: Int): Flow<List<MovieEntity>>@Query("SELECT * FROM movies WHERE id = :id")suspend fun getById(id: Long): MovieEntity?@@ -350,9 +371,10 @@ interface SeriesDao {WHERE s.provider_id = :providerIdAND series_fts MATCH :queryORDER BY s.name ASC+ LIMIT :limit""")- fun search(providerId: Long, query: String): Flow<List<SeriesEntity>>+ fun search(providerId: Long, query: String, limit: Int): Flow<List<SeriesEntity>>@Query("SELECT * FROM series WHERE id = :id")suspend fun getById(id: Long): SeriesEntity?@@ -627,6 +649,9 @@ interface ProgramDao {@Query("SELECT * FROM programs WHERE provider_id = :providerId AND channel_id IN (:channelIds) AND start_time <= :now AND end_time > :now")fun getNowPlayingForChannels(providerId: Long, channelIds: List<String>, now: Long = System.currentTimeMillis()): Flow<List<ProgramEntity>>+ @Query("SELECT * FROM programs WHERE provider_id = :providerId AND channel_id IN (:channelIds) AND start_time <= :now AND end_time > :now")+ suspend fun getNowPlayingForChannelsSync(providerId: Long, channelIds: List<String>, now: Long = System.currentTimeMillis()): List<ProgramEntity>+@Insert(onConflict = OnConflictStrategy.REPLACE)suspend fun insertAll(programs: List<ProgramEntity>)diff --git a/data/src/main/java/com/streamvault/data/local/entity/Entities.kt b/data/src/main/java/com/streamvault/data/local/entity/Entities.ktindex bd815648..cbe6556c 100644--- a/data/src/main/java/com/streamvault/data/local/entity/Entities.kt+++ b/data/src/main/java/com/streamvault/data/local/entity/Entities.kt@@ -45,7 +45,8 @@ data class ProviderEntity(Index(value = ["provider_id"]),Index(value = ["provider_id", "category_id"]),Index(value = ["provider_id", "stream_id"], unique = true),- Index(value = ["logical_group_id"])+ Index(value = ["logical_group_id"]),+ Index(value = ["provider_id", "category_id", "logical_group_id"])])data class ChannelEntity(diff --git a/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.ktindex 9fb53010..853433e0 100644--- a/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt+++ b/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt@@ -30,6 +30,11 @@ class ChannelRepositoryImpl @Inject constructor(private val parentalControlManager: com.streamvault.domain.manager.ParentalControlManager,private val xtreamStreamUrlResolver: XtreamStreamUrlResolver) : ChannelRepository {+ private companion object {+ const val GLOBAL_SEARCH_LIMIT = 320+ const val CATEGORY_SEARCH_LIMIT = 750+ val QUALITY_HEIGHT_REGEX = Regex("(?<!\\d)(2160|1440|1080|720|576|480|360|240)p?(?!\\d)", RegexOption.IGNORE_CASE)+ }private data class ChannelGroupAccumulator(var primary: ChannelEntity,@@ -64,9 +69,9 @@ class ChannelRepositoryImpl @Inject constructor(} else {combine(if (categoryId == ChannelRepository.ALL_CHANNELS_ID) {- channelDao.search(providerId, ftsQuery)+ channelDao.search(providerId, ftsQuery, CATEGORY_SEARCH_LIMIT)} else {- channelDao.searchByCategory(providerId, categoryId, ftsQuery)+ channelDao.searchByCategory(providerId, categoryId, ftsQuery, CATEGORY_SEARCH_LIMIT)},preferencesRepository.parentalControlLevel,parentalControlManager.unlockedCategoriesForProvider(providerId)@@ -88,36 +93,19 @@ class ChannelRepositoryImpl @Inject constructor(override fun getCategories(providerId: Long): Flow<List<Category>> =combine(categoryDao.getByProviderAndType(providerId, ContentType.LIVE.name),- channelDao.getByProvider(providerId),+ channelDao.getGroupedCategoryCounts(providerId),preferencesRepository.parentalControlLevel,parentalControlManager.unlockedCategoriesForProvider(providerId)- ) { categories: List<CategoryEntity>, channelEntities: List<ChannelEntity>, level: Int, unlockedCats: Set<Long> ->- val filteredChannels = applyVisibilityFilter(channelEntities, level, unlockedCats)- val groupedChannels = groupPrimaryChannelEntities(filteredChannels)- val countMap = groupedChannels- .mapNotNull { entity -> entity.categoryId }- .groupingBy { categoryId -> categoryId }- .eachCount()-- val allChannelsCategory = Category(- id = ChannelRepository.ALL_CHANNELS_ID,- name = "All Channels",- type = ContentType.LIVE,- count = groupedChannels.size- )-+ ) { categories: List<CategoryEntity>, categoryCounts, level: Int, unlockedCats: Set<Long> ->+ val countMap = categoryCounts.associate { count -> count.categoryId to count.item_count }val mappedCategories = categories.map { entity ->val domain = entity.toDomain().copy(count = countMap[entity.categoryId] ?: 0)- // If unlocked, update domain model (though Category model doesn't strictly need it if we trust the check elsewhere,- // but nice for UI to show 'unlocked' icon if we had one. For now just passing through).- if (unlockedCats.contains(entity.categoryId)) {+ if (unlockedCats.contains(entity.categoryId)) {domain.copy(isUserProtected = false)} else {domain}}-- // Filter categories if level is HIDDENval filteredCategories = if (level == 2) {mappedCategories.filter { category ->(!category.isAdult && !category.isUserProtected) || unlockedCats.contains(category.id)@@ -125,7 +113,14 @@ class ChannelRepositoryImpl @Inject constructor(} else {mappedCategories}-++ val allChannelsCategory = Category(+ id = ChannelRepository.ALL_CHANNELS_ID,+ name = "All Channels",+ type = ContentType.LIVE,+ count = filteredCategories.sumOf(Category::count)+ )+listOf(allChannelsCategory) + filteredCategories}@@ -134,7 +129,7 @@ class ChannelRepositoryImpl @Inject constructor(if (ftsQuery.isBlank()) {flowOf(emptyList())} else combine(- channelDao.search(providerId, ftsQuery),+ channelDao.search(providerId, ftsQuery, GLOBAL_SEARCH_LIMIT),preferencesRepository.parentalControlLevel,parentalControlManager.unlockedCategoriesForProvider(providerId)) { entities, level, unlockedCats ->@@ -228,8 +223,13 @@ class ChannelRepositoryImpl @Inject constructor(.sortedWith(channelPriorityComparator).map { it.streamUrl }- val mergedQualityOptions = buildMergedQualityOptions(primaryEntity, alternativeStreams)- val domain = primaryEntity.toDomain().copy(+ val primaryDomain = primaryEntity.toDomain()+ val mergedQualityOptions = buildMergedQualityOptions(+ baseOptions = primaryDomain.qualityOptions,+ primaryStreamUrl = primaryEntity.streamUrl,+ alternativeStreams = alternativeStreams+ )+ val domain = primaryDomain.copy(qualityOptions = mergedQualityOptions,alternativeStreams = alternativeStreams)@@ -274,24 +274,12 @@ class ChannelRepositoryImpl @Inject constructor(channelDao.getByCategoryWithoutErrors(providerId, categoryId)}- private fun groupPrimaryChannelEntities(entities: List<ChannelEntity>): List<ChannelEntity> {- val primaries = LinkedHashMap<String, ChannelEntity>()- entities.forEach { entity ->- val key = channelGroupKey(entity)- val current = primaries[key]- if (current == null || channelPriorityComparator.compare(entity, current) < 0) {- primaries[key] = entity- }- }- return primaries.values.toList()- }-private fun buildMergedQualityOptions(- primaryEntity: ChannelEntity,+ baseOptions: List<com.streamvault.domain.model.ChannelQualityOption>,+ primaryStreamUrl: String,alternativeStreams: List<String>): List<com.streamvault.domain.model.ChannelQualityOption> {- val baseOptions = primaryEntity.toDomain().qualityOptions- val derivedOptions = (listOf(primaryEntity.streamUrl) + alternativeStreams)+ val derivedOptions = (listOf(primaryStreamUrl) + alternativeStreams).mapNotNull(::deriveQualityOption)return (baseOptions + derivedOptions).distinctBy { option -> option.height to option.label }@@ -308,10 +296,6 @@ class ChannelRepositoryImpl @Inject constructor()}- private companion object {- val QUALITY_HEIGHT_REGEX = Regex("(?<!\\d)(2160|1440|1080|720|576|480|360|240)p?(?!\\d)", RegexOption.IGNORE_CASE)- }-private fun channelGroupKey(entity: ChannelEntity): String =if (entity.logicalGroupId.isNotBlank()) entity.logicalGroupId else entity.id.toString()}diff --git a/data/src/main/java/com/streamvault/data/repository/EpgRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/EpgRepositoryImpl.ktindex 5f388b04..5324878b 100644--- a/data/src/main/java/com/streamvault/data/repository/EpgRepositoryImpl.kt+++ b/data/src/main/java/com/streamvault/data/repository/EpgRepositoryImpl.kt@@ -131,6 +131,25 @@ class EpgRepositoryImpl @Inject constructor(}}+ override suspend fun getNowPlayingForChannelsSnapshot(+ providerId: Long,+ channelIds: List<String>+ ): Map<String, Program?> {+ if (channelIds.isEmpty()) return emptyMap()++ val now = System.currentTimeMillis()+ val entities = if (channelIds.size <= 500) {+ programDao.getNowPlayingForChannelsSync(providerId, channelIds, now)+ } else {+ channelIds.chunked(500).flatMap { chunk ->+ programDao.getNowPlayingForChannelsSync(providerId, chunk, now)+ }+ }++ val grouped = entities.map { it.toDomain() }.groupBy { it.channelId }+ return channelIds.associateWith { id -> grouped[id]?.firstOrNull() }+ }+override fun getNowAndNext(providerId: Long, channelId: String): Flow<Pair<Program?, Program?>> =nowTicker().flatMapLatest { now ->programDao.getForChannel(diff --git a/data/src/main/java/com/streamvault/data/repository/MovieRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/MovieRepositoryImpl.ktindex ac7156f3..0698e907 100644--- a/data/src/main/java/com/streamvault/data/repository/MovieRepositoryImpl.kt+++ b/data/src/main/java/com/streamvault/data/repository/MovieRepositoryImpl.kt@@ -41,6 +41,9 @@ class MovieRepositoryImpl @Inject constructor(private val playbackHistoryDao: PlaybackHistoryDao,private val xtreamStreamUrlResolver: XtreamStreamUrlResolver) : MovieRepository {+ private companion object {+ const val SEARCH_RESULT_LIMIT = 320+ }override fun getMovies(providerId: Long): Flow<List<Movie>> =preferencesRepository.parentalControlLevel.flatMapLatest { level ->@@ -227,7 +230,7 @@ class MovieRepositoryImpl @Inject constructor(if (ftsQuery.isBlank()) {flowOf(emptyList())} else combine(- movieDao.search(providerId, ftsQuery),+ movieDao.search(providerId, ftsQuery, SEARCH_RESULT_LIMIT),preferencesRepository.parentalControlLevel) { entities: List<MovieEntity>, level: Int ->if (level == 2) {diff --git a/data/src/main/java/com/streamvault/data/repository/SeriesRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/SeriesRepositoryImpl.ktindex 042ced15..b14d5d4c 100644--- a/data/src/main/java/com/streamvault/data/repository/SeriesRepositoryImpl.kt+++ b/data/src/main/java/com/streamvault/data/repository/SeriesRepositoryImpl.kt@@ -36,6 +36,9 @@ class SeriesRepositoryImpl @Inject constructor(private val preferencesRepository: PreferencesRepository,private val xtreamStreamUrlResolver: XtreamStreamUrlResolver) : SeriesRepository {+ private companion object {+ const val SEARCH_RESULT_LIMIT = 320+ }private data class CachedXtreamProvider(val signature: String,@@ -215,7 +218,7 @@ class SeriesRepositoryImpl @Inject constructor(if (ftsQuery.isBlank()) {flowOf(emptyList())} else combine(- seriesDao.search(providerId, ftsQuery),+ seriesDao.search(providerId, ftsQuery, SEARCH_RESULT_LIMIT),preferencesRepository.parentalControlLevel) { entities: List<SeriesEntity>, level: Int ->if (level == 2) {diff --git a/data/src/main/java/com/streamvault/data/sync/SyncManager.kt b/data/src/main/java/com/streamvault/data/sync/SyncManager.ktindex 4560042b..3ccfe38f 100644--- a/data/src/main/java/com/streamvault/data/sync/SyncManager.kt+++ b/data/src/main/java/com/streamvault/data/sync/SyncManager.kt@@ -22,9 +22,7 @@ import com.streamvault.data.remote.xtream.XtreamUrlFactoryimport com.streamvault.data.security.CredentialCryptoimport com.streamvault.data.util.AdultContentClassifierimport com.streamvault.data.util.UrlSecurityPolicy-import com.streamvault.domain.model.Channelimport com.streamvault.domain.model.ContentType-import com.streamvault.domain.model.Movieimport com.streamvault.domain.model.Providerimport com.streamvault.domain.model.ProviderTypeimport com.streamvault.domain.model.SyncMetadata@@ -92,17 +90,30 @@ class SyncManager @Inject constructor(val sourceName: String? = null)+ private class StableLongHasher {+ private val digest = MessageDigest.getInstance("SHA-256")++ fun hash(input: String): Long {+ val bytes = digest.digest(input.toByteArray(Charsets.UTF_8))+ var result = 0L+ for (i in 0 until 8) {+ result = (result shl 8) or (bytes[i].toLong() and 0xFF)+ }+ return result and Long.MAX_VALUE+ }+ }+private class CategoryAccumulator(private val providerId: Long,private val type: ContentType,- private val startId: Long // retained for API compatibility but no longer used in ID generation+ private val hasher: StableLongHasher) {private val categoryIds = LinkedHashMap<String, Long>()val count: Intget() = categoryIds.sizefun idFor(name: String): Long {- return categoryIds.getOrPut(name) { stableId(providerId, type, name) }+ return categoryIds.getOrPut(name) { stableId(providerId, type, name, hasher) }}fun entities(): List<CategoryEntity> {@@ -119,13 +130,13 @@ class SyncManager @Inject constructor(}/** Generates a stable, collision-resistant ID from the provider+type+name triple. */- private fun stableId(providerId: Long, type: ContentType, name: String): Long {- val key = "$providerId/${type.name}/$name"- val bytes = java.security.MessageDigest.getInstance("SHA-256")- .digest(key.toByteArray(Charsets.UTF_8))- var result = 0L- for (i in 0 until 8) result = (result shl 8) or (bytes[i].toLong() and 0xFF)- return (result and Long.MAX_VALUE).coerceAtLeast(1L)+ private fun stableId(+ providerId: Long,+ type: ContentType,+ name: String,+ hasher: StableLongHasher+ ): Long {+ return hasher.hash("$providerId/${type.name}/$name").coerceAtLeast(1L)}}@@ -451,8 +462,9 @@ class SyncManager @Inject constructor(progress(provider.id, onProgress, "Downloading Playlist...")val existingChannelIds = if (includeLive) channelDao.getIdMappings(provider.id).associate { it.remoteId to it.id } else emptyMap()val existingMovieIds = if (includeMovies) movieDao.getIdMappings(provider.id).associate { it.remoteId to it.id } else emptyMap()- val liveCategories = CategoryAccumulator(provider.id, ContentType.LIVE, 1L)- val movieCategories = CategoryAccumulator(provider.id, ContentType.MOVIE, 10_000L)+ val stableLongHasher = StableLongHasher()+ val liveCategories = CategoryAccumulator(provider.id, ContentType.LIVE, stableLongHasher)+ val movieCategories = CategoryAccumulator(provider.id, ContentType.MOVIE, stableLongHasher)val channelBatch = ArrayList<ChannelEntity>(batchSize)val movieBatch = ArrayList<MovieEntity>(batchSize)val seenLiveStreamIds = if (includeLive) mutableSetOf<Long>() else null@@ -464,8 +476,6 @@ class SyncManager @Inject constructor(var nextMilestone = PROGRESS_INTERVALval warnings = mutableListOf<String>()var insecureStreamCount = 0- var publishedLiveCategoryCount = 0- var publishedMovieCategoryCount = 0openPlaylistStream(provider) { streamed ->progress(provider.id, onProgress, "Parsing Playlist...")@@ -482,14 +492,6 @@ class SyncManager @Inject constructor() { entry ->parsedCount++if (parsedCount >= nextMilestone) {- if (includeLive && liveCategories.count > publishedLiveCategoryCount) {- categoryDao.insertAll(liveCategories.entities())- publishedLiveCategoryCount = liveCategories.count- }- if (includeMovies && movieCategories.count > publishedMovieCategoryCount) {- categoryDao.insertAll(movieCategories.entities())- publishedMovieCategoryCount = movieCategories.count- }progress(provider.id, onProgress, "Imported $parsedCount playlist entries...")nextMilestone += PROGRESS_INTERVAL}@@ -506,24 +508,25 @@ class SyncManager @Inject constructor(return@parseStreaming}val groupTitle = entry.groupTitle.ifBlank { "Uncategorized" }- val stableStreamId = stableId(provider.id, entry.tvgId, entry.url)+ val stableStreamId = stableId(provider.id, entry.tvgId, entry.url, stableLongHasher)+ val categoryId = movieCategories.idFor(groupTitle)+ val isAdult = AdultContentClassifier.isAdultCategoryName(groupTitle)seenMovieStreamIds?.add(stableStreamId)- movieCategories.idFor(groupTitle)movieBatch.add(- Movie(+ MovieEntity(id = existingMovieIds[stableStreamId] ?: 0L,+ streamId = stableStreamId,name = entry.name,posterUrl = safeLogoUrl,- categoryId = movieCategories.idFor(groupTitle),+ categoryId = categoryId,categoryName = groupTitle,streamUrl = entry.url,providerId = provider.id,rating = entry.rating?.toFloatOrNull() ?: 0f,year = entry.year,genre = entry.genre,- isAdult = AdultContentClassifier.isAdultCategoryName(groupTitle),- streamId = stableStreamId- ).toEntity()+ isAdult = isAdult+ ))movieCount++if (movieBatch.size >= batchSize) {@@ -534,16 +537,18 @@ class SyncManager @Inject constructor(return@parseStreaming}val groupTitle = entry.groupTitle.ifBlank { "Uncategorized" }- val stableStreamId = stableId(provider.id, entry.tvgId, entry.url)+ val stableStreamId = stableId(provider.id, entry.tvgId, entry.url, stableLongHasher)+ val categoryId = liveCategories.idFor(groupTitle)+ val isAdult = AdultContentClassifier.isAdultCategoryName(groupTitle)seenLiveStreamIds?.add(stableStreamId)- liveCategories.idFor(groupTitle)channelBatch.add(- Channel(+ ChannelEntity(id = existingChannelIds[stableStreamId] ?: 0L,+ streamId = stableStreamId,name = entry.name,logoUrl = safeLogoUrl,groupTitle = groupTitle,- categoryId = liveCategories.idFor(groupTitle),+ categoryId = categoryId,categoryName = groupTitle,epgChannelId = entry.tvgId ?: entry.tvgName,number = entry.tvgChno ?: 0,@@ -552,9 +557,8 @@ class SyncManager @Inject constructor(catchUpDays = entry.catchUpDays ?: 0,catchUpSource = safeCatchUpSource,providerId = provider.id,- isAdult = AdultContentClassifier.isAdultCategoryName(groupTitle),- streamId = stableStreamId- ).toEntity()+ isAdult = isAdult+ ))liveCount++if (channelBatch.size >= batchSize) {@@ -694,21 +698,17 @@ class SyncManager @Inject constructor(}}- private fun stableId(providerId: Long, tvgId: String?, url: String): Long {+ private fun stableId(+ providerId: Long,+ tvgId: String?,+ url: String,+ hasher: StableLongHasher+ ): Long {return if (!tvgId.isNullOrBlank()) {- hashToLong("$providerId:tvg:$tvgId")+ hasher.hash("$providerId:tvg:$tvgId")} else {- hashToLong("$providerId:url:$url")- }- }-- private fun hashToLong(input: String): Long {- val digest = MessageDigest.getInstance("SHA-256").digest(input.toByteArray(Charsets.UTF_8))- var result = 0L- for (i in 0 until 8) {- result = (result shl 8) or (digest[i].toLong() and 0xFF)+ hasher.hash("$providerId:url:$url")}- return result and Long.MAX_VALUE}/** Delegates to M3uParser to avoid duplicate logic. */diff --git a/data/src/test/java/com/streamvault/data/repository/ChannelRepositoryImplTest.kt b/data/src/test/java/com/streamvault/data/repository/ChannelRepositoryImplTest.ktnew file mode 100644index 00000000..c16078b5--- /dev/null+++ b/data/src/test/java/com/streamvault/data/repository/ChannelRepositoryImplTest.kt@@ -0,0 +1,117 @@+package com.streamvault.data.repository++import com.google.common.truth.Truth.assertThat+import com.streamvault.data.local.dao.CategoryDao+import com.streamvault.data.local.dao.ChannelDao+import com.streamvault.data.local.entity.CategoryCount+import com.streamvault.data.local.entity.CategoryEntity+import com.streamvault.data.preferences.PreferencesRepository+import com.streamvault.data.remote.xtream.XtreamStreamUrlResolver+import com.streamvault.domain.manager.ParentalControlManager+import com.streamvault.domain.model.ContentType+import kotlinx.coroutines.flow.first+import kotlinx.coroutines.flow.flowOf+import kotlinx.coroutines.test.runTest+import org.junit.Test+import org.mockito.kotlin.any+import org.mockito.kotlin.eq+import org.mockito.kotlin.mock+import org.mockito.kotlin.never+import org.mockito.kotlin.verify+import org.mockito.kotlin.whenever++class ChannelRepositoryImplTest {++ private val channelDao: ChannelDao = mock()+ private val categoryDao: CategoryDao = mock()+ private val preferencesRepository: PreferencesRepository = mock()+ private val parentalControlManager: ParentalControlManager = mock()+ private val xtreamStreamUrlResolver: XtreamStreamUrlResolver = mock()++ @Test+ fun `getCategories uses grouped counts without loading all channels`() = runTest {+ whenever(categoryDao.getByProviderAndType(7L, ContentType.LIVE.name)).thenReturn(+ flowOf(+ listOf(+ categoryEntity(id = 10L, name = "News"),+ categoryEntity(id = 20L, name = "Sports")+ )+ )+ )+ whenever(channelDao.getGroupedCategoryCounts(7L)).thenReturn(+ flowOf(+ listOf(+ CategoryCount(categoryId = 10L, item_count = 4),+ CategoryCount(categoryId = 20L, item_count = 6)+ )+ )+ )+ whenever(preferencesRepository.parentalControlLevel).thenReturn(flowOf(0))+ whenever(parentalControlManager.unlockedCategoriesForProvider(7L)).thenReturn(flowOf(emptySet()))++ val repository = createRepository()++ val result = repository.getCategories(7L).first()++ assertThat(result.map { it.name to it.count }).containsExactly(+ "All Channels" to 10,+ "News" to 4,+ "Sports" to 6+ ).inOrder()+ verify(channelDao).getGroupedCategoryCounts(7L)+ verify(channelDao, never()).getByProvider(any())+ }++ @Test+ fun `getCategories keeps unlocked protected category visible at hidden level`() = runTest {+ whenever(categoryDao.getByProviderAndType(7L, ContentType.LIVE.name)).thenReturn(+ flowOf(+ listOf(+ categoryEntity(id = 10L, name = "Kids"),+ categoryEntity(id = 20L, name = "Adults", isUserProtected = true)+ )+ )+ )+ whenever(channelDao.getGroupedCategoryCounts(7L)).thenReturn(+ flowOf(+ listOf(+ CategoryCount(categoryId = 10L, item_count = 3),+ CategoryCount(categoryId = 20L, item_count = 5)+ )+ )+ )+ whenever(preferencesRepository.parentalControlLevel).thenReturn(flowOf(2))+ whenever(parentalControlManager.unlockedCategoriesForProvider(eq(7L))).thenReturn(flowOf(setOf(20L)))++ val repository = createRepository()++ val result = repository.getCategories(7L).first()++ assertThat(result.map { it.name to it.count }).containsExactly(+ "All Channels" to 8,+ "Kids" to 3,+ "Adults" to 5+ ).inOrder()+ assertThat(result.first { it.id == 20L }.isUserProtected).isFalse()+ }++ private fun createRepository() = ChannelRepositoryImpl(+ channelDao = channelDao,+ categoryDao = categoryDao,+ preferencesRepository = preferencesRepository,+ parentalControlManager = parentalControlManager,+ xtreamStreamUrlResolver = xtreamStreamUrlResolver+ )++ private fun categoryEntity(+ id: Long,+ name: String,+ isUserProtected: Boolean = false+ ) = CategoryEntity(+ categoryId = id,+ name = name,+ type = ContentType.LIVE,+ providerId = 7L,+ isUserProtected = isUserProtected+ )+}diff --git a/docs/audit/COMPREHENSIVE_CODE_REVIEW_2026-03-20.md b/docs/audit/COMPREHENSIVE_CODE_REVIEW_2026-03-20.mddeleted file mode 100644index f9836d39..00000000--- a/docs/audit/COMPREHENSIVE_CODE_REVIEW_2026-03-20.md+++ /dev/null@@ -1,123 +0,0 @@-# StreamVault Comprehensive Code Review--Date: 2026-03-20--Scope:-- Repo-wide audit of app, data, domain, and player modules.-- Focus on edge cases, logic correctness, feature completeness, UI linkage, duplicate code, and test health.--Validation performed:-- `./gradlew.bat :app:compileDebugKotlin :domain:test :data:testDebugUnitTest` -> passed.-- `./gradlew.bat :app:compileDebugAndroidTestKotlin` -> passed after the follow-up fixes below.--Status update:-- Fixed: player provider-switch playlist state.-- Fixed: stale player overlay Android test call sites by restoring source compatibility.-- Fixed: misleading static decoder and buffer rows in Settings.-- Fixed: guide scheduled-only persistence.-- Fixed: persisted recent search queries.-- Fixed: stale duplicate tmp player overlay snapshot.-- Reduced: duplicated Movies and Series VOD constants, shared screen plumbing, favorite/group dialog actions, browse-state setters, reorder mechanics, and preview/search catalog builders.-- Remaining larger structural follow-up: deeper Movies and Series selected-category loading and overall viewmodel surface duplication.--## Findings--### 1. High: Player provider switches can retain the previous playlist and stale channel navigation state--Evidence:-- [PlayerViewModel.kt](app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt#L602) assigns `currentProviderId = providerId` before the playlist reload gate.-- [PlayerViewModel.kt](app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt#L676) checks whether the playlist should reload with `providerId != currentProviderId`.-- [PlayerViewModel.kt](app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt#L679) assigns `currentProviderId = providerId` again inside the reload branch.--Why it matters:-- If the player is opened for a different provider but the category ID is unchanged, the provider-change branch can be skipped because the comparison is already invalidated.-- That leaves `channelList`, `currentChannelIndex`, numeric zapping, and last-channel fallback attached to the old provider context.-- The user-visible outcome is wrong next/previous channel behavior and stale live overlays after provider switches.--### 2. High: Android instrumentation test sources are broken by player overlay API drift--Evidence:-- The current overlay signature requires new parameters such as `playbackSpeed`, `quickActionsFocusRequester`, recurring recording callbacks, PiP, and Cast callbacks in [PlayerControlsChrome.kt](app/src/main/java/com/streamvault/app/ui/screens/player/overlay/PlayerControlsChrome.kt#L83).-- Existing test call sites still use the old signature in [PlayerSmokeTest.kt](app/src/androidTest/java/com/streamvault/app/ui/PlayerSmokeTest.kt#L91) and [PlayerOverlayGoldenTest.kt](app/src/androidTest/java/com/streamvault/app/ui/screens/player/overlay/PlayerOverlayGoldenTest.kt#L61).--Observed failure:-- `:app:compileDebugAndroidTestKotlin` fails with missing-parameter errors for the added overlay arguments.--Why it matters:-- UI test coverage for the player is effectively offline.-- This is exactly the surface where multiple recent features were added, so regression risk is high.--### 3. Medium: Settings exposes decoder mode and buffer duration as settings rows, but they are not settings--Evidence:-- [SettingsScreen.kt](app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt#L475) shows a decoder mode row with a fixed `Auto` value.-- [SettingsScreen.kt](app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt#L476) shows a buffer duration row with a fixed `5s` value.-- There is player-side decoder logic in [PlayerEngine.kt](player/src/main/java/com/streamvault/player/PlayerEngine.kt#L44) and recovery-mode switching in [PlayerViewModel.kt](app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt#L282), but no editable settings flow or persistence for either row.--Why it matters:-- The UI implies these controls are configurable when they are not.-- That creates a feature-completeness gap and misleads users during troubleshooting.--### 4. Medium: The guide does not persist or restore the scheduled-only filter, unlike the rest of its state--Evidence:-- The scheduled-only toggle only flips in-memory state in [EpgViewModel.kt](app/src/main/java/com/streamvault/app/ui/screens/epg/EpgViewModel.kt#L181).-- Restored guide state in [EpgViewModel.kt](app/src/main/java/com/streamvault/app/ui/screens/epg/EpgViewModel.kt#L410) includes density, channel mode, favorites-only, and anchor time, but not scheduled-only.-- Preferences support exists for the other guide settings in [PreferencesRepository.kt](data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt#L395), [PreferencesRepository.kt](data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt#L405), [PreferencesRepository.kt](data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt#L415), and [PreferencesRepository.kt](data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt#L425).--Why it matters:-- The guide appears stateful, but one of its main filters silently resets.-- That inconsistency is a TV UX problem because users expect return-to-guide behavior to preserve the current browsing mode.--### 5. Medium: Recent search queries are view-model-only and disappear across process death or app restart--Evidence:-- Recent searches live only in the in-memory state flow in [SearchScreen.kt](app/src/main/java/com/streamvault/app/ui/screens/search/SearchScreen.kt#L77).-- They are updated and trimmed in [SearchScreen.kt](app/src/main/java/com/streamvault/app/ui/screens/search/SearchScreen.kt#L142) and cleared in [SearchScreen.kt](app/src/main/java/com/streamvault/app/ui/screens/search/SearchScreen.kt#L161).-- There is no matching persistence in [PreferencesRepository.kt](data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt).--Why it matters:-- The implementation satisfies dedupe and cap rules only for the current process lifetime.-- For a living-room device app, losing recent queries on restart is a noticeable UX downgrade.--### 6. Medium: Movies and Series flows are duplicated heavily enough that behavior drift is already likely--Evidence:-- The view models mirror the same structure and state choreography in [MoviesViewModel.kt](app/src/main/java/com/streamvault/app/ui/screens/movies/MoviesViewModel.kt#L39) and [SeriesViewModel.kt](app/src/main/java/com/streamvault/app/ui/screens/series/SeriesViewModel.kt#L38).-- The screens also mirror the same layout and interaction structure in [MoviesScreen.kt](app/src/main/java/com/streamvault/app/ui/screens/movies/MoviesScreen.kt#L70) and [SeriesScreen.kt](app/src/main/java/com/streamvault/app/ui/screens/series/SeriesScreen.kt#L69).--Why it matters:-- Every browse, search, reorder, favorite, and dialog change has to be kept in sync twice.-- The risk is not theoretical: the player overlay tests already drifted after API changes, and these mirrored screens have the same maintenance profile.--Status update:-- This was partially reduced in follow-up fixes.-- Shared VOD defaults, snackbar/PIN screen helpers, favorite/group dialog repository actions, browse-state helper functions, reorder helper functions, and preview/search catalog builders now live under the shared VOD package.-- The remaining duplication is concentrated more narrowly in selected-category loading and some viewmodel-specific state wiring rather than the earlier full end-to-end duplicated surface.--### 7. Low: A stale source snapshot in tmp duplicates active player overlay code and increases review noise--Evidence:-- The live implementation is in [PlayerControlsChrome.kt](app/src/main/java/com/streamvault/app/ui/screens/player/overlay/PlayerControlsChrome.kt).-- A duplicate snapshot also exists in [tmp/PlayerControlsChrome_HEAD.kt](tmp/PlayerControlsChrome_HEAD.kt).--Why it matters:-- It increases search noise and makes code review, refactoring, and grep-based exploration less reliable.-- It also raises the chance of updating the wrong file during future edits.--## Additional Notes--### Confirmed strengths--- Core compile and unit-test path is healthy: `:app:compileDebugKotlin`, `:domain:test`, and `:data:testDebugUnitTest` passed.-- The playback settings called out in the recent UI checklist are actually wired into Settings for playback speed, preferred audio language, subtitle appearance, and per-network quality caps. See [SettingsScreen.kt](app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt#L443) and [SettingsScreen.kt](app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt#L742).-- EPG program search is exposed in the guide UI and routes into repository-backed search. See [EpgScreen.kt](app/src/main/java/com/streamvault/app/ui/screens/epg/EpgScreen.kt#L108) and [EpgViewModel.kt](app/src/main/java/com/streamvault/app/ui/screens/epg/EpgViewModel.kt#L458).-- Provider onboarding is centralized through the shared validation/use-case path instead of raw screen logic. See [ProviderSetupViewModel.kt](app/src/main/java/com/streamvault/app/ui/screens/provider/ProviderSetupViewModel.kt#L17).--### Recommended priorities--1. Fix the player provider-switch state bug first because it affects live playback correctness.-2. Restore Android test compilation for the player overlays before adding more player UI features.-3. Either make decoder and buffer rows configurable or relabel/remove them so Settings stays truthful.-4. Persist guide scheduled-only and search recent-query state for consistent TV UX.-5. Start consolidating Movies and Series browse flows into shared VOD browse primitives.\ No newline at end of filediff --git a/docs/audit/UI_VALIDATION_CHECKLIST.md b/docs/audit/UI_VALIDATION_CHECKLIST.mddeleted file mode 100644index 38c608d0..00000000--- a/docs/audit/UI_VALIDATION_CHECKLIST.md+++ /dev/null@@ -1,398 +0,0 @@-# StreamVault UI Validation Checklist--Last updated: 2026-03-20--Purpose: manual QA list for the user-visible changes completed from the pre-release missing-features audit.--Scope:-- Only includes changes that affect UI, user flows, or visible playback behavior.-- Does not list backend-only work such as schema changes, mappers, parsers, or repository internals unless the change alters something you can verify on screen.--How to use this file:-- Treat each item as a manual test case.-- Verify both the visible UI and the runtime behavior.-- If behavior differs from the Expected Behavior section, note the screen, provider type, and content type used.--## 1. Player--### 1.1 Manual quality selection--Where to test:-- Start a stream that exposes multiple Media3 video variants.-- Open the in-player track or quality controls.--What changed:-- The player now exposes actual video quality choices instead of only automatic adaptive playback.--Expected behavior:-- You should see an Auto option plus one or more manual quality options when the stream provides them.-- Selecting a manual option should lock playback to that variant instead of immediately bouncing back to Auto.-- Reopening the quality control during the same session should show the selected option as active.-- If the stream only has one video track, the quality chooser should not show a fake list of variants.--### 1.2 Network-specific quality preferences--Where to test:-- Settings.-- Use one Wi-Fi network and one Ethernet connection if available.--What changed:-- Settings now expose separate max-quality preferences for Wi-Fi and Ethernet.--Expected behavior:-- Settings should show separate rows for Wi-Fi and Ethernet quality preference.-- Each row should allow Auto, 2160p, 1080p, 720p, and 480p style caps.-- After changing a cap, new playback sessions should respect that network-specific preference.-- Auto should remove the cap instead of forcing a fixed resolution.--### 1.3 Default playback speed--Where to test:-- Settings.-- Movie playback.-- Episode playback.--What changed:-- Default VOD playback speed is now configurable and persisted.--Expected behavior:-- Settings should show a Default Playback Speed row.-- Allowed values should include 0.5x, 0.75x, 1x, 1.25x, 1.5x, and 2x.-- Starting VOD playback after changing the default should apply the selected speed automatically.-- Live TV should not behave like VOD speed control unless the screen already supports that explicitly.--### 1.4 Preferred audio language--Where to test:-- Settings.-- Any movie or episode with multiple audio languages.--What changed:-- Audio selection now supports an automatic language preference plus an explicit preferred language override.--Expected behavior:-- Settings should show a Preferred Audio Language row.-- The automatic option should map to app language first, otherwise device language.-- If the content contains a matching audio language, playback should choose it automatically.-- Manual in-player audio selection should still work after auto-selection has occurred.--### 1.5 Subtitle appearance--Where to test:-- Settings.-- Any subtitle-capable VOD item.--What changed:-- Subtitle size, text color, and background style are now configurable and persisted.--Expected behavior:-- Settings should show subtitle size, subtitle text color, and subtitle background rows.-- Changing these values should immediately affect newly shown subtitles in playback.-- The selected appearance should persist across sessions.-- Backup export and import should preserve these subtitle settings.--### 1.6 Seek preview thumbnails--Where to test:-- Movie and episode playback.-- Scrub the seek bar on a direct-file VOD stream.--What changed:-- Scrubbing now shows preview cards instead of only a time position.--Expected behavior:-- During scrubbing, a preview card should show a timestamp and either a frame thumbnail or artwork fallback.-- HLS or DASH streams that cannot supply preview frames should fall back cleanly to artwork.-- The seek UI should remain stable instead of flashing or collapsing when preview extraction is unsupported.--### 1.7 Stream failover--Where to test:-- A live channel with alternate stream URLs or a provider/source known to fail over.--What changed:-- The player now retries alternate stream URLs before surfacing a terminal playback failure.--Expected behavior:-- A failed primary stream should attempt recovery before the player gives up.-- If an alternate stream works, playback should recover without requiring a manual channel restart.-- The user should not immediately get a hard failure on the first stream error if alternates exist.--### 1.8 DRM playback error messaging--Where to test:-- Any stream that triggers DRM-related playback failure.--What changed:-- DRM failures are now separated from generic source failures.--Expected behavior:-- DRM-specific playback failures should surface a DRM-oriented error message, not a generic source or network message.-- Non-DRM failures should still show the appropriate network, source, or decoder error.--## 2. Search--### 2.1 Unified cross-content search--Where to test:-- Global search screen.--What changed:-- Search now flows through a shared domain use case across live, movies, and series.--Expected behavior:-- Search should return results across the active providerโs live, movie, and series catalogs.-- Switching tabs should scope results correctly to All, Live, Movies, or Series.-- Recent queries should remain trimmed, deduplicated, and capped.--### 2.2 Improved result ordering--Where to test:-- Global search screen.-- EPG search.--What changed:-- Search results are now ranked by relevance rather than arbitrary Room or FTS ordering.--Expected behavior:-- Exact title matches should appear before prefix matches.-- Prefix matches should appear before loose contains matches.-- Searches like Sports should prefer Sports over longer partial-match titles.--## 3. EPG And Live TV--### 3.1 Program search in the guide--Where to test:-- TV Guide or EPG screen.--What changed:-- The guide now supports in-window program-title search.--Expected behavior:-- The guide should expose a program search input.-- Entering a query should filter guide results to matching programs inside the active time window.-- If no programs match, the guide should show a clear no-results empty state rather than a broken or blank layout.--### 3.2 Category-aware guide browsing--Where to test:-- TV Guide or EPG screen.--What changed:-- Program loading is now category-aware at the repository level instead of being only channel-driven UI filtering.--Expected behavior:-- Changing guide category should load the matching guide content for that category.-- Search inside the guide should stay scoped to the selected category when a category is active.--### 3.3 Channel-number ordering and healthy-channel preference--Where to test:-- Live TV guide and live channel browsing.--What changed:-- Channels now preserve provider numbering and the browse layer can prefer channels without known errors.--Expected behavior:-- Channels should appear in provider number order rather than arbitrary app-side ordering.-- Favorites-only or other filtered views should still be able to show the userโs chosen channel even if it has prior errors.--### 3.4 Recent live category--Where to test:-- Home or live-TV category rail.--What changed:-- Recent live history is exposed as a virtual recent category.--Expected behavior:-- A Recent live category should be visible even when its item count is zero.-- After watching live channels, the Recent category should populate with recently viewed channels.--## 4. Movies And Series--### 4.1 Continue watching behavior--Where to test:-- Dashboard.-- Movies.-- Series.-- Favorites.--What changed:-- Continue-watching assembly now uses shared domain logic with resume filtering and series-aware deduplication.--Expected behavior:-- Continue-watching rows should not show duplicate entries for the same series.-- Near-complete titles should fall out of continue watching once they meet the completion threshold.-- Resume items should appear provider-scoped and ordered by recent activity.--### 4.2 Movie recommendations--Where to test:-- Launcher recommendations if available.-- Any in-app recommendation or preview surfaces that consume movie recommendations.--What changed:-- Recommendations are now personalized rather than always falling back to generic top-rated content.--Expected behavior:-- When enough viewing or favorite history exists, recommendations should reflect that history.-- If no personalized signal exists, the app should still fall back cleanly to top-rated preview behavior.--### 4.3 Browse filtering and sorting--Where to test:-- Movies and series library screens.--What changed:-- Full-library browse semantics now support repository-backed search, filtering, sorting, and paging.--Expected behavior:-- Search, sort, and filter choices should affect the actual loaded list instead of only superficial client-side transforms.-- Sorts like title, release, rating, and watch count should produce stable results.-- Filters like favorites, in progress, unwatched, and top rated should behave consistently across larger libraries.--### 4.4 Series unwatched badge--Where to test:-- Series detail screen.--What changed:-- Series detail now exposes repository-backed unwatched episode counts.--Expected behavior:-- The series detail UI should show how many episodes are left to finish.-- Completing or marking episodes watched should update that count correctly.--## 5. Recording--### 5.1 Recurring schedule actions--Where to test:-- Live player quick actions.-- Settings recording list.--What changed:-- Recording schedules now support one-time, daily, and weekly recurrence.--Expected behavior:-- The player should expose one-time, daily, and weekly recording actions.-- Settings should display recurrence labels for scheduled items.-- Daily and weekly schedules should roll forward to the next occurrence after the current one becomes due.--### 5.2 Recording conflict handling--Where to test:-- Create overlapping manual and scheduled recordings.--What changed:-- Overlapping recordings are now rejected instead of silently double-starting.--Expected behavior:-- Creating an overlapping recording should fail with a clear conflict message.-- Due scheduled recordings that overlap an active one should not start a second recording behind the scenes.--## 6. Backup And Restore--### 6.1 Backup import preview coverage--Where to test:-- Settings backup import preview dialog.--What changed:-- Backup preview now includes more restored sections and exposes recording schedule import as a selectable section.--Expected behavior:-- The import preview should show counts for preferences, providers, saved library, playback history, split screen presets, and recording schedules.-- Saved Library counts should include protected category data now that it is part of backup coverage.-- The import plan should allow toggling recording schedules on or off.--### 6.2 Backup persistence of player and parental settings--Where to test:-- Export backup.-- Change settings.-- Re-import backup.--What changed:-- Backup now preserves parental PIN data, protected categories, scheduled recordings, subtitle appearance, playback speed, preferred audio language, and network quality caps.--Expected behavior:-- After import, the app should restore those settings instead of only basic provider or favorite data.-- Restored protected categories should appear locked again.-- Restored recording schedules should reappear in recording-related settings surfaces.--## 7. Settings--### 7.1 New playback preference rows--Where to test:-- Settings playback section.--What changed:-- Several new settings rows now exist for player behavior.--Expected behavior:-- Settings should show rows for:- - Default Playback Speed- - Preferred Audio Language- - Subtitle Size- - Subtitle Text Color- - Subtitle Background- - Wi-Fi Quality Preference- - Ethernet Quality Preference-- Each row should open a working selection dialog with the current choice highlighted.--### 7.2 Provider refresh warning messaging--Where to test:-- Settings provider management actions.--What changed:-- Provider refresh now routes through a shared sync use case and surfaces partial-warning messaging more consistently.--Expected behavior:-- A clean refresh should report success.-- A partial refresh should report completion with warnings instead of pretending the refresh was fully clean.--## 8. Android TV Platform Surfaces--### 8.1 Watch Next and launcher recommendations--Where to test:-- Android TV home screen if supported by the device.--What changed:-- The app now publishes Watch Next content and launcher recommendation rows using real playback and recommendation data.--Expected behavior:-- Recent playback should be eligible to appear in Watch Next.-- Launcher movie recommendations should not always be static top-rated content when personalized data exists.--### 8.2 Voice search and external routing--Where to test:-- Android TV global search or external app routing into StreamVault.--What changed:-- MainActivity now handles searchable and external route entry points.--Expected behavior:-- External search or route intents should land in the correct app flow instead of dropping the user at an unrelated default screen.--## 9. Quick Regression List--Use this section as a short smoke pass after bigger changes.--- Open Settings and verify all new playback rows exist and open dialogs.-- Start a multi-variant VOD item and verify quality selection works.-- Set non-default playback speed and confirm the next VOD session starts at that speed.-- Change subtitle appearance and verify playback reflects the new style.-- Run a global search for an exact title and confirm result ordering looks relevance-based.-- Use EPG search and verify no-results handling is clean.-- Schedule daily and weekly recordings and confirm recurrence labels appear in Settings.-- Export and re-import a backup, then verify restored player preferences, protected categories, and recording schedules.-- Check continue-watching rows for duplicate-series cleanup and completed-title removal.-- Trigger a provider refresh and verify partial warnings show when appropriate.diff --git a/docs/images/.gitkeep b/docs/images/.gitkeepnew file mode 100644index 00000000..8b137891--- /dev/null+++ b/docs/images/.gitkeep@@ -0,0 +1 @@+diff --git a/domain/src/main/java/com/streamvault/domain/repository/EpgRepository.kt b/domain/src/main/java/com/streamvault/domain/repository/EpgRepository.ktindex 5cc3d99b..31b953be 100644--- a/domain/src/main/java/com/streamvault/domain/repository/EpgRepository.kt+++ b/domain/src/main/java/com/streamvault/domain/repository/EpgRepository.kt@@ -11,6 +11,7 @@ interface EpgRepository {fun searchPrograms(providerId: Long, query: String, startTime: Long, endTime: Long, categoryId: Long? = null, limit: Int = 250): Flow<List<Program>>fun getNowPlaying(providerId: Long, channelId: String): Flow<Program?>fun getNowPlayingForChannels(providerId: Long, channelIds: List<String>): Flow<Map<String, Program?>>+ suspend fun getNowPlayingForChannelsSnapshot(providerId: Long, channelIds: List<String>): Map<String, Program?>fun getNowAndNext(providerId: Long, channelId: String): Flow<Pair<Program?, Program?>>suspend fun refreshEpg(providerId: Long, epgUrl: String): Result<Unit>suspend fun clearOldPrograms(beforeTime: Long)diff --git a/player/src/main/java/com/streamvault/player/Media3PlayerEngine.kt b/player/src/main/java/com/streamvault/player/Media3PlayerEngine.ktindex 9153c230..db00356b 100644--- a/player/src/main/java/com/streamvault/player/Media3PlayerEngine.kt+++ b/player/src/main/java/com/streamvault/player/Media3PlayerEngine.kt@@ -6,6 +6,8 @@ import android.media.AudioManagerimport android.net.Uriimport android.net.ConnectivityManagerimport android.net.NetworkCapabilities+import android.graphics.Color as AndroidColor+import android.view.LayoutInflaterimport android.view.Viewimport androidx.annotation.OptInimport androidx.media3.common.C@@ -15,11 +17,15 @@ import androidx.media3.common.PlaybackExceptionimport androidx.media3.common.Playerimport androidx.media3.common.util.UnstableApiimport androidx.media3.datasource.DataSource-import androidx.media3.datasource.DefaultHttpDataSourceimport androidx.media3.datasource.okhttp.OkHttpDataSourceimport androidx.media3.exoplayer.DefaultRenderersFactoryimport androidx.media3.exoplayer.ExoPlayer+import androidx.media3.exoplayer.Rendererimport androidx.media3.exoplayer.ScrubbingModeParameters+import androidx.media3.exoplayer.mediacodec.MediaCodecInfo+import androidx.media3.exoplayer.mediacodec.MediaCodecSelector+import androidx.media3.exoplayer.video.MediaCodecVideoRenderer+import androidx.media3.exoplayer.video.VideoRendererEventListenerimport androidx.media3.exoplayer.dash.DashMediaSourceimport androidx.media3.exoplayer.hls.HlsMediaSourceimport androidx.media3.exoplayer.rtsp.RtspMediaSource@@ -27,6 +33,7 @@ import androidx.media3.exoplayer.source.MediaSourceimport androidx.media3.exoplayer.source.ProgressiveMediaSourceimport androidx.media3.exoplayer.analytics.AnalyticsListenerimport androidx.media3.exoplayer.DecoderReuseEvaluation+import androidx.media3.ui.AspectRatioFrameLayoutimport androidx.media3.ui.CaptionStyleCompatimport androidx.media3.ui.PlayerView@@ -43,7 +50,6 @@ import android.os.Handlerimport android.os.Looperimport android.os.SystemClockimport android.util.Log-import android.graphics.Color as AndroidColorimport com.streamvault.domain.model.DrmInfoimport com.streamvault.domain.model.DrmSchemeimport dagger.hilt.android.qualifiers.ApplicationContext@@ -98,6 +104,9 @@ class Media3PlayerEngine @Inject constructor(private var preferredWifiMaxVideoHeight: Int? = nullprivate var preferredEthernetMaxVideoHeight: Int? = nullprivate var boundPlayerView: PlayerView? = null+ /** Tracks the last video width/height so we can detect actual resolution changes. */+ private var lastVideoWidth = 0+ private var lastVideoHeight = 0/** Remembers the volume before mute so unmute restores it. */private var volumeBeforeMute = 1f/** Pre-warmed media source for rapid next-channel start. */@@ -214,22 +223,7 @@ class Media3PlayerEngine @Inject constructor(exoPlayer?.volume = effectiveVolume()}- private fun applySubtitleStyle(playerView: PlayerView?) {- val subtitleView = playerView?.subtitleView ?: return- subtitleView.setStyle(- CaptionStyleCompat(- subtitleStyle.foregroundColorArgb,- subtitleStyle.backgroundColorArgb,- AndroidColor.TRANSPARENT,- CaptionStyleCompat.EDGE_TYPE_NONE,- AndroidColor.TRANSPARENT,- null- )- )- subtitleView.setFractionalTextSize(- SubtitleView.DEFAULT_TEXT_SIZE_FRACTION * subtitleStyle.textScale.coerceIn(0.75f, 1.75f)- )- }+private fun getOrCreatePlayer(): ExoPlayer {return exoPlayer ?: createPlayer().also {@@ -241,7 +235,49 @@ class Media3PlayerEngine @Inject constructor(}private fun createPlayer(): ExoPlayer {- val renderersFactory = DefaultRenderersFactory(context).apply {+ // Custom renderers factory that disables video decoder reuse.+ // The emulator's goldfish H264 decoder (and some real HW decoders) produce+ // zoom/crop artefacts when the codec is reused with a flush during ABR+ // bitrate switches. By returning REUSE_RESULT_NO the player creates a+ // fresh decoder for every track switch, which is slightly heavier but+ // eliminates the glitch entirely.+ val renderersFactory = object : DefaultRenderersFactory(context) {+ override fun buildVideoRenderers(+ context: Context,+ extensionRendererMode: Int,+ mediaCodecSelector: MediaCodecSelector,+ enableDecoderFallback: Boolean,+ eventHandler: Handler,+ eventListener: VideoRendererEventListener,+ allowedVideoJoiningTimeMs: Long,+ out: ArrayList<Renderer>+ ) {+ out.add(object : MediaCodecVideoRenderer(+ context,+ mediaCodecSelector,+ allowedVideoJoiningTimeMs,+ enableDecoderFallback,+ eventHandler,+ eventListener,+ 50 // MAX_DROPPED_VIDEO_FRAME_COUNT_TO_NOTIFY+ ) {+ override fun canReuseCodec(+ codecInfo: MediaCodecInfo,+ oldFormat: Format,+ newFormat: Format+ ): DecoderReuseEvaluation {+ Log.w(TAG, "DECODER_NO_REUSE: ${oldFormat.width}x${oldFormat.height}@${oldFormat.bitrate} -> ${newFormat.width}x${newFormat.height}@${newFormat.bitrate}")+ return DecoderReuseEvaluation(+ codecInfo.name,+ oldFormat,+ newFormat,+ DecoderReuseEvaluation.REUSE_RESULT_NO,+ DecoderReuseEvaluation.DISCARD_REASON_MAX_INPUT_SIZE_EXCEEDED+ )+ }+ })+ }+ }.apply {setExtensionRendererMode(when (currentDecoderMode) {DecoderMode.AUTO -> DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER@@ -285,6 +321,7 @@ class Media3PlayerEngine @Inject constructor().build().apply {+ videoScalingMode = C.VIDEO_SCALING_MODE_SCALE_TO_FITplaybackParameters = PlaybackParameters(_playbackSpeed.value)trackSelectionParameters = trackSelectionParameters.buildUpon()@@ -297,9 +334,7 @@ class Media3PlayerEngine @Inject constructor(decoderReuseEvaluation: DecoderReuseEvaluation?) {decoderReuseEvaluation?.let { eval ->- if (eval.result != 0) { // Not REUSE_RESULT_YES- Log.d(TAG, "Decoder reuse: result=${eval.result}, discardReasons=${eval.discardReasons}")- }+ Log.d(TAG, "Decoder reuse eval: result=${eval.result}, discardReasons=${eval.discardReasons}")}lastFrameRate = format.frameRate.takeIf { it > 0f } ?: lastFrameRate_playerStats.update {@@ -324,6 +359,12 @@ class Media3PlayerEngine @Inject constructor(}}+ override fun onRenderedFirstFrame(+ eventTime: AnalyticsListener.EventTime,+ output: Any,+ renderTimeMs: Long+ ) { /* no-op */ }+override fun onDroppedVideoFrames(eventTime: AnalyticsListener.EventTime,droppedFrames: Int,@@ -379,11 +420,16 @@ class Media3PlayerEngine @Inject constructor(}override fun onVideoSizeChanged(videoSize: androidx.media3.common.VideoSize) {+ Log.d(TAG, "VIDEO_SIZE_CHANGED: ${videoSize.width}x${videoSize.height} (was ${lastVideoWidth}x${lastVideoHeight})")_videoFormat.value = VideoFormat(width = videoSize.width,height = videoSize.height,frameRate = lastFrameRate)+ if (videoSize.width > 0 && videoSize.height > 0) {+ lastVideoWidth = videoSize.width+ lastVideoHeight = videoSize.height+ }}override fun onPlayerError(error: PlaybackException) {@@ -493,6 +539,8 @@ class Media3PlayerEngine @Inject constructor(retryCount = 0lastFrameRate = 0flastBandwidthStatsUpdateMs = 0L+ lastVideoWidth = 0+ lastVideoHeight = 0handler.removeCallbacksAndMessages(null)val player = getOrCreatePlayer()_error.tryEmit(null)@@ -878,6 +926,8 @@ class Media3PlayerEngine @Inject constructor(preloadedStreamInfo = nullmediaSession?.release()mediaSession = null+ boundPlayerView?.player = null+ boundPlayerView = nullexoPlayer?.release()exoPlayer = nulllastStreamInfo = null@@ -1030,36 +1080,68 @@ class Media3PlayerEngine @Inject constructor(}override fun createRenderView(context: Context, resizeMode: PlayerSurfaceResizeMode): View {- return PlayerView(context).apply {- useController = false- setShutterBackgroundColor(AndroidColor.TRANSPARENT)- setKeepContentOnPlayerReset(false)- setShowBuffering(PlayerView.SHOW_BUFFERING_NEVER)- enableComposeSurfaceSyncWorkaroundIfAvailable()+ // Inflate PlayerView with surface_type="texture_view" โ+ // TextureView renders through the GPU/view pipeline, not SurfaceFlinger.+ // This avoids the known Media3 issue where SurfaceView overflows its+ // bounds inside Compose AndroidView (issue #1107), causing zoom/PiP.+ return (LayoutInflater.from(context).inflate(+ R.layout.player_texture_view, null+ ) as PlayerView).apply {+ layoutParams = android.widget.FrameLayout.LayoutParams(+ android.widget.FrameLayout.LayoutParams.MATCH_PARENT,+ android.widget.FrameLayout.LayoutParams.MATCH_PARENT+ )+ setShutterBackgroundColor(AndroidColor.BLACK)applyResizeMode(resizeMode)}}override fun bindRenderView(renderView: View, resizeMode: PlayerSurfaceResizeMode) {val playerView = renderView as? PlayerView ?: return- val previousBoundView = boundPlayerView- boundPlayerView = playerViewval player = getOrCreatePlayer()- playerView.enableComposeSurfaceSyncWorkaroundIfAvailable()- if (playerView.player !== player || previousBoundView !== playerView) {+ if (boundPlayerView !== playerView) {+ boundPlayerView?.player = null+ playerView.player = player+ boundPlayerView = playerView+ } else if (playerView.player !== player) {playerView.player = player}playerView.applyResizeMode(resizeMode)- playerView.requestLayout()- playerView.invalidate()applySubtitleStyle(playerView)}+ override fun releaseRenderView(renderView: View) {+ val playerView = renderView as? PlayerView ?: return+ if (playerView.player != null) {+ playerView.player = null+ }+ if (boundPlayerView === playerView) {+ boundPlayerView = null+ }+ }+override fun setSubtitleStyle(style: PlayerSubtitleStyle) {subtitleStyle = style.copy(textScale = style.textScale.coerceIn(0.75f, 1.75f))applySubtitleStyle(boundPlayerView)}+ private fun applySubtitleStyle(playerView: PlayerView?) {+ val subtitleView = playerView?.subtitleView ?: return+ subtitleView.setStyle(+ CaptionStyleCompat(+ subtitleStyle.foregroundColorArgb,+ subtitleStyle.backgroundColorArgb,+ AndroidColor.TRANSPARENT,+ CaptionStyleCompat.EDGE_TYPE_NONE,+ AndroidColor.TRANSPARENT,+ null+ )+ )+ subtitleView.setFractionalTextSize(+ SubtitleView.DEFAULT_TEXT_SIZE_FRACTION * subtitleStyle.textScale.coerceIn(0.75f, 1.75f)+ )+ }+private fun PlayerView.applyResizeMode(surfaceResizeMode: PlayerSurfaceResizeMode) {resizeMode = when (surfaceResizeMode) {PlayerSurfaceResizeMode.FIT -> AspectRatioFrameLayout.RESIZE_MODE_FIT@@ -1068,13 +1150,6 @@ class Media3PlayerEngine @Inject constructor(}}- private fun PlayerView.enableComposeSurfaceSyncWorkaroundIfAvailable() {- runCatching {- javaClass.getMethod("setEnableComposeSurfaceSyncWorkaround", Boolean::class.javaPrimitiveType)- .invoke(this, true)- }- }-private fun requestAudioFocusIfNeeded(): Boolean {if (bypassAudioFocus) {if (isDucked) {diff --git a/player/src/main/java/com/streamvault/player/PlayerEngine.kt b/player/src/main/java/com/streamvault/player/PlayerEngine.ktindex 27b5e40f..f6b766c5 100644--- a/player/src/main/java/com/streamvault/player/PlayerEngine.kt+++ b/player/src/main/java/com/streamvault/player/PlayerEngine.kt@@ -73,6 +73,7 @@ interface PlayerEngine {fun createRenderView(context: Context, resizeMode: PlayerSurfaceResizeMode): Viewfun bindRenderView(renderView: View, resizeMode: PlayerSurfaceResizeMode)+ fun releaseRenderView(renderView: View)}enum class PlayerSurfaceResizeMode {diff --git a/player/src/main/res/layout/player_texture_view.xml b/player/src/main/res/layout/player_texture_view.xmlnew file mode 100644index 00000000..97ffeb6d--- /dev/null+++ b/player/src/main/res/layout/player_texture_view.xml@@ -0,0 +1,10 @@+<?xml version="1.0" encoding="utf-8"?>+<androidx.media3.ui.PlayerView+ xmlns:android="http://schemas.android.com/apk/res/android"+ xmlns:app="http://schemas.android.com/apk/res-auto"+ android:layout_width="match_parent"+ android:layout_height="match_parent"+ app:surface_type="texture_view"+ app:use_controller="false"+ app:keep_content_on_player_reset="false"+ app:show_buffering="never" />