Skip to content

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

chore: consolidate pending workspace changes

David Nashashcb9a74222fce
diff --git a/app/src/main/java/com/streamvault/app/MainActivity.kt b/app/src/main/java/com/streamvault/app/MainActivity.kt
index 1ffce74b..72361ab2 100644
--- a/app/src/main/java/com/streamvault/app/MainActivity.kt
+++ b/app/src/main/java/com/streamvault/app/MainActivity.kt
@@ -22,6 +22,7 @@ import com.streamvault.app.tv.LauncherRecommendationsManager
import com.streamvault.app.tv.WatchNextManager
import com.streamvault.app.tvinput.TvInputChannelSyncManager
import com.streamvault.app.ui.theme.StreamVaultTheme
+import com.streamvault.app.ui.time.LocalAppTimeFormat
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
@@ -114,6 +115,7 @@ class MainActivity : ComponentActivity() {
}
setContent {
val appLanguage by preferencesRepository.appLanguage.collectAsState(initial = "system")
+ val appTimeFormat by preferencesRepository.appTimeFormat.collectAsState(initial = com.streamvault.domain.model.AppTimeFormat.SYSTEM)
val currentContext = LocalContext.current
val configuration = remember(appLanguage) {
@@ -152,7 +154,8 @@ class MainActivity : ComponentActivity() {
CompositionLocalProvider(
LocalContext provides localizedContext,
- LocalLayoutDirection provides layoutDirection
+ LocalLayoutDirection provides layoutDirection,
+ LocalAppTimeFormat provides appTimeFormat
) {
StreamVaultTheme {
AppNavigation(mainActivity = this@MainActivity)
diff --git a/app/src/main/java/com/streamvault/app/di/DatabaseModule.kt b/app/src/main/java/com/streamvault/app/di/DatabaseModule.kt
index 771469eb..06941333 100644
--- a/app/src/main/java/com/streamvault/app/di/DatabaseModule.kt
+++ b/app/src/main/java/com/streamvault/app/di/DatabaseModule.kt
@@ -78,7 +78,11 @@ object DatabaseModule {
StreamVaultDatabase.MIGRATION_36_37,
StreamVaultDatabase.MIGRATION_37_38,
StreamVaultDatabase.MIGRATION_38_39,
- StreamVaultDatabase.MIGRATION_39_40
+ StreamVaultDatabase.MIGRATION_39_40,
+ StreamVaultDatabase.MIGRATION_40_41,
+ StreamVaultDatabase.MIGRATION_41_42,
+ StreamVaultDatabase.MIGRATION_42_43,
+ StreamVaultDatabase.MIGRATION_43_44
)
// NOTE: fallbackToDestructiveMigration() intentionally removed.
// All future schema changes MUST add a corresponding Migration in StreamVaultDatabase.
@@ -112,4 +116,5 @@ object DatabaseModule {
@Provides fun provideRecordingRunDao(db: StreamVaultDatabase): RecordingRunDao = db.recordingRunDao()
@Provides fun provideProgramReminderDao(db: StreamVaultDatabase): ProgramReminderDao = db.programReminderDao()
@Provides fun provideRecordingStorageDao(db: StreamVaultDatabase): RecordingStorageDao = db.recordingStorageDao()
+ @Provides fun providePlaybackCompatibilityDao(db: StreamVaultDatabase): PlaybackCompatibilityDao = db.playbackCompatibilityDao()
}
diff --git a/app/src/main/java/com/streamvault/app/di/NetworkModule.kt b/app/src/main/java/com/streamvault/app/di/NetworkModule.kt
index 60946abf..93069b84 100644
--- a/app/src/main/java/com/streamvault/app/di/NetworkModule.kt
+++ b/app/src/main/java/com/streamvault/app/di/NetworkModule.kt
@@ -102,8 +102,9 @@ object NetworkModule {
@MainPlayerEngine
fun provideMainPlayerEngine(
@ApplicationContext context: Context,
- okHttpClient: OkHttpClient
- ): PlayerEngine = Media3PlayerEngine(context, okHttpClient)
+ okHttpClient: OkHttpClient,
+ playbackCompatibilityRepository: com.streamvault.domain.repository.PlaybackCompatibilityRepository
+ ): PlayerEngine = Media3PlayerEngine(context, okHttpClient, playbackCompatibilityRepository)
/**
* Factory binding for preview and multiview playback.
@@ -113,8 +114,9 @@ object NetworkModule {
@AuxiliaryPlayerEngine
fun provideAuxiliaryPlayerEngine(
@ApplicationContext context: Context,
- okHttpClient: OkHttpClient
- ): PlayerEngine = Media3PlayerEngine(context, okHttpClient).apply {
+ okHttpClient: OkHttpClient,
+ playbackCompatibilityRepository: com.streamvault.domain.repository.PlaybackCompatibilityRepository
+ ): PlayerEngine = Media3PlayerEngine(context, okHttpClient, playbackCompatibilityRepository).apply {
enableMediaSession = false
bypassAudioFocus = true
}
diff --git a/app/src/main/java/com/streamvault/app/di/RepositoryModule.kt b/app/src/main/java/com/streamvault/app/di/RepositoryModule.kt
index cb0d05b5..3ce81ee8 100644
--- a/app/src/main/java/com/streamvault/app/di/RepositoryModule.kt
+++ b/app/src/main/java/com/streamvault/app/di/RepositoryModule.kt
@@ -63,6 +63,9 @@ abstract class RepositoryModule {
@Binds @Singleton
abstract fun bindSyncMetadataRepository(impl: SyncMetadataRepositoryImpl): SyncMetadataRepository
+ @Binds @Singleton
+ abstract fun bindPlaybackCompatibilityRepository(impl: PlaybackCompatibilityRepositoryImpl): PlaybackCompatibilityRepository
+
@Binds @Singleton
abstract fun bindDatabaseTransactionRunner(impl: RoomDatabaseTransactionRunner): DatabaseTransactionRunner
diff --git a/app/src/main/java/com/streamvault/app/ui/components/dialogs/ProgramHistoryDialog.kt b/app/src/main/java/com/streamvault/app/ui/components/dialogs/ProgramHistoryDialog.kt
index 1d744dd9..4d989999 100644
--- a/app/src/main/java/com/streamvault/app/ui/components/dialogs/ProgramHistoryDialog.kt
+++ b/app/src/main/java/com/streamvault/app/ui/components/dialogs/ProgramHistoryDialog.kt
@@ -44,6 +44,8 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import com.streamvault.app.R
+import com.streamvault.app.ui.time.LocalAppTimeFormat
+import com.streamvault.app.ui.time.createTimeFormatter
import com.streamvault.domain.model.Program
import java.time.Instant
import java.time.ZoneId
@@ -64,7 +66,8 @@ fun ProgramHistoryDialog(
val isTelevisionDevice = rememberIsTelevisionDevice()
val locale = Locale.getDefault()
val zoneId = remember { ZoneId.systemDefault() }
- val timeFormat = remember(locale) { DateTimeFormatter.ofPattern("HH:mm", locale) }
+ val appTimeFormat = LocalAppTimeFormat.current
+ val timeFormat = remember(appTimeFormat, locale) { appTimeFormat.createTimeFormatter(locale) }
val dayFormat = remember(locale) { DateTimeFormatter.ofPattern("EEE, MMM d", locale) }
LaunchedEffect(Unit) {
diff --git a/app/src/main/java/com/streamvault/app/ui/components/shell/InfiniteScrollEffect.kt b/app/src/main/java/com/streamvault/app/ui/components/shell/InfiniteScrollEffect.kt
new file mode 100644
index 00000000..445beeb9
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/components/shell/InfiniteScrollEffect.kt
@@ -0,0 +1,73 @@
+package com.streamvault.app.ui.components.shell
+
+import androidx.compose.foundation.lazy.LazyListState
+import androidx.compose.foundation.lazy.grid.LazyGridState
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.derivedStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.snapshotFlow
+import kotlinx.coroutines.flow.distinctUntilChanged
+import kotlinx.coroutines.flow.filter
+
+/**
+ * Triggers [onLoadMore] once when the user scrolls within [prefetchDistance]
+ * items of the end of the list. The callback is suppressed while [enabled]
+ * is false, [canLoadMore] is false, or [isLoading] is true. The effect
+ * re-arms after the visible tail moves further from the end and crosses
+ * the threshold again.
+ */
+@Composable
+fun InfiniteScrollEffect(
+ listState: LazyListState,
+ enabled: Boolean,
+ canLoadMore: Boolean,
+ isLoading: Boolean,
+ prefetchDistance: Int = 3,
+ onLoadMore: () -> Unit
+) {
+ if (!enabled) return
+ val shouldLoadMore = remember(listState, prefetchDistance) {
+ derivedStateOf {
+ val info = listState.layoutInfo
+ val total = info.totalItemsCount
+ if (total == 0) return@derivedStateOf false
+ val lastVisible = info.visibleItemsInfo.lastOrNull()?.index ?: return@derivedStateOf false
+ lastVisible >= total - 1 - prefetchDistance
+ }
+ }
+ LaunchedEffect(shouldLoadMore, canLoadMore, isLoading) {
+ snapshotFlow { shouldLoadMore.value }
+ .distinctUntilChanged()
+ .filter { it && canLoadMore && !isLoading }
+ .collect { onLoadMore() }
+ }
+}
+
+/** Grid variant of [InfiniteScrollEffect]. */
+@Composable
+fun InfiniteScrollEffect(
+ gridState: LazyGridState,
+ enabled: Boolean,
+ canLoadMore: Boolean,
+ isLoading: Boolean,
+ prefetchDistance: Int = 6,
+ onLoadMore: () -> Unit
+) {
+ if (!enabled) return
+ val shouldLoadMore = remember(gridState, prefetchDistance) {
+ derivedStateOf {
+ val info = gridState.layoutInfo
+ val total = info.totalItemsCount
+ if (total == 0) return@derivedStateOf false
+ val lastVisible = info.visibleItemsInfo.lastOrNull()?.index ?: return@derivedStateOf false
+ lastVisible >= total - 1 - prefetchDistance
+ }
+ }
+ LaunchedEffect(shouldLoadMore, canLoadMore, isLoading) {
+ snapshotFlow { shouldLoadMore.value }
+ .distinctUntilChanged()
+ .filter { it && canLoadMore && !isLoading }
+ .collect { onLoadMore() }
+ }
+}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/dashboard/DashboardScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/dashboard/DashboardScreen.kt
index 45c75284..86f01787 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/dashboard/DashboardScreen.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/dashboard/DashboardScreen.kt
@@ -63,6 +63,8 @@ import com.streamvault.app.ui.components.shell.AppHeroHeader
import com.streamvault.app.ui.components.shell.AppScreenScaffold
import com.streamvault.app.ui.components.shell.StatusPill
import com.streamvault.app.ui.design.AppColors
+import com.streamvault.app.ui.time.LocalAppTimeFormat
+import com.streamvault.app.ui.time.createDateTimeFormat
import com.streamvault.app.ui.design.AppColors.Brand as Primary
import com.streamvault.app.ui.design.AppColors.Focus as FocusBorder
import com.streamvault.app.ui.design.AppColors.SurfaceElevated as SurfaceElevated
@@ -496,12 +498,13 @@ private fun DashboardProviderHealthCard(
onOpenDiagnostics: () -> Unit
) {
val context = androidx.compose.ui.platform.LocalContext.current
- val syncLabel = remember(health.lastSyncedAt) {
+ val appTimeFormat = LocalAppTimeFormat.current
+ val dateTimeFormat = remember(appTimeFormat) { appTimeFormat.createDateTimeFormat() }
+ val syncLabel = remember(health.lastSyncedAt, dateTimeFormat) {
if (health.lastSyncedAt <= 0L) {
context.getString(R.string.dashboard_provider_no_sync)
} else {
- val format = SimpleDateFormat("MMM d, HH:mm", Locale.getDefault())
- context.getString(R.string.dashboard_provider_synced_at, format.format(Date(health.lastSyncedAt)))
+ context.getString(R.string.dashboard_provider_synced_at, dateTimeFormat.format(Date(health.lastSyncedAt)))
}
}
val expiryLabel = remember(health.expirationDate) {
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/dashboard/DashboardViewModel.kt b/app/src/main/java/com/streamvault/app/ui/screens/dashboard/DashboardViewModel.kt
index c653af2a..a8e484bc 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/dashboard/DashboardViewModel.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/dashboard/DashboardViewModel.kt
@@ -163,21 +163,19 @@ class DashboardViewModel @Inject constructor(
combinedProfileId: Long?
): Flow<DashboardUiState> {
val movieShelf = combine(
- movieRepository.getMovies(provider.id),
+ movieRepository.getFreshPreview(provider.id, MOVIE_SHELF_LIMIT),
preferencesRepository.parentalControlLevel
) { movies, level ->
movies
.filter { !shouldHideVodFromHome(it, level) }
- .sortedByDescending(::movieFreshnessScore)
.take(MOVIE_SHELF_LIMIT)
}
val seriesShelf = combine(
- seriesRepository.getSeries(provider.id),
+ seriesRepository.getFreshPreview(provider.id, SERIES_SHELF_LIMIT),
preferencesRepository.parentalControlLevel
) { series, level ->
series
.filter { !shouldHideVodFromHome(it, level) }
- .sortedByDescending(::seriesFreshnessScore)
.take(SERIES_SHELF_LIMIT)
}
val contentShelves = combine(
@@ -359,9 +357,9 @@ class DashboardViewModel @Inject constructor(
private fun observeLiveChannelCount(providerIds: List<Long>): Flow<Int> = when (providerIds.size) {
0 -> flowOf(0)
- 1 -> channelRepository.getChannels(providerIds.first()).map { it.size }
+ 1 -> channelRepository.getChannelCount(providerIds.first())
else -> combine(providerIds.map { providerId ->
- channelRepository.getChannels(providerId).map { channels -> channels.size }
+ channelRepository.getChannelCount(providerId)
}) { counts ->
counts.sum()
}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgGridComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgGridComponents.kt
index 27ddd5ac..4c41ec27 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgGridComponents.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgGridComponents.kt
@@ -22,6 +22,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -49,6 +50,8 @@ import com.streamvault.app.ui.components.ChannelLogoBadge
import com.streamvault.app.ui.interaction.TvButton
import com.streamvault.app.ui.interaction.TvClickableSurface
import com.streamvault.app.ui.model.guideLookupKey
+import com.streamvault.app.ui.time.LocalAppTimeFormat
+import com.streamvault.app.ui.time.createTimeFormatter
import com.streamvault.app.ui.theme.FocusBorder
import com.streamvault.app.ui.theme.OnSurface
import com.streamvault.app.ui.theme.OnSurfaceDim
@@ -61,9 +64,6 @@ import com.streamvault.domain.model.Channel
import com.streamvault.domain.model.Program
import java.time.Instant
import java.time.ZoneId
-import java.time.format.DateTimeFormatter
-import java.time.format.FormatStyle
-import java.util.Locale
import kotlin.math.max
@Composable
@@ -119,7 +119,8 @@ internal fun EpgGrid(
onChannelClick: (Channel) -> Unit,
onProgramClick: (Channel, Program) -> Unit,
onChannelFocused: (Channel, Program?, Boolean) -> Unit,
- onProgramFocused: (Channel, Program, Boolean) -> Unit
+ onProgramFocused: (Channel, Program, Boolean) -> Unit,
+ onRequestMoreChannels: () -> Unit = {}
) {
val channelRailWidth = 180.dp
val timelineGap = 4.dp
@@ -166,6 +167,9 @@ internal fun EpgGrid(
items = channels,
key = { index, channel -> epgChannelKey(channel, index) }
) { index, channel ->
+ if (index >= channels.size - 15) {
+ LaunchedEffect(channels.size) { onRequestMoreChannels() }
+ }
val programs = channel.guideLookupKey()?.let { lookupKey ->
programsByChannel[lookupKey].orEmpty()
}.orEmpty()
@@ -207,7 +211,8 @@ private fun GuideTimelineHeader(
scrollState: androidx.compose.foundation.ScrollState
) {
val now = currentGuideNow()
- val hourFormat = remember { DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT) }
+ val appTimeFormat = LocalAppTimeFormat.current
+ val hourFormat = remember(appTimeFormat) { appTimeFormat.createTimeFormatter() }
val zone = remember { ZoneId.systemDefault() }
val totalDuration = (windowEnd - windowStart).coerceAtLeast(1L)
val clampedNow = now.coerceIn(windowStart, windowEnd)
@@ -510,7 +515,8 @@ fun ProgramItem(
val now = currentGuideNow()
val isCurrent = now in program.startTime until program.endTime
- val format = remember { DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT) }
+ val appTimeFormat = LocalAppTimeFormat.current
+ val format = remember(appTimeFormat) { appTimeFormat.createTimeFormatter() }
val zone = remember { ZoneId.systemDefault() }
val startStr = format.format(Instant.ofEpochMilli(program.startTime).atZone(zone))
val endStr = format.format(Instant.ofEpochMilli(program.endTime).atZone(zone))
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgHeroComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgHeroComponents.kt
index 3dd255b2..618fb469 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgHeroComponents.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgHeroComponents.kt
@@ -36,6 +36,8 @@ import com.streamvault.app.R
import com.streamvault.app.ui.components.ChannelLogoBadge
import com.streamvault.app.ui.interaction.TvClickableSurface
import com.streamvault.app.ui.model.guideLookupKey
+import com.streamvault.app.ui.time.LocalAppTimeFormat
+import com.streamvault.app.ui.time.createTimeFormat
import com.streamvault.app.ui.theme.FocusBorder
import com.streamvault.app.ui.theme.OnSurface
import com.streamvault.app.ui.theme.OnSurfaceDim
@@ -44,9 +46,7 @@ import com.streamvault.app.ui.theme.SurfaceElevated
import com.streamvault.app.ui.theme.SurfaceHighlight
import com.streamvault.domain.model.Channel
import com.streamvault.domain.model.Program
-import java.text.SimpleDateFormat
import java.util.Date
-import java.util.Locale
internal data class GuideHeroSelection(
val channel: Channel,
@@ -128,7 +128,8 @@ internal fun ImmersiveGuideHero(
isRefreshing: Boolean,
modifier: Modifier = Modifier
) {
- val format = remember { SimpleDateFormat("HH:mm", Locale.getDefault()) }
+ val appTimeFormat = LocalAppTimeFormat.current
+ val format = remember(appTimeFormat) { appTimeFormat.createTimeFormat() }
val currentTime = System.currentTimeMillis()
val lastUpdatedLabel = remember(lastUpdatedAt, currentTime) {
lastUpdatedAt?.let { updatedAt ->
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgScreen.kt
index 35d6b575..deca0c76 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgScreen.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgScreen.kt
@@ -450,7 +450,8 @@ fun FullEpgScreen(
topNavVisible = isFirstRow
focusedChannel = channel
focusedProgram = program
- }
+ },
+ onRequestMoreChannels = viewModel::requestMoreChannels
)
}
}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgScreenDialogs.kt b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgScreenDialogs.kt
index 473d5651..ab7e8e25 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgScreenDialogs.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgScreenDialogs.kt
@@ -52,6 +52,8 @@ import androidx.tv.material3.Text
import com.streamvault.app.R
import com.streamvault.app.ui.interaction.TvClickableSurface
import com.streamvault.app.ui.interaction.TvButton
+import com.streamvault.app.ui.time.LocalAppTimeFormat
+import com.streamvault.app.ui.time.createTimeFormat
import com.streamvault.app.ui.theme.FocusBorder
import com.streamvault.app.ui.theme.OnSurface
import com.streamvault.app.ui.theme.OnSurfaceDim
@@ -64,9 +66,7 @@ import com.streamvault.domain.model.EpgMatchType
import com.streamvault.domain.model.EpgOverrideCandidate
import com.streamvault.domain.model.EpgSourceType
import com.streamvault.domain.model.Program
-import java.text.SimpleDateFormat
import java.util.Date
-import java.util.Locale
@Composable
private fun GuideModalDialog(
@@ -317,7 +317,8 @@ internal fun CompactGuideProgramDialog(
onScheduleWeeklyRecording: (() -> Unit)?
) {
var showDetails by rememberSaveable(program.startTime, program.endTime, program.title) { mutableStateOf(false) }
- val format = remember { SimpleDateFormat("HH:mm", Locale.getDefault()) }
+ val appTimeFormat = LocalAppTimeFormat.current
+ val format = remember(appTimeFormat) { appTimeFormat.createTimeFormat() }
val firstButtonFocusRequester = remember { FocusRequester() }
LaunchedEffect(Unit) { firstButtonFocusRequester.requestFocus() }
GuideModalDialog(onDismiss = onDismiss) {
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgViewModel.kt b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgViewModel.kt
index dfffe556..fae0f4b0 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgViewModel.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgViewModel.kt
@@ -35,6 +35,7 @@ import com.streamvault.domain.usecase.ScheduleRecordingCommand
import com.streamvault.domain.util.AdultContentVisibilityPolicy
import com.streamvault.data.preferences.PreferencesRepository
import dagger.hilt.android.lifecycle.HiltViewModel
+import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.FlowPreview
@@ -93,7 +94,8 @@ data class EpgUiState(
val guideWindowStart: Long = DEFAULT_NOW - EpgViewModel.LOOKBACK_MS,
val guideWindowEnd: Long = DEFAULT_NOW + EpgViewModel.LOOKAHEAD_MS,
val recordingMessage: String? = null,
- val pendingRecordingConflict: RecordingConflictInfo? = null
+ val pendingRecordingConflict: RecordingConflictInfo? = null,
+ val hasMoreChannels: Boolean = false
) {
companion object {
private val DEFAULT_NOW = System.currentTimeMillis()
@@ -177,7 +179,10 @@ private data class GuideBaseSnapshot(
val baseGuideStale: Boolean,
val guideAnchorTime: Long,
val guideWindowStart: Long,
- val guideWindowEnd: Long
+ val guideWindowEnd: Long,
+ val hiddenCategoryIds: Set<Long> = emptySet(),
+ val nextRawChannelOffset: Int = 0,
+ val hasMoreChannels: Boolean = false
)
private data class GuideDisplaySnapshot(
@@ -195,6 +200,12 @@ private data class GuideBaseComputation(
val hasUpcomingData: Boolean
)
+private data class GuidePrefetchedPage(
+ val channels: List<Channel>,
+ val programs: GuideProgramsResult,
+ val nextRawOffset: Int
+)
+
private data class GuideSelectionRequest(
val requestedCategoryId: Long,
val anchorTime: Long,
@@ -275,6 +286,8 @@ class EpgViewModel @Inject constructor(
val programReminderUiState: StateFlow<ProgramReminderUiState> = _programReminderUiState.asStateFlow()
private var overrideSearchJob: Job? = null
private var guideFallbackJob: Job? = null
+ private var prefetchJob: Deferred<GuidePrefetchedPage?>? = null
+ private var loadMoreJob: Job? = null
private var combinedCategoriesById: Map<Long, CombinedCategory> = emptyMap()
init {
@@ -316,6 +329,129 @@ class EpgViewModel @Inject constructor(
refreshNonce.update { it + 1 }
}
+ fun requestMoreChannels() {
+ val snapshot = baseGuideSnapshot.value ?: return
+ if (!snapshot.hasMoreChannels) return
+ if (loadMoreJob?.isActive == true) return
+ val deferred = prefetchJob
+ if (deferred == null) {
+ val nextChannels = snapshot.allChannels
+ .drop(snapshot.visibleChannels.size)
+ .take(MAX_CHANNELS)
+ if (nextChannels.isEmpty()) {
+ baseGuideSnapshot.update { it?.copy(hasMoreChannels = false) }
+ return
+ }
+ loadMoreJob = viewModelScope.launch {
+ val programs = loadGuideProgramsForSnapshot(snapshot, nextChannels)
+ val current = baseGuideSnapshot.value ?: return@launch
+ if (current.selectedCategoryId != snapshot.selectedCategoryId ||
+ current.providerId != snapshot.providerId
+ ) return@launch
+ val newVisible = current.visibleChannels + nextChannels
+ baseGuideSnapshot.update { s ->
+ s?.copy(
+ visibleChannels = newVisible,
+ baseProgramsByChannel = s.baseProgramsByChannel + programs.programsByChannel,
+ hasMoreChannels = newVisible.size < s.allChannels.size
+ )
+ }
+ }
+ return
+ }
+ if (deferred.isCancelled) return
+ prefetchJob = null
+ loadMoreJob = viewModelScope.launch {
+ val page = deferred.await() ?: run {
+ baseGuideSnapshot.update { it?.copy(hasMoreChannels = false) }
+ return@launch
+ }
+ val current = baseGuideSnapshot.value ?: return@launch
+ // Guard: category must not have changed while prefetch was running
+ if (current.selectedCategoryId != snapshot.selectedCategoryId ||
+ current.providerId != snapshot.providerId
+ ) return@launch
+ val newVisible = current.visibleChannels + page.channels
+ baseGuideSnapshot.update { s ->
+ s?.copy(
+ visibleChannels = newVisible,
+ allChannels = newVisible,
+ baseProgramsByChannel = s.baseProgramsByChannel + page.programs.programsByChannel,
+ nextRawChannelOffset = page.nextRawOffset,
+ hasMoreChannels = page.channels.size >= MAX_CHANNELS
+ )
+ }
+ baseGuideSnapshot.value?.let { schedulePrefetchNextPage(it) }
+ }
+ }
+
+ private suspend fun loadGuideProgramsForSnapshot(
+ snapshot: GuideBaseSnapshot,
+ channels: List<Channel>
+ ): GuideProgramsResult =
+ if (snapshot.providerId > 0L) {
+ loadGuidePrograms(
+ providerId = snapshot.providerId,
+ channels = channels,
+ windowStart = snapshot.guideWindowStart,
+ windowEnd = snapshot.guideWindowEnd
+ )
+ } else {
+ loadCombinedGuidePrograms(
+ channels = channels,
+ windowStart = snapshot.guideWindowStart,
+ windowEnd = snapshot.guideWindowEnd
+ )
+ }
+
+ private fun schedulePrefetchNextPage(snapshot: GuideBaseSnapshot) {
+ if (!snapshot.hasMoreChannels) return
+ prefetchJob = viewModelScope.async<GuidePrefetchedPage?>(Dispatchers.IO) {
+ val channels = fetchGuideChannelPage(
+ providerId = snapshot.providerId,
+ categoryId = snapshot.selectedCategoryId,
+ offset = snapshot.nextRawChannelOffset,
+ hiddenCategoryIds = snapshot.hiddenCategoryIds,
+ favoritesOnly = snapshot.showFavoritesOnly,
+ favoriteChannelIds = snapshot.favoriteChannelIds
+ )
+ if (channels.isEmpty()) return@async null
+ val programs = loadGuidePrograms(
+ providerId = snapshot.providerId,
+ channels = channels,
+ windowStart = snapshot.guideWindowStart,
+ windowEnd = snapshot.guideWindowEnd
+ )
+ GuidePrefetchedPage(
+ channels = channels,
+ programs = programs,
+ nextRawOffset = snapshot.nextRawChannelOffset + MAX_CHANNELS
+ )
+ }
+ }
+
+ private suspend fun fetchGuideChannelPage(
+ providerId: Long,
+ categoryId: Long,
+ offset: Int,
+ hiddenCategoryIds: Set<Long>,
+ favoritesOnly: Boolean,
+ favoriteChannelIds: Set<Long>
+ ): List<Channel> {
+ if (providerId <= 0L) return emptyList()
+ // Favorites and virtual group categories aren't offset-pageable; All Channels is a negative sentinel but is pageable.
+ if (categoryId != ChannelRepository.ALL_CHANNELS_ID &&
+ (categoryId == VirtualCategoryIds.FAVORITES || categoryId < 0L)
+ ) return emptyList()
+ val withoutErrors = channelRepository.getChannelsWithoutErrorsPageOffset(providerId, categoryId, MAX_CHANNELS, offset)
+ val raw = withoutErrors.ifEmpty {
+ channelRepository.getChannelsByCategoryPageOffset(providerId, categoryId, MAX_CHANNELS, offset)
+ }
+ val filtered = if (hiddenCategoryIds.isEmpty()) raw
+ else raw.filterNot { it.categoryId in hiddenCategoryIds }
+ return if (favoritesOnly) filtered.filter { it.id in favoriteChannelIds } else filtered
+ }
+
fun openEpgOverride(channel: Channel) {
_overrideUiState.value = EpgOverrideUiState(
channel = channel,
@@ -811,6 +947,7 @@ class EpgViewModel @Inject constructor(
channels = visibleChannels,
existingProgramsByChannel = guideResult.programsByChannel
)
+ baseGuideSnapshot.value?.let { schedulePrefetchNextPage(it) }
finalizeStartupCategory(request.resolvedCategoryId)
}
}
@@ -972,7 +1109,12 @@ class EpgViewModel @Inject constructor(
channelSelection: GuideChannelSelection,
guideResult: GuideProgramsResult
) {
+ prefetchJob?.cancel()
+ prefetchJob = null
val visibleChannels = channelSelection.channels.take(MAX_CHANNELS)
+ val supportsOffsetPaging = providerId > 0L &&
+ (request.resolvedCategoryId == ChannelRepository.ALL_CHANNELS_ID ||
+ (request.resolvedCategoryId != VirtualCategoryIds.FAVORITES && request.resolvedCategoryId >= 0L))
val computedNow = System.currentTimeMillis()
val computedChannelsWithSchedule = visibleChannels.count { channel ->
channel.guideLookupKey()
@@ -1001,7 +1143,14 @@ class EpgViewModel @Inject constructor(
baseGuideStale = visibleChannels.isNotEmpty() && (computedChannelsWithSchedule == 0 || !computedHasUpcomingData),
guideAnchorTime = request.anchorTime,
guideWindowStart = request.windowStart,
- guideWindowEnd = request.windowEnd
+ guideWindowEnd = request.windowEnd,
+ hiddenCategoryIds = request.hiddenCategoryIds,
+ nextRawChannelOffset = MAX_CHANNELS,
+ hasMoreChannels = if (supportsOffsetPaging) {
+ channelSelection.channels.size >= MAX_CHANNELS
+ } else {
+ channelSelection.channels.size > visibleChannels.size
+ }
)
}
@@ -1095,7 +1244,8 @@ class EpgViewModel @Inject constructor(
isGuideStale = displaySnapshot.isGuideStale,
guideAnchorTime = baseSnapshot.guideAnchorTime,
guideWindowStart = baseSnapshot.guideWindowStart,
- guideWindowEnd = baseSnapshot.guideWindowEnd
+ guideWindowEnd = baseSnapshot.guideWindowEnd,
+ hasMoreChannels = baseSnapshot.hasMoreChannels
)
}
}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeSidebarComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeSidebarComponents.kt
index 2a014029..1fe3907b 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeSidebarComponents.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeSidebarComponents.kt
@@ -61,14 +61,14 @@ import com.streamvault.app.ui.theme.Primary
import com.streamvault.app.ui.theme.PrimaryLight
import com.streamvault.app.ui.theme.SurfaceElevated
import com.streamvault.app.ui.theme.SurfaceHighlight
+import com.streamvault.app.ui.time.LocalAppTimeFormat
+import com.streamvault.app.ui.time.createTimeFormat
import com.streamvault.domain.model.Category
import com.streamvault.domain.model.Channel
import com.streamvault.player.PlayerEngine
import com.streamvault.player.PlayerRenderSurfaceType
import com.streamvault.player.PlayerSurfaceResizeMode
-import java.text.SimpleDateFormat
import java.util.Date
-import java.util.Locale
@Composable
internal fun CompactSplitLauncherButton(
@@ -210,11 +210,13 @@ internal fun LivePreviewPane(
style = MaterialTheme.typography.bodyLarge,
color = OnBackground
)
+ val appTimeFormat = LocalAppTimeFormat.current
+ val timeFormat = remember(appTimeFormat) { appTimeFormat.createTimeFormat() }
Text(
text = stringResource(
R.string.time_range_format,
- formatProgramTime(program.startTime),
- formatProgramTime(program.endTime)
+ timeFormat.format(Date(program.startTime)),
+ timeFormat.format(Date(program.endTime))
),
style = MaterialTheme.typography.bodySmall,
color = OnSurfaceDim
@@ -253,11 +255,6 @@ internal fun LivePreviewPane(
}
}
-private fun formatProgramTime(timestampMs: Long): String {
- if (timestampMs <= 0L) return "--:--"
- return SimpleDateFormat("HH:mm", Locale.getDefault()).format(Date(timestampMs))
-}
-
@Composable
internal fun CategoryItem(
category: Category,
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/movies/MoviesScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/movies/MoviesScreen.kt
index b136092d..8c52110d 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/movies/MoviesScreen.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/movies/MoviesScreen.kt
@@ -66,6 +66,7 @@ import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import com.streamvault.app.ui.components.shell.BrowseSearchLaunchCard
import com.streamvault.app.ui.components.shell.LoadMoreCard
+import com.streamvault.app.ui.components.shell.InfiniteScrollEffect
import com.streamvault.app.ui.components.shell.AppNavigationChrome
import com.streamvault.app.ui.components.shell.AppMessageState
import com.streamvault.app.ui.components.shell.AppScreenScaffold
@@ -98,6 +99,9 @@ fun MoviesScreen(
currentRoute: String,
viewModel: MoviesViewModel = hiltViewModel()
) {
+ remember(viewModel) {
+ viewModel.resetPreviewRowsForScreenEntry()
+ }
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
val snackbarHostState = remember { SnackbarHostState() }
val initialContentFocusRequester = remember { FocusRequester() }
@@ -399,8 +403,18 @@ private fun MoviesVodContent(
}
}
val openProtectedCategory: (Category) -> Unit = onProtectedCategoryClick
- val visibleCategoryNames = remember(uiState.categoryNames, categoryByName, uiState.parentalControlLevel, uiState.unlockedCategoryIds) {
- uiState.categoryNames.filter { name ->
+ val browseCategoryNames = remember(uiState.categoryNames, uiState.providerCategories, uiState.categories, uiState.favoriteCategoryName) {
+ buildList {
+ val names = linkedSetOf<String>()
+ uiState.categoryNames.forEach(names::add)
+ uiState.providerCategories.forEach { names.add(it.name) }
+ uiState.categories.forEach { names.add(it.name) }
+ names.add(uiState.favoriteCategoryName)
+ addAll(names)
+ }
+ }
+ val visibleCategoryNames = remember(browseCategoryNames, categoryByName, uiState.parentalControlLevel, uiState.unlockedCategoryIds) {
+ browseCategoryNames.filter { name ->
val category = categoryByName[name]
category == null || !isCategoryHidden(category)
}
@@ -474,7 +488,16 @@ private fun MoviesVodContent(
}
if (uiState.selectedCategory == null) {
+ val previewListState = androidx.compose.foundation.lazy.rememberLazyListState()
+ InfiniteScrollEffect(
+ listState = previewListState,
+ enabled = uiState.vodInfiniteScroll,
+ canLoadMore = uiState.hasMorePreviewRows,
+ isLoading = uiState.isLoadingPreviewRows,
+ onLoadMore = onLoadMorePreviewRows
+ )
LazyColumn(
+ state = previewListState,
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(bottom = 28.dp)
) {
@@ -511,7 +534,7 @@ private fun MoviesVodContent(
VodActionChip(
key = "categories",
label = stringResource(R.string.movies_categories_title),
- detail = "${uiState.categoryNames.size} groups",
+ detail = "${visibleCategoryNames.count { name -> categoryByName[name]?.id != VodBrowseDefaults.FAVORITES_SENTINEL_ID }} groups",
onClick = { showCategoryPicker = true }
)
)
@@ -670,11 +693,17 @@ private fun MoviesVodContent(
}
}
}
- if (uiState.hasMorePreviewRows && !uiState.isLoadingPreviewRows && catEntries.isNotEmpty()) {
+ if (uiState.hasMorePreviewRows && !uiState.isLoadingPreviewRows && !uiState.vodInfiniteScroll && catEntries.isNotEmpty()) {
item(key = "load_more_preview_trigger") {
- LaunchedEffect(catEntries.size) {
- onLoadMorePreviewRows()
- }
+ LoadMoreCard(
+ label = stringResource(
+ R.string.library_load_more,
+ catEntries.size,
+ visibleCategoryNames.size
+ ),
+ onClick = onLoadMorePreviewRows,
+ modifier = Modifier.padding(horizontal = 24.dp, vertical = 12.dp)
+ )
}
}
}
@@ -709,7 +738,16 @@ private fun MoviesVodContent(
)
}
+ val modernGridState = androidx.compose.foundation.lazy.grid.rememberLazyGridState()
+ InfiniteScrollEffect(
+ gridState = modernGridState,
+ enabled = !uiState.isReorderMode,
+ canLoadMore = uiState.canLoadMoreSelectedCategory,
+ isLoading = uiState.isLoadingSelectedCategory,
+ onLoadMore = onLoadMore
+ )
LazyVerticalGrid(
+ state = modernGridState,
columns = GridCells.Adaptive(minSize = 136.dp),
modifier = Modifier
.fillMaxSize()
@@ -848,20 +886,6 @@ private fun MoviesVodContent(
}
)
}
-
- if (!uiState.isReorderMode && uiState.canLoadMoreSelectedCategory) {
- item(span = { GridItemSpan(maxLineSpan) }) {
- LoadMoreCard(
- label = stringResource(
- R.string.library_load_more,
- uiState.selectedCategoryLoadedCount,
- uiState.selectedCategoryTotalCount
- ),
- onClick = onLoadMore,
- modifier = Modifier.padding(top = 8.dp, bottom = 24.dp)
- )
- }
- }
}
}
}
@@ -929,8 +953,18 @@ private fun MoviesVodClassicContent(
}
}
val openProtectedCategory: (Category) -> Unit = onProtectedCategoryClick
- val visibleCategoryNames = remember(uiState.categoryNames, categoryByName, uiState.parentalControlLevel, uiState.unlockedCategoryIds) {
- uiState.categoryNames.filter { name ->
+ val browseCategoryNames = remember(uiState.categoryNames, uiState.providerCategories, uiState.categories, uiState.favoriteCategoryName) {
+ buildList {
+ val names = linkedSetOf<String>()
+ uiState.categoryNames.forEach(names::add)
+ uiState.providerCategories.forEach { names.add(it.name) }
+ uiState.categories.forEach { names.add(it.name) }
+ names.add(uiState.favoriteCategoryName)
+ addAll(names)
+ }
+ }
+ val visibleCategoryNames = remember(browseCategoryNames, categoryByName, uiState.parentalControlLevel, uiState.unlockedCategoryIds) {
+ browseCategoryNames.filter { name ->
val category = categoryByName[name]
category == null || !isCategoryHidden(category)
}
@@ -1111,7 +1145,16 @@ private fun MoviesVodClassicContent(
)
}
+ val classicGridState = androidx.compose.foundation.lazy.grid.rememberLazyGridState()
+ InfiniteScrollEffect(
+ gridState = classicGridState,
+ enabled = !uiState.isReorderMode,
+ canLoadMore = uiState.canLoadMoreSelectedCategory,
+ isLoading = uiState.isLoadingSelectedCategory,
+ onLoadMore = onLoadMore
+ )
LazyVerticalGrid(
+ state = classicGridState,
columns = GridCells.Adaptive(minSize = 136.dp),
modifier = Modifier
.fillMaxWidth()
@@ -1174,20 +1217,6 @@ private fun MoviesVodClassicContent(
}
)
}
-
- if (!uiState.isReorderMode && uiState.canLoadMoreSelectedCategory) {
- item(span = { GridItemSpan(maxLineSpan) }) {
- LoadMoreCard(
- label = stringResource(
- R.string.library_load_more,
- uiState.selectedCategoryLoadedCount,
- uiState.selectedCategoryTotalCount
- ),
- onClick = onLoadMore,
- modifier = Modifier.padding(top = 8.dp)
- )
- }
- }
}
}
}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/movies/MoviesViewModel.kt b/app/src/main/java/com/streamvault/app/ui/screens/movies/MoviesViewModel.kt
index 1b65568e..39345f00 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/movies/MoviesViewModel.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/movies/MoviesViewModel.kt
@@ -15,6 +15,7 @@ import com.streamvault.domain.model.LibraryBrowseQuery
import com.streamvault.domain.model.LibrarySortBy
import com.streamvault.domain.model.Movie
import com.streamvault.domain.model.PlaybackHistory
+import com.streamvault.domain.model.ProviderType
import com.streamvault.domain.model.Result
import com.streamvault.domain.repository.FavoriteRepository
import com.streamvault.domain.repository.MovieRepository
@@ -51,6 +52,7 @@ import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
+import kotlinx.coroutines.flow.distinctUntilChangedBy
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flatMapLatest
@@ -82,6 +84,7 @@ class MoviesViewModel @Inject constructor(
const val UNCATEGORIZED = "Uncategorized"
const val MIN_SEARCH_QUERY_LENGTH = 2
const val FAVORITE_ID_FETCH_BUFFER = 80
+ const val INITIAL_PREVIEW_BATCH_SIZE = 6
}
private val _uiState = MutableStateFlow(MoviesUiState())
@@ -91,7 +94,7 @@ class MoviesViewModel @Inject constructor(
private val _selectedCategoryLoadLimit = MutableStateFlow(VodBrowseDefaults.SELECTED_CATEGORY_PAGE_SIZE)
private val _selectedLibraryFilterType = MutableStateFlow(LibraryFilterType.ALL)
private val _selectedLibrarySortBy = MutableStateFlow(LibrarySortBy.LIBRARY)
- private val _previewBatchSize = MutableStateFlow(8)
+ private val _previewBatchSize = MutableStateFlow(INITIAL_PREVIEW_BATCH_SIZE)
private var activeProviderId: Long? = null
private data class PreviewLoadResult(
@@ -152,7 +155,13 @@ class MoviesViewModel @Inject constructor(
categories = providerCategories,
hiddenCategoryIds = hiddenCategoryIds,
sortMode = sortMode
- )
+ ).let { categories ->
+ if (provider.type == ProviderType.STALKER_PORTAL) {
+ categories.filterNot(::isLikelyProviderWideStalkerCategory)
+ } else {
+ categories
+ }
+ }
MovieCatalogDependencies(
allFavorites = allFavorites,
customCategories = customCategories,
@@ -175,6 +184,12 @@ class MoviesViewModel @Inject constructor(
query = query.trim()
)
}
+ .distinctUntilChangedBy { params ->
+ params.copy(
+ providerCategoryCounts = emptyMap(),
+ libraryCount = 0
+ )
+ }
}
.flatMapLatest { params ->
_previewBatchSize.flatMapLatest { batchSize ->
@@ -231,9 +246,13 @@ class MoviesViewModel @Inject constructor(
val currentSelected = _uiState.value.selectedCategory
val preserveSelectedCategory = currentSelected != null && _searchQuery.value.isNotBlank()
val resolvedSelected = currentSelected?.takeIf { selected ->
+ val customCategoryNames = _uiState.value.categories.mapTo(linkedSetOf()) { it.name }
+ val providerCategoryNames = snapshot.providerCategories.mapTo(linkedSetOf()) { it.name }
preserveSelectedCategory ||
selected == _uiState.value.fullLibraryCategoryName ||
- selected in snapshot.categoryNames
+ selected in snapshot.categoryNames ||
+ selected in providerCategoryNames ||
+ selected in customCategoryNames
}
_uiState.update {
it.copy(
@@ -266,6 +285,12 @@ class MoviesViewModel @Inject constructor(
}
}
+ viewModelScope.launch {
+ preferencesRepository.vodInfiniteScroll.collectLatest { enabled ->
+ _uiState.update { it.copy(vodInfiniteScroll = enabled) }
+ }
+ }
+
viewModelScope.launch {
providerRepository.getActiveProvider()
.filterNotNull()
@@ -465,7 +490,7 @@ class MoviesViewModel @Inject constructor(
}
fun selectCategory(categoryName: String?) {
- _previewBatchSize.value = 8
+ _previewBatchSize.value = INITIAL_PREVIEW_BATCH_SIZE
activeProviderId?.let { providerId ->
parentalControlManager.retainUnlockedCategory(
providerId = providerId,
@@ -505,17 +530,38 @@ class MoviesViewModel @Inject constructor(
fun loadMorePreviewRows() {
if (_uiState.value.hasMorePreviewRows && !_uiState.value.isLoadingPreviewRows) {
- _previewBatchSize.update { it + 8 }
+ _previewBatchSize.update { it + INITIAL_PREVIEW_BATCH_SIZE }
}
}
fun setSearchQuery(query: String) {
- _previewBatchSize.value = 8
+ _previewBatchSize.value = INITIAL_PREVIEW_BATCH_SIZE
setVodSearchQuery(query, _searchQuery, _uiState) { updatedQuery ->
copy(searchQuery = updatedQuery)
}
}
+ fun resetPreviewRowsForScreenEntry() {
+ _previewBatchSize.value = INITIAL_PREVIEW_BATCH_SIZE
+ _uiState.update { state ->
+ if (state.selectedCategory != null || state.searchQuery.isNotBlank()) {
+ state
+ } else {
+ val providerNames = state.providerCategories.mapTo(linkedSetOf()) { it.name }
+ val initialProviderNames = state.providerCategories
+ .take(INITIAL_PREVIEW_BATCH_SIZE)
+ .mapTo(linkedSetOf()) { it.name }
+ fun keepRow(name: String): Boolean = name !in providerNames || name in initialProviderNames
+ state.copy(
+ moviesByCategory = state.moviesByCategory.filterKeys(::keepRow),
+ categoryNames = state.categoryNames.filter(::keepRow),
+ categoryCounts = state.categoryCounts.filterKeys(::keepRow),
+ hasMorePreviewRows = state.providerCategories.size > INITIAL_PREVIEW_BATCH_SIZE
+ )
+ }
+ }
+ }
+
fun setSelectedLibraryFilterType(filterType: LibraryFilterType) {
setVodLibraryFilterType(
filterType = filterType,
@@ -929,6 +975,16 @@ class MoviesViewModel @Inject constructor(
)
}
+ private fun isLikelyProviderWideStalkerCategory(category: Category): Boolean {
+ val name = category.name.trim().lowercase()
+ return name == "*" ||
+ name == "all" ||
+ name == "all movies" ||
+ name == "all vod" ||
+ name == "all videos" ||
+ name == "all categories"
+ }
+
private suspend fun loadSelectedCategoryItems(
request: SelectedMovieCategoryRequest
): SelectedMovieCategorySnapshot {
@@ -945,7 +1001,7 @@ class MoviesViewModel @Inject constructor(
.map { it.contentId }
.toSet()
- val (selectedItems, totalCount) = when (request.selectedCategory) {
+ val (selectedItems, totalCount, hasMoreRemote) = when (request.selectedCategory) {
VodBrowseDefaults.FULL_LIBRARY_CATEGORY -> {
val result = movieRepository
.browseMovies(
@@ -959,7 +1015,11 @@ class MoviesViewModel @Inject constructor(
)
)
.first()
- result.items.filterNot { movie -> movie.categoryId in request.hiddenCategoryIds } to result.totalCount
+ Triple(
+ result.items.filterNot { movie -> movie.categoryId in request.hiddenCategoryIds },
+ result.totalCount,
+ result.hasMoreRemote
+ )
}
VodBrowseDefaults.FAVORITES_CATEGORY -> {
val ids = request.allFavorites
@@ -986,7 +1046,11 @@ class MoviesViewModel @Inject constructor(
request.sortBy,
request.query
)
- filteredItems.take(request.loadLimit) to if (fetchIds === ids) filteredItems.size else ids.size
+ Triple(
+ filteredItems.take(request.loadLimit),
+ if (fetchIds === ids) filteredItems.size else ids.size,
+ false
+ )
}
else -> {
val customCategory = request.customCategories.firstOrNull { it.name == request.selectedCategory }
@@ -1015,7 +1079,11 @@ class MoviesViewModel @Inject constructor(
request.sortBy,
request.query
)
- filteredItems.take(request.loadLimit) to if (fetchIds === ids) filteredItems.size else ids.size
+ Triple(
+ filteredItems.take(request.loadLimit),
+ if (fetchIds === ids) filteredItems.size else ids.size,
+ false
+ )
} else {
val providerCategory = request.providerCategories.firstOrNull { it.name == request.selectedCategory }
if (providerCategory != null) {
@@ -1032,9 +1100,9 @@ class MoviesViewModel @Inject constructor(
)
)
.first()
- result.items to result.totalCount
+ Triple(result.items, result.totalCount, result.hasMoreRemote)
} else {
- emptyList<Movie>() to 0
+ Triple(emptyList<Movie>(), 0, false)
}
}
}
@@ -1047,7 +1115,7 @@ class MoviesViewModel @Inject constructor(
items = enrichedItems,
loadedCount = enrichedItems.size,
totalCount = totalCount,
- canLoadMore = totalCount > enrichedItems.size
+ canLoadMore = totalCount > enrichedItems.size || hasMoreRemote
)
}
@@ -1206,6 +1274,7 @@ data class MoviesUiState(
val selectedLibraryFilterType: LibraryFilterType = LibraryFilterType.ALL,
val selectedLibrarySortBy: LibrarySortBy = LibrarySortBy.LIBRARY,
val vodViewMode: VodViewMode = VodViewMode.MODERN,
+ val vodInfiniteScroll: Boolean = false,
val continueWatching: List<PlaybackHistory> = emptyList(),
val hasProviders: Boolean = false,
val hasActiveProvider: Boolean = false,
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/multiview/MultiViewViewModel.kt b/app/src/main/java/com/streamvault/app/ui/screens/multiview/MultiViewViewModel.kt
index 30bb6830..134f3613 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/multiview/MultiViewViewModel.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/multiview/MultiViewViewModel.kt
@@ -76,6 +76,11 @@ class MultiViewViewModel @Inject constructor(
private val playerEngines = mutableMapOf<Int, PlayerEngine>()
init {
+ viewModelScope.launch {
+ preferencesRepository.playerAudioVideoOffsetMs.collect {
+ applyAudioVideoOffsetsToActiveEngines()
+ }
+ }
viewModelScope.launch {
combine(
preferencesRepository.getMultiViewPreset(0),
@@ -243,6 +248,7 @@ class MultiViewViewModel @Inject constructor(
val channel = slot.channel
?: throw IllegalStateException("Missing channel for slot ${slot.index}")
+ engine.setAudioVideoOffsetMs(effectiveAudioVideoOffsetForChannel(channel.id))
val streamInfo = when (val result = channelRepository.getStreamInfo(channel)) {
is Result.Success -> result.data
is Result.Error -> throw IllegalStateException(result.message)
@@ -565,6 +571,22 @@ class MultiViewViewModel @Inject constructor(
}
}
+ private suspend fun effectiveAudioVideoOffsetForChannel(channelId: Long): Int {
+ val globalOffset = preferencesRepository.playerAudioVideoOffsetMs.first()
+ if (channelId <= 0L) return globalOffset
+ return preferencesRepository.observeAudioVideoOffsetForChannel(channelId).first() ?: globalOffset
+ }
+
+ private fun applyAudioVideoOffsetsToActiveEngines() {
+ val slots = _uiState.value.slots
+ playerEngines.forEach { (index, engine) ->
+ val channelId = slots.getOrNull(index)?.channel?.id ?: return@forEach
+ viewModelScope.launch {
+ engine.setAudioVideoOffsetMs(effectiveAudioVideoOffsetForChannel(channelId))
+ }
+ }
+ }
+
private fun detectDeviceTier(): DevicePerformanceTier {
val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as? ActivityManager
val memoryClass = activityManager?.memoryClass ?: 256
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.kt
index 889c4889..adfbb099 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
@@ -94,7 +94,11 @@ import com.streamvault.app.ui.screens.player.overlay.PlayerAspectRatioToast
import com.streamvault.app.ui.screens.player.overlay.PlayerControlsOverlay
import com.streamvault.app.ui.screens.player.overlay.PlayerNumericInputOverlay
import com.streamvault.app.ui.screens.player.overlay.PlayerResolutionBadge
+import com.streamvault.app.ui.screens.player.overlay.PlayerAudioVideoOffsetDialog
import com.streamvault.app.ui.screens.player.overlay.PlayerSpeedSelectionDialog
+import com.streamvault.app.ui.screens.player.overlay.PlayerSleepTimerDialog
+import com.streamvault.app.ui.screens.player.overlay.PlayerSleepTimerWarningOverlay
+import com.streamvault.app.ui.screens.player.overlay.NextEpisodeCountdownOverlay
import com.streamvault.app.ui.screens.multiview.MultiViewViewModel
import com.streamvault.app.ui.screens.multiview.MultiViewPlannerDialog
import com.streamvault.app.navigation.Routes
@@ -152,6 +156,7 @@ fun PlayerScreen(
val playerEngine by viewModel.activePlayerEngine.collectAsStateWithLifecycle()
val playbackState by playerEngine.playbackState.collectAsStateWithLifecycle()
val isPlaying by playerEngine.isPlaying.collectAsStateWithLifecycle()
+ val renderSurfaceType by playerEngine.renderSurfaceType.collectAsStateWithLifecycle()
val showControls by viewModel.showControls.collectAsStateWithLifecycle()
val videoFormat by viewModel.videoFormat.collectAsStateWithLifecycle()
val playerError by viewModel.playerError.collectAsStateWithLifecycle()
@@ -161,6 +166,8 @@ fun PlayerScreen(
val currentChannel by viewModel.currentChannel.collectAsStateWithLifecycle()
val currentSeries by viewModel.currentSeries.collectAsStateWithLifecycle()
val currentEpisode by viewModel.currentEpisode.collectAsStateWithLifecycle()
+ val nextEpisodeForAutoPlay by viewModel.nextEpisode.collectAsStateWithLifecycle()
+ val autoPlayCountdown by viewModel.autoPlayCountdown.collectAsStateWithLifecycle()
val playbackTitle by viewModel.playbackTitle.collectAsStateWithLifecycle()
val resumePrompt by viewModel.resumePrompt.collectAsStateWithLifecycle()
val currentSeriesSeasons = remember(currentSeries) {
@@ -194,14 +201,20 @@ fun PlayerScreen(
val isMuted by viewModel.isMuted.collectAsStateWithLifecycle()
val mediaTitle by viewModel.mediaTitle.collectAsStateWithLifecycle()
val playbackSpeed by viewModel.playbackSpeed.collectAsStateWithLifecycle()
+ val audioVideoOffsetState by viewModel.audioVideoOffsetUiState.collectAsStateWithLifecycle()
val castConnectionState by viewModel.castConnectionState.collectAsStateWithLifecycle()
val seekPreview by viewModel.seekPreview.collectAsStateWithLifecycle()
val preventStandbyDuringPlayback by viewModel.preventStandbyDuringPlayback.collectAsStateWithLifecycle()
val timeshiftUiState by viewModel.timeshiftUiState.collectAsStateWithLifecycle()
+ val sleepTimerUiState by viewModel.sleepTimerUiState.collectAsStateWithLifecycle()
+ val sleepTimerExitEvent by viewModel.sleepTimerExitEvent.collectAsStateWithLifecycle()
var showTrackSelection by remember { mutableStateOf<TrackType?>(null) }
var showVariantSelection by remember { mutableStateOf(false) }
var showSpeedSelection by remember { mutableStateOf(false) }
+ var showAudioVideoOffsetDialog by remember { mutableStateOf(false) }
+ var showStopPlaybackTimerDialog by remember { mutableStateOf(false) }
+ var showIdleStandbyTimerDialog by remember { mutableStateOf(false) }
var showProgramHistory by remember { mutableStateOf(false) }
var showSplitDialog by remember { mutableStateOf(false) }
var showEpisodePicker by remember { mutableStateOf(false) }
@@ -239,6 +252,13 @@ fun PlayerScreen(
)
}
+ LaunchedEffect(sleepTimerExitEvent) {
+ if (sleepTimerExitEvent > 0) {
+ viewModel.consumeSleepTimerExitEvent()
+ onBack()
+ }
+ }
+
LaunchedEffect(isInPictureInPictureMode) {
if (isInPictureInPictureMode) {
viewModel.closeOverlays()
@@ -285,7 +305,7 @@ fun PlayerScreen(
// Consolidated focus management for all overlays
val liveOverlayVisible = contentType == "LIVE" && (showChannelListOverlay || showCategoryListOverlay || showEpgOverlay || showChannelInfoOverlay)
- val anyOverlayVisible = liveOverlayVisible || showTrackSelection != null || showVariantSelection || showSpeedSelection || showProgramHistory || showSplitDialog || showEpisodePicker || showDiagnostics
+ val anyOverlayVisible = liveOverlayVisible || showTrackSelection != null || showVariantSelection || showSpeedSelection || showAudioVideoOffsetDialog || showStopPlaybackTimerDialog || showIdleStandbyTimerDialog || showProgramHistory || showSplitDialog || showEpisodePicker || showDiagnostics
LaunchedEffect(contentType, showCategoryListOverlay, showChannelListOverlay, showEpgOverlay, showChannelInfoOverlay) {
if (contentType == "LIVE" && (showCategoryListOverlay || showChannelListOverlay || showEpgOverlay || showChannelInfoOverlay)) {
@@ -404,10 +424,10 @@ fun PlayerScreen(
}
}
- LaunchedEffect(showControls, showTrackSelection, showVariantSelection, showSpeedSelection, showProgramHistory, showSplitDialog, showEpisodePicker) {
+ LaunchedEffect(showControls, showTrackSelection, showVariantSelection, showSpeedSelection, showAudioVideoOffsetDialog, showStopPlaybackTimerDialog, showIdleStandbyTimerDialog, showProgramHistory, showSplitDialog, showEpisodePicker) {
if (!showControls) {
viewModel.cancelControlsAutoHide()
- } else if (showTrackSelection != null || showVariantSelection || showSpeedSelection || showProgramHistory || showSplitDialog || showEpisodePicker) {
+ } else if (showTrackSelection != null || showVariantSelection || showSpeedSelection || showAudioVideoOffsetDialog || showStopPlaybackTimerDialog || showIdleStandbyTimerDialog || showProgramHistory || showSplitDialog || showEpisodePicker) {
viewModel.cancelControlsAutoHide()
} else {
viewModel.hideControlsAfterDelay()
@@ -431,6 +451,9 @@ fun PlayerScreen(
showSplitDialog,
showEpisodePicker,
showSpeedSelection,
+ showAudioVideoOffsetDialog,
+ showStopPlaybackTimerDialog,
+ showIdleStandbyTimerDialog,
showTrackSelection,
showVariantSelection,
showDiagnostics,
@@ -449,6 +472,12 @@ fun PlayerScreen(
showSplitDialog -> showSplitDialog = false
showEpisodePicker -> showEpisodePicker = false
showSpeedSelection -> showSpeedSelection = false
+ showAudioVideoOffsetDialog -> {
+ showAudioVideoOffsetDialog = false
+ viewModel.dismissAudioVideoOffsetPreview()
+ }
+ showStopPlaybackTimerDialog -> showStopPlaybackTimerDialog = false
+ showIdleStandbyTimerDialog -> showIdleStandbyTimerDialog = false
showVariantSelection -> showVariantSelection = false
showTrackSelection != null -> showTrackSelection = null
showDiagnostics -> viewModel.toggleDiagnostics()
@@ -476,6 +505,7 @@ fun PlayerScreen(
.focusable()
.pointerInput(contentType, anyOverlayVisible, showControls) {
detectTapGestures {
+ viewModel.notifyUserActivity()
when {
anyOverlayVisible -> return@detectTapGestures
showControls -> viewModel.toggleControls()
@@ -500,13 +530,14 @@ fun PlayerScreen(
if (event.nativeKeyEvent.action != KeyEvent.ACTION_DOWN) {
return@onPreviewKeyEvent false
}
+ viewModel.notifyUserActivity()
if (contentType != "LIVE") {
return@onPreviewKeyEvent false
}
if (showChannelListOverlay || showCategoryListOverlay || showEpgOverlay) {
return@onPreviewKeyEvent false
}
- if (showTrackSelection != null || showVariantSelection || showSpeedSelection || showProgramHistory || showSplitDialog || showEpisodePicker) {
+ if (showTrackSelection != null || showVariantSelection || showSpeedSelection || showAudioVideoOffsetDialog || showStopPlaybackTimerDialog || showIdleStandbyTimerDialog || showProgramHistory || showSplitDialog || showEpisodePicker) {
return@onPreviewKeyEvent false
}
if (showChannelInfoOverlay && channelInfoSubPanelOpen) {
@@ -538,7 +569,25 @@ fun PlayerScreen(
.onKeyEvent { event ->
// Only handle KeyDown to avoid double actions
if (event.nativeKeyEvent.action == KeyEvent.ACTION_DOWN) {
- if (showTrackSelection != null || showVariantSelection || showSpeedSelection) {
+ viewModel.notifyUserActivity()
+ if (showTrackSelection != null || showVariantSelection || showSpeedSelection || showAudioVideoOffsetDialog || showStopPlaybackTimerDialog || showIdleStandbyTimerDialog) {
+ if (showAudioVideoOffsetDialog) {
+ return@onKeyEvent when (event.nativeKeyEvent.keyCode) {
+ KeyEvent.KEYCODE_BACK -> {
+ showAudioVideoOffsetDialog = false
+ viewModel.dismissAudioVideoOffsetPreview()
+ true
+ }
+ KeyEvent.KEYCODE_DPAD_UP,
+ KeyEvent.KEYCODE_DPAD_DOWN,
+ KeyEvent.KEYCODE_DPAD_LEFT,
+ KeyEvent.KEYCODE_DPAD_RIGHT,
+ KeyEvent.KEYCODE_DPAD_CENTER,
+ KeyEvent.KEYCODE_ENTER,
+ KeyEvent.KEYCODE_NUMPAD_ENTER -> false
+ else -> true
+ }
+ }
if (showSpeedSelection) {
return@onKeyEvent when (event.nativeKeyEvent.keyCode) {
KeyEvent.KEYCODE_BACK -> {
@@ -573,6 +622,8 @@ fun PlayerScreen(
}
return@onKeyEvent when (event.nativeKeyEvent.keyCode) {
KeyEvent.KEYCODE_BACK -> {
+ showStopPlaybackTimerDialog = false
+ showIdleStandbyTimerDialog = false
showTrackSelection = null
true
}
@@ -771,7 +822,7 @@ fun PlayerScreen(
PlayerRenderView(
playerEngine = playerEngine,
resizeMode = aspectRatio.toPlayerSurfaceResizeMode(),
- surfaceType = PlayerRenderSurfaceType.SURFACE_VIEW,
+ surfaceType = renderSurfaceType,
modifier = Modifier.fillMaxSize()
)
@@ -882,6 +933,7 @@ fun PlayerScreen(
isMuted = isMuted,
playbackSpeed = playbackSpeed,
mediaTitle = mediaTitle,
+ sleepTimerUiState = sleepTimerUiState,
timeshiftUiState = timeshiftUiState,
playButtonFocusRequester = playButtonFocusRequester,
quickActionsFocusRequester = quickActionsFocusRequester,
@@ -902,6 +954,9 @@ fun PlayerScreen(
onOpenAudioTracks = { showTrackSelection = TrackType.AUDIO },
onOpenVideoTracks = { showTrackSelection = TrackType.VIDEO },
onOpenPlaybackSpeed = { showSpeedSelection = true },
+ onOpenStopPlaybackTimer = { showStopPlaybackTimerDialog = true },
+ onOpenIdleStandbyTimer = { showIdleStandbyTimerDialog = true },
+ onOpenAudioVideoSync = { showAudioVideoOffsetDialog = true },
showEpisodesAction = canOpenEpisodePicker,
onOpenEpisodes = { showEpisodePicker = true },
onOpenSplitScreen = { showSplitDialog = true },
@@ -915,7 +970,10 @@ fun PlayerScreen(
onSetScrubbingMode = viewModel::setScrubbingMode,
seekPreview = seekPreview,
onSeekPreviewPositionChanged = viewModel::updateSeekPreview,
- onUserInteraction = viewModel::refreshControlsAutoHide
+ onUserInteraction = {
+ viewModel.notifyUserActivity()
+ viewModel.refreshControlsAutoHide()
+ }
)
PlayerNumericInputOverlay(
@@ -941,7 +999,38 @@ fun PlayerScreen(
.align(Alignment.TopEnd)
.padding(32.dp)
)
-
+
+ if (!isInPictureInPictureMode) {
+ PlayerSleepTimerWarningOverlay(
+ state = sleepTimerUiState,
+ modifier = Modifier
+ .align(Alignment.TopCenter)
+ .padding(top = 88.dp),
+ onExtendStopTimer = { viewModel.extendStopPlaybackTimer() },
+ onDisableStopTimer = viewModel::disableStopPlaybackTimer,
+ onExtendIdleTimer = { viewModel.extendIdleStandbyTimer() },
+ onDisableIdleTimer = viewModel::disableIdleStandbyTimer
+ )
+ }
+
+ // Auto-Play Next Episode countdown overlay
+ val countdownSeconds = autoPlayCountdown
+ val countdownEpisode = nextEpisodeForAutoPlay
+ if (!isInPictureInPictureMode && countdownSeconds != null && countdownEpisode != null) {
+ Box(
+ modifier = Modifier
+ .align(Alignment.BottomEnd)
+ .padding(end = 32.dp, bottom = 32.dp)
+ ) {
+ NextEpisodeCountdownOverlay(
+ nextEpisode = countdownEpisode,
+ secondsRemaining = countdownSeconds,
+ onPlayNow = { viewModel.playNextEpisodeNow() },
+ onCancel = { viewModel.cancelAutoPlay() }
+ )
+ }
+ }
+
// Resume Prompt Dialog
if (!isInPictureInPictureMode && resumePrompt.show) {
PlayerResumePrompt(
@@ -975,6 +1064,42 @@ fun PlayerScreen(
onDismiss = { showSpeedSelection = false },
onSelectSpeed = viewModel::setPlaybackSpeed
)
+ PlayerSleepTimerDialog(
+ visible = showStopPlaybackTimerDialog,
+ title = stringResource(R.string.player_stop_playback_after),
+ selectedMinutes = sleepTimerUiState.stopTimerMinutes,
+ onDismiss = { showStopPlaybackTimerDialog = false },
+ onSelectMinutes = { minutes ->
+ viewModel.notifyUserActivity()
+ viewModel.setStopPlaybackTimer(minutes)
+ showStopPlaybackTimerDialog = false
+ }
+ )
+ PlayerSleepTimerDialog(
+ visible = showIdleStandbyTimerDialog,
+ title = stringResource(R.string.player_idle_standby_after),
+ selectedMinutes = sleepTimerUiState.idleTimerMinutes,
+ onDismiss = { showIdleStandbyTimerDialog = false },
+ onSelectMinutes = { minutes ->
+ viewModel.notifyUserActivity()
+ viewModel.setIdleStandbyTimer(minutes)
+ showIdleStandbyTimerDialog = false
+ }
+ )
+ PlayerAudioVideoOffsetDialog(
+ visible = showAudioVideoOffsetDialog && castConnectionState != CastConnectionState.CONNECTED,
+ state = audioVideoOffsetState,
+ canSaveChannel = currentChannel != null,
+ onDismiss = {
+ showAudioVideoOffsetDialog = false
+ viewModel.dismissAudioVideoOffsetPreview()
+ },
+ onAdjust = viewModel::adjustAudioVideoOffset,
+ onReset = viewModel::resetAudioVideoOffsetPreview,
+ onSaveForChannel = viewModel::saveAudioVideoOffsetForChannel,
+ onSaveAsGlobal = viewModel::saveAudioVideoOffsetAsGlobal,
+ onUseGlobal = viewModel::useGlobalAudioVideoOffset
+ )
PlayerEpisodeSelectionDialog(
visible = showEpisodePicker,
seriesTitle = currentSeries?.name ?: playbackTitle.ifBlank { title },
@@ -1125,6 +1250,7 @@ fun PlayerScreen(
onOpenAudioTracks = { showTrackSelection = TrackType.AUDIO },
onOpenVideoTracks = { showTrackSelection = TrackType.VIDEO },
onOpenVariants = { showVariantSelection = true },
+ onOpenAudioVideoSync = { showAudioVideoOffsetDialog = true },
onEnterPictureInPicture = enterPictureInPicture,
isCastConnected = castConnectionState == CastConnectionState.CONNECTED,
onCast = { viewModel.castCurrentMedia { mainActivity?.openCastRouteChooser() } },
@@ -1176,6 +1302,7 @@ private fun PlayerControlsOverlayHost(
isMuted: Boolean,
playbackSpeed: Float,
mediaTitle: String?,
+ sleepTimerUiState: SleepTimerUiState,
timeshiftUiState: PlayerTimeshiftUiState,
playButtonFocusRequester: FocusRequester,
quickActionsFocusRequester: FocusRequester,
@@ -1196,6 +1323,9 @@ private fun PlayerControlsOverlayHost(
onOpenAudioTracks: () -> Unit,
onOpenVideoTracks: () -> Unit,
onOpenPlaybackSpeed: () -> Unit,
+ onOpenStopPlaybackTimer: () -> Unit,
+ onOpenIdleStandbyTimer: () -> Unit,
+ onOpenAudioVideoSync: () -> Unit,
showEpisodesAction: Boolean,
onOpenEpisodes: () -> Unit,
onOpenSplitScreen: () -> Unit,
@@ -1233,6 +1363,7 @@ private fun PlayerControlsOverlayHost(
isMuted = isMuted,
playbackSpeed = playbackSpeed,
mediaTitle = mediaTitle,
+ sleepTimerUiState = sleepTimerUiState,
timeshiftUiState = timeshiftUiState,
playButtonFocusRequester = playButtonFocusRequester,
quickActionsFocusRequester = quickActionsFocusRequester,
@@ -1253,6 +1384,9 @@ private fun PlayerControlsOverlayHost(
onOpenAudioTracks = onOpenAudioTracks,
onOpenVideoTracks = onOpenVideoTracks,
onOpenPlaybackSpeed = onOpenPlaybackSpeed,
+ onOpenStopPlaybackTimer = onOpenStopPlaybackTimer,
+ onOpenIdleStandbyTimer = onOpenIdleStandbyTimer,
+ onOpenAudioVideoSync = onOpenAudioVideoSync,
showEpisodesAction = showEpisodesAction,
onOpenEpisodes = onOpenEpisodes,
onOpenSplitScreen = onOpenSplitScreen,
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt
index b29d81fa..ff5dde33 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt
@@ -48,6 +48,8 @@ import com.streamvault.domain.repository.MovieRepository
import com.streamvault.domain.repository.PlaybackHistoryRepository
import com.streamvault.domain.repository.SeriesRepository
import com.streamvault.player.Media3PlayerEngine
+import com.streamvault.player.AUDIO_VIDEO_OFFSET_MAX_MS
+import com.streamvault.player.AUDIO_VIDEO_OFFSET_MIN_MS
import com.streamvault.player.PlaybackState
import com.streamvault.player.PlayerEngine
import com.streamvault.player.PlayerError
@@ -94,7 +96,7 @@ class PlayerViewModel @Inject constructor(
private val xtreamStreamUrlResolver: XtreamStreamUrlResolver,
private val seekThumbnailProvider: SeekThumbnailProvider,
private val livePreviewHandoffManager: LivePreviewHandoffManager,
- private val okHttpClient: OkHttpClient
+ private val okHttpClient: OkHttpClient,
) : ViewModel() {
companion object {
private const val MUTE_TOGGLE_DEBOUNCE_MS = 250L
@@ -102,10 +104,13 @@ class PlayerViewModel @Inject constructor(
private const val MAX_UPCOMING_PROGRAM_ITEMS = 24
private const val PLAYER_EPG_REFRESH_INTERVAL_MS = 30_000L
private const val MIN_WATCHED_FOR_AUTO_PLAY_MS = 5_000L
+ private const val AUTO_PLAY_COUNTDOWN_SECONDS = 10
private const val TOKEN_RENEWAL_LEAD_MS = 60_000L
private const val TOKEN_RENEWAL_CHECK_INTERVAL_MS = 10_000L
private const val LOW_BANDWIDTH_THRESHOLD_BPS = 500_000L
private const val LOW_BANDWIDTH_DURATION_SECONDS = 30
+ private val PLAYBACK_TIMER_PRESETS_MINUTES = setOf(0, 15, 30, 45, 60, 90, 120)
+ private const val TIMER_TICK_MS = 1_000L
}
private val activePlayerEngineFlow = MutableStateFlow(mainPlayerEngine)
@@ -146,6 +151,9 @@ class PlayerViewModel @Inject constructor(
private val _nextEpisode = MutableStateFlow<Episode?>(null)
val nextEpisode: StateFlow<Episode?> = _nextEpisode.asStateFlow()
+ private val _autoPlayCountdown = MutableStateFlow<Int?>(null)
+ val autoPlayCountdown: StateFlow<Int?> = _autoPlayCountdown.asStateFlow()
+
internal val playbackTitleFlow = MutableStateFlow("")
val playbackTitle: StateFlow<String> = playbackTitleFlow.asStateFlow()
@@ -195,6 +203,9 @@ class PlayerViewModel @Inject constructor(
val playerNotice: StateFlow<PlayerNoticeState?> = _playerNotice.asStateFlow()
private val _playerDiagnostics = MutableStateFlow(PlayerDiagnosticsUiState())
val playerDiagnostics: StateFlow<PlayerDiagnosticsUiState> = _playerDiagnostics.asStateFlow()
+ private val audioVideoOffsetPreviewMs = MutableStateFlow<Int?>(null)
+ private val _audioVideoOffsetUiState = MutableStateFlow(PlayerAudioVideoOffsetUiState())
+ val audioVideoOffsetUiState: StateFlow<PlayerAudioVideoOffsetUiState> = _audioVideoOffsetUiState.asStateFlow()
private val _seekPreview = MutableStateFlow(SeekPreviewState())
val seekPreview: StateFlow<SeekPreviewState> = _seekPreview.asStateFlow()
private val _recordingItems = MutableStateFlow<List<RecordingItem>>(emptyList())
@@ -203,6 +214,10 @@ class PlayerViewModel @Inject constructor(
val currentChannelRecording: StateFlow<RecordingItem?> = currentChannelFlowRecording.asStateFlow()
private val _timeshiftUiState = MutableStateFlow(PlayerTimeshiftUiState())
val timeshiftUiState: StateFlow<PlayerTimeshiftUiState> = _timeshiftUiState.asStateFlow()
+ private val _sleepTimerUiState = MutableStateFlow(SleepTimerUiState())
+ val sleepTimerUiState: StateFlow<SleepTimerUiState> = _sleepTimerUiState.asStateFlow()
+ private val _sleepTimerExitEvent = MutableStateFlow(0)
+ val sleepTimerExitEvent: StateFlow<Int> = _sleepTimerExitEvent.asStateFlow()
internal var channelInfoHideJob: Job? = null
internal var liveOverlayHideJob: Job? = null
@@ -237,6 +252,8 @@ class PlayerViewModel @Inject constructor(
private var playerNoticeTimeoutMs: Long = 6_000L
internal var diagnosticsTimeoutMs: Long = 15_000L
private var preferredDecoderMode: DecoderMode = DecoderMode.AUTO
+ private var preferredSurfaceMode: com.streamvault.domain.model.PlayerSurfaceMode =
+ com.streamvault.domain.model.PlayerSurfaceMode.AUTO
private var timeshiftConfig: TimeshiftConfig = TimeshiftConfig()
// Zapping state
@@ -291,19 +308,34 @@ class PlayerViewModel @Inject constructor(
private var lowBandwidthMonitorJob: Job? = null
private var progressTrackingJob: Job? = null
private var tokenRenewalJob: Job? = null
+ private var stopPlaybackTimerJob: Job? = null
+ private var idleStandbyTimerJob: Job? = null
internal var zapOverlayJob: Job? = null
private var aspectRatioJob: Job? = null
internal var zapBufferWatchdogJob: Job? = null
+ private var autoPlayCountdownJob: Job? = null
internal var zapAutoRevertEnabled: Boolean = true
+ private var autoPlayNextEpisodeEnabled: Boolean = true
private var isAppInForeground: Boolean = true
private var shouldResumeAfterForeground: Boolean = false
private var seekPreviewRequestVersion: Long = 0L
private var lastMuteToggleAtMs: Long = 0L
+ private var stopPlaybackTimerEndsAtMs: Long = 0L
+ private var idleStandbyTimerEndsAtMs: Long = 0L
+ private var defaultStopPlaybackTimerMinutes: Int = 0
+ private var defaultIdleStandbyTimerMinutes: Int = 0
+ private var playbackTimerDefaultsApplied = false
+ private var sleepTimerExitEmitted = false
val castConnectionState: StateFlow<CastConnectionState> = castManager.connectionState
private fun setActivePlayerEngine(engine: PlayerEngine) {
if (activePlayerEngineFlow.value === engine) return
+ // Media3 session IDs must be globally unique. Release the outgoing engine's
+ // MediaSession before the incoming engine's session is created by the combine
+ // flow at the bottom of init. Mirrors the explicit release done in the forward
+ // handoff path (mainPlayerEngine.setMediaSessionEnabled(false)) for the reverse.
+ activePlayerEngineFlow.value.setMediaSessionEnabled(false)
activePlayerEngineFlow.value = engine
}
@@ -485,11 +517,70 @@ class PlayerViewModel @Inject constructor(
viewModelScope.launch {
preferencesRepository.zapAutoRevert.collect { zapAutoRevertEnabled = it }
}
+ viewModelScope.launch {
+ preferencesRepository.autoPlayNextEpisode.collect { autoPlayNextEpisodeEnabled = it }
+ }
+ viewModelScope.launch {
+ preferencesRepository.defaultStopPlaybackTimerMinutes.collect {
+ defaultStopPlaybackTimerMinutes = sanitizePlaybackTimerMinutes(it)
+ }
+ }
+ viewModelScope.launch {
+ preferencesRepository.defaultIdleStandbyTimerMinutes.collect {
+ defaultIdleStandbyTimerMinutes = sanitizePlaybackTimerMinutes(it)
+ }
+ }
viewModelScope.launch {
preferencesRepository.playerMediaSessionEnabled
.combine(activePlayerEngineFlow) { enabled, engine -> engine to enabled }
.collect { (engine, enabled) -> engine.setMediaSessionEnabled(enabled) }
}
+ viewModelScope.launch {
+ currentChannelFlow
+ .map { it?.id }
+ .distinctUntilChanged()
+ .collect { audioVideoOffsetPreviewMs.value = null }
+ }
+ viewModelScope.launch {
+ val channelOffsetFlow = currentChannelFlow
+ .map { it?.id?.takeIf { channelId -> channelId > 0L } }
+ .distinctUntilChanged()
+ .flatMapLatest { channelId ->
+ if (channelId == null) {
+ flowOf(null)
+ } else {
+ preferencesRepository.observeAudioVideoOffsetForChannel(channelId)
+ }
+ }
+
+ combine(
+ preferencesRepository.playerAudioVideoOffsetMs,
+ channelOffsetFlow,
+ audioVideoOffsetPreviewMs,
+ activePlayerEngineFlow
+ ) { globalOffset, channelOffset, previewOffset, engine ->
+ val effectiveOffset = (previewOffset ?: channelOffset ?: globalOffset)
+ .coerceIn(AUDIO_VIDEO_OFFSET_MIN_MS, AUDIO_VIDEO_OFFSET_MAX_MS)
+ AudioVideoOffsetSnapshot(
+ globalOffsetMs = globalOffset,
+ channelOverrideMs = channelOffset,
+ previewOffsetMs = previewOffset,
+ effectiveOffsetMs = effectiveOffset,
+ engine = engine
+ )
+ }.collect { snapshot ->
+ _audioVideoOffsetUiState.value = PlayerAudioVideoOffsetUiState(
+ globalOffsetMs = snapshot.globalOffsetMs,
+ channelOverrideMs = snapshot.channelOverrideMs,
+ previewOffsetMs = snapshot.previewOffsetMs,
+ effectiveOffsetMs = snapshot.effectiveOffsetMs
+ )
+ snapshot.engine.setAudioVideoOffsetMs(snapshot.effectiveOffsetMs)
+ _playerDiagnostics.update {
+ it.copy(audioVideoOffsetMs = snapshot.effectiveOffsetMs)
+ }
+ }
+ }
viewModelScope.launch {
combine(
preferencesRepository.playerTimeshiftEnabled,
@@ -523,10 +614,27 @@ class PlayerViewModel @Inject constructor(
}
}
}
+ viewModelScope.launch {
+ preferencesRepository.playerSurfaceMode
+ .combine(activePlayerEngineFlow) { mode, engine -> engine to mode }
+ .collect { (engine, mode) ->
+ preferredSurfaceMode = mode
+ engine.setSurfaceMode(mode)
+ }
+ }
viewModelScope.launch {
var consecutiveLowBandwidthSeconds = 0
var noticeShown = false
activePlayerEngineFlow.flatMapLatest { it.playerStats }.collect { stats ->
+ _playerDiagnostics.update {
+ it.copy(
+ activeDecoderName = stats.videoDecoderName,
+ activeDecoderPolicy = stats.activeDecoderPolicy,
+ renderSurfaceType = stats.renderSurfaceType,
+ videoStallCount = stats.videoStallCount,
+ lastVideoFrameAgoMs = stats.lastVideoFrameAgoMs
+ )
+ }
if (!playerEngine.isPlaying.value || currentContentType != ContentType.LIVE) {
consecutiveLowBandwidthSeconds = 0
noticeShown = false
@@ -859,7 +967,54 @@ class PlayerViewModel @Inject constructor(
}
}
+ fun previewAudioVideoOffset(offsetMs: Int) {
+ audioVideoOffsetPreviewMs.value = offsetMs.coerceIn(AUDIO_VIDEO_OFFSET_MIN_MS, AUDIO_VIDEO_OFFSET_MAX_MS)
+ }
+
+ fun adjustAudioVideoOffset(deltaMs: Int) {
+ val current = audioVideoOffsetPreviewMs.value ?: _audioVideoOffsetUiState.value.effectiveOffsetMs
+ previewAudioVideoOffset(current + deltaMs)
+ }
+
+ fun resetAudioVideoOffsetPreview() {
+ previewAudioVideoOffset(0)
+ }
+
+ fun dismissAudioVideoOffsetPreview() {
+ audioVideoOffsetPreviewMs.value = null
+ }
+
+ fun saveAudioVideoOffsetForChannel() {
+ val channelId = currentChannelFlow.value?.id?.takeIf { it > 0L } ?: return
+ val offsetMs = _audioVideoOffsetUiState.value.effectiveOffsetMs
+ viewModelScope.launch {
+ preferencesRepository.setAudioVideoOffsetForChannel(channelId, offsetMs)
+ audioVideoOffsetPreviewMs.value = null
+ }
+ }
+
+ fun saveAudioVideoOffsetAsGlobal() {
+ val offsetMs = _audioVideoOffsetUiState.value.effectiveOffsetMs
+ val channelId = currentChannelFlow.value?.id?.takeIf { it > 0L }
+ viewModelScope.launch {
+ preferencesRepository.setPlayerAudioVideoOffsetMs(offsetMs)
+ if (channelId != null) {
+ preferencesRepository.clearAudioVideoOffsetForChannel(channelId)
+ }
+ audioVideoOffsetPreviewMs.value = null
+ }
+ }
+
+ fun useGlobalAudioVideoOffset() {
+ val channelId = currentChannelFlow.value?.id?.takeIf { it > 0L } ?: return
+ viewModelScope.launch {
+ preferencesRepository.clearAudioVideoOffsetForChannel(channelId)
+ audioVideoOffsetPreviewMs.value = null
+ }
+ }
+
fun seekTo(positionMs: Long) {
+ notifyUserActivity()
playerEngine.seekTo(positionMs)
clearSeekPreview()
}
@@ -950,6 +1105,7 @@ class PlayerViewModel @Inject constructor(
_currentSeries.value = null
_currentEpisode.value = null
_nextEpisode.value = null
+ cancelAutoPlay()
}
private fun resolveEpisode(
@@ -978,45 +1134,45 @@ class PlayerViewModel @Inject constructor(
private fun buildEpisodePlaybackTitle(episode: Episode): String =
"${episode.title} - S${episode.seasonNumber}E${episode.episodeNumber}"
- private fun loadSeriesEpisodeContext(
+ private suspend fun loadSeriesEpisodeContext(
requestVersion: Long,
providerId: Long,
seriesId: Long,
episodeId: Long,
seasonNumber: Int?,
episodeNumber: Int?
- ) {
- viewModelScope.launch {
- when (val result = seriesRepository.getSeriesDetails(providerId, seriesId)) {
- is Result.Success -> {
- if (!isActivePlaybackSession(requestVersion)) return@launch
- val series = result.data.sanitizedForPlayer()
- val resolvedEpisode = resolveEpisode(series, episodeId, seasonNumber, episodeNumber)
- _currentSeries.value = series
- _currentEpisode.value = resolvedEpisode
- _nextEpisode.value = resolvedEpisode?.let { findNextEpisode(series, it) }
- currentSeriesId = seriesId
- currentSeasonNumber = resolvedEpisode?.seasonNumber ?: seasonNumber
- currentEpisodeNumber = resolvedEpisode?.episodeNumber ?: episodeNumber
- if (resolvedEpisode != null && currentContentType == ContentType.SERIES_EPISODE) {
- currentArtworkUrl = resolvedEpisode.coverUrl
- ?: currentArtworkUrl
- ?: series.posterUrl
- ?: series.backdropUrl
- currentTitle = buildEpisodePlaybackTitle(resolvedEpisode)
- playbackTitleFlow.value = currentTitle
- }
+ ): Episode? {
+ return when (val result = seriesRepository.getSeriesDetails(providerId, seriesId)) {
+ is Result.Success -> {
+ if (!isActivePlaybackSession(requestVersion)) return null
+ val series = result.data.sanitizedForPlayer()
+ val resolvedEpisode = resolveEpisode(series, episodeId, seasonNumber, episodeNumber)
+ _currentSeries.value = series
+ _currentEpisode.value = resolvedEpisode
+ _nextEpisode.value = resolvedEpisode?.let { findNextEpisode(series, it) }
+ currentSeriesId = seriesId
+ currentSeasonNumber = resolvedEpisode?.seasonNumber ?: seasonNumber
+ currentEpisodeNumber = resolvedEpisode?.episodeNumber ?: episodeNumber
+ if (resolvedEpisode != null && currentContentType == ContentType.SERIES_EPISODE) {
+ currentArtworkUrl = resolvedEpisode.coverUrl
+ ?: currentArtworkUrl
+ ?: series.posterUrl
+ ?: series.backdropUrl
+ currentTitle = buildEpisodePlaybackTitle(resolvedEpisode)
+ playbackTitleFlow.value = currentTitle
}
+ resolvedEpisode
+ }
- else -> {
- if (!isActivePlaybackSession(requestVersion)) return@launch
- _currentSeries.value = null
- _currentEpisode.value = null
- _nextEpisode.value = null
- currentSeriesId = seriesId
- currentSeasonNumber = seasonNumber
- currentEpisodeNumber = episodeNumber
- }
+ else -> {
+ if (!isActivePlaybackSession(requestVersion)) return null
+ _currentSeries.value = null
+ _currentEpisode.value = null
+ _nextEpisode.value = null
+ currentSeriesId = seriesId
+ currentSeasonNumber = seasonNumber
+ currentEpisodeNumber = episodeNumber
+ null
}
}
}
@@ -1066,14 +1222,39 @@ class PlayerViewModel @Inject constructor(
val position = playerEngine.currentPosition.value
val duration = playerEngine.duration.value
if (position > MIN_WATCHED_FOR_AUTO_PLAY_MS || duration > 0L) {
- _nextEpisode.value?.let { episode ->
- playEpisode(episode, showResumePrompt = false)
+ val next = _nextEpisode.value ?: return@launch
+ if (autoPlayNextEpisodeEnabled) {
+ startAutoPlayCountdown(next)
}
}
}
}
}
+ private fun startAutoPlayCountdown(episode: Episode) {
+ autoPlayCountdownJob?.cancel()
+ autoPlayCountdownJob = viewModelScope.launch {
+ for (remaining in AUTO_PLAY_COUNTDOWN_SECONDS downTo 1) {
+ _autoPlayCountdown.value = remaining
+ delay(1_000L)
+ }
+ _autoPlayCountdown.value = null
+ playEpisode(episode, showResumePrompt = false)
+ }
+ }
+
+ fun cancelAutoPlay() {
+ autoPlayCountdownJob?.cancel()
+ autoPlayCountdownJob = null
+ _autoPlayCountdown.value = null
+ }
+
+ fun playNextEpisodeNow() {
+ val episode = _nextEpisode.value ?: return
+ cancelAutoPlay()
+ playEpisode(episode, showResumePrompt = false)
+ }
+
private fun currentPlaybackIdentityUrl(): String =
currentResolvedPlaybackUrl.ifBlank { currentStreamUrl }
@@ -1135,6 +1316,8 @@ class PlayerViewModel @Inject constructor(
wifiMaxHeight = preferencesRepository.playerWifiMaxVideoHeight.first(),
ethernetMaxHeight = preferencesRepository.playerEthernetMaxVideoHeight.first()
)
+ playerEngine.setSurfaceMode(preferencesRepository.playerSurfaceMode.first())
+ playerEngine.setAudioVideoOffsetMs(_audioVideoOffsetUiState.value.effectiveOffsetMs)
}
private suspend fun tryAdoptPreviewHandoff(
@@ -1336,6 +1519,7 @@ class PlayerViewModel @Inject constructor(
currentSeasonNumber = seasonNumber
currentEpisodeNumber = episodeNumber
currentStreamClassLabel = if (hasArchiveRequest) "Catch-up" else "Primary"
+ applyDefaultPlaybackTimersIfNeeded()
if (currentContentType == ContentType.LIVE && currentCombinedProfileId != null) {
val activeCombinedProfileId = currentCombinedProfileId
viewModelScope.launch {
@@ -1351,16 +1535,7 @@ class PlayerViewModel @Inject constructor(
if (!hasArchiveRequest) {
pendingCatchUpUrls = emptyList()
}
- if (currentContentType == ContentType.SERIES_EPISODE && providerId > 0 && currentSeriesId != null) {
- loadSeriesEpisodeContext(
- requestVersion = requestVersion,
- providerId = providerId,
- seriesId = currentSeriesId ?: -1L,
- episodeId = internalChannelId,
- seasonNumber = seasonNumber,
- episodeNumber = episodeNumber
- )
- } else {
+ if (currentContentType != ContentType.SERIES_EPISODE || providerId <= 0 || currentSeriesId == null) {
clearSeriesEpisodeContext()
}
if (currentContentType != ContentType.LIVE) {
@@ -1373,6 +1548,7 @@ class PlayerViewModel @Inject constructor(
}
hasRetriedWithSoftwareDecoder = false
playerEngine.setDecoderMode(preferredDecoderMode)
+ playerEngine.setSurfaceMode(preferredSurfaceMode)
updateDecoderMode(preferredDecoderMode)
updateStreamClass(currentStreamClassLabel)
@@ -1387,13 +1563,40 @@ class PlayerViewModel @Inject constructor(
if (tryAdoptPreviewHandoff(requestVersion, internalChannelId, providerId)) {
return@launch
}
- val streamInfo = resolvePlaybackStreamInfo(streamUrl, internalChannelId, providerId, currentContentType)
+ var playbackLogicalUrl = streamUrl
+ var playbackContentId = internalChannelId
+ if (currentContentType == ContentType.SERIES_EPISODE && providerId > 0 && currentSeriesId != null) {
+ val resolvedEpisode = loadSeriesEpisodeContext(
+ requestVersion = requestVersion,
+ providerId = providerId,
+ seriesId = currentSeriesId ?: -1L,
+ episodeId = internalChannelId,
+ seasonNumber = seasonNumber,
+ episodeNumber = episodeNumber
+ )
+ if (!isActivePlaybackSession(requestVersion, streamUrl)) return@launch
+ resolvedEpisode?.streamUrl
+ ?.takeIf { it.isNotBlank() }
+ ?.let { refreshedUrl -> playbackLogicalUrl = refreshedUrl }
+ resolvedEpisode?.id
+ ?.takeIf { it > 0L }
+ ?.let { resolvedId -> playbackContentId = resolvedId }
+ }
+ val streamInfo = resolvePlaybackStreamInfo(
+ playbackLogicalUrl,
+ playbackContentId,
+ providerId,
+ currentContentType
+ )
if (!isActivePlaybackSession(requestVersion, streamUrl)) return@launch
if (streamInfo == null) {
if (!isActivePlaybackSession(requestVersion, streamUrl)) return@launch
showPlayerNotice(message = "No playable stream URL was available.", recoveryType = PlayerRecoveryType.SOURCE)
return@launch
}
+ currentStreamUrl = playbackLogicalUrl
+ currentContentId = playbackContentId
+ if (!isActivePlaybackSession(requestVersion, playbackLogicalUrl)) return@launch
if (!preparePlayer(streamInfo, requestVersion)) return@launch
// Check for resume position after the player is fully prepared (VOD only).
@@ -1401,7 +1604,7 @@ class PlayerViewModel @Inject constructor(
// not a stale one that may have already been replaced by prepareInternal().
if (showResumePrompt && currentContentType != ContentType.LIVE && currentContentId != -1L && currentProviderId != -1L) {
val history = playbackHistoryRepository.getPlaybackHistory(currentContentId, currentContentType, currentProviderId)
- if (isActivePlaybackSession(requestVersion, streamUrl)) {
+ if (isActivePlaybackSession(requestVersion, playbackLogicalUrl)) {
if (history != null && history.resumePositionMs > 5000L && !isPlaybackComplete(history.resumePositionMs, history.totalDurationMs)) {
playerEngine.pause()
_resumePrompt.value = ResumePromptState(
@@ -1644,6 +1847,7 @@ class PlayerViewModel @Inject constructor(
}
}
playerEngine.stopLiveTimeshift()
+ clearPlaybackTimers()
}
fun handOffPlaybackToMultiView() {
@@ -2476,6 +2680,7 @@ class PlayerViewModel @Inject constructor(
}
fun play() {
+ notifyUserActivity()
if (currentContentType == ContentType.LIVE &&
timeshiftConfig.enabled &&
timeshiftUiState.value.engineState.status == LiveTimeshiftStatus.PAUSED_BEHIND_LIVE
@@ -2487,6 +2692,7 @@ class PlayerViewModel @Inject constructor(
}
fun pause() {
+ notifyUserActivity()
if (currentContentType == ContentType.LIVE && timeshiftConfig.enabled) {
playerEngine.pauseTimeshift()
} else {
@@ -2494,9 +2700,180 @@ class PlayerViewModel @Inject constructor(
}
}
- fun seekForward() = playerEngine.seekForward()
- fun seekBackward() = playerEngine.seekBackward()
- fun seekToLiveEdge() = playerEngine.seekToLiveEdge()
+ fun setStopPlaybackTimer(minutes: Int) {
+ val normalized = sanitizePlaybackTimerMinutes(minutes)
+ if (normalized == 0) {
+ disableStopPlaybackTimer()
+ return
+ }
+ stopPlaybackTimerEndsAtMs = SystemClock.elapsedRealtime() + normalized * 60_000L
+ sleepTimerExitEmitted = false
+ updateSleepTimerState(stopMinutes = normalized)
+ startStopPlaybackTimerJob(normalized)
+ showPlayerNotice(message = "Playback will stop in ${formatTimerMinutesNotice(normalized)}.")
+ }
+
+ fun setIdleStandbyTimer(minutes: Int) {
+ val normalized = sanitizePlaybackTimerMinutes(minutes)
+ if (normalized == 0) {
+ disableIdleStandbyTimer()
+ return
+ }
+ idleStandbyTimerEndsAtMs = SystemClock.elapsedRealtime() + normalized * 60_000L
+ sleepTimerExitEmitted = false
+ updateSleepTimerState(idleMinutes = normalized)
+ startIdleStandbyTimerJob(normalized)
+ showPlayerNotice(message = "Idle standby will be allowed after ${formatTimerMinutesNotice(normalized)} without activity.")
+ }
+
+ fun extendStopPlaybackTimer(minutes: Int = 30) {
+ val current = _sleepTimerUiState.value
+ if (!current.stopTimerActive) return
+ stopPlaybackTimerEndsAtMs += minutes * 60_000L
+ sleepTimerExitEmitted = false
+ updateSleepTimerState(stopMinutes = current.stopTimerMinutes)
+ }
+
+ fun extendIdleStandbyTimer(minutes: Int = 30) {
+ val current = _sleepTimerUiState.value
+ if (!current.idleTimerActive) return
+ idleStandbyTimerEndsAtMs += minutes * 60_000L
+ sleepTimerExitEmitted = false
+ updateSleepTimerState(idleMinutes = current.idleTimerMinutes)
+ }
+
+ fun disableStopPlaybackTimer() {
+ stopPlaybackTimerJob?.cancel()
+ stopPlaybackTimerJob = null
+ stopPlaybackTimerEndsAtMs = 0L
+ _sleepTimerUiState.update { it.copy(stopTimerMinutes = 0, stopRemainingMs = 0L) }
+ }
+
+ fun disableIdleStandbyTimer() {
+ idleStandbyTimerJob?.cancel()
+ idleStandbyTimerJob = null
+ idleStandbyTimerEndsAtMs = 0L
+ _sleepTimerUiState.update { it.copy(idleTimerMinutes = 0, idleRemainingMs = 0L) }
+ }
+
+ fun notifyUserActivity() {
+ val current = _sleepTimerUiState.value
+ if (!current.idleTimerActive) return
+ idleStandbyTimerEndsAtMs = SystemClock.elapsedRealtime() + current.idleTimerMinutes * 60_000L
+ updateSleepTimerState(idleMinutes = current.idleTimerMinutes)
+ }
+
+ fun consumeSleepTimerExitEvent() {
+ _sleepTimerExitEvent.value = 0
+ }
+
+ private fun applyDefaultPlaybackTimersIfNeeded() {
+ if (playbackTimerDefaultsApplied) return
+ playbackTimerDefaultsApplied = true
+ sleepTimerExitEmitted = false
+ viewModelScope.launch {
+ val stopMinutes = sanitizePlaybackTimerMinutes(preferencesRepository.defaultStopPlaybackTimerMinutes.first())
+ val idleMinutes = sanitizePlaybackTimerMinutes(preferencesRepository.defaultIdleStandbyTimerMinutes.first())
+ if (!playbackTimerDefaultsApplied || _sleepTimerUiState.value.stopTimerActive || _sleepTimerUiState.value.idleTimerActive) {
+ return@launch
+ }
+ if (stopMinutes > 0) {
+ setStopPlaybackTimer(stopMinutes)
+ }
+ if (idleMinutes > 0) {
+ setIdleStandbyTimer(idleMinutes)
+ }
+ }
+ }
+
+ private fun startStopPlaybackTimerJob(minutes: Int) {
+ stopPlaybackTimerJob?.cancel()
+ stopPlaybackTimerJob = viewModelScope.launch {
+ while (true) {
+ val remainingMs = updateSleepTimerState(stopMinutes = minutes).stopRemainingMs
+ if (remainingMs <= 0L) {
+ expirePlaybackTimer()
+ return@launch
+ }
+ delay(TIMER_TICK_MS)
+ }
+ }
+ }
+
+ private fun startIdleStandbyTimerJob(minutes: Int) {
+ idleStandbyTimerJob?.cancel()
+ idleStandbyTimerJob = viewModelScope.launch {
+ while (true) {
+ val remainingMs = updateSleepTimerState(idleMinutes = minutes).idleRemainingMs
+ if (remainingMs <= 0L) {
+ expirePlaybackTimer()
+ return@launch
+ }
+ delay(TIMER_TICK_MS)
+ }
+ }
+ }
+
+ private fun updateSleepTimerState(
+ stopMinutes: Int = _sleepTimerUiState.value.stopTimerMinutes,
+ idleMinutes: Int = _sleepTimerUiState.value.idleTimerMinutes
+ ): SleepTimerUiState {
+ val now = SystemClock.elapsedRealtime()
+ val next = _sleepTimerUiState.value.copy(
+ stopTimerMinutes = stopMinutes,
+ stopRemainingMs = if (stopPlaybackTimerEndsAtMs > 0L) (stopPlaybackTimerEndsAtMs - now).coerceAtLeast(0L) else 0L,
+ idleTimerMinutes = idleMinutes,
+ idleRemainingMs = if (idleStandbyTimerEndsAtMs > 0L) (idleStandbyTimerEndsAtMs - now).coerceAtLeast(0L) else 0L
+ )
+ _sleepTimerUiState.value = next
+ return next
+ }
+
+ private fun expirePlaybackTimer() {
+ if (sleepTimerExitEmitted) return
+ sleepTimerExitEmitted = true
+ stopPlaybackTimerJob?.cancel()
+ idleStandbyTimerJob?.cancel()
+ stopPlaybackTimerJob = null
+ idleStandbyTimerJob = null
+ stopPlaybackTimerEndsAtMs = 0L
+ idleStandbyTimerEndsAtMs = 0L
+ _sleepTimerUiState.value = SleepTimerUiState()
+ _sleepTimerExitEvent.value += 1
+ }
+
+ private fun clearPlaybackTimers() {
+ stopPlaybackTimerJob?.cancel()
+ idleStandbyTimerJob?.cancel()
+ stopPlaybackTimerJob = null
+ idleStandbyTimerJob = null
+ stopPlaybackTimerEndsAtMs = 0L
+ idleStandbyTimerEndsAtMs = 0L
+ playbackTimerDefaultsApplied = false
+ sleepTimerExitEmitted = false
+ _sleepTimerUiState.value = SleepTimerUiState()
+ }
+
+ private fun sanitizePlaybackTimerMinutes(minutes: Int): Int =
+ minutes.takeIf { it in PLAYBACK_TIMER_PRESETS_MINUTES } ?: 0
+
+ private fun formatTimerMinutesNotice(minutes: Int): String =
+ if (minutes == 1) "1 minute" else "$minutes minutes"
+
+ fun seekForward() {
+ notifyUserActivity()
+ playerEngine.seekForward()
+ }
+
+ fun seekBackward() {
+ notifyUserActivity()
+ playerEngine.seekBackward()
+ }
+
+ fun seekToLiveEdge() {
+ notifyUserActivity()
+ playerEngine.seekToLiveEdge()
+ }
fun playEpisode(episode: Episode, showResumePrompt: Boolean = true) {
prepare(
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModelModels.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModelModels.kt
index 397f5376..fa661a16 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModelModels.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModelModels.kt
@@ -41,8 +41,14 @@ data class PlayerDiagnosticsUiState(
val providerName: String = "",
val providerSourceLabel: String = "",
val decoderMode: DecoderMode = DecoderMode.AUTO,
+ val activeDecoderName: String = "Unknown",
+ val activeDecoderPolicy: String = "AUTO",
+ val renderSurfaceType: String = "SURFACE_VIEW",
+ val videoStallCount: Int = 0,
+ val lastVideoFrameAgoMs: Long = 0,
val streamClassLabel: String = "Primary",
val playbackStateLabel: String = "Idle",
+ val audioVideoOffsetMs: Int = 0,
val alternativeStreamCount: Int = 0,
val channelErrorCount: Int = 0,
val archiveSupportLabel: String = "",
@@ -51,6 +57,16 @@ data class PlayerDiagnosticsUiState(
val troubleshootingHints: List<String> = emptyList()
)
+data class PlayerAudioVideoOffsetUiState(
+ val globalOffsetMs: Int = 0,
+ val channelOverrideMs: Int? = null,
+ val previewOffsetMs: Int? = null,
+ val effectiveOffsetMs: Int = 0
+) {
+ val hasChannelOverride: Boolean
+ get() = channelOverrideMs != null
+}
+
data class PlayerTimeshiftUiState(
val available: Boolean = false,
val enabledForSession: Boolean = false,
@@ -62,6 +78,25 @@ data class PlayerTimeshiftUiState(
val engineState: LiveTimeshiftState = LiveTimeshiftState()
)
+data class SleepTimerUiState(
+ val stopTimerMinutes: Int = 0,
+ val stopRemainingMs: Long = 0L,
+ val idleTimerMinutes: Int = 0,
+ val idleRemainingMs: Long = 0L
+) {
+ val stopTimerActive: Boolean
+ get() = stopTimerMinutes > 0 && stopRemainingMs > 0L
+
+ val idleTimerActive: Boolean
+ get() = idleTimerMinutes > 0 && idleRemainingMs > 0L
+
+ val stopTimerWarningVisible: Boolean
+ get() = stopTimerActive && stopRemainingMs <= 60_000L
+
+ val idleTimerWarningVisible: Boolean
+ get() = idleTimerActive && idleRemainingMs <= 60_000L
+}
+
enum class PlayerRecoveryType {
NETWORK,
SOURCE,
@@ -92,6 +127,14 @@ internal data class EpgRequestKey(
val streamId: Long
)
+internal data class AudioVideoOffsetSnapshot(
+ val globalOffsetMs: Int,
+ val channelOverrideMs: Int?,
+ val previewOffsetMs: Int?,
+ val effectiveOffsetMs: Int,
+ val engine: com.streamvault.player.PlayerEngine
+)
+
internal data class PlayerUiTimeouts(
val controlsMs: Long,
val liveOverlayMs: Long,
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/overlay/PlayerControlsChrome.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/overlay/PlayerControlsChrome.kt
index 2d25faa9..1e02cd96 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/player/overlay/PlayerControlsChrome.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/overlay/PlayerControlsChrome.kt
@@ -70,6 +70,9 @@ import com.streamvault.app.ui.components.rememberCrossfadeImageModel
import com.streamvault.app.ui.screens.player.NumericChannelInputState
import com.streamvault.app.ui.screens.player.PlayerTimeshiftUiState
import com.streamvault.app.ui.screens.player.SeekPreviewState
+import com.streamvault.app.ui.screens.player.SleepTimerUiState
+import com.streamvault.app.ui.time.LocalAppTimeFormat
+import com.streamvault.app.ui.time.createTimeFormat
import com.streamvault.app.ui.theme.ErrorColor
import com.streamvault.app.ui.theme.Primary
import com.streamvault.domain.model.Program
@@ -78,7 +81,6 @@ import coil3.compose.AsyncImage
import kotlinx.coroutines.delay
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
-import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import com.streamvault.app.ui.interaction.TvClickableSurface
@@ -110,6 +112,7 @@ fun PlayerControlsOverlay(
isMuted: Boolean,
playbackSpeed: Float = 1f,
mediaTitle: String?,
+ sleepTimerUiState: SleepTimerUiState = SleepTimerUiState(),
timeshiftUiState: PlayerTimeshiftUiState = PlayerTimeshiftUiState(),
playButtonFocusRequester: FocusRequester,
quickActionsFocusRequester: FocusRequester = FocusRequester(),
@@ -129,6 +132,9 @@ fun PlayerControlsOverlay(
onOpenAudioTracks: () -> Unit,
onOpenVideoTracks: () -> Unit,
onOpenPlaybackSpeed: () -> Unit = {},
+ onOpenStopPlaybackTimer: () -> Unit = {},
+ onOpenIdleStandbyTimer: () -> Unit = {},
+ onOpenAudioVideoSync: () -> Unit = {},
showEpisodesAction: Boolean = false,
onOpenEpisodes: () -> Unit = {},
onOpenSplitScreen: () -> Unit,
@@ -195,6 +201,7 @@ fun PlayerControlsOverlay(
isMuted = isMuted,
playbackSpeed = playbackSpeed,
mediaTitle = mediaTitle,
+ sleepTimerUiState = sleepTimerUiState,
timeshiftUiState = timeshiftUiState,
playButtonFocusRequester = playButtonFocusRequester,
quickActionsFocusRequester = quickActionsFocusRequester,
@@ -211,6 +218,9 @@ fun PlayerControlsOverlay(
onOpenAudioTracks = onOpenAudioTracks,
onOpenVideoTracks = onOpenVideoTracks,
onOpenPlaybackSpeed = onOpenPlaybackSpeed,
+ onOpenStopPlaybackTimer = onOpenStopPlaybackTimer,
+ onOpenIdleStandbyTimer = onOpenIdleStandbyTimer,
+ onOpenAudioVideoSync = onOpenAudioVideoSync,
showEpisodesAction = showEpisodesAction,
onOpenEpisodes = onOpenEpisodes,
onOpenSplitScreen = onOpenSplitScreen,
@@ -398,6 +408,8 @@ private fun PlayerTopBar(
) {
val screenWidth = LocalConfiguration.current.screenWidthDp.dp
val isTelevisionDevice = rememberIsTelevisionDevice()
+ val appTimeFormat = LocalAppTimeFormat.current
+ val timeFormat = remember(appTimeFormat) { appTimeFormat.createTimeFormat() }
val topBarHeight = when {
screenWidth < 700.dp -> 100.dp
!isTelevisionDevice && screenWidth < 1280.dp -> 116.dp
@@ -458,16 +470,16 @@ private fun PlayerTopBar(
}
Row(verticalAlignment = Alignment.CenterVertically) {
- val currentTime = remember(clockLabelOverride) {
+ val currentTime = remember(clockLabelOverride, timeFormat) {
mutableStateOf(
- clockLabelOverride ?: SimpleDateFormat("HH:mm", Locale.getDefault()).format(Date())
+ clockLabelOverride ?: timeFormat.format(Date())
)
}
- LaunchedEffect(clockLabelOverride) {
+ LaunchedEffect(clockLabelOverride, timeFormat) {
if (clockLabelOverride == null) {
while (true) {
+ currentTime.value = timeFormat.format(Date())
delay(10_000)
- currentTime.value = SimpleDateFormat("HH:mm", Locale.getDefault()).format(Date())
}
} else {
currentTime.value = clockLabelOverride
@@ -518,6 +530,7 @@ private fun PlayerBottomBar(
isMuted: Boolean,
playbackSpeed: Float,
mediaTitle: String?,
+ sleepTimerUiState: SleepTimerUiState,
timeshiftUiState: PlayerTimeshiftUiState,
playButtonFocusRequester: FocusRequester,
quickActionsFocusRequester: FocusRequester,
@@ -533,6 +546,9 @@ private fun PlayerBottomBar(
onOpenAudioTracks: () -> Unit,
onOpenVideoTracks: () -> Unit,
onOpenPlaybackSpeed: () -> Unit,
+ onOpenStopPlaybackTimer: () -> Unit,
+ onOpenIdleStandbyTimer: () -> Unit,
+ onOpenAudioVideoSync: () -> Unit,
showEpisodesAction: Boolean,
onOpenEpisodes: () -> Unit,
onOpenSplitScreen: () -> Unit,
@@ -604,6 +620,7 @@ private fun PlayerBottomBar(
currentRecordingStatus = currentRecordingStatus,
isMuted = isMuted,
mediaTitle = mediaTitle,
+ sleepTimerUiState = sleepTimerUiState,
timeshiftUiState = timeshiftUiState,
playButtonFocusRequester = playButtonFocusRequester,
quickActionsFocusRequester = quickActionsFocusRequester,
@@ -618,6 +635,9 @@ private fun PlayerBottomBar(
onOpenSubtitleTracks = onOpenSubtitleTracks,
onOpenAudioTracks = onOpenAudioTracks,
onOpenVideoTracks = onOpenVideoTracks,
+ onOpenStopPlaybackTimer = onOpenStopPlaybackTimer,
+ onOpenIdleStandbyTimer = onOpenIdleStandbyTimer,
+ onOpenAudioVideoSync = onOpenAudioVideoSync,
onOpenSplitScreen = onOpenSplitScreen,
onEnterPictureInPicture = onEnterPictureInPicture,
onToggleMute = onToggleMute,
@@ -646,6 +666,7 @@ private fun PlayerBottomBar(
videoQualityCount = videoQualityCount,
isMuted = isMuted,
playbackSpeed = playbackSpeed,
+ sleepTimerUiState = sleepTimerUiState,
playButtonFocusRequester = playButtonFocusRequester,
quickActionsFocusRequester = quickActionsFocusRequester,
onSeekToPosition = onSeekToPosition,
@@ -655,6 +676,9 @@ private fun PlayerBottomBar(
onOpenAudioTracks = onOpenAudioTracks,
onOpenVideoTracks = onOpenVideoTracks,
onOpenPlaybackSpeed = onOpenPlaybackSpeed,
+ onOpenStopPlaybackTimer = onOpenStopPlaybackTimer,
+ onOpenIdleStandbyTimer = onOpenIdleStandbyTimer,
+ onOpenAudioVideoSync = onOpenAudioVideoSync,
showEpisodesAction = showEpisodesAction,
onOpenEpisodes = onOpenEpisodes,
onEnterPictureInPicture = onEnterPictureInPicture,
@@ -686,6 +710,7 @@ private fun PlayerLiveInfo(
currentRecordingStatus: RecordingStatus?,
isMuted: Boolean,
mediaTitle: String?,
+ sleepTimerUiState: SleepTimerUiState,
timeshiftUiState: PlayerTimeshiftUiState,
playButtonFocusRequester: FocusRequester,
quickActionsFocusRequester: FocusRequester,
@@ -700,6 +725,9 @@ private fun PlayerLiveInfo(
onOpenSubtitleTracks: () -> Unit,
onOpenAudioTracks: () -> Unit,
onOpenVideoTracks: () -> Unit,
+ onOpenStopPlaybackTimer: () -> Unit,
+ onOpenIdleStandbyTimer: () -> Unit,
+ onOpenAudioVideoSync: () -> Unit,
onOpenSplitScreen: () -> Unit,
onEnterPictureInPicture: () -> Unit,
onToggleMute: () -> Unit,
@@ -715,6 +743,8 @@ private fun PlayerLiveInfo(
onSetScrubbingMode: (Boolean) -> Unit
) {
val showTimeshiftControls = timeshiftUiState.available && !isCastConnected
+ val appTimeFormat = LocalAppTimeFormat.current
+ val timeFormat = remember(appTimeFormat) { appTimeFormat.createTimeFormat() }
val primaryActions = buildList {
if (showTimeshiftControls) {
add(PlayerActionSpec(stringResource(R.string.player_jump_to_live), onSeekToLiveEdge))
@@ -727,6 +757,28 @@ private fun PlayerLiveInfo(
stringResource(if (isCastConnected) R.string.player_stop_casting else R.string.player_cast),
if (isCastConnected) onStopCasting else onCast
))
+ add(PlayerActionSpec(
+ sleepTimerActionLabel(
+ title = stringResource(R.string.player_stop_playback_after),
+ activeLabel = stringResource(
+ R.string.player_stop_timer_status,
+ formatTimerRemaining(sleepTimerUiState.stopRemainingMs)
+ ),
+ active = sleepTimerUiState.stopTimerActive
+ ),
+ onOpenStopPlaybackTimer
+ ))
+ add(PlayerActionSpec(
+ sleepTimerActionLabel(
+ title = stringResource(R.string.player_idle_standby_after),
+ activeLabel = stringResource(
+ R.string.player_idle_timer_status,
+ formatTimerRemaining(sleepTimerUiState.idleRemainingMs)
+ ),
+ active = sleepTimerUiState.idleTimerActive
+ ),
+ onOpenIdleStandbyTimer
+ ))
add(PlayerActionSpec(stringResource(R.string.player_picture_in_picture), onEnterPictureInPicture))
if (currentProgram?.hasArchive == true) {
add(PlayerActionSpec(stringResource(R.string.player_restart), onRestartProgram))
@@ -752,6 +804,9 @@ private fun PlayerLiveInfo(
if (videoQualityCount > 0) {
add(PlayerActionSpec(stringResource(R.string.player_video_quality), onOpenVideoTracks))
}
+ if (!isCastConnected) {
+ add(PlayerActionSpec(stringResource(R.string.player_av_sync_short), onOpenAudioVideoSync))
+ }
add(PlayerActionSpec(stringResource(R.string.multiview_nav), onOpenSplitScreen))
}
@@ -781,6 +836,12 @@ private fun PlayerLiveInfo(
if (isMuted) {
PlayerMetaPill(text = stringResource(R.string.player_muted_badge))
}
+ if (sleepTimerUiState.stopTimerActive) {
+ PlayerMetaPill(text = stringResource(R.string.player_stop_timer_status, formatTimerRemaining(sleepTimerUiState.stopRemainingMs)))
+ }
+ if (sleepTimerUiState.idleTimerActive) {
+ PlayerMetaPill(text = stringResource(R.string.player_idle_timer_status, formatTimerRemaining(sleepTimerUiState.idleRemainingMs)))
+ }
if (showTimeshiftControls) {
PlayerMetaPill(
text = if (timeshiftUiState.bufferedBehindLiveMs > 1_000L) {
@@ -853,12 +914,12 @@ private fun PlayerLiveInfo(
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
- text = SimpleDateFormat("HH:mm", Locale.getDefault()).format(Date(start)),
+ text = timeFormat.format(Date(start)),
style = MaterialTheme.typography.labelSmall,
color = Color.White.copy(alpha = 0.5f)
)
Text(
- text = SimpleDateFormat("HH:mm", Locale.getDefault()).format(Date(end)),
+ text = timeFormat.format(Date(end)),
style = MaterialTheme.typography.labelSmall,
color = Color.White.copy(alpha = 0.5f)
)
@@ -893,6 +954,7 @@ private fun PlayerVodInfo(
videoQualityCount: Int,
isMuted: Boolean,
playbackSpeed: Float,
+ sleepTimerUiState: SleepTimerUiState,
playButtonFocusRequester: FocusRequester,
quickActionsFocusRequester: FocusRequester,
onSeekToPosition: (Long) -> Unit,
@@ -902,6 +964,9 @@ private fun PlayerVodInfo(
onOpenAudioTracks: () -> Unit,
onOpenVideoTracks: () -> Unit,
onOpenPlaybackSpeed: () -> Unit,
+ onOpenStopPlaybackTimer: () -> Unit,
+ onOpenIdleStandbyTimer: () -> Unit,
+ onOpenAudioVideoSync: () -> Unit,
showEpisodesAction: Boolean,
onOpenEpisodes: () -> Unit,
onEnterPictureInPicture: () -> Unit,
@@ -974,6 +1039,31 @@ private fun PlayerVodInfo(
onOpenPlaybackSpeed
)
)
+ if (!isCastConnected) {
+ add(PlayerActionSpec(stringResource(R.string.player_av_sync_short), onOpenAudioVideoSync))
+ }
+ add(PlayerActionSpec(
+ sleepTimerActionLabel(
+ title = stringResource(R.string.player_stop_playback_after),
+ activeLabel = stringResource(
+ R.string.player_stop_timer_status,
+ formatTimerRemaining(sleepTimerUiState.stopRemainingMs)
+ ),
+ active = sleepTimerUiState.stopTimerActive
+ ),
+ onOpenStopPlaybackTimer
+ ))
+ add(PlayerActionSpec(
+ sleepTimerActionLabel(
+ title = stringResource(R.string.player_idle_standby_after),
+ activeLabel = stringResource(
+ R.string.player_idle_timer_status,
+ formatTimerRemaining(sleepTimerUiState.idleRemainingMs)
+ ),
+ active = sleepTimerUiState.idleTimerActive
+ ),
+ onOpenIdleStandbyTimer
+ ))
add(PlayerActionSpec(
stringResource(if (isCastConnected) R.string.player_stop_casting else R.string.player_cast),
if (isCastConnected) onStopCasting else onCast
@@ -1292,6 +1382,22 @@ private fun formatPlaybackSpeedLabel(speed: Float): String {
}
}
+private fun sleepTimerActionLabel(title: String, activeLabel: String, active: Boolean): String =
+ if (active) activeLabel else title
+
+private fun formatTimerRemaining(ms: Long): String {
+ val totalSeconds = (ms.coerceAtLeast(0L) + 999L) / 1000L
+ if (totalSeconds < 60L) return "${totalSeconds}s"
+ val totalMinutes = (totalSeconds + 59L) / 60L
+ return if (totalMinutes < 60L) {
+ "${totalMinutes}m"
+ } else {
+ val hours = totalMinutes / 60L
+ val minutes = totalMinutes % 60L
+ if (minutes == 0L) "${hours}h" else "${hours}h ${minutes}m"
+ }
+}
+
@Composable
private fun PlayerQuickSettingsButton(
text: String,
@@ -1493,8 +1599,10 @@ private fun LiveTimeshiftScrubber(
val engineState = timeshiftUiState.engineState
val oldestWallMs = engineState.bufferStartMs
+ val appTimeFormat = LocalAppTimeFormat.current
+ val timeFormat = remember(appTimeFormat) { appTimeFormat.createTimeFormat() }
val oldestLabel = if (oldestWallMs > 0L) {
- SimpleDateFormat("HH:mm", Locale.getDefault()).format(Date(oldestWallMs))
+ timeFormat.format(Date(oldestWallMs))
} else if (bufferDepthMs > 1_000L) {
"-${formatTimeshiftDuration(bufferDepthMs)}"
} else {
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/overlay/PlayerOverlays.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/overlay/PlayerOverlays.kt
index 624b7e51..998c5169 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/player/overlay/PlayerOverlays.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/overlay/PlayerOverlays.kt
@@ -77,6 +77,8 @@ import com.streamvault.app.ui.components.shell.StatusPill
import com.streamvault.app.ui.design.AppColors
import com.streamvault.app.ui.screens.player.PlayerDiagnosticsUiState
import com.streamvault.app.ui.screens.player.PlayerTimeshiftUiState
+import com.streamvault.app.ui.time.LocalAppTimeFormat
+import com.streamvault.app.ui.time.createTimeFormat
import com.streamvault.domain.model.RecordingStatus
import com.streamvault.app.ui.design.AppColors.Brand as Primary
import com.streamvault.app.ui.design.AppColors.SurfaceElevated as SurfaceVariant
@@ -86,7 +88,6 @@ import com.streamvault.domain.model.Channel
import com.streamvault.domain.model.Program
import com.streamvault.player.PlayerStats
import com.streamvault.player.timeshift.LiveTimeshiftStatus
-import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import com.streamvault.app.ui.interaction.TvClickableSurface
@@ -203,6 +204,7 @@ fun ChannelInfoOverlay(
onOpenAudioTracks: () -> Unit = {},
onOpenVideoTracks: () -> Unit = {},
onOpenVariants: () -> Unit = {},
+ onOpenAudioVideoSync: () -> Unit = {},
onEnterPictureInPicture: () -> Unit = {},
isCastConnected: Boolean = false,
onCast: () -> Unit = {},
@@ -210,7 +212,8 @@ fun ChannelInfoOverlay(
timeshiftUiState: PlayerTimeshiftUiState = PlayerTimeshiftUiState(),
onTransientPanelVisibilityChanged: (Boolean) -> Unit = {}
) {
- val timeFormat = SimpleDateFormat("HH:mm", Locale.getDefault())
+ val appTimeFormat = LocalAppTimeFormat.current
+ val timeFormat = remember(appTimeFormat) { appTimeFormat.createTimeFormat() }
val showTimeshiftControls = timeshiftUiState.available && !isCastConnected
val hasCatchUpOptions = currentChannel?.catchUpSupported == true || currentProgram?.hasArchive == true
var expandedPanel by remember { mutableStateOf<ChannelInfoPanel?>(null) }
@@ -544,6 +547,19 @@ fun ChannelInfoOverlay(
)
}
}
+ if (!isCastConnected) {
+ item {
+ QuickActionButton(
+ icon = "A/V",
+ label = stringResource(R.string.player_av_sync_short),
+ onClick = {
+ expandedPanel = null
+ onOpenAudioVideoSync()
+ },
+ onInteraction = { handleMainActionFocus(null) }
+ )
+ }
+ }
item {
QuickActionButton(
icon = stringResource(R.string.player_action_guide),
@@ -1567,7 +1583,8 @@ fun EpgOverlay(
onOpenArchiveBrowser: (() -> Unit)? = null,
onOverlayInteracted: () -> Unit = {}
) {
- val timeFormat = SimpleDateFormat("HH:mm", Locale.getDefault())
+ val appTimeFormat = LocalAppTimeFormat.current
+ val timeFormat = remember(appTimeFormat) { appTimeFormat.createTimeFormat() }
val listState = rememberLazyListState()
val filteredUpcoming = remember(upcomingPrograms, currentProgram, nextProgram) {
upcomingPrograms.filter { it.id != currentProgram?.id && it.id != nextProgram?.id }
@@ -1832,6 +1849,8 @@ fun DiagnosticsOverlay(
}
PlayerOverlaySectionLabel(stringResource(R.string.player_diagnostics_section_playback))
PlayerMetaRow(stringResource(R.string.player_diagnostics_decoder), diagnostics.decoderMode.name)
+ PlayerMetaRow(stringResource(R.string.player_diagnostics_active_decoder), diagnostics.activeDecoderName)
+ PlayerMetaRow(stringResource(R.string.player_diagnostics_surface), diagnostics.renderSurfaceType)
PlayerMetaRow(stringResource(R.string.player_diagnostics_stream_class), diagnostics.streamClassLabel)
PlayerMetaRow(stringResource(R.string.player_diagnostics_playback_state), diagnostics.playbackStateLabel)
if (diagnostics.archiveSupportLabel.isNotBlank()) {
@@ -1846,11 +1865,16 @@ fun DiagnosticsOverlay(
PlayerMetaRow(stringResource(R.string.player_diagnostics_video_codec), stats.videoCodec)
PlayerMetaRow(stringResource(R.string.player_diagnostics_video_bitrate), "${stats.videoBitrate / 1000} kbps")
PlayerMetaRow(stringResource(R.string.player_diagnostics_dropped_frames), stats.droppedFrames.toString())
+ PlayerMetaRow(stringResource(R.string.player_diagnostics_video_stalls), diagnostics.videoStallCount.toString())
+ if (diagnostics.lastVideoFrameAgoMs > 0L) {
+ PlayerMetaRow(stringResource(R.string.player_diagnostics_last_frame), "${diagnostics.lastVideoFrameAgoMs} ms")
+ }
if (stats.ttffMs > 0L) {
PlayerMetaRow("TTFF", "${stats.ttffMs} ms")
}
PlayerOverlaySectionLabel(stringResource(R.string.player_diagnostics_section_audio))
PlayerMetaRow(stringResource(R.string.player_diagnostics_audio_codec), stats.audioCodec)
+ PlayerMetaRow(stringResource(R.string.player_diagnostics_av_offset), formatOffsetLabel(diagnostics.audioVideoOffsetMs))
PlayerOverlaySectionLabel(stringResource(R.string.player_diagnostics_section_recovery))
diagnostics.lastFailureReason?.let { reason ->
PlayerMetaRow(stringResource(R.string.player_diagnostics_last_failure), reason, maxLines = 3)
@@ -1893,6 +1917,12 @@ fun DiagnosticsOverlay(
}
}
+private fun formatOffsetLabel(offsetMs: Int): String = when {
+ offsetMs > 0 -> "+$offsetMs ms"
+ offsetMs < 0 -> "$offsetMs ms"
+ else -> "0 ms"
+}
+
@Composable
fun CategoryListOverlay(
categories: List<com.streamvault.domain.model.Category>,
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/overlay/PlayerSystemOverlays.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/overlay/PlayerSystemOverlays.kt
index bfb19b69..33edd94b 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/player/overlay/PlayerSystemOverlays.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/overlay/PlayerSystemOverlays.kt
@@ -1,6 +1,7 @@
package com.streamvault.app.ui.screens.player.overlay
import android.view.KeyEvent
+import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.focusGroup
@@ -16,6 +17,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.lazy.LazyColumn
@@ -29,6 +31,9 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
+import androidx.compose.animation.core.animateFloatAsState
+import androidx.compose.animation.core.tween
+import androidx.compose.animation.core.LinearEasing
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
@@ -37,6 +42,8 @@ import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.StrokeCap
+import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.input.key.onPreviewKeyEvent
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.stringResource
@@ -58,7 +65,9 @@ import com.streamvault.app.ui.design.AppColors
import com.streamvault.app.ui.design.requestFocusSafely
import com.streamvault.app.ui.screens.player.PlayerNoticeAction
import com.streamvault.app.ui.screens.player.PlayerNoticeState
+import com.streamvault.app.ui.screens.player.PlayerAudioVideoOffsetUiState
import com.streamvault.app.ui.screens.player.PlayerRecoveryType
+import com.streamvault.app.ui.screens.player.SleepTimerUiState
import com.streamvault.app.ui.theme.AccentAmber
import com.streamvault.app.ui.theme.ErrorColor
import com.streamvault.app.ui.theme.OnBackground
@@ -76,6 +85,8 @@ import com.streamvault.domain.model.Season
import com.streamvault.player.PlayerError
import com.streamvault.player.PlayerTrack
import com.streamvault.player.TrackType
+import com.streamvault.player.AUDIO_VIDEO_OFFSET_MAX_MS
+import com.streamvault.player.AUDIO_VIDEO_OFFSET_MIN_MS
import java.util.Locale
import com.streamvault.app.ui.interaction.TvClickableSurface
import com.streamvault.app.ui.interaction.TvButton
@@ -500,6 +511,270 @@ fun PlayerSpeedSelectionDialog(
}
}
+@Composable
+fun PlayerSleepTimerDialog(
+ visible: Boolean,
+ title: String,
+ selectedMinutes: Int,
+ onDismiss: () -> Unit,
+ onSelectMinutes: (Int) -> Unit
+) {
+ if (!visible) return
+
+ val firstItemFocusRequester = remember { FocusRequester() }
+ val options = remember { listOf(0, 15, 30, 45, 60, 90, 120) }
+
+ LaunchedEffect(visible) {
+ firstItemFocusRequester.requestFocusSafely(
+ tag = "PlayerSleepTimerDialog",
+ target = "First timer option"
+ )
+ }
+
+ Dialog(
+ onDismissRequest = onDismiss,
+ properties = DialogProperties(usePlatformDefaultWidth = false)
+ ) {
+ Box(
+ modifier = Modifier
+ .fillMaxSize()
+ .background(Color.Black.copy(alpha = 0.8f))
+ .clickable(onClick = onDismiss),
+ contentAlignment = Alignment.Center
+ ) {
+ Column(
+ modifier = Modifier
+ .widthIn(min = 300.dp, max = 420.dp)
+ .background(SurfaceElevated, RoundedCornerShape(12.dp))
+ .padding(24.dp)
+ .onPreviewKeyEvent { event ->
+ if (event.nativeKeyEvent.action != KeyEvent.ACTION_DOWN) return@onPreviewKeyEvent false
+ when (event.nativeKeyEvent.keyCode) {
+ KeyEvent.KEYCODE_DPAD_UP,
+ KeyEvent.KEYCODE_DPAD_DOWN,
+ KeyEvent.KEYCODE_DPAD_LEFT,
+ KeyEvent.KEYCODE_DPAD_RIGHT,
+ KeyEvent.KEYCODE_DPAD_CENTER,
+ KeyEvent.KEYCODE_ENTER,
+ KeyEvent.KEYCODE_NUMPAD_ENTER,
+ KeyEvent.KEYCODE_BACK -> false
+ else -> true
+ }
+ }
+ ) {
+ Text(
+ text = title,
+ style = MaterialTheme.typography.titleLarge,
+ color = Color.White,
+ modifier = Modifier.padding(bottom = 16.dp)
+ )
+
+ LazyColumn(verticalArrangement = Arrangement.spacedBy(8.dp)) {
+ items(options, key = { it }) { minutes ->
+ TrackSelectionItem(
+ name = formatTimerPresetLabel(minutes),
+ isSelected = minutes == selectedMinutes,
+ onClick = { onSelectMinutes(minutes) },
+ modifier = if (minutes == options.first()) {
+ Modifier.focusRequester(firstItemFocusRequester)
+ } else {
+ Modifier
+ }
+ )
+ }
+ }
+ }
+ }
+ }
+}
+
+@Composable
+fun PlayerSleepTimerWarningOverlay(
+ state: SleepTimerUiState,
+ modifier: Modifier = Modifier,
+ onExtendStopTimer: () -> Unit,
+ onDisableStopTimer: () -> Unit,
+ onExtendIdleTimer: () -> Unit,
+ onDisableIdleTimer: () -> Unit
+) {
+ val showStopWarning = state.stopTimerWarningVisible
+ val showIdleWarning = !showStopWarning && state.idleTimerWarningVisible
+ if (!showStopWarning && !showIdleWarning) return
+
+ val message = if (showStopWarning) {
+ stringResource(R.string.player_timer_warning_stop, formatTimerCountdown(state.stopRemainingMs))
+ } else {
+ stringResource(R.string.player_timer_warning_idle, formatTimerCountdown(state.idleRemainingMs))
+ }
+ val onExtend = if (showStopWarning) onExtendStopTimer else onExtendIdleTimer
+ val onDisable = if (showStopWarning) onDisableStopTimer else onDisableIdleTimer
+
+ Surface(
+ modifier = modifier,
+ shape = RoundedCornerShape(18.dp),
+ colors = SurfaceDefaults.colors(containerColor = SurfaceElevated.copy(alpha = 0.94f)),
+ border = Border(androidx.compose.foundation.BorderStroke(1.dp, Primary.copy(alpha = 0.35f)))
+ ) {
+ Row(
+ modifier = Modifier.padding(horizontal = 18.dp, vertical = 12.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(12.dp)
+ ) {
+ Text(
+ text = message,
+ style = MaterialTheme.typography.bodyMedium,
+ color = Color.White,
+ fontWeight = FontWeight.Bold
+ )
+ TvButton(onClick = onExtend) {
+ Text(text = stringResource(R.string.player_timer_extend_30))
+ }
+ TvButton(onClick = onDisable) {
+ Text(text = stringResource(R.string.player_timer_disable))
+ }
+ }
+ }
+}
+
+@Composable
+fun PlayerAudioVideoOffsetDialog(
+ visible: Boolean,
+ state: PlayerAudioVideoOffsetUiState,
+ canSaveChannel: Boolean,
+ onDismiss: () -> Unit,
+ onAdjust: (Int) -> Unit,
+ onReset: () -> Unit,
+ onSaveForChannel: () -> Unit,
+ onSaveAsGlobal: () -> Unit,
+ onUseGlobal: () -> Unit
+) {
+ if (!visible) return
+
+ val firstItemFocusRequester = remember { FocusRequester() }
+ val effectiveLabel = remember(state.effectiveOffsetMs) {
+ formatAudioVideoOffsetLabel(state.effectiveOffsetMs)
+ }
+ val sourceLabel = when {
+ state.previewOffsetMs != null -> stringResource(R.string.player_av_sync_preview)
+ state.hasChannelOverride -> stringResource(R.string.player_av_sync_channel)
+ else -> stringResource(R.string.player_av_sync_global)
+ }
+
+ LaunchedEffect(visible) {
+ firstItemFocusRequester.requestFocusSafely(
+ tag = "PlayerAudioVideoOffsetDialog",
+ target = "First A/V sync option"
+ )
+ }
+
+ Dialog(
+ onDismissRequest = onDismiss,
+ properties = DialogProperties(usePlatformDefaultWidth = false)
+ ) {
+ Box(
+ modifier = Modifier
+ .fillMaxSize()
+ .background(Color.Black.copy(alpha = 0.8f))
+ .clickable(onClick = onDismiss),
+ contentAlignment = Alignment.Center
+ ) {
+ Column(
+ modifier = Modifier
+ .widthIn(min = 340.dp, max = 460.dp)
+ .background(SurfaceElevated, RoundedCornerShape(12.dp))
+ .padding(24.dp)
+ .onPreviewKeyEvent { event ->
+ if (event.nativeKeyEvent.action != KeyEvent.ACTION_DOWN) return@onPreviewKeyEvent false
+ when (event.nativeKeyEvent.keyCode) {
+ KeyEvent.KEYCODE_DPAD_UP,
+ KeyEvent.KEYCODE_DPAD_DOWN,
+ KeyEvent.KEYCODE_DPAD_LEFT,
+ KeyEvent.KEYCODE_DPAD_RIGHT,
+ KeyEvent.KEYCODE_DPAD_CENTER,
+ KeyEvent.KEYCODE_ENTER,
+ KeyEvent.KEYCODE_NUMPAD_ENTER,
+ KeyEvent.KEYCODE_BACK -> false
+ else -> true
+ }
+ }
+ ) {
+ Text(
+ text = stringResource(R.string.player_av_sync_title),
+ style = MaterialTheme.typography.titleLarge,
+ color = Color.White
+ )
+ Text(
+ text = stringResource(R.string.player_av_sync_value, effectiveLabel, sourceLabel),
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim,
+ modifier = Modifier.padding(top = 6.dp, bottom = 16.dp)
+ )
+
+ LazyColumn(verticalArrangement = Arrangement.spacedBy(8.dp)) {
+ item {
+ TrackSelectionItem(
+ name = stringResource(R.string.player_av_sync_minus_50),
+ isSelected = false,
+ onClick = { onAdjust(-50) },
+ enabled = state.effectiveOffsetMs > AUDIO_VIDEO_OFFSET_MIN_MS,
+ modifier = Modifier.focusRequester(firstItemFocusRequester)
+ )
+ }
+ item {
+ TrackSelectionItem(
+ name = stringResource(R.string.player_av_sync_plus_50),
+ isSelected = false,
+ onClick = { onAdjust(50) },
+ enabled = state.effectiveOffsetMs < AUDIO_VIDEO_OFFSET_MAX_MS
+ )
+ }
+ item {
+ TrackSelectionItem(
+ name = stringResource(R.string.player_av_sync_reset),
+ isSelected = state.effectiveOffsetMs == 0,
+ onClick = onReset
+ )
+ }
+ if (canSaveChannel) {
+ item {
+ TrackSelectionItem(
+ name = stringResource(R.string.player_av_sync_save_channel),
+ isSelected = state.hasChannelOverride && state.previewOffsetMs == null,
+ onClick = {
+ onSaveForChannel()
+ onDismiss()
+ }
+ )
+ }
+ }
+ item {
+ TrackSelectionItem(
+ name = stringResource(R.string.player_av_sync_save_global),
+ isSelected = false,
+ onClick = {
+ onSaveAsGlobal()
+ onDismiss()
+ }
+ )
+ }
+ if (canSaveChannel && state.hasChannelOverride) {
+ item {
+ TrackSelectionItem(
+ name = stringResource(R.string.player_av_sync_use_global),
+ isSelected = false,
+ onClick = {
+ onUseGlobal()
+ onDismiss()
+ }
+ )
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
@Composable
fun PlayerEpisodeSelectionDialog(
visible: Boolean,
@@ -903,6 +1178,32 @@ private fun formatPlaybackSpeedLabel(speed: Float): String {
}
}
+@Composable
+private fun formatTimerPresetLabel(minutes: Int): String =
+ if (minutes <= 0) {
+ stringResource(R.string.player_timer_off)
+ } else {
+ androidx.compose.ui.platform.LocalContext.current.resources.getQuantityString(
+ R.plurals.settings_timer_minutes,
+ minutes,
+ minutes
+ )
+ }
+
+private fun formatTimerCountdown(ms: Long): String {
+ val totalSeconds = (ms.coerceAtLeast(0L) + 999L) / 1000L
+ if (totalSeconds < 60L) return "${totalSeconds}s"
+ val minutes = totalSeconds / 60L
+ val seconds = totalSeconds % 60L
+ return if (seconds == 0L) "${minutes}m" else "${minutes}m ${seconds}s"
+}
+
+private fun formatAudioVideoOffsetLabel(offsetMs: Int): String = when {
+ offsetMs > 0 -> "+$offsetMs ms"
+ offsetMs < 0 -> "$offsetMs ms"
+ else -> "0 ms"
+}
+
private fun buildVariantSelectionLabel(variant: LiveChannelVariant): String {
val metaParts = buildList {
variant.attributes.resolutionLabel?.let(::add)
@@ -932,10 +1233,11 @@ private fun TrackSelectionItem(
name: String,
isSelected: Boolean,
onClick: () -> Unit,
+ enabled: Boolean = true,
modifier: Modifier = Modifier
) {
TvClickableSurface(
- onClick = onClick,
+ onClick = { if (enabled) onClick() },
shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
colors = ClickableSurfaceDefaults.colors(
containerColor = if (isSelected) Primary.copy(alpha = 0.2f) else Color.Transparent,
@@ -950,7 +1252,11 @@ private fun TrackSelectionItem(
Text(
text = name,
style = MaterialTheme.typography.bodyLarge,
- color = if (isSelected) Primary else Color.White,
+ color = when {
+ !enabled -> Color.White.copy(alpha = 0.38f)
+ isSelected -> Primary
+ else -> Color.White
+ },
modifier = Modifier.weight(1f)
)
if (isSelected) {
@@ -1094,3 +1400,155 @@ private fun playerNoticeActionLabel(action: PlayerNoticeAction): String =
PlayerNoticeAction.ALTERNATE_STREAM -> stringResource(R.string.player_try_alternate_stream)
PlayerNoticeAction.OPEN_GUIDE -> stringResource(R.string.player_open_guide_action)
}
+
+@Composable
+fun NextEpisodeCountdownOverlay(
+ nextEpisode: Episode,
+ secondsRemaining: Int,
+ totalSeconds: Int = 10,
+ onPlayNow: () -> Unit,
+ onCancel: () -> Unit,
+ modifier: Modifier = Modifier
+) {
+ val playNowFocusRequester = remember { FocusRequester() }
+
+ LaunchedEffect(Unit) {
+ playNowFocusRequester.requestFocusSafely(
+ tag = "NextEpisodeCountdown",
+ target = "Play Now button"
+ )
+ }
+
+ val progress = (secondsRemaining.toFloat() / totalSeconds.toFloat()).coerceIn(0f, 1f)
+ val animatedSweep by animateFloatAsState(
+ targetValue = 360f * progress,
+ animationSpec = tween(durationMillis = 900, easing = LinearEasing),
+ label = "countdown_arc"
+ )
+
+ Box(
+ modifier = modifier
+ .widthIn(max = 360.dp)
+ .background(Color.Black.copy(alpha = 0.90f), RoundedCornerShape(16.dp))
+ .padding(20.dp)
+ ) {
+ Column(verticalArrangement = Arrangement.spacedBy(14.dp)) {
+ // "UP NEXT" label
+ Text(
+ text = stringResource(R.string.player_up_next),
+ style = MaterialTheme.typography.labelMedium,
+ color = Primary,
+ fontWeight = FontWeight.Bold
+ )
+
+ // Episode info: arc timer + title + thumbnail
+ Row(
+ horizontalArrangement = Arrangement.spacedBy(12.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ // Circular countdown arc
+ Box(contentAlignment = Alignment.Center, modifier = Modifier.size(60.dp)) {
+ Canvas(modifier = Modifier.fillMaxSize()) {
+ drawArc(
+ color = Color.White.copy(alpha = 0.12f),
+ startAngle = -90f,
+ sweepAngle = 360f,
+ useCenter = false,
+ style = Stroke(width = 4.dp.toPx())
+ )
+ drawArc(
+ color = Primary,
+ startAngle = -90f,
+ sweepAngle = animatedSweep,
+ useCenter = false,
+ style = Stroke(width = 4.dp.toPx(), cap = StrokeCap.Round)
+ )
+ }
+ Text(
+ text = secondsRemaining.toString(),
+ style = MaterialTheme.typography.titleLarge,
+ color = Color.White,
+ fontWeight = FontWeight.Bold
+ )
+ }
+
+ // Title and subtitle
+ Column(modifier = Modifier.weight(1f)) {
+ val episodeLabel = buildString {
+ append("S${nextEpisode.seasonNumber}E${nextEpisode.episodeNumber}")
+ if (nextEpisode.title.isNotBlank()) append(" · ${nextEpisode.title}")
+ }
+ Text(
+ text = episodeLabel,
+ style = MaterialTheme.typography.bodyMedium,
+ color = Color.White,
+ fontWeight = FontWeight.SemiBold,
+ maxLines = 2,
+ overflow = TextOverflow.Ellipsis
+ )
+ Text(
+ text = stringResource(R.string.player_auto_play_countdown, secondsRemaining),
+ style = MaterialTheme.typography.bodySmall,
+ color = TextSecondary
+ )
+ }
+
+ // Episode thumbnail
+ if (!nextEpisode.coverUrl.isNullOrBlank()) {
+ AsyncImage(
+ model = nextEpisode.coverUrl,
+ contentDescription = null,
+ contentScale = ContentScale.Crop,
+ modifier = Modifier
+ .width(80.dp)
+ .height(55.dp)
+ .clip(RoundedCornerShape(6.dp))
+ )
+ }
+ }
+
+ // Action buttons
+ Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
+ TvClickableSurface(
+ onClick = onPlayNow,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Primary,
+ focusedContainerColor = PrimaryLight
+ ),
+ modifier = Modifier
+ .weight(1f)
+ .focusRequester(playNowFocusRequester)
+ ) {
+ Text(
+ text = stringResource(R.string.player_auto_play_play_now),
+ color = Color.White,
+ fontWeight = FontWeight.Bold,
+ modifier = Modifier
+ .padding(vertical = 10.dp)
+ .fillMaxWidth(),
+ textAlign = TextAlign.Center
+ )
+ }
+ TvClickableSurface(
+ onClick = onCancel,
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = SurfaceElevated,
+ focusedContainerColor = SurfaceHighlight
+ ),
+ modifier = Modifier.weight(1f)
+ ) {
+ Text(
+ text = stringResource(R.string.player_auto_play_cancel),
+ color = Color.White,
+ modifier = Modifier
+ .padding(vertical = 10.dp)
+ .fillMaxWidth(),
+ textAlign = TextAlign.Center
+ )
+ }
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/series/SeriesDetailScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/series/SeriesDetailScreen.kt
index 35e94f1a..595d1a2f 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/series/SeriesDetailScreen.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/series/SeriesDetailScreen.kt
@@ -22,6 +22,9 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
@@ -60,6 +63,8 @@ import com.streamvault.app.ui.interaction.TvClickableSurface
import com.streamvault.app.ui.interaction.TvButton
import com.streamvault.app.ui.interaction.TvIconButton
+private const val EPISODE_DETAIL_PAGE_SIZE = 100
+
@Composable
fun SeriesDetailScreen(
onEpisodeClick: (Episode) -> Unit,
@@ -142,6 +147,10 @@ private fun SeriesDetailContent(
PaddingValues(horizontal = 56.dp, vertical = 36.dp)
}
val posterWidth = if (compactLayout) 132.dp else 220.dp
+ var visibleEpisodeLimit by remember(selectedSeason?.seasonNumber) {
+ mutableStateOf(EPISODE_DETAIL_PAGE_SIZE)
+ }
+ val visibleEpisodes = selectedSeason?.episodes.orEmpty().take(visibleEpisodeLimit)
AsyncImage(
model = rememberCrossfadeImageModel(series.backdropUrl ?: series.posterUrl),
@@ -416,9 +425,27 @@ private fun SeriesDetailContent(
)
}
}
- items(season.episodes, key = { it.id }) { episode ->
+ items(visibleEpisodes, key = { it.id }) { episode ->
EpisodeItem(episode = episode, onClick = { onEpisodeClick(episode) })
}
+ if (visibleEpisodes.size < season.episodes.size) {
+ item {
+ TvButton(
+ onClick = {
+ visibleEpisodeLimit = (visibleEpisodeLimit + EPISODE_DETAIL_PAGE_SIZE)
+ .coerceAtMost(season.episodes.size)
+ }
+ ) {
+ Text(
+ text = stringResource(
+ R.string.library_load_more,
+ visibleEpisodes.size,
+ season.episodes.size
+ )
+ )
+ }
+ }
+ }
}
}
}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/series/SeriesScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/series/SeriesScreen.kt
index e142a26d..95d251e7 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/series/SeriesScreen.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/series/SeriesScreen.kt
@@ -69,6 +69,7 @@ import com.streamvault.app.ui.components.dialogs.RenameGroupDialog
import com.streamvault.app.ui.components.shell.BrowseHeroPanel
import com.streamvault.app.ui.components.shell.BrowseSearchLaunchCard
import com.streamvault.app.ui.components.shell.LoadMoreCard
+import com.streamvault.app.ui.components.shell.InfiniteScrollEffect
import com.streamvault.app.ui.components.shell.AppNavigationChrome
import com.streamvault.app.ui.components.shell.AppMessageState
import com.streamvault.app.ui.components.shell.AppScreenScaffold
@@ -99,6 +100,9 @@ fun SeriesScreen(
currentRoute: String,
viewModel: SeriesViewModel = hiltViewModel()
) {
+ remember(viewModel) {
+ viewModel.resetPreviewRowsForScreenEntry()
+ }
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
val snackbarHostState = remember { SnackbarHostState() }
val initialContentFocusRequester = remember { FocusRequester() }
@@ -398,8 +402,18 @@ private fun SeriesVodContent(
}
}
val openProtectedCategory: (Category) -> Unit = onProtectedCategoryClick
- val visibleCategoryNames = remember(uiState.categoryNames, categoryByName, uiState.parentalControlLevel, uiState.unlockedCategoryIds) {
- uiState.categoryNames.filter { name ->
+ val browseCategoryNames = remember(uiState.categoryNames, uiState.providerCategories, uiState.categories, uiState.favoriteCategoryName) {
+ buildList {
+ val names = linkedSetOf<String>()
+ uiState.categoryNames.forEach(names::add)
+ uiState.providerCategories.forEach { names.add(it.name) }
+ uiState.categories.forEach { names.add(it.name) }
+ names.add(uiState.favoriteCategoryName)
+ addAll(names)
+ }
+ }
+ val visibleCategoryNames = remember(browseCategoryNames, categoryByName, uiState.parentalControlLevel, uiState.unlockedCategoryIds) {
+ browseCategoryNames.filter { name ->
val category = categoryByName[name]
category == null || !isCategoryHidden(category)
}
@@ -473,7 +487,16 @@ private fun SeriesVodContent(
}
if (uiState.selectedCategory == null) {
+ val previewListState = androidx.compose.foundation.lazy.rememberLazyListState()
+ InfiniteScrollEffect(
+ listState = previewListState,
+ enabled = uiState.vodInfiniteScroll,
+ canLoadMore = uiState.hasMorePreviewRows,
+ isLoading = uiState.isLoadingPreviewRows,
+ onLoadMore = onLoadMorePreviewRows
+ )
LazyColumn(
+ state = previewListState,
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(bottom = 28.dp)
) {
@@ -510,7 +533,7 @@ private fun SeriesVodContent(
VodActionChip(
key = "categories",
label = stringResource(R.string.series_categories_title),
- detail = "${uiState.categoryNames.size} groups",
+ detail = "${visibleCategoryNames.count { name -> categoryByName[name]?.id != VodBrowseDefaults.FAVORITES_SENTINEL_ID }} groups",
onClick = { showCategoryPicker = true }
)
)
@@ -656,11 +679,17 @@ private fun SeriesVodContent(
}
}
}
- if (uiState.hasMorePreviewRows && !uiState.isLoadingPreviewRows && catEntries.isNotEmpty()) {
+ if (uiState.hasMorePreviewRows && !uiState.isLoadingPreviewRows && !uiState.vodInfiniteScroll && catEntries.isNotEmpty()) {
item(key = "load_more_preview_trigger") {
- LaunchedEffect(catEntries.size) {
- onLoadMorePreviewRows()
- }
+ LoadMoreCard(
+ label = stringResource(
+ R.string.library_load_more,
+ catEntries.size,
+ visibleCategoryNames.size
+ ),
+ onClick = onLoadMorePreviewRows,
+ modifier = Modifier.padding(horizontal = 24.dp, vertical = 12.dp)
+ )
}
}
}
@@ -695,7 +724,16 @@ private fun SeriesVodContent(
)
}
+ val modernGridState = androidx.compose.foundation.lazy.grid.rememberLazyGridState()
+ InfiniteScrollEffect(
+ gridState = modernGridState,
+ enabled = !uiState.isReorderMode,
+ canLoadMore = uiState.canLoadMoreSelectedCategory,
+ isLoading = uiState.isLoadingSelectedCategory,
+ onLoadMore = onLoadMore
+ )
LazyVerticalGrid(
+ state = modernGridState,
columns = GridCells.Adaptive(minSize = 136.dp),
modifier = Modifier
.fillMaxSize()
@@ -834,20 +872,6 @@ private fun SeriesVodContent(
}
)
}
-
- if (!uiState.isReorderMode && uiState.canLoadMoreSelectedCategory) {
- item(span = { GridItemSpan(maxLineSpan) }) {
- LoadMoreCard(
- label = stringResource(
- R.string.library_load_more,
- uiState.selectedCategoryLoadedCount,
- uiState.selectedCategoryTotalCount
- ),
- onClick = onLoadMore,
- modifier = Modifier.padding(top = 8.dp, bottom = 24.dp)
- )
- }
- }
}
}
}
@@ -915,8 +939,18 @@ private fun SeriesVodClassicContent(
}
}
val openProtectedCategory: (Category) -> Unit = onProtectedCategoryClick
- val visibleCategoryNames = remember(uiState.categoryNames, categoryByName, uiState.parentalControlLevel, uiState.unlockedCategoryIds) {
- uiState.categoryNames.filter { name ->
+ val browseCategoryNames = remember(uiState.categoryNames, uiState.providerCategories, uiState.categories, uiState.favoriteCategoryName) {
+ buildList {
+ val names = linkedSetOf<String>()
+ uiState.categoryNames.forEach(names::add)
+ uiState.providerCategories.forEach { names.add(it.name) }
+ uiState.categories.forEach { names.add(it.name) }
+ names.add(uiState.favoriteCategoryName)
+ addAll(names)
+ }
+ }
+ val visibleCategoryNames = remember(browseCategoryNames, categoryByName, uiState.parentalControlLevel, uiState.unlockedCategoryIds) {
+ browseCategoryNames.filter { name ->
val category = categoryByName[name]
category == null || !isCategoryHidden(category)
}
@@ -1097,7 +1131,16 @@ private fun SeriesVodClassicContent(
)
}
+ val classicGridState = androidx.compose.foundation.lazy.grid.rememberLazyGridState()
+ InfiniteScrollEffect(
+ gridState = classicGridState,
+ enabled = !uiState.isReorderMode,
+ canLoadMore = uiState.canLoadMoreSelectedCategory,
+ isLoading = uiState.isLoadingSelectedCategory,
+ onLoadMore = onLoadMore
+ )
LazyVerticalGrid(
+ state = classicGridState,
columns = GridCells.Adaptive(minSize = 136.dp),
modifier = Modifier
.fillMaxWidth()
@@ -1160,20 +1203,6 @@ private fun SeriesVodClassicContent(
}
)
}
-
- if (!uiState.isReorderMode && uiState.canLoadMoreSelectedCategory) {
- item(span = { GridItemSpan(maxLineSpan) }) {
- LoadMoreCard(
- label = stringResource(
- R.string.library_load_more,
- uiState.selectedCategoryLoadedCount,
- uiState.selectedCategoryTotalCount
- ),
- onClick = onLoadMore,
- modifier = Modifier.padding(top = 8.dp)
- )
- }
- }
}
}
}
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/series/SeriesViewModel.kt b/app/src/main/java/com/streamvault/app/ui/screens/series/SeriesViewModel.kt
index b66f14b1..7021f7ea 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/series/SeriesViewModel.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/series/SeriesViewModel.kt
@@ -14,6 +14,7 @@ import com.streamvault.domain.model.LibraryFilterType
import com.streamvault.domain.model.LibraryBrowseQuery
import com.streamvault.domain.model.LibrarySortBy
import com.streamvault.domain.model.PlaybackHistory
+import com.streamvault.domain.model.ProviderType
import com.streamvault.domain.model.Result
import com.streamvault.domain.model.Series
import com.streamvault.domain.repository.FavoriteRepository
@@ -50,6 +51,7 @@ import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
+import kotlinx.coroutines.flow.distinctUntilChangedBy
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flatMapLatest
@@ -81,6 +83,7 @@ class SeriesViewModel @Inject constructor(
const val UNCATEGORIZED = "Uncategorized"
const val MIN_SEARCH_QUERY_LENGTH = 2
const val FAVORITE_ID_FETCH_BUFFER = 80
+ const val INITIAL_PREVIEW_BATCH_SIZE = 6
}
private val _uiState = MutableStateFlow(SeriesUiState())
@@ -90,7 +93,7 @@ class SeriesViewModel @Inject constructor(
private val _selectedCategoryLoadLimit = MutableStateFlow(VodBrowseDefaults.SELECTED_CATEGORY_PAGE_SIZE)
private val _selectedLibraryFilterType = MutableStateFlow(LibraryFilterType.ALL)
private val _selectedLibrarySortBy = MutableStateFlow(LibrarySortBy.LIBRARY)
- private val _previewBatchSize = MutableStateFlow(8)
+ private val _previewBatchSize = MutableStateFlow(INITIAL_PREVIEW_BATCH_SIZE)
private var activeProviderId: Long? = null
private data class PreviewLoadResult(
@@ -147,14 +150,21 @@ class SeriesViewModel @Inject constructor(
val libraryCount = values[4] as Int
val hiddenCategoryIds = values[5] as Set<Long>
val sortMode = values[6] as CategorySortMode
+ val visibleProviderCategories = applyProviderCategoryDisplayPreferences(
+ categories = providerCategories,
+ hiddenCategoryIds = hiddenCategoryIds,
+ sortMode = sortMode
+ ).let { categories ->
+ if (provider.type == ProviderType.STALKER_PORTAL) {
+ categories.filterNot(::isLikelyProviderWideStalkerCategory)
+ } else {
+ categories
+ }
+ }
SeriesCatalogDependencies(
allFavorites = allFavorites,
customCategories = customCategories,
- providerCategories = applyProviderCategoryDisplayPreferences(
- categories = providerCategories,
- hiddenCategoryIds = hiddenCategoryIds,
- sortMode = sortMode
- ),
+ providerCategories = visibleProviderCategories,
providerCategoryCounts = providerCategoryCounts,
libraryCount = libraryCount,
hiddenCategoryIds = hiddenCategoryIds,
@@ -173,6 +183,12 @@ class SeriesViewModel @Inject constructor(
query = query.trim()
)
}
+ .distinctUntilChangedBy { params ->
+ params.copy(
+ providerCategoryCounts = emptyMap(),
+ libraryCount = 0
+ )
+ }
}
.flatMapLatest { params ->
_previewBatchSize.flatMapLatest { batchSize ->
@@ -229,9 +245,13 @@ class SeriesViewModel @Inject constructor(
val currentSelected = _uiState.value.selectedCategory
val preserveSelectedCategory = currentSelected != null && _searchQuery.value.isNotBlank()
val resolvedSelected = currentSelected?.takeIf { selected ->
+ val customCategoryNames = _uiState.value.categories.mapTo(linkedSetOf()) { it.name }
+ val providerCategoryNames = snapshot.providerCategories.mapTo(linkedSetOf()) { it.name }
preserveSelectedCategory ||
selected == _uiState.value.fullLibraryCategoryName ||
- selected in snapshot.categoryNames
+ selected in snapshot.categoryNames ||
+ selected in providerCategoryNames ||
+ selected in customCategoryNames
}
_uiState.update {
it.copy(
@@ -264,6 +284,12 @@ class SeriesViewModel @Inject constructor(
}
}
+ viewModelScope.launch {
+ preferencesRepository.vodInfiniteScroll.collectLatest { enabled ->
+ _uiState.update { it.copy(vodInfiniteScroll = enabled) }
+ }
+ }
+
viewModelScope.launch {
providerRepository.getActiveProvider()
.filterNotNull()
@@ -469,7 +495,7 @@ class SeriesViewModel @Inject constructor(
}
fun selectCategory(categoryName: String?) {
- _previewBatchSize.value = 8
+ _previewBatchSize.value = INITIAL_PREVIEW_BATCH_SIZE
activeProviderId?.let { providerId ->
parentalControlManager.retainUnlockedCategory(
providerId = providerId,
@@ -509,17 +535,38 @@ class SeriesViewModel @Inject constructor(
fun loadMorePreviewRows() {
if (_uiState.value.hasMorePreviewRows && !_uiState.value.isLoadingPreviewRows) {
- _previewBatchSize.update { it + 8 }
+ _previewBatchSize.update { it + INITIAL_PREVIEW_BATCH_SIZE }
}
}
fun setSearchQuery(query: String) {
- _previewBatchSize.value = 8
+ _previewBatchSize.value = INITIAL_PREVIEW_BATCH_SIZE
setVodSearchQuery(query, _searchQuery, _uiState) { updatedQuery ->
copy(searchQuery = updatedQuery)
}
}
+ fun resetPreviewRowsForScreenEntry() {
+ _previewBatchSize.value = INITIAL_PREVIEW_BATCH_SIZE
+ _uiState.update { state ->
+ if (state.selectedCategory != null || state.searchQuery.isNotBlank()) {
+ state
+ } else {
+ val providerNames = state.providerCategories.mapTo(linkedSetOf()) { it.name }
+ val initialProviderNames = state.providerCategories
+ .take(INITIAL_PREVIEW_BATCH_SIZE)
+ .mapTo(linkedSetOf()) { it.name }
+ fun keepRow(name: String): Boolean = name !in providerNames || name in initialProviderNames
+ state.copy(
+ seriesByCategory = state.seriesByCategory.filterKeys(::keepRow),
+ categoryNames = state.categoryNames.filter(::keepRow),
+ categoryCounts = state.categoryCounts.filterKeys(::keepRow),
+ hasMorePreviewRows = state.providerCategories.size > INITIAL_PREVIEW_BATCH_SIZE
+ )
+ }
+ }
+ }
+
fun setSelectedLibraryFilterType(filterType: LibraryFilterType) {
setVodLibraryFilterType(
filterType = filterType,
@@ -933,6 +980,16 @@ class SeriesViewModel @Inject constructor(
)
}
+ private fun isLikelyProviderWideStalkerCategory(category: Category): Boolean {
+ val name = category.name.trim().lowercase()
+ return name == "*" ||
+ name == "all" ||
+ name == "all series" ||
+ name == "all tv series" ||
+ name == "all shows" ||
+ name == "all categories"
+ }
+
private suspend fun loadSelectedCategoryItems(
request: SelectedSeriesCategoryRequest
): SelectedSeriesCategorySnapshot {
@@ -949,7 +1006,7 @@ class SeriesViewModel @Inject constructor(
.map { it.contentId }
.toSet()
- val (selectedItems, totalCount) = when (request.selectedCategory) {
+ val (selectedItems, totalCount, hasMoreRemote) = when (request.selectedCategory) {
VodBrowseDefaults.FULL_LIBRARY_CATEGORY -> {
val result = seriesRepository
.browseSeries(
@@ -963,7 +1020,11 @@ class SeriesViewModel @Inject constructor(
)
)
.first()
- result.items.filterNot { item -> item.categoryId in request.hiddenCategoryIds } to result.totalCount
+ Triple(
+ result.items.filterNot { item -> item.categoryId in request.hiddenCategoryIds },
+ result.totalCount,
+ result.hasMoreRemote
+ )
}
VodBrowseDefaults.FAVORITES_CATEGORY -> {
val ids = request.allFavorites
@@ -991,7 +1052,11 @@ class SeriesViewModel @Inject constructor(
request.sortBy,
request.query
)
- filteredItems.take(request.loadLimit) to if (fetchIds === ids) filteredItems.size else ids.size
+ Triple(
+ filteredItems.take(request.loadLimit),
+ if (fetchIds === ids) filteredItems.size else ids.size,
+ false
+ )
}
else -> {
val customCategory = request.customCategories.firstOrNull { it.name == request.selectedCategory }
@@ -1021,7 +1086,11 @@ class SeriesViewModel @Inject constructor(
request.sortBy,
request.query
)
- filteredItems.take(request.loadLimit) to if (fetchIds === ids) filteredItems.size else ids.size
+ Triple(
+ filteredItems.take(request.loadLimit),
+ if (fetchIds === ids) filteredItems.size else ids.size,
+ false
+ )
} else {
val providerCategory = request.providerCategories.firstOrNull { it.name == request.selectedCategory }
if (providerCategory != null) {
@@ -1038,9 +1107,9 @@ class SeriesViewModel @Inject constructor(
)
)
.first()
- result.items to result.totalCount
+ Triple(result.items, result.totalCount, result.hasMoreRemote)
} else {
- emptyList<Series>() to 0
+ Triple(emptyList<Series>(), 0, false)
}
}
}
@@ -1053,7 +1122,7 @@ class SeriesViewModel @Inject constructor(
items = enrichedItems,
loadedCount = enrichedItems.size,
totalCount = totalCount,
- canLoadMore = totalCount > enrichedItems.size
+ canLoadMore = totalCount > enrichedItems.size || hasMoreRemote
)
}
@@ -1213,6 +1282,7 @@ data class SeriesUiState(
val selectedLibraryFilterType: LibraryFilterType = LibraryFilterType.ALL,
val selectedLibrarySortBy: LibrarySortBy = LibrarySortBy.LIBRARY,
val vodViewMode: VodViewMode = VodViewMode.MODERN,
+ val vodInfiniteScroll: Boolean = false,
val continueWatching: List<PlaybackHistory> = emptyList(),
val hasProviders: Boolean = false,
val hasActiveProvider: Boolean = false,
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsDialogComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsDialogComponents.kt
index 4fe6feb5..883944f9 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsDialogComponents.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsDialogComponents.kt
@@ -965,14 +965,21 @@ internal fun ClickableSettingsRow(
}
@Composable
-internal fun SwitchSettingsRow(label: String, value: String, checked: Boolean, onCheckedChange: (Boolean) -> Unit) {
+internal fun SwitchSettingsRow(
+ label: String,
+ value: String,
+ checked: Boolean,
+ onCheckedChange: (Boolean) -> Unit,
+ enabled: Boolean = true,
+ indent: androidx.compose.ui.unit.Dp = 0.dp
+) {
val focusRequester = remember { FocusRequester() }
TvClickableSurface(
- onClick = { onCheckedChange(!checked) },
+ onClick = { if (enabled) onCheckedChange(!checked) },
shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
colors = ClickableSurfaceDefaults.colors(
containerColor = Color.Transparent,
- focusedContainerColor = Primary.copy(alpha = 0.15f)
+ focusedContainerColor = if (enabled) Primary.copy(alpha = 0.15f) else Color.Transparent
),
scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
modifier = Modifier
@@ -980,23 +987,28 @@ internal fun SwitchSettingsRow(label: String, value: String, checked: Boolean, o
.focusRequester(focusRequester)
.mouseClickable(
focusRequester = focusRequester,
- onClick = { onCheckedChange(!checked) }
+ onClick = { if (enabled) onCheckedChange(!checked) }
)
) {
Row(
modifier = Modifier
.fillMaxWidth()
- .padding(horizontal = 8.dp, vertical = 12.dp),
+ .padding(start = 8.dp + indent, end = 8.dp, top = 12.dp, bottom = 12.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
- Text(text = label, style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(
+ text = label,
+ style = MaterialTheme.typography.bodyMedium,
+ color = if (enabled) OnSurface else OnSurfaceDim
+ )
Text(text = value, style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim)
}
Switch(
checked = checked,
- onCheckedChange = { onCheckedChange(it) }
+ onCheckedChange = { if (enabled) onCheckedChange(it) },
+ enabled = enabled
)
}
}
@@ -1219,9 +1231,12 @@ internal fun formatBytes(bytes: Long): String {
}
}
-internal fun formatTimestamp(timestampMs: Long): String {
+internal fun formatTimestamp(
+ timestampMs: Long,
+ dateTimeFormat: DateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT)
+): String {
if (timestampMs <= 0L) return "--:--"
- return java.text.SimpleDateFormat("MMM d, HH:mm", Locale.getDefault()).format(java.util.Date(timestampMs))
+ return dateTimeFormat.format(java.util.Date(timestampMs))
}
internal data class AppLanguageOption(
@@ -1318,6 +1333,101 @@ internal fun formatPlaybackSpeedLabel(speed: Float): String {
}
}
+internal fun formatPlaybackTimerMinutesLabel(minutes: Int, context: android.content.Context): String {
+ return if (minutes <= 0) {
+ context.getString(R.string.settings_timer_off)
+ } else {
+ context.resources.getQuantityString(R.plurals.settings_timer_minutes, minutes, minutes)
+ }
+}
+
+@Composable
+internal fun PlaybackTimerPresetDialog(
+ title: String,
+ selectedMinutes: Int,
+ onDismiss: () -> Unit,
+ onSelect: (Int) -> Unit
+) {
+ val context = androidx.compose.ui.platform.LocalContext.current
+ val options = remember { listOf(0, 15, 30, 45, 60, 90, 120) }
+
+ PremiumSelectionDialog(
+ title = title,
+ onDismiss = onDismiss
+ ) {
+ options.forEachIndexed { index, minutes ->
+ LevelOption(
+ level = index,
+ text = formatPlaybackTimerMinutesLabel(minutes, context),
+ currentLevel = if (selectedMinutes == minutes) index else -1,
+ onSelect = { onSelect(minutes) }
+ )
+ }
+ }
+}
+
+internal fun formatAudioVideoOffsetLabel(offsetMs: Int): String = when {
+ offsetMs > 0 -> "+$offsetMs ms"
+ offsetMs < 0 -> "$offsetMs ms"
+ else -> "0 ms"
+}
+
+@Composable
+internal fun AudioVideoOffsetValueDialog(
+ title: String,
+ subtitle: String,
+ initialValue: Int,
+ onDismiss: () -> Unit,
+ onConfirm: (Int) -> Unit
+) {
+ var value by rememberSaveable(initialValue) { mutableStateOf(initialValue.coerceIn(-2_000, 2_000)) }
+
+ PremiumDialog(
+ title = title,
+ subtitle = subtitle,
+ onDismissRequest = onDismiss,
+ widthFraction = 0.42f,
+ content = {
+ Column(verticalArrangement = Arrangement.spacedBy(14.dp)) {
+ Text(
+ text = formatAudioVideoOffsetLabel(value),
+ style = MaterialTheme.typography.headlineSmall,
+ color = Primary
+ )
+ Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
+ PremiumDialogFooterButton(
+ label = "-50",
+ onClick = { value = (value - 50).coerceAtLeast(-2_000) }
+ )
+ PremiumDialogFooterButton(
+ label = "+50",
+ onClick = { value = (value + 50).coerceAtMost(2_000) }
+ )
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_reset),
+ onClick = { value = 0 }
+ )
+ }
+ }
+ },
+ footer = {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.End)
+ ) {
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_cancel),
+ onClick = onDismiss
+ )
+ PremiumDialogFooterButton(
+ label = stringResource(R.string.settings_save),
+ onClick = { onConfirm(value) }
+ )
+ }
+ }
+ )
+}
+
@Composable
internal fun RecordingMetaPill(label: String, value: String) {
Column(
@@ -1446,9 +1556,19 @@ internal fun formatDecoderModeLabel(mode: DecoderMode, context: android.content.
DecoderMode.AUTO -> context.getString(R.string.settings_decoder_auto)
DecoderMode.HARDWARE -> context.getString(R.string.settings_decoder_hardware)
DecoderMode.SOFTWARE -> context.getString(R.string.settings_decoder_software)
+ DecoderMode.COMPATIBILITY -> context.getString(R.string.settings_decoder_compatibility)
}
}
+internal fun formatSurfaceModeLabel(
+ mode: com.streamvault.domain.model.PlayerSurfaceMode,
+ context: android.content.Context
+): String = when (mode) {
+ com.streamvault.domain.model.PlayerSurfaceMode.AUTO -> context.getString(R.string.settings_surface_auto)
+ com.streamvault.domain.model.PlayerSurfaceMode.SURFACE_VIEW -> context.getString(R.string.settings_surface_surface_view)
+ com.streamvault.domain.model.PlayerSurfaceMode.TEXTURE_VIEW -> context.getString(R.string.settings_surface_texture_view)
+}
+
internal fun formatTimeoutSecondsLabel(seconds: Int, context: android.content.Context): String {
return context.resources.getQuantityString(
R.plurals.settings_timeout_seconds,
@@ -1476,7 +1596,8 @@ internal fun formatSpeedTestValueLabel(speedTest: InternetSpeedTestUiModel): Str
internal fun formatSpeedTestSummary(
speedTest: InternetSpeedTestUiModel,
- context: android.content.Context
+ context: android.content.Context,
+ dateTimeFormat: DateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT)
): String {
val transportLabel = when (speedTest.transportLabel) {
InternetSpeedTestTransport.WIFI.name -> context.getString(R.string.settings_speed_test_transport_wifi)
@@ -1485,7 +1606,7 @@ internal fun formatSpeedTestSummary(
InternetSpeedTestTransport.OTHER.name -> context.getString(R.string.settings_speed_test_transport_other)
else -> context.getString(R.string.settings_speed_test_transport_unknown)
}
- val measuredAtLabel = formatTimestamp(speedTest.measuredAtMs)
+ val measuredAtLabel = formatTimestamp(speedTest.measuredAtMs, dateTimeFormat)
return if (speedTest.isEstimated) {
context.getString(R.string.settings_speed_test_summary_estimated, transportLabel, measuredAtLabel)
} else {
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsEpgSection.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsEpgSection.kt
index 719a9bea..90f6b8d3 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsEpgSection.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsEpgSection.kt
@@ -74,7 +74,7 @@ internal fun LazyListScope.epgSourcesSection(
)
}
} else {
- items(epgSources, key = { it.id }) { source ->
+ items(epgSources, key = { source -> "epg-source-${source.id}" }) { source ->
Box(
modifier = Modifier
.fillMaxWidth()
@@ -192,7 +192,7 @@ internal fun LazyListScope.epgSourcesSection(
modifier = Modifier.padding(bottom = 8.dp)
)
}
- items(providers, key = { it.id }) { provider ->
+ items(providers, key = { provider -> "epg-provider-${provider.id}" }) { provider ->
val assignments = uiState.epgSourceAssignments[provider.id].orEmpty()
val resolutionSummary = uiState.epgResolutionSummaries[provider.id]
val assignedSourceIds = assignments.map { it.epgSourceId }.toSet()
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderComponents.kt
index 11077ec4..dc493082 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderComponents.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsProviderComponents.kt
@@ -44,12 +44,15 @@ import com.streamvault.app.ui.interaction.TvButton
import com.streamvault.app.ui.interaction.TvClickableSurface
import com.streamvault.app.ui.interaction.mouseClickable
import com.streamvault.app.ui.theme.*
+import com.streamvault.app.ui.time.LocalAppTimeFormat
+import com.streamvault.app.ui.time.createDateTimeFormat
import com.streamvault.domain.model.ActiveLiveSource
import com.streamvault.domain.model.CombinedM3uProfile
import com.streamvault.domain.model.Provider
import com.streamvault.domain.model.ProviderStatus
import com.streamvault.domain.model.ProviderType
import kotlinx.coroutines.launch
+import java.text.DateFormat
import java.util.Locale
@Composable
@@ -1222,6 +1225,8 @@ private fun ProviderDiagnosticsPanel(
@Composable
private fun DatabaseMaintenancePanel(report: DatabaseMaintenanceUiModel) {
+ val appTimeFormat = LocalAppTimeFormat.current
+ val dateTimeFormat = remember(appTimeFormat) { appTimeFormat.createDateTimeFormat() }
Column(
modifier = Modifier
.fillMaxWidth()
@@ -1235,7 +1240,7 @@ private fun DatabaseMaintenancePanel(report: DatabaseMaintenanceUiModel) {
color = Primary
)
Text(
- text = "Last maintenance ${formatDiagnosticTimestamp(report.ranAt)}",
+ text = "Last maintenance ${formatDiagnosticTimestamp(report.ranAt, dateTimeFormat)}",
style = MaterialTheme.typography.bodySmall,
color = OnSurface
)
@@ -1305,7 +1310,9 @@ private fun ProviderDiagnosticPill(
count: Int,
timestamp: Long
) {
- val syncLabel = remember(timestamp) { formatDiagnosticTimestamp(timestamp) }
+ val appTimeFormat = LocalAppTimeFormat.current
+ val dateTimeFormat = remember(appTimeFormat) { appTimeFormat.createDateTimeFormat() }
+ val syncLabel = remember(timestamp, dateTimeFormat) { formatDiagnosticTimestamp(timestamp, dateTimeFormat) }
Surface(
shape = RoundedCornerShape(10.dp),
colors = SurfaceDefaults.colors(
@@ -1369,11 +1376,11 @@ private fun ProviderDiagnosticsUiModel.healthSummary(providerType: ProviderType)
return warnings.joinToString(" • ")
}
-private fun formatDiagnosticTimestamp(timestamp: Long): String? =
+private fun formatDiagnosticTimestamp(timestamp: Long, dateTimeFormat: DateFormat): String? =
if (timestamp <= 0L) {
null
} else {
- java.text.SimpleDateFormat("MMM d, HH:mm", java.util.Locale.getDefault()).format(java.util.Date(timestamp))
+ dateTimeFormat.format(java.util.Date(timestamp))
}
private fun formatMaintenanceBytes(bytes: Long): String {
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingComponents.kt
index d39698e0..9e66b94f 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingComponents.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsRecordingComponents.kt
@@ -44,6 +44,8 @@ import com.streamvault.app.ui.design.FocusSpec
import com.streamvault.app.ui.interaction.TvClickableSurface
import com.streamvault.app.ui.interaction.mouseClickable
import com.streamvault.app.ui.theme.*
+import com.streamvault.app.ui.time.LocalAppTimeFormat
+import com.streamvault.app.ui.time.createDateTimeFormat
import com.streamvault.domain.manager.BackupConflictStrategy
import com.streamvault.domain.manager.BackupImportPlan
import com.streamvault.domain.manager.BackupPreview
@@ -946,6 +948,8 @@ private fun RecordingDetailPanel(
onToggleSchedule: (Boolean) -> Unit
) {
val accent = recordingStatusAccent(item.status)
+ val appTimeFormat = LocalAppTimeFormat.current
+ val dateTimeFormat = remember(appTimeFormat) { appTimeFormat.createDateTimeFormat() }
Surface(
modifier = modifier,
colors = SurfaceDefaults.colors(containerColor = SurfaceElevated),
@@ -997,8 +1001,8 @@ private fun RecordingDetailPanel(
Text(
text = stringResource(
R.string.settings_recording_time_window,
- formatTimestamp(item.scheduledStartMs),
- formatTimestamp(item.scheduledEndMs)
+ formatTimestamp(item.scheduledStartMs, dateTimeFormat),
+ formatTimestamp(item.scheduledEndMs, dateTimeFormat)
),
style = MaterialTheme.typography.bodySmall,
color = OnSurface
@@ -1182,10 +1186,12 @@ private fun recordingDisplaySubtitle(item: RecordingItem): String? {
@Composable
private fun recordingListSecondaryLine(item: RecordingItem): String {
val subtitle = recordingDisplaySubtitle(item)
+ val appTimeFormat = LocalAppTimeFormat.current
+ val dateTimeFormat = remember(appTimeFormat) { appTimeFormat.createDateTimeFormat() }
return subtitle ?: stringResource(
R.string.settings_recording_time_window,
- formatTimestamp(item.scheduledStartMs),
- formatTimestamp(item.scheduledEndMs)
+ formatTimestamp(item.scheduledStartMs, dateTimeFormat),
+ formatTimestamp(item.scheduledEndMs, dateTimeFormat)
)
}
@@ -1272,11 +1278,13 @@ internal fun RecordingItemCard(
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
+ val appTimeFormat = LocalAppTimeFormat.current
+ val dateTimeFormat = remember(appTimeFormat) { appTimeFormat.createDateTimeFormat() }
Text(
text = stringResource(
R.string.settings_recording_time_window,
- formatTimestamp(item.scheduledStartMs),
- formatTimestamp(item.scheduledEndMs)
+ formatTimestamp(item.scheduledStartMs, dateTimeFormat),
+ formatTimestamp(item.scheduledEndMs, dateTimeFormat)
),
style = MaterialTheme.typography.labelSmall,
color = OnSurface,
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt
index ce39f53c..4f7f70bb 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreen.kt
@@ -53,6 +53,7 @@ import androidx.documentfile.provider.DocumentFile
import com.streamvault.app.ui.interaction.TvClickableSurface
import com.streamvault.app.ui.interaction.TvButton
import com.streamvault.app.ui.interaction.TvIconButton
+import com.streamvault.app.ui.time.createDateTimeFormat
import com.streamvault.app.util.OfficialBuildStatus
import com.streamvault.app.util.OfficialBuildVerifier
@@ -76,6 +77,7 @@ import com.streamvault.domain.model.ChannelNumberingMode
import com.streamvault.domain.model.ContentType
import com.streamvault.domain.model.DecoderMode
import com.streamvault.domain.model.ActiveLiveSource
+import com.streamvault.domain.model.AppTimeFormat
import com.streamvault.domain.model.CombinedM3uProfile
import com.streamvault.domain.model.GroupedChannelLabelMode
import com.streamvault.domain.model.LiveChannelGroupingMode
@@ -129,15 +131,25 @@ fun SettingsScreen(
val appLanguageLabel = remember(uiState.appLanguage, context) {
displayLanguageLabel(uiState.appLanguage, context.getString(R.string.settings_system_default))
}
+ val timeFormatLabel = remember(uiState.appTimeFormat, context) {
+ formatAppTimeFormatLabel(uiState.appTimeFormat, context)
+ }
+ val dateTimeFormat = remember(uiState.appTimeFormat) { uiState.appTimeFormat.createDateTimeFormat() }
val preferredAudioLanguageLabel = remember(uiState.preferredAudioLanguage, context) {
displayLanguageLabel(uiState.preferredAudioLanguage, context.getString(R.string.settings_audio_language_auto))
}
val playbackSpeedLabel = remember(uiState.playerPlaybackSpeed) {
formatPlaybackSpeedLabel(uiState.playerPlaybackSpeed)
}
+ val audioVideoOffsetLabel = remember(uiState.playerAudioVideoOffsetMs) {
+ formatAudioVideoOffsetLabel(uiState.playerAudioVideoOffsetMs)
+ }
val decoderModeLabel = remember(uiState.playerDecoderMode, context) {
formatDecoderModeLabel(uiState.playerDecoderMode, context)
}
+ val surfaceModeLabel = remember(uiState.playerSurfaceMode, context) {
+ formatSurfaceModeLabel(uiState.playerSurfaceMode, context)
+ }
val controlsTimeoutLabel = remember(uiState.playerControlsTimeoutSeconds, context) {
formatTimeoutSecondsLabel(uiState.playerControlsTimeoutSeconds, context)
}
@@ -168,12 +180,18 @@ fun SettingsScreen(
val timeshiftDepthLabel = remember(uiState.playerTimeshiftDepthMinutes, context) {
formatTimeshiftDepthLabel(uiState.playerTimeshiftDepthMinutes, context)
}
+ val defaultStopTimerLabel = remember(uiState.defaultStopPlaybackTimerMinutes, context) {
+ formatPlaybackTimerMinutesLabel(uiState.defaultStopPlaybackTimerMinutes, context)
+ }
+ val defaultIdleTimerLabel = remember(uiState.defaultIdleStandbyTimerMinutes, context) {
+ formatPlaybackTimerMinutesLabel(uiState.defaultIdleStandbyTimerMinutes, context)
+ }
val lastSpeedTestLabel = remember(uiState.lastSpeedTest) {
uiState.lastSpeedTest?.let(::formatSpeedTestValueLabel)
?: context.getString(R.string.settings_speed_test_not_run)
}
- val lastSpeedTestSummary = remember(uiState.lastSpeedTest, context) {
- uiState.lastSpeedTest?.let { formatSpeedTestSummary(it, context) }
+ val lastSpeedTestSummary = remember(uiState.lastSpeedTest, context, dateTimeFormat) {
+ uiState.lastSpeedTest?.let { formatSpeedTestSummary(it, context, dateTimeFormat) }
?: context.getString(R.string.settings_speed_test_summary_default)
}
val speedTestRecommendationLabel = remember(uiState.lastSpeedTest, context) {
@@ -206,6 +224,7 @@ fun SettingsScreen(
var showPinDialog by rememberSaveable { mutableStateOf(false) }
var showLevelDialog by rememberSaveable { mutableStateOf(false) }
var showLanguageDialog by rememberSaveable { mutableStateOf(false) }
+ var showTimeFormatDialog by rememberSaveable { mutableStateOf(false) }
var showLiveTvModeDialog by rememberSaveable { mutableStateOf(false) }
var showLiveTvQuickFilterVisibilityDialog by rememberSaveable { mutableStateOf(false) }
var showLiveChannelNumberingDialog by rememberSaveable { mutableStateOf(false) }
@@ -215,8 +234,12 @@ fun SettingsScreen(
var showVodViewModeDialog by rememberSaveable { mutableStateOf(false) }
var showGuideDefaultCategoryDialog by rememberSaveable { mutableStateOf(false) }
var showPlaybackSpeedDialog by rememberSaveable { mutableStateOf(false) }
+ var showAudioVideoOffsetDialog by rememberSaveable { mutableStateOf(false) }
var showDecoderModeDialog by rememberSaveable { mutableStateOf(false) }
+ var showSurfaceModeDialog by rememberSaveable { mutableStateOf(false) }
var showTimeshiftDepthDialog by rememberSaveable { mutableStateOf(false) }
+ var showDefaultStopTimerDialog by rememberSaveable { mutableStateOf(false) }
+ var showDefaultIdleTimerDialog by rememberSaveable { mutableStateOf(false) }
var showControlsTimeoutDialog by rememberSaveable { mutableStateOf(false) }
var showLiveOverlayTimeoutDialog by rememberSaveable { mutableStateOf(false) }
var showNoticeTimeoutDialog by rememberSaveable { mutableStateOf(false) }
@@ -465,6 +488,29 @@ fun SettingsScreen(
}
}
HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
+ TvClickableSurface(
+ onClick = { viewModel.setAutoPlayNextEpisode(!uiState.autoPlayNextEpisode) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.15f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = stringResource(R.string.settings_auto_play_next_episode), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(text = stringResource(R.string.settings_auto_play_next_episode_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
+ }
+ Switch(checked = uiState.autoPlayNextEpisode, onCheckedChange = { viewModel.setAutoPlayNextEpisode(it) })
+ }
+ }
+ HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
TvClickableSurface(
onClick = { viewModel.setPlayerMediaSessionEnabled(!uiState.playerMediaSessionEnabled) },
shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
@@ -554,12 +600,32 @@ fun SettingsScreen(
value = decoderModeLabel,
onClick = { showDecoderModeDialog = true }
)
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_surface_mode),
+ value = surfaceModeLabel,
+ onClick = { showSurfaceModeDialog = true }
+ )
HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
ClickableSettingsRow(
label = stringResource(R.string.settings_default_playback_speed),
value = playbackSpeedLabel,
onClick = { showPlaybackSpeedDialog = true }
)
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_default_stop_timer),
+ value = defaultStopTimerLabel,
+ onClick = { showDefaultStopTimerDialog = true }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_default_idle_standby_timer),
+ value = defaultIdleTimerLabel,
+ onClick = { showDefaultIdleTimerDialog = true }
+ )
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_audio_video_sync_default),
+ value = audioVideoOffsetLabel,
+ onClick = { showAudioVideoOffsetDialog = true }
+ )
ClickableSettingsRow(
label = stringResource(R.string.settings_player_controls_timeout),
value = controlsTimeoutLabel,
@@ -739,11 +805,27 @@ fun SettingsScreen(
value = guideDefaultCategoryLabel,
onClick = { showGuideDefaultCategoryDialog = true }
)
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_time_format),
+ value = timeFormatLabel,
+ onClick = { showTimeFormatDialog = true }
+ )
ClickableSettingsRow(
label = stringResource(R.string.settings_vod_view_mode),
value = stringResource(uiState.vodViewMode.labelResId()),
onClick = { showVodViewModeDialog = true }
)
+ SwitchSettingsRow(
+ label = stringResource(R.string.settings_vod_infinite_scroll),
+ value = stringResource(
+ if (uiState.vodInfiniteScroll) R.string.settings_vod_infinite_scroll_on
+ else R.string.settings_vod_infinite_scroll_off
+ ),
+ checked = uiState.vodInfiniteScroll,
+ onCheckedChange = { viewModel.setVodInfiniteScroll(it) },
+ enabled = uiState.vodViewMode == VodViewMode.MODERN,
+ indent = 24.dp
+ )
HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
ClickableSettingsRow(
label = stringResource(R.string.settings_category_sort_live),
@@ -1165,10 +1247,18 @@ fun SettingsScreen(
onShowGuideDefaultCategoryDialogChange = { showGuideDefaultCategoryDialog = it },
showPlaybackSpeedDialog = showPlaybackSpeedDialog,
onShowPlaybackSpeedDialogChange = { showPlaybackSpeedDialog = it },
+ showAudioVideoOffsetDialog = showAudioVideoOffsetDialog,
+ onShowAudioVideoOffsetDialogChange = { showAudioVideoOffsetDialog = it },
showDecoderModeDialog = showDecoderModeDialog,
onShowDecoderModeDialogChange = { showDecoderModeDialog = it },
+ showSurfaceModeDialog = showSurfaceModeDialog,
+ onShowSurfaceModeDialogChange = { showSurfaceModeDialog = it },
showTimeshiftDepthDialog = showTimeshiftDepthDialog,
onShowTimeshiftDepthDialogChange = { showTimeshiftDepthDialog = it },
+ showDefaultStopTimerDialog = showDefaultStopTimerDialog,
+ onShowDefaultStopTimerDialogChange = { showDefaultStopTimerDialog = it },
+ showDefaultIdleTimerDialog = showDefaultIdleTimerDialog,
+ onShowDefaultIdleTimerDialogChange = { showDefaultIdleTimerDialog = it },
showControlsTimeoutDialog = showControlsTimeoutDialog,
onShowControlsTimeoutDialogChange = { showControlsTimeoutDialog = it },
showLiveOverlayTimeoutDialog = showLiveOverlayTimeoutDialog,
@@ -1205,6 +1295,8 @@ fun SettingsScreen(
onPendingProtectionLevelChange = { pendingProtectionLevel = it },
showLanguageDialog = showLanguageDialog,
onShowLanguageDialogChange = { showLanguageDialog = it },
+ showTimeFormatDialog = showTimeFormatDialog,
+ onShowTimeFormatDialogChange = { showTimeFormatDialog = it },
showRecordingPatternDialog = showRecordingPatternDialog,
onShowRecordingPatternDialogChange = { showRecordingPatternDialog = it },
showRecordingRetentionDialog = showRecordingRetentionDialog,
@@ -1252,6 +1344,17 @@ private fun android.content.Context.findMainActivity(): MainActivity? {
return null
}
+private fun formatAppTimeFormatLabel(
+ format: AppTimeFormat,
+ context: android.content.Context
+): String = context.getString(
+ when (format) {
+ AppTimeFormat.SYSTEM -> R.string.settings_time_format_system
+ AppTimeFormat.TWELVE_HOUR -> R.string.settings_time_format_12h
+ AppTimeFormat.TWENTY_FOUR_HOUR -> R.string.settings_time_format_24h
+ }
+)
+
private fun formatTimeshiftDepthLabel(
depthMinutes: Int,
context: android.content.Context
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenDialogs.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenDialogs.kt
index 06d61747..d7382b72 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenDialogs.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsScreenDialogs.kt
@@ -38,6 +38,7 @@ import com.streamvault.app.ui.theme.TextSecondary
import com.streamvault.domain.model.CategorySortMode
import com.streamvault.domain.model.ContentType
import com.streamvault.domain.model.DecoderMode
+import com.streamvault.domain.model.AppTimeFormat
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
@@ -65,10 +66,18 @@ internal fun SettingsScreenDialogs(
onShowGuideDefaultCategoryDialogChange: (Boolean) -> Unit,
showPlaybackSpeedDialog: Boolean,
onShowPlaybackSpeedDialogChange: (Boolean) -> Unit,
+ showAudioVideoOffsetDialog: Boolean,
+ onShowAudioVideoOffsetDialogChange: (Boolean) -> Unit,
showDecoderModeDialog: Boolean,
onShowDecoderModeDialogChange: (Boolean) -> Unit,
+ showSurfaceModeDialog: Boolean,
+ onShowSurfaceModeDialogChange: (Boolean) -> Unit,
showTimeshiftDepthDialog: Boolean,
onShowTimeshiftDepthDialogChange: (Boolean) -> Unit,
+ showDefaultStopTimerDialog: Boolean,
+ onShowDefaultStopTimerDialogChange: (Boolean) -> Unit,
+ showDefaultIdleTimerDialog: Boolean,
+ onShowDefaultIdleTimerDialogChange: (Boolean) -> Unit,
showControlsTimeoutDialog: Boolean,
onShowControlsTimeoutDialogChange: (Boolean) -> Unit,
showLiveOverlayTimeoutDialog: Boolean,
@@ -105,6 +114,8 @@ internal fun SettingsScreenDialogs(
onPendingProtectionLevelChange: (Int?) -> Unit,
showLanguageDialog: Boolean,
onShowLanguageDialogChange: (Boolean) -> Unit,
+ showTimeFormatDialog: Boolean,
+ onShowTimeFormatDialogChange: (Boolean) -> Unit,
showRecordingPatternDialog: Boolean,
onShowRecordingPatternDialogChange: (Boolean) -> Unit,
showRecordingRetentionDialog: Boolean,
@@ -253,12 +264,45 @@ internal fun SettingsScreenDialogs(
}
}
+ if (showTimeFormatDialog) {
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_select_time_format),
+ onDismiss = { onShowTimeFormatDialogChange(false) }
+ ) {
+ AppTimeFormat.entries.forEachIndexed { index, format ->
+ LevelOption(
+ level = index,
+ text = context.getString(format.labelResId()),
+ currentLevel = if (uiState.appTimeFormat == format) index else -1,
+ onSelect = {
+ viewModel.setAppTimeFormat(format)
+ onShowTimeFormatDialogChange(false)
+ }
+ )
+ }
+ }
+ }
+
+ if (showAudioVideoOffsetDialog) {
+ AudioVideoOffsetValueDialog(
+ title = stringResource(R.string.settings_audio_video_sync_default),
+ subtitle = stringResource(R.string.settings_audio_video_sync_default_subtitle),
+ initialValue = uiState.playerAudioVideoOffsetMs,
+ onDismiss = { onShowAudioVideoOffsetDialogChange(false) },
+ onConfirm = { offsetMs ->
+ viewModel.setPlayerAudioVideoOffsetMs(offsetMs)
+ onShowAudioVideoOffsetDialogChange(false)
+ }
+ )
+ }
+
if (showDecoderModeDialog) {
val decoderOptions = remember(context) {
listOf(
DecoderMode.AUTO to context.getString(R.string.settings_decoder_auto),
DecoderMode.HARDWARE to context.getString(R.string.settings_decoder_hardware),
- DecoderMode.SOFTWARE to context.getString(R.string.settings_decoder_software)
+ DecoderMode.SOFTWARE to context.getString(R.string.settings_decoder_software),
+ DecoderMode.COMPATIBILITY to context.getString(R.string.settings_decoder_compatibility)
)
}
PremiumSelectionDialog(
@@ -279,6 +323,32 @@ internal fun SettingsScreenDialogs(
}
}
+ if (showSurfaceModeDialog) {
+ val surfaceOptions = remember(context) {
+ listOf(
+ com.streamvault.domain.model.PlayerSurfaceMode.AUTO to context.getString(R.string.settings_surface_auto),
+ com.streamvault.domain.model.PlayerSurfaceMode.SURFACE_VIEW to context.getString(R.string.settings_surface_surface_view),
+ com.streamvault.domain.model.PlayerSurfaceMode.TEXTURE_VIEW to context.getString(R.string.settings_surface_texture_view)
+ )
+ }
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_surface_mode),
+ onDismiss = { onShowSurfaceModeDialogChange(false) }
+ ) {
+ surfaceOptions.forEachIndexed { index, option ->
+ LevelOption(
+ level = index,
+ text = option.second,
+ currentLevel = if (uiState.playerSurfaceMode == option.first) index else -1,
+ onSelect = {
+ viewModel.setPlayerSurfaceMode(option.first)
+ onShowSurfaceModeDialogChange(false)
+ }
+ )
+ }
+ }
+ }
+
if (showControlsTimeoutDialog) {
TimeoutValueDialog(
title = stringResource(R.string.settings_player_controls_timeout),
@@ -353,6 +423,30 @@ internal fun SettingsScreenDialogs(
}
}
+ if (showDefaultStopTimerDialog) {
+ PlaybackTimerPresetDialog(
+ title = stringResource(R.string.settings_default_stop_timer),
+ selectedMinutes = uiState.defaultStopPlaybackTimerMinutes,
+ onDismiss = { onShowDefaultStopTimerDialogChange(false) },
+ onSelect = { minutes ->
+ viewModel.setDefaultStopPlaybackTimerMinutes(minutes)
+ onShowDefaultStopTimerDialogChange(false)
+ }
+ )
+ }
+
+ if (showDefaultIdleTimerDialog) {
+ PlaybackTimerPresetDialog(
+ title = stringResource(R.string.settings_default_idle_standby_timer),
+ selectedMinutes = uiState.defaultIdleStandbyTimerMinutes,
+ onDismiss = { onShowDefaultIdleTimerDialogChange(false) },
+ onSelect = { minutes ->
+ viewModel.setDefaultIdleStandbyTimerMinutes(minutes)
+ onShowDefaultIdleTimerDialogChange(false)
+ }
+ )
+ }
+
if (showLiveTvFiltersDialog) {
LiveTvQuickFiltersDialog(
filters = uiState.liveTvCategoryFilters,
@@ -848,6 +942,12 @@ internal fun SettingsScreenDialogs(
}
}
+private fun AppTimeFormat.labelResId(): Int = when (this) {
+ AppTimeFormat.SYSTEM -> R.string.settings_time_format_system
+ AppTimeFormat.TWELVE_HOUR -> R.string.settings_time_format_12h
+ AppTimeFormat.TWENTY_FOUR_HOUR -> R.string.settings_time_format_24h
+}
+
@Composable
private fun SyncingOverlay(
isSyncing: Boolean,
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsStateBindings.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsStateBindings.kt
index c1e27394..21801841 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsStateBindings.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsStateBindings.kt
@@ -8,6 +8,7 @@ import com.streamvault.app.ui.model.LiveTvChannelMode
import com.streamvault.app.ui.model.LiveTvQuickFilterVisibilityMode
import com.streamvault.app.ui.model.VodViewMode
import com.streamvault.data.preferences.PreferencesRepository
+import com.streamvault.domain.model.AppTimeFormat
import com.streamvault.domain.model.Category
import com.streamvault.domain.model.CategorySortMode
import com.streamvault.domain.model.ChannelNumberingMode
@@ -50,10 +51,13 @@ internal fun observeSettingsPreferenceSnapshot(
parentalControlLevel = level,
hasParentalPin = hasParentalPin,
appLanguage = "system",
+ appTimeFormat = AppTimeFormat.SYSTEM,
preferredAudioLanguage = "auto",
playerMediaSessionEnabled = true,
playerDecoderMode = DecoderMode.AUTO,
+ playerSurfaceMode = com.streamvault.domain.model.PlayerSurfaceMode.AUTO,
playerPlaybackSpeed = 1f,
+ playerAudioVideoOffsetMs = 0,
playerControlsTimeoutSeconds = 5,
playerLiveOverlayTimeoutSeconds = 4,
playerNoticeTimeoutSeconds = 6,
@@ -65,6 +69,8 @@ internal fun observeSettingsPreferenceSnapshot(
ethernetMaxVideoHeight = null,
playerTimeshiftEnabled = false,
playerTimeshiftDepthMinutes = 30,
+ defaultStopPlaybackTimerMinutes = 0,
+ defaultIdleStandbyTimerMinutes = 0,
lastSpeedTestMegabits = null,
lastSpeedTestTimestamp = null,
lastSpeedTestTransport = null,
@@ -84,10 +90,12 @@ internal fun observeSettingsPreferenceSnapshot(
groupedChannelLabelMode = GroupedChannelLabelMode.HYBRID,
liveVariantPreferenceMode = LiveVariantPreferenceMode.BALANCED,
vodViewMode = VodViewMode.MODERN,
+ vodInfiniteScroll = false,
guideDefaultCategoryId = VirtualCategoryIds.FAVORITES,
guideDefaultCategoryOptions = emptyList(),
preventStandbyDuringPlayback = true,
zapAutoRevert = true,
+ autoPlayNextEpisode = true,
autoCheckAppUpdates = true,
autoDownloadAppUpdates = false,
lastAppUpdateCheckAt = null,
@@ -100,14 +108,20 @@ internal fun observeSettingsPreferenceSnapshot(
)
}.combine(preferencesRepository.appLanguage) { snapshot, language ->
snapshot.copy(appLanguage = language)
+ }.combine(preferencesRepository.appTimeFormat) { snapshot, timeFormat ->
+ snapshot.copy(appTimeFormat = timeFormat)
}.combine(preferencesRepository.preferredAudioLanguage) { snapshot, preferredAudioLanguage ->
snapshot.copy(preferredAudioLanguage = preferredAudioLanguage ?: "auto")
}.combine(preferencesRepository.playerMediaSessionEnabled) { snapshot, mediaSessionEnabled ->
snapshot.copy(playerMediaSessionEnabled = mediaSessionEnabled)
}.combine(preferencesRepository.playerDecoderMode) { snapshot, decoderMode ->
snapshot.copy(playerDecoderMode = decoderMode)
+ }.combine(preferencesRepository.playerSurfaceMode) { snapshot, surfaceMode ->
+ snapshot.copy(playerSurfaceMode = surfaceMode)
}.combine(preferencesRepository.playerPlaybackSpeed) { snapshot, playerPlaybackSpeed ->
snapshot.copy(playerPlaybackSpeed = playerPlaybackSpeed)
+ }.combine(preferencesRepository.playerAudioVideoOffsetMs) { snapshot, playerAudioVideoOffsetMs ->
+ snapshot.copy(playerAudioVideoOffsetMs = playerAudioVideoOffsetMs)
}.combine(preferencesRepository.playerControlsTimeoutSeconds) { snapshot, timeoutSeconds ->
snapshot.copy(playerControlsTimeoutSeconds = timeoutSeconds)
}.combine(preferencesRepository.playerLiveOverlayTimeoutSeconds) { snapshot, timeoutSeconds ->
@@ -130,6 +144,10 @@ internal fun observeSettingsPreferenceSnapshot(
snapshot.copy(playerTimeshiftEnabled = enabled)
}.combine(preferencesRepository.playerTimeshiftDepthMinutes) { snapshot, depthMinutes ->
snapshot.copy(playerTimeshiftDepthMinutes = depthMinutes)
+ }.combine(preferencesRepository.defaultStopPlaybackTimerMinutes) { snapshot, minutes ->
+ snapshot.copy(defaultStopPlaybackTimerMinutes = minutes)
+ }.combine(preferencesRepository.defaultIdleStandbyTimerMinutes) { snapshot, minutes ->
+ snapshot.copy(defaultIdleStandbyTimerMinutes = minutes)
}.combine(preferencesRepository.lastSpeedTestMegabits) { snapshot, lastSpeedTestMegabits ->
snapshot.copy(lastSpeedTestMegabits = lastSpeedTestMegabits)
}.combine(preferencesRepository.lastSpeedTestTimestamp) { snapshot, lastSpeedTestTimestamp ->
@@ -170,12 +188,16 @@ internal fun observeSettingsPreferenceSnapshot(
snapshot.copy(liveVariantPreferenceMode = liveVariantPreferenceMode)
}.combine(preferencesRepository.vodViewMode) { snapshot, vodViewMode ->
snapshot.copy(vodViewMode = VodViewMode.fromStorage(vodViewMode))
+ }.combine(preferencesRepository.vodInfiniteScroll) { snapshot, vodInfiniteScroll ->
+ snapshot.copy(vodInfiniteScroll = vodInfiniteScroll)
}.combine(preferencesRepository.guideDefaultCategoryId) { snapshot, guideDefaultCategoryId ->
snapshot.copy(guideDefaultCategoryId = guideDefaultCategoryId ?: VirtualCategoryIds.FAVORITES)
}.combine(preferencesRepository.preventStandbyDuringPlayback) { snapshot, preventStandby ->
snapshot.copy(preventStandbyDuringPlayback = preventStandby)
}.combine(preferencesRepository.zapAutoRevert) { snapshot, zapAutoRevert ->
snapshot.copy(zapAutoRevert = zapAutoRevert)
+ }.combine(preferencesRepository.autoPlayNextEpisode) { snapshot, autoPlayNextEpisode ->
+ snapshot.copy(autoPlayNextEpisode = autoPlayNextEpisode)
}.combine(preferencesRepository.autoCheckAppUpdates) { snapshot, autoCheckAppUpdates ->
snapshot.copy(autoCheckAppUpdates = autoCheckAppUpdates)
}.combine(preferencesRepository.autoDownloadAppUpdates) { snapshot, autoDownloadAppUpdates ->
@@ -205,10 +227,13 @@ internal fun SettingsUiState.applyPreferenceSnapshot(snapshot: SettingsPreferenc
parentalControlLevel = snapshot.parentalControlLevel,
hasParentalPin = snapshot.hasParentalPin,
appLanguage = snapshot.appLanguage,
+ appTimeFormat = snapshot.appTimeFormat,
preferredAudioLanguage = snapshot.preferredAudioLanguage,
playerMediaSessionEnabled = snapshot.playerMediaSessionEnabled,
playerDecoderMode = snapshot.playerDecoderMode,
+ playerSurfaceMode = snapshot.playerSurfaceMode,
playerPlaybackSpeed = snapshot.playerPlaybackSpeed,
+ playerAudioVideoOffsetMs = snapshot.playerAudioVideoOffsetMs,
playerControlsTimeoutSeconds = snapshot.playerControlsTimeoutSeconds,
playerLiveOverlayTimeoutSeconds = snapshot.playerLiveOverlayTimeoutSeconds,
playerNoticeTimeoutSeconds = snapshot.playerNoticeTimeoutSeconds,
@@ -220,6 +245,8 @@ internal fun SettingsUiState.applyPreferenceSnapshot(snapshot: SettingsPreferenc
ethernetMaxVideoHeight = snapshot.ethernetMaxVideoHeight,
playerTimeshiftEnabled = snapshot.playerTimeshiftEnabled,
playerTimeshiftDepthMinutes = snapshot.playerTimeshiftDepthMinutes,
+ defaultStopPlaybackTimerMinutes = snapshot.defaultStopPlaybackTimerMinutes,
+ defaultIdleStandbyTimerMinutes = snapshot.defaultIdleStandbyTimerMinutes,
lastSpeedTest = snapshot.lastSpeedTestMegabits?.let {
InternetSpeedTestUiModel(
megabitsPerSecond = it,
@@ -243,10 +270,12 @@ internal fun SettingsUiState.applyPreferenceSnapshot(snapshot: SettingsPreferenc
groupedChannelLabelMode = snapshot.groupedChannelLabelMode,
liveVariantPreferenceMode = snapshot.liveVariantPreferenceMode,
vodViewMode = snapshot.vodViewMode,
+ vodInfiniteScroll = snapshot.vodInfiniteScroll,
guideDefaultCategoryId = snapshot.guideDefaultCategoryId,
guideDefaultCategoryOptions = guideDefaultCategoryOptions,
preventStandbyDuringPlayback = snapshot.preventStandbyDuringPlayback,
zapAutoRevert = snapshot.zapAutoRevert,
+ autoPlayNextEpisode = snapshot.autoPlayNextEpisode,
autoCheckAppUpdates = snapshot.autoCheckAppUpdates,
autoDownloadAppUpdates = snapshot.autoDownloadAppUpdates,
appUpdate = cachedAppUpdate.copy(
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.kt
index 03ef7be4..2d2d80b8 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
@@ -25,6 +25,7 @@ import com.streamvault.domain.manager.BackupPreview
import com.streamvault.domain.manager.ParentalControlManager
import com.streamvault.domain.manager.RecordingManager
import com.streamvault.domain.model.Category
+import com.streamvault.domain.model.AppTimeFormat
import com.streamvault.domain.model.CategorySortMode
import com.streamvault.domain.model.ChannelNumberingMode
import com.streamvault.domain.model.ContentType
@@ -419,18 +420,36 @@ class SettingsViewModel @Inject constructor(
}
}
+ fun setVodInfiniteScroll(enabled: Boolean) {
+ viewModelScope.launch {
+ preferencesRepository.setVodInfiniteScroll(enabled)
+ }
+ }
+
fun setGuideDefaultCategory(categoryId: Long) {
viewModelScope.launch {
preferencesRepository.setGuideDefaultCategoryId(categoryId)
}
}
+ fun setAppTimeFormat(format: AppTimeFormat) {
+ viewModelScope.launch {
+ preferencesRepository.setAppTimeFormat(format)
+ }
+ }
+
fun setPreventStandbyDuringPlayback(prevent: Boolean) {
viewModelScope.launch {
preferencesRepository.setPreventStandbyDuringPlayback(prevent)
}
}
+ fun setAutoPlayNextEpisode(enabled: Boolean) {
+ viewModelScope.launch {
+ preferencesRepository.setAutoPlayNextEpisode(enabled)
+ }
+ }
+
fun setAutoCheckAppUpdates(enabled: Boolean) {
viewModelScope.launch {
preferencesRepository.setAutoCheckAppUpdates(enabled)
@@ -491,6 +510,12 @@ class SettingsViewModel @Inject constructor(
}
}
+ fun setPlayerAudioVideoOffsetMs(offsetMs: Int) {
+ viewModelScope.launch {
+ preferencesRepository.setPlayerAudioVideoOffsetMs(offsetMs)
+ }
+ }
+
fun setPlayerMediaSessionEnabled(enabled: Boolean) {
viewModelScope.launch {
preferencesRepository.setPlayerMediaSessionEnabled(enabled)
@@ -509,6 +534,18 @@ class SettingsViewModel @Inject constructor(
}
}
+ fun setDefaultStopPlaybackTimerMinutes(minutes: Int) {
+ viewModelScope.launch {
+ preferencesRepository.setDefaultStopPlaybackTimerMinutes(minutes)
+ }
+ }
+
+ fun setDefaultIdleStandbyTimerMinutes(minutes: Int) {
+ viewModelScope.launch {
+ preferencesRepository.setDefaultIdleStandbyTimerMinutes(minutes)
+ }
+ }
+
fun setZapAutoRevert(enabled: Boolean) {
viewModelScope.launch {
preferencesRepository.setZapAutoRevert(enabled)
@@ -539,6 +576,12 @@ class SettingsViewModel @Inject constructor(
}
}
+ fun setPlayerSurfaceMode(mode: com.streamvault.domain.model.PlayerSurfaceMode) {
+ viewModelScope.launch {
+ preferencesRepository.setPlayerSurfaceMode(mode)
+ }
+ }
+
fun setPlayerControlsTimeoutSeconds(seconds: Int) {
viewModelScope.launch {
preferencesRepository.setPlayerControlsTimeoutSeconds(seconds)
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsViewModelModels.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsViewModelModels.kt
index 7645c486..ee259be4 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsViewModelModels.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsViewModelModels.kt
@@ -13,6 +13,7 @@ import com.streamvault.data.preferences.DatabaseMaintenanceSnapshot
import com.streamvault.domain.manager.BackupImportPlan
import com.streamvault.domain.manager.BackupPreview
import com.streamvault.domain.model.ActiveLiveSource
+import com.streamvault.domain.model.AppTimeFormat
import com.streamvault.domain.model.Category
import com.streamvault.domain.model.CategorySortMode
import com.streamvault.domain.model.ChannelNumberingMode
@@ -23,6 +24,7 @@ import com.streamvault.domain.model.EpgResolutionSummary
import com.streamvault.domain.model.GroupedChannelLabelMode
import com.streamvault.domain.model.LiveChannelGroupingMode
import com.streamvault.domain.model.LiveVariantPreferenceMode
+import com.streamvault.domain.model.PlayerSurfaceMode
import com.streamvault.domain.model.Provider
import com.streamvault.domain.model.RecordingItem
import com.streamvault.domain.model.RecordingStorageState
@@ -50,10 +52,13 @@ internal data class SettingsPreferenceSnapshot(
val parentalControlLevel: Int,
val hasParentalPin: Boolean,
val appLanguage: String,
+ val appTimeFormat: AppTimeFormat,
val preferredAudioLanguage: String,
val playerMediaSessionEnabled: Boolean,
val playerDecoderMode: DecoderMode,
+ val playerSurfaceMode: PlayerSurfaceMode,
val playerPlaybackSpeed: Float,
+ val playerAudioVideoOffsetMs: Int,
val playerControlsTimeoutSeconds: Int,
val playerLiveOverlayTimeoutSeconds: Int,
val playerNoticeTimeoutSeconds: Int,
@@ -65,6 +70,8 @@ internal data class SettingsPreferenceSnapshot(
val ethernetMaxVideoHeight: Int?,
val playerTimeshiftEnabled: Boolean,
val playerTimeshiftDepthMinutes: Int,
+ val defaultStopPlaybackTimerMinutes: Int,
+ val defaultIdleStandbyTimerMinutes: Int,
val lastSpeedTestMegabits: Double?,
val lastSpeedTestTimestamp: Long?,
val lastSpeedTestTransport: String?,
@@ -84,10 +91,12 @@ internal data class SettingsPreferenceSnapshot(
val groupedChannelLabelMode: GroupedChannelLabelMode,
val liveVariantPreferenceMode: LiveVariantPreferenceMode,
val vodViewMode: VodViewMode,
+ val vodInfiniteScroll: Boolean,
val guideDefaultCategoryId: Long,
val guideDefaultCategoryOptions: List<Category>,
val preventStandbyDuringPlayback: Boolean,
val zapAutoRevert: Boolean,
+ val autoPlayNextEpisode: Boolean,
val autoCheckAppUpdates: Boolean,
val autoDownloadAppUpdates: Boolean,
val lastAppUpdateCheckAt: Long?,
@@ -206,10 +215,13 @@ data class SettingsUiState(
val parentalControlLevel: Int = 0,
val hasParentalPin: Boolean = false,
val appLanguage: String = "system",
+ val appTimeFormat: AppTimeFormat = AppTimeFormat.SYSTEM,
val preferredAudioLanguage: String = "auto",
val playerMediaSessionEnabled: Boolean = true,
val playerDecoderMode: DecoderMode = DecoderMode.AUTO,
+ val playerSurfaceMode: PlayerSurfaceMode = PlayerSurfaceMode.AUTO,
val playerPlaybackSpeed: Float = 1f,
+ val playerAudioVideoOffsetMs: Int = 0,
val playerControlsTimeoutSeconds: Int = 5,
val playerLiveOverlayTimeoutSeconds: Int = 4,
val playerNoticeTimeoutSeconds: Int = 6,
@@ -221,6 +233,8 @@ data class SettingsUiState(
val ethernetMaxVideoHeight: Int? = null,
val playerTimeshiftEnabled: Boolean = false,
val playerTimeshiftDepthMinutes: Int = 30,
+ val defaultStopPlaybackTimerMinutes: Int = 0,
+ val defaultIdleStandbyTimerMinutes: Int = 0,
val lastSpeedTest: InternetSpeedTestUiModel? = null,
val isRunningInternetSpeedTest: Boolean = false,
val backupPreview: BackupPreview? = null,
@@ -245,10 +259,12 @@ data class SettingsUiState(
val groupedChannelLabelMode: GroupedChannelLabelMode = GroupedChannelLabelMode.HYBRID,
val liveVariantPreferenceMode: LiveVariantPreferenceMode = LiveVariantPreferenceMode.BALANCED,
val vodViewMode: VodViewMode = VodViewMode.MODERN,
+ val vodInfiniteScroll: Boolean = false,
val guideDefaultCategoryId: Long = com.streamvault.domain.model.VirtualCategoryIds.FAVORITES,
val guideDefaultCategoryOptions: List<Category> = emptyList(),
val preventStandbyDuringPlayback: Boolean = true,
val zapAutoRevert: Boolean = true,
+ val autoPlayNextEpisode: Boolean = true,
val categorySortModes: Map<ContentType, CategorySortMode> = emptyMap(),
val hiddenCategories: List<Category> = emptyList(),
val epgSources: List<com.streamvault.domain.model.EpgSource> = emptyList(),
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/vod/VodCatalogBuilders.kt b/app/src/main/java/com/streamvault/app/ui/screens/vod/VodCatalogBuilders.kt
index a740e8ea..0c3ed967 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/vod/VodCatalogBuilders.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/vod/VodCatalogBuilders.kt
@@ -82,12 +82,16 @@ suspend fun <Item> buildVodPreviewCatalog(
}
}
+ val requestedProviderCategoryIds = providerPreviews.keys.filterNotNull().toSet()
+ providerCategories.forEach { category ->
+ countMap[category.name] = providerCategoryCounts[category.id] ?: providerPreviews[category.id]?.size ?: 0
+ }
providerCategories
+ .filter { category -> category.id in requestedProviderCategoryIds }
.forEach { category ->
val preview = providerPreviews[category.id].orEmpty()
.let { items -> markVodFavorites(items, globalFavoriteIds, itemId, copyWithFavorite) }
previewRows[category.name] = preview
- countMap[category.name] = providerCategoryCounts[category.id] ?: preview.size
}
return VodCatalogSnapshot(
diff --git a/app/src/main/java/com/streamvault/app/ui/time/AppTimeFormatters.kt b/app/src/main/java/com/streamvault/app/ui/time/AppTimeFormatters.kt
new file mode 100644
index 00000000..b32c6712
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/ui/time/AppTimeFormatters.kt
@@ -0,0 +1,29 @@
+package com.streamvault.app.ui.time
+
+import androidx.compose.runtime.compositionLocalOf
+import com.streamvault.domain.model.AppTimeFormat
+import java.text.DateFormat
+import java.text.SimpleDateFormat
+import java.time.format.DateTimeFormatter
+import java.time.format.FormatStyle
+import java.util.Locale
+
+val LocalAppTimeFormat = compositionLocalOf { AppTimeFormat.SYSTEM }
+
+fun AppTimeFormat.createTimeFormat(locale: Locale = Locale.getDefault()): DateFormat = when (this) {
+ AppTimeFormat.SYSTEM -> DateFormat.getTimeInstance(DateFormat.SHORT, locale)
+ AppTimeFormat.TWELVE_HOUR -> SimpleDateFormat("h:mm a", locale)
+ AppTimeFormat.TWENTY_FOUR_HOUR -> SimpleDateFormat("HH:mm", locale)
+}
+
+fun AppTimeFormat.createDateTimeFormat(locale: Locale = Locale.getDefault()): DateFormat = when (this) {
+ AppTimeFormat.SYSTEM -> DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, locale)
+ AppTimeFormat.TWELVE_HOUR -> SimpleDateFormat("MMM d, h:mm a", locale)
+ AppTimeFormat.TWENTY_FOUR_HOUR -> SimpleDateFormat("MMM d, HH:mm", locale)
+}
+
+fun AppTimeFormat.createTimeFormatter(locale: Locale = Locale.getDefault()): DateTimeFormatter = when (this) {
+ AppTimeFormat.SYSTEM -> DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT).withLocale(locale)
+ AppTimeFormat.TWELVE_HOUR -> DateTimeFormatter.ofPattern("h:mm a", locale)
+ AppTimeFormat.TWENTY_FOUR_HOUR -> DateTimeFormatter.ofPattern("HH:mm", locale)
+}
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b200c2d4..c5fd437b 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -368,7 +368,14 @@
<string name="settings_guide_default_category">Guide default category</string>
<string name="settings_select_guide_default_category">Select guide default category</string>
<string name="settings_guide_default_category_fallback">All Channels</string>
+ <string name="settings_time_format">Time Format</string>
+ <string name="settings_select_time_format">Select time format</string>
+ <string name="settings_time_format_system">System Default</string>
+ <string name="settings_time_format_12h">12-hour (9:44 PM)</string>
+ <string name="settings_time_format_24h">24-hour (21:44)</string>
<string name="settings_default_playback_speed">Default Playback Speed</string>
+ <string name="settings_audio_video_sync_default">A/V Sync Default</string>
+ <string name="settings_audio_video_sync_default_subtitle">Positive values delay audio relative to video.</string>
<string name="settings_media_session">System Media Session</string>
<string name="settings_media_session_subtitle">Expose playback to Android system media controls. Disable this if playback crashes on a specific device when opening the player.</string>
<string name="settings_live_timeshift">Enable Local Live Rewind</string>
@@ -464,6 +471,9 @@
<string name="settings_vod_view_mode_modern_desc">Shelf-based browsing with featured rows and category previews.</string>
<string name="settings_vod_view_mode_classic">Classic</string>
<string name="settings_vod_view_mode_classic_desc">Category list on the left with a stacked poster grid on the right.</string>
+ <string name="settings_vod_infinite_scroll">Infinite scroll</string>
+ <string name="settings_vod_infinite_scroll_on">Auto-load more category rows as you scroll near the end.</string>
+ <string name="settings_vod_infinite_scroll_off">Show a Load more button to fetch the next batch of category rows.</string>
<string name="vod_classic_categories_title">Categories</string>
<string name="vod_classic_category_search">Search in categories</string>
<string name="vod_classic_all">All</string>
@@ -474,7 +484,12 @@
<string name="settings_decoder_mode">Decoder Mode</string>
<string name="settings_decoder_auto">Auto (HW preferred)</string>
<string name="settings_decoder_hardware">Hardware Only</string>
- <string name="settings_decoder_software">Prefer Software Extensions</string>
+ <string name="settings_decoder_software">Prefer Software Decoder</string>
+ <string name="settings_decoder_compatibility">Compatibility Mode</string>
+ <string name="settings_surface_mode">Video Surface</string>
+ <string name="settings_surface_auto">Auto</string>
+ <string name="settings_surface_surface_view">SurfaceView</string>
+ <string name="settings_surface_texture_view">TextureView</string>
<string name="settings_select_decoder_mode">Select Decoder Mode</string>
<string name="settings_buffer_duration">Buffer Duration</string>
<string name="settings_buffer_5s">5 seconds</string>
@@ -538,6 +553,7 @@
<string name="settings_level_hidden_desc">HIDDEN - Content hidden from all lists</string>
<string name="settings_level_hidden_subtitle">Adult categories not shown anywhere.</string>
<string name="settings_cancel">Cancel</string>
+ <string name="settings_reset">Reset</string>
<string name="settings_protection_level">Protection Level</string>
<string name="settings_level_off">OFF</string>
<string name="settings_level_locked">LOCKED</string>
@@ -906,6 +922,18 @@
<string name="player_play">Play</string>
<string name="player_pause">Pause</string>
<string name="player_playback_label">Playback</string>
+ <string name="player_av_sync_short">A/V Sync</string>
+ <string name="player_av_sync_title">A/V Sync</string>
+ <string name="player_av_sync_value">%1$s - %2$s</string>
+ <string name="player_av_sync_preview">Preview</string>
+ <string name="player_av_sync_channel">Channel</string>
+ <string name="player_av_sync_global">Global</string>
+ <string name="player_av_sync_minus_50">A/V sync -50 ms</string>
+ <string name="player_av_sync_plus_50">A/V sync +50 ms</string>
+ <string name="player_av_sync_reset">Reset to 0 ms</string>
+ <string name="player_av_sync_save_channel">Save for channel</string>
+ <string name="player_av_sync_save_global">Set as global</string>
+ <string name="player_av_sync_use_global">Use global</string>
<string name="player_more_controls">More controls</string>
<string name="player_live_now">Now Playing</string>
<string name="player_live_channel">Channel %1$d</string>
@@ -993,6 +1021,10 @@
<string name="player_diagnostics_provider">Provider</string>
<string name="player_diagnostics_source">Source</string>
<string name="player_diagnostics_decoder">Decoder</string>
+ <string name="player_diagnostics_active_decoder">Active Decoder</string>
+ <string name="player_diagnostics_surface">Surface</string>
+ <string name="player_diagnostics_video_stalls">Video Stalls</string>
+ <string name="player_diagnostics_last_frame">Last Video Frame</string>
<string name="player_diagnostics_stream_class">Stream Class</string>
<string name="player_diagnostics_playback_state">Playback State</string>
<string name="player_diagnostics_archive">Archive</string>
@@ -1001,6 +1033,7 @@
<string name="player_diagnostics_resolution">Resolution</string>
<string name="player_diagnostics_video_codec">Video Codec</string>
<string name="player_diagnostics_audio_codec">Audio Codec</string>
+ <string name="player_diagnostics_av_offset">A/V Offset</string>
<string name="player_diagnostics_video_bitrate">Video Bitrate</string>
<string name="player_diagnostics_dropped_frames">Dropped Frames</string>
<string name="player_diagnostics_last_failure">Last Failure</string>
@@ -1271,8 +1304,30 @@
<string name="settings_xtream_text_classification_subtitle">Use category name keywords to flag adult content when the provider doesn\'t set the adult flag explicitly</string>
<string name="settings_xtream_base64_compatibility">Xtream Base64 Text Compatibility</string>
<string name="settings_xtream_base64_compatibility_subtitle">Broadly decode Xtream names and categories when a provider stores them as Base64. Leave this off unless text looks encoded.</string>
- <string name="settings_prevent_standby">Keep Screen On During Playback</string>
- <string name="settings_prevent_standby_subtitle">Prevents the TV from showing a standby warning while a channel or video is playing</string>
+ <string name="settings_prevent_standby">Keep screen on during normal playback</string>
+ <string name="settings_prevent_standby_subtitle">Keeps the player awake normally. Sleep and idle standby timers still stop playback when they expire.</string>
+ <string name="settings_auto_play_next_episode">Auto-Play Next Episode</string>
+ <string name="settings_auto_play_next_episode_subtitle">Show a 10-second countdown and automatically advance to the next episode when one ends.</string>
+ <string name="player_up_next">Up Next</string>
+ <string name="player_auto_play_play_now">Play Now</string>
+ <string name="player_auto_play_cancel">Cancel</string>
+ <string name="player_auto_play_countdown">Playing in %1$d s</string>
+ <string name="settings_default_stop_timer">Default stop playback timer</string>
+ <string name="settings_default_idle_standby_timer">Default idle standby timer</string>
+ <string name="settings_timer_off">Off</string>
+ <plurals name="settings_timer_minutes">
+ <item quantity="one">%1$d minute</item>
+ <item quantity="other">%1$d minutes</item>
+ </plurals>
+ <string name="player_stop_playback_after">Stop Playback After</string>
+ <string name="player_idle_standby_after">Allow Standby After Idle</string>
+ <string name="player_stop_timer_status">Stop in %1$s</string>
+ <string name="player_idle_timer_status">Idle standby %1$s</string>
+ <string name="player_timer_off">Off</string>
+ <string name="player_timer_warning_stop">Playback stops in %1$s</string>
+ <string name="player_timer_warning_idle">Standby allowed in %1$s</string>
+ <string name="player_timer_extend_30">+30 min</string>
+ <string name="player_timer_disable">Disable</string>
<string name="settings_clear_history_dialog_title">Clear Watch History?</string>
<string name="settings_clear_history_dialog_body">This will permanently delete all watch history, continue watching progress, and last visited categories across all providers.</string>
diff --git a/data/schemas/com.streamvault.data.local.StreamVaultDatabase/41.json b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/41.json
new file mode 100644
index 00000000..a20be460
--- /dev/null
+++ b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/41.json
@@ -0,0 +1,4082 @@
+{
+ "formatVersion": 1,
+ "database": {
+ "version": 41,
+ "identityHash": "24487bb8174187903ca8732c577dde47",
+ "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, `stalker_mac_address` TEXT NOT NULL, `stalker_device_profile` TEXT NOT NULL, `stalker_device_timezone` TEXT NOT NULL, `stalker_device_locale` TEXT NOT NULL, `is_active` INTEGER NOT NULL, `max_connections` INTEGER NOT NULL, `expiration_date` INTEGER, `api_version` TEXT, `allowed_output_formats_json` TEXT NOT NULL, `epg_sync_mode` TEXT NOT NULL, `xtream_fast_sync_enabled` INTEGER NOT NULL, `m3u_vod_classification_enabled` INTEGER NOT NULL, `status` TEXT NOT NULL, `last_synced_at` INTEGER NOT NULL, `created_at` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "serverUrl",
+ "columnName": "server_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "username",
+ "columnName": "username",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "password",
+ "columnName": "password",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "m3uUrl",
+ "columnName": "m3u_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgUrl",
+ "columnName": "epg_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerMacAddress",
+ "columnName": "stalker_mac_address",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceProfile",
+ "columnName": "stalker_device_profile",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceTimezone",
+ "columnName": "stalker_device_timezone",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceLocale",
+ "columnName": "stalker_device_locale",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isActive",
+ "columnName": "is_active",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "maxConnections",
+ "columnName": "max_connections",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "expirationDate",
+ "columnName": "expiration_date",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "apiVersion",
+ "columnName": "api_version",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "allowedOutputFormatsJson",
+ "columnName": "allowed_output_formats_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSyncMode",
+ "columnName": "epg_sync_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xtreamFastSyncEnabled",
+ "columnName": "xtream_fast_sync_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "m3uVodClassificationEnabled",
+ "columnName": "m3u_vod_classification_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSyncedAt",
+ "columnName": "last_synced_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_providers_server_url_username_stalker_mac_address",
+ "unique": true,
+ "columnNames": [
+ "server_url",
+ "username",
+ "stalker_mac_address"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_providers_server_url_username_stalker_mac_address` ON `${TABLE_NAME}` (`server_url`, `username`, `stalker_mac_address`)"
+ }
+ ]
+ },
+ {
+ "tableName": "channels",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `logo_url` TEXT, `group_title` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `epg_channel_id` TEXT, `number` INTEGER NOT NULL, `catch_up_supported` INTEGER NOT NULL, `catch_up_days` INTEGER NOT NULL, `catchUpSource` TEXT, `provider_id` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `logical_group_id` TEXT NOT NULL, `error_count` INTEGER NOT NULL, `quality_options_json` TEXT, `sync_fingerprint` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logoUrl",
+ "columnName": "logo_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupTitle",
+ "columnName": "group_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgChannelId",
+ "columnName": "epg_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "number",
+ "columnName": "number",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSupported",
+ "columnName": "catch_up_supported",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpDays",
+ "columnName": "catch_up_days",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSource",
+ "columnName": "catchUpSource",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logicalGroupId",
+ "columnName": "logical_group_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "errorCount",
+ "columnName": "error_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "qualityOptionsJson",
+ "columnName": "quality_options_json",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channels_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_category_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id_category_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_stream_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "stream_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channels_provider_id_stream_id` ON `${TABLE_NAME}` (`provider_id`, `stream_id`)"
+ },
+ {
+ "name": "index_channels_logical_group_id",
+ "unique": false,
+ "columnNames": [
+ "logical_group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_logical_group_id` ON `${TABLE_NAME}` (`logical_group_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_category_id_logical_group_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id",
+ "logical_group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id_category_id_logical_group_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`, `logical_group_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channel_preferences",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `channel_id` INTEGER NOT NULL, `aspect_ratio` TEXT, `audio_video_offset_ms` INTEGER, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`channel_id`) REFERENCES `channels`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "aspectRatio",
+ "columnName": "aspect_ratio",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "audioVideoOffsetMs",
+ "columnName": "audio_video_offset_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_preferences_channel_id",
+ "unique": true,
+ "columnNames": [
+ "channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channel_preferences_channel_id` ON `${TABLE_NAME}` (`channel_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "channels",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "channel_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channels_fts",
+ "createSql": "CREATE VIRTUAL TABLE IF NOT EXISTS `${TABLE_NAME}` USING FTS4(`name` TEXT NOT NULL, content=`channels`)",
+ "fields": [
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": []
+ },
+ "ftsVersion": "FTS4",
+ "ftsOptions": {
+ "tokenizer": "simple",
+ "tokenizerArgs": [],
+ "contentTable": "channels",
+ "languageIdColumnName": "",
+ "matchInfo": "FTS4",
+ "notIndexedColumns": [],
+ "prefixSizes": [],
+ "preferredOrder": "ASC"
+ },
+ "contentSyncTriggers": [
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_BEFORE_UPDATE BEFORE UPDATE ON `channels` BEGIN DELETE FROM `channels_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_BEFORE_DELETE BEFORE DELETE ON `channels` BEGIN DELETE FROM `channels_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_AFTER_UPDATE AFTER UPDATE ON `channels` BEGIN INSERT INTO `channels_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_AFTER_INSERT AFTER INSERT ON `channels` BEGIN INSERT INTO `channels_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END"
+ ]
+ },
+ {
+ "tableName": "movies",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `container_extension` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `duration` TEXT, `duration_seconds` INTEGER NOT NULL, `rating` REAL NOT NULL, `year` TEXT, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `provider_id` INTEGER NOT NULL, `watch_progress` INTEGER NOT NULL, `watch_count` INTEGER NOT NULL, `last_watched_at` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, `added_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "duration",
+ "columnName": "duration",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "durationSeconds",
+ "columnName": "duration_seconds",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "year",
+ "columnName": "year",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchProgress",
+ "columnName": "watch_progress",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchCount",
+ "columnName": "watch_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastWatchedAt",
+ "columnName": "last_watched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "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, `sync_fingerprint` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "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
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "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, `sync_fingerprint` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "parentId",
+ "columnName": "parent_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_categories_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_categories_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_categories_provider_id_type",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_categories_provider_id_type` ON `${TABLE_NAME}` (`provider_id`, `type`)"
+ },
+ {
+ "name": "index_categories_provider_id_category_id_type",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "category_id",
+ "type"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_categories_provider_id_category_id_type` ON `${TABLE_NAME}` (`provider_id`, `category_id`, `type`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channel_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `logo_url` TEXT, `group_title` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `epg_channel_id` TEXT, `number` INTEGER NOT NULL, `catch_up_supported` INTEGER NOT NULL, `catch_up_days` INTEGER NOT NULL, `catchUpSource` TEXT, `is_adult` INTEGER NOT NULL, `logical_group_id` TEXT NOT NULL, `error_count` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `stream_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logoUrl",
+ "columnName": "logo_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupTitle",
+ "columnName": "group_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgChannelId",
+ "columnName": "epg_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "number",
+ "columnName": "number",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSupported",
+ "columnName": "catch_up_supported",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpDays",
+ "columnName": "catch_up_days",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSource",
+ "columnName": "catchUpSource",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logicalGroupId",
+ "columnName": "logical_group_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "errorCount",
+ "columnName": "error_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "stream_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_channel_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "movie_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `container_extension` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `duration` TEXT, `duration_seconds` INTEGER NOT NULL, `rating` REAL NOT NULL, `year` TEXT, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, `added_at` INTEGER NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `stream_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "duration",
+ "columnName": "duration",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "durationSeconds",
+ "columnName": "duration_seconds",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "year",
+ "columnName": "year",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "stream_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_movie_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_movie_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "series_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `series_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `rating` REAL NOT NULL, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `episode_run_time` TEXT, `last_modified` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `series_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "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": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "series_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_series_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_series_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "category_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `parent_id` INTEGER, `type` TEXT NOT NULL, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `category_id`, `type`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "parentId",
+ "columnName": "parent_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "category_id",
+ "type"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_category_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_category_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_category_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_category_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ },
+ {
+ "name": "index_category_import_stage_provider_id_type",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_category_import_stage_provider_id_type` ON `${TABLE_NAME}` (`provider_id`, `type`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "programs",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` TEXT NOT NULL, `title` TEXT NOT NULL, `description` TEXT NOT NULL, `start_time` INTEGER NOT NULL, `end_time` INTEGER NOT NULL, `lang` TEXT NOT NULL, `rating` TEXT, `image_url` TEXT, `genre` TEXT, `category` TEXT, `has_archive` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "startTime",
+ "columnName": "start_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "endTime",
+ "columnName": "end_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lang",
+ "columnName": "lang",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "imageUrl",
+ "columnName": "image_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "category",
+ "columnName": "category",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "hasArchive",
+ "columnName": "has_archive",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_programs_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_programs_provider_id_channel_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_channel_id` ON `${TABLE_NAME}` (`provider_id`, `channel_id`)"
+ },
+ {
+ "name": "index_programs_provider_id_end_time_channel_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "end_time",
+ "channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_end_time_channel_id` ON `${TABLE_NAME}` (`provider_id`, `end_time`, `channel_id`)"
+ },
+ {
+ "name": "index_programs_provider_id_start_time_end_time",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "start_time",
+ "end_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_start_time_end_time` ON `${TABLE_NAME}` (`provider_id`, `start_time`, `end_time`)"
+ },
+ {
+ "name": "index_programs_start_time",
+ "unique": false,
+ "columnNames": [
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_start_time` ON `${TABLE_NAME}` (`start_time`)"
+ },
+ {
+ "name": "index_programs_provider_id_channel_id_start_time",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_channel_id_start_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `start_time`)"
+ },
+ {
+ "name": "index_programs_provider_id_channel_id_start_time_end_time",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "start_time",
+ "end_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_programs_provider_id_channel_id_start_time_end_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `start_time`, `end_time`)"
+ }
+ ]
+ },
+ {
+ "tableName": "favorites",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `content_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `position` INTEGER NOT NULL, `group_id` INTEGER, `added_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`group_id`) REFERENCES `virtual_groups`(`id`) ON UPDATE NO ACTION ON DELETE SET NULL )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentId",
+ "columnName": "content_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "position",
+ "columnName": "position",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "groupId",
+ "columnName": "group_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_favorites_provider_id_content_id_content_type_group_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "content_id",
+ "content_type",
+ "group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_favorites_provider_id_content_id_content_type_group_id` ON `${TABLE_NAME}` (`provider_id`, `content_id`, `content_type`, `group_id`)"
+ },
+ {
+ "name": "index_favorites_provider_id_content_type_group_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type",
+ "group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_favorites_provider_id_content_type_group_id` ON `${TABLE_NAME}` (`provider_id`, `content_type`, `group_id`)"
+ },
+ {
+ "name": "index_favorites_group_id_position",
+ "unique": false,
+ "columnNames": [
+ "group_id",
+ "position"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_favorites_group_id_position` ON `${TABLE_NAME}` (`group_id`, `position`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "virtual_groups",
+ "onDelete": "SET NULL",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "group_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "virtual_groups",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `icon_emoji` TEXT, `position` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `content_type` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "iconEmoji",
+ "columnName": "icon_emoji",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "position",
+ "columnName": "position",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_virtual_groups_provider_id_content_type",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_virtual_groups_provider_id_content_type` ON `${TABLE_NAME}` (`provider_id`, `content_type`)"
+ },
+ {
+ "name": "index_virtual_groups_position",
+ "unique": false,
+ "columnNames": [
+ "position"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_virtual_groups_position` ON `${TABLE_NAME}` (`position`)"
+ },
+ {
+ "name": "index_virtual_groups_content_type",
+ "unique": false,
+ "columnNames": [
+ "content_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_virtual_groups_content_type` ON `${TABLE_NAME}` (`content_type`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "playback_history",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `content_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `title` TEXT NOT NULL, `poster_url` TEXT, `stream_url` TEXT NOT NULL, `resume_position_ms` INTEGER NOT NULL, `total_duration_ms` INTEGER NOT NULL, `last_watched_at` INTEGER NOT NULL, `watch_count` INTEGER NOT NULL, `watched_status` TEXT NOT NULL, `series_id` INTEGER, `season_number` INTEGER, `episode_number` INTEGER, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentId",
+ "columnName": "content_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "resumePositionMs",
+ "columnName": "resume_position_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalDurationMs",
+ "columnName": "total_duration_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastWatchedAt",
+ "columnName": "last_watched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchCount",
+ "columnName": "watch_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchedStatus",
+ "columnName": "watched_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesId",
+ "columnName": "series_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "seasonNumber",
+ "columnName": "season_number",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "episodeNumber",
+ "columnName": "episode_number",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_playback_history_content_id_content_type_provider_id",
+ "unique": true,
+ "columnNames": [
+ "content_id",
+ "content_type",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_playback_history_content_id_content_type_provider_id` ON `${TABLE_NAME}` (`content_id`, `content_type`, `provider_id`)"
+ },
+ {
+ "name": "index_playback_history_last_watched_at",
+ "unique": false,
+ "columnNames": [
+ "last_watched_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_history_last_watched_at` ON `${TABLE_NAME}` (`last_watched_at`)"
+ },
+ {
+ "name": "index_playback_history_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_history_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "tmdb_identity",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`tmdb_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `canonical_provider_id` INTEGER NOT NULL, `first_seen_at` INTEGER NOT NULL, PRIMARY KEY(`tmdb_id`, `content_type`), FOREIGN KEY(`canonical_provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "canonicalProviderId",
+ "columnName": "canonical_provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "firstSeenAt",
+ "columnName": "first_seen_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "tmdb_id",
+ "content_type"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_tmdb_identity_content_type",
+ "unique": false,
+ "columnNames": [
+ "content_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_tmdb_identity_content_type` ON `${TABLE_NAME}` (`content_type`)"
+ },
+ {
+ "name": "index_tmdb_identity_canonical_provider_id",
+ "unique": false,
+ "columnNames": [
+ "canonical_provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_tmdb_identity_canonical_provider_id` ON `${TABLE_NAME}` (`canonical_provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "canonical_provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "search_history",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `query` TEXT NOT NULL, `content_scope` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `used_at` INTEGER NOT NULL, `use_count` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "query",
+ "columnName": "query",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentScope",
+ "columnName": "content_scope",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "usedAt",
+ "columnName": "used_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "useCount",
+ "columnName": "use_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_search_history_content_scope_provider_id_used_at",
+ "unique": false,
+ "columnNames": [
+ "content_scope",
+ "provider_id",
+ "used_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_search_history_content_scope_provider_id_used_at` ON `${TABLE_NAME}` (`content_scope`, `provider_id`, `used_at`)"
+ },
+ {
+ "name": "index_search_history_used_at",
+ "unique": false,
+ "columnNames": [
+ "used_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_search_history_used_at` ON `${TABLE_NAME}` (`used_at`)"
+ },
+ {
+ "name": "index_search_history_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_search_history_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_search_history_query_content_scope_provider_id",
+ "unique": true,
+ "columnNames": [
+ "query",
+ "content_scope",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_search_history_query_content_scope_provider_id` ON `${TABLE_NAME}` (`query`, `content_scope`, `provider_id`)"
+ }
+ ]
+ },
+ {
+ "tableName": "sync_metadata",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `last_live_sync` INTEGER NOT NULL, `last_live_success` INTEGER NOT NULL, `last_movie_sync` INTEGER NOT NULL, `last_series_sync` INTEGER NOT NULL, `last_series_success` INTEGER NOT NULL, `last_epg_sync` INTEGER NOT NULL, `last_epg_success` INTEGER NOT NULL, `last_movie_attempt` INTEGER NOT NULL, `last_movie_success` INTEGER NOT NULL, `last_movie_partial` INTEGER NOT NULL, `live_count` INTEGER NOT NULL, `movie_count` INTEGER NOT NULL, `series_count` INTEGER NOT NULL, `epg_count` INTEGER NOT NULL, `last_sync_status` TEXT NOT NULL, `movie_sync_mode` TEXT NOT NULL, `movie_warnings_count` INTEGER NOT NULL, `movie_catalog_stale` INTEGER NOT NULL, `live_avoid_full_until` INTEGER NOT NULL, `movie_avoid_full_until` INTEGER NOT NULL, `series_avoid_full_until` INTEGER NOT NULL, `live_sequential_failures_remembered` INTEGER NOT NULL, `live_healthy_sync_streak` INTEGER NOT NULL, `movie_parallel_failures_remembered` INTEGER NOT NULL, `movie_healthy_sync_streak` INTEGER NOT NULL, `series_sequential_failures_remembered` INTEGER NOT NULL, `series_healthy_sync_streak` INTEGER NOT NULL, PRIMARY KEY(`provider_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastLiveSync",
+ "columnName": "last_live_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastLiveSuccess",
+ "columnName": "last_live_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMovieSync",
+ "columnName": "last_movie_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSeriesSync",
+ "columnName": "last_series_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSeriesSuccess",
+ "columnName": "last_series_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastEpgSync",
+ "columnName": "last_epg_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastEpgSuccess",
+ "columnName": "last_epg_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMovieAttempt",
+ "columnName": "last_movie_attempt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMovieSuccess",
+ "columnName": "last_movie_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMoviePartial",
+ "columnName": "last_movie_partial",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveCount",
+ "columnName": "live_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieCount",
+ "columnName": "movie_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesCount",
+ "columnName": "series_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgCount",
+ "columnName": "epg_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSyncStatus",
+ "columnName": "last_sync_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieSyncMode",
+ "columnName": "movie_sync_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieWarningsCount",
+ "columnName": "movie_warnings_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieCatalogStale",
+ "columnName": "movie_catalog_stale",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveAvoidFullUntil",
+ "columnName": "live_avoid_full_until",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieAvoidFullUntil",
+ "columnName": "movie_avoid_full_until",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesAvoidFullUntil",
+ "columnName": "series_avoid_full_until",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveSequentialFailuresRemembered",
+ "columnName": "live_sequential_failures_remembered",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveHealthySyncStreak",
+ "columnName": "live_healthy_sync_streak",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieParallelFailuresRemembered",
+ "columnName": "movie_parallel_failures_remembered",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieHealthySyncStreak",
+ "columnName": "movie_healthy_sync_streak",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesSequentialFailuresRemembered",
+ "columnName": "series_sequential_failures_remembered",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesHealthySyncStreak",
+ "columnName": "series_healthy_sync_streak",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "movie_category_hydration",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `last_hydrated_at` INTEGER NOT NULL, `item_count` INTEGER NOT NULL, `last_status` TEXT NOT NULL, `last_error` TEXT, PRIMARY KEY(`provider_id`, `category_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastHydratedAt",
+ "columnName": "last_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemCount",
+ "columnName": "item_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastStatus",
+ "columnName": "last_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_movie_category_hydration_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_category_hydration_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "series_category_hydration",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `last_hydrated_at` INTEGER NOT NULL, `item_count` INTEGER NOT NULL, `last_status` TEXT NOT NULL, `last_error` TEXT, PRIMARY KEY(`provider_id`, `category_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastHydratedAt",
+ "columnName": "last_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemCount",
+ "columnName": "item_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastStatus",
+ "columnName": "last_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_series_category_hydration_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_category_hydration_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "epg_sources",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `url` TEXT NOT NULL, `enabled` INTEGER NOT NULL, `last_refresh_at` INTEGER NOT NULL, `last_success_at` INTEGER NOT NULL, `last_error` TEXT, `priority` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, `etag` TEXT, `last_modified_header` TEXT)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "url",
+ "columnName": "url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastRefreshAt",
+ "columnName": "last_refresh_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSuccessAt",
+ "columnName": "last_success_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "etag",
+ "columnName": "etag",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastModifiedHeader",
+ "columnName": "last_modified_header",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_epg_sources_url",
+ "unique": true,
+ "columnNames": [
+ "url"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_sources_url` ON `${TABLE_NAME}` (`url`)"
+ }
+ ]
+ },
+ {
+ "tableName": "provider_epg_sources",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `epg_source_id` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_provider_epg_sources_provider_id_epg_source_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_provider_epg_sources_provider_id_epg_source_id` ON `${TABLE_NAME}` (`provider_id`, `epg_source_id`)"
+ },
+ {
+ "name": "index_provider_epg_sources_epg_source_id",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_provider_epg_sources_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "epg_sources",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "epg_source_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "epg_channels",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `epg_source_id` INTEGER NOT NULL, `xmltv_channel_id` TEXT NOT NULL, `display_name` TEXT NOT NULL, `normalized_name` TEXT NOT NULL, `icon_url` TEXT, FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "displayName",
+ "columnName": "display_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "normalizedName",
+ "columnName": "normalized_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "iconUrl",
+ "columnName": "icon_url",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_epg_channels_epg_source_id_xmltv_channel_id",
+ "unique": true,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_channels_epg_source_id_xmltv_channel_id` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`)"
+ },
+ {
+ "name": "index_epg_channels_epg_source_id",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_channels_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
+ },
+ {
+ "name": "index_epg_channels_normalized_name",
+ "unique": false,
+ "columnNames": [
+ "normalized_name"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_channels_normalized_name` ON `${TABLE_NAME}` (`normalized_name`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "epg_sources",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "epg_source_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "epg_programmes",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `epg_source_id` INTEGER NOT NULL, `xmltv_channel_id` TEXT NOT NULL, `start_time` INTEGER NOT NULL, `end_time` INTEGER NOT NULL, `title` TEXT NOT NULL, `subtitle` TEXT, `description` TEXT NOT NULL, `category` TEXT, `lang` TEXT NOT NULL, `rating` TEXT, `image_url` TEXT, `episode_info` TEXT, FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "startTime",
+ "columnName": "start_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "endTime",
+ "columnName": "end_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "subtitle",
+ "columnName": "subtitle",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "category",
+ "columnName": "category",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lang",
+ "columnName": "lang",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "imageUrl",
+ "columnName": "image_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "episodeInfo",
+ "columnName": "episode_info",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_epg_programmes_epg_source_id_xmltv_channel_id_start_time",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id",
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id_xmltv_channel_id_start_time` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`, `start_time`)"
+ },
+ {
+ "name": "index_epg_programmes_epg_source_id_xmltv_channel_id_start_time_end_time",
+ "unique": true,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id",
+ "start_time",
+ "end_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id_xmltv_channel_id_start_time_end_time` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`, `start_time`, `end_time`)"
+ },
+ {
+ "name": "index_epg_programmes_epg_source_id",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
+ },
+ {
+ "name": "index_epg_programmes_start_time",
+ "unique": false,
+ "columnNames": [
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_start_time` ON `${TABLE_NAME}` (`start_time`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "epg_sources",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "epg_source_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channel_epg_mappings",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_channel_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `source_type` TEXT NOT NULL, `epg_source_id` INTEGER, `xmltv_channel_id` TEXT, `match_type` TEXT, `confidence` REAL NOT NULL, `matched_at` INTEGER NOT NULL, `failed_attempts` INTEGER NOT NULL, `source` TEXT, `is_manual_override` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerChannelId",
+ "columnName": "provider_channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sourceType",
+ "columnName": "source_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "matchType",
+ "columnName": "match_type",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "confidence",
+ "columnName": "confidence",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "matchedAt",
+ "columnName": "matched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failedAttempts",
+ "columnName": "failed_attempts",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "source",
+ "columnName": "source",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isManualOverride",
+ "columnName": "is_manual_override",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_epg_mappings_provider_id_provider_channel_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "provider_channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channel_epg_mappings_provider_id_provider_channel_id` ON `${TABLE_NAME}` (`provider_id`, `provider_channel_id`)"
+ },
+ {
+ "name": "index_channel_epg_mappings_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_epg_mappings_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "combined_m3u_profiles",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `enabled` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ }
+ },
+ {
+ "tableName": "combined_m3u_profile_members",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `profile_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, FOREIGN KEY(`profile_id`) REFERENCES `combined_m3u_profiles`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profileId",
+ "columnName": "profile_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_combined_m3u_profile_members_profile_id",
+ "unique": false,
+ "columnNames": [
+ "profile_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_profile_id` ON `${TABLE_NAME}` (`profile_id`)"
+ },
+ {
+ "name": "index_combined_m3u_profile_members_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_combined_m3u_profile_members_profile_id_provider_id",
+ "unique": true,
+ "columnNames": [
+ "profile_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_profile_id_provider_id` ON `${TABLE_NAME}` (`profile_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "combined_m3u_profiles",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "profile_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_schedules",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` INTEGER NOT NULL, `channel_name` TEXT NOT NULL, `stream_url` TEXT NOT NULL, `program_title` TEXT, `requested_start_ms` INTEGER NOT NULL, `requested_end_ms` INTEGER NOT NULL, `recurrence` TEXT NOT NULL, `recurring_rule_id` TEXT, `enabled` INTEGER NOT NULL, `is_manual` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "requestedStartMs",
+ "columnName": "requested_start_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "requestedEndMs",
+ "columnName": "requested_end_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurrence",
+ "columnName": "recurrence",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurringRuleId",
+ "columnName": "recurring_rule_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isManual",
+ "columnName": "is_manual",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_recording_schedules_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_recording_schedules_enabled_requested_start_ms",
+ "unique": false,
+ "columnNames": [
+ "enabled",
+ "requested_start_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_enabled_requested_start_ms` ON `${TABLE_NAME}` (`enabled`, `requested_start_ms`)"
+ },
+ {
+ "name": "index_recording_schedules_recurring_rule_id",
+ "unique": false,
+ "columnNames": [
+ "recurring_rule_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_recurring_rule_id` ON `${TABLE_NAME}` (`recurring_rule_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_runs",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `schedule_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` INTEGER NOT NULL, `channel_name` TEXT NOT NULL, `stream_url` TEXT NOT NULL, `program_title` TEXT, `scheduled_start_ms` INTEGER NOT NULL, `scheduled_end_ms` INTEGER NOT NULL, `recurrence` TEXT NOT NULL, `recurring_rule_id` TEXT, `status` TEXT NOT NULL, `source_type` TEXT NOT NULL, `resolved_url` TEXT, `headers_json` TEXT NOT NULL, `user_agent` TEXT, `expiration_time` INTEGER, `provider_label` TEXT, `output_uri` TEXT, `output_display_path` TEXT, `bytes_written` INTEGER NOT NULL, `average_throughput_bps` INTEGER NOT NULL, `retry_count` INTEGER NOT NULL, `last_progress_at_ms` INTEGER, `failure_category` TEXT NOT NULL, `failure_reason` TEXT, `terminal_at_ms` INTEGER, `started_at_ms` INTEGER, `ended_at_ms` INTEGER, `schedule_enabled` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `alarm_start_at_ms` INTEGER, `alarm_stop_at_ms` INTEGER, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`schedule_id`) REFERENCES `recording_schedules`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "scheduleId",
+ "columnName": "schedule_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "scheduledStartMs",
+ "columnName": "scheduled_start_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "scheduledEndMs",
+ "columnName": "scheduled_end_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurrence",
+ "columnName": "recurrence",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurringRuleId",
+ "columnName": "recurring_rule_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sourceType",
+ "columnName": "source_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "resolvedUrl",
+ "columnName": "resolved_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "headersJson",
+ "columnName": "headers_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userAgent",
+ "columnName": "user_agent",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "expirationTime",
+ "columnName": "expiration_time",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "providerLabel",
+ "columnName": "provider_label",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputUri",
+ "columnName": "output_uri",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputDisplayPath",
+ "columnName": "output_display_path",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "bytesWritten",
+ "columnName": "bytes_written",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "averageThroughputBytesPerSecond",
+ "columnName": "average_throughput_bps",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryCount",
+ "columnName": "retry_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastProgressAtMs",
+ "columnName": "last_progress_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "failureCategory",
+ "columnName": "failure_category",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failure_reason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "terminalAtMs",
+ "columnName": "terminal_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "startedAtMs",
+ "columnName": "started_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "endedAtMs",
+ "columnName": "ended_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "scheduleEnabled",
+ "columnName": "schedule_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "alarmStartAtMs",
+ "columnName": "alarm_start_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "alarmStopAtMs",
+ "columnName": "alarm_stop_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_recording_runs_schedule_id",
+ "unique": false,
+ "columnNames": [
+ "schedule_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_schedule_id` ON `${TABLE_NAME}` (`schedule_id`)"
+ },
+ {
+ "name": "index_recording_runs_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_recording_runs_status_scheduled_start_ms",
+ "unique": false,
+ "columnNames": [
+ "status",
+ "scheduled_start_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_status_scheduled_start_ms` ON `${TABLE_NAME}` (`status`, `scheduled_start_ms`)"
+ },
+ {
+ "name": "index_recording_runs_alarm_start_at_ms",
+ "unique": false,
+ "columnNames": [
+ "alarm_start_at_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_alarm_start_at_ms` ON `${TABLE_NAME}` (`alarm_start_at_ms`)"
+ },
+ {
+ "name": "index_recording_runs_alarm_stop_at_ms",
+ "unique": false,
+ "columnNames": [
+ "alarm_stop_at_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_alarm_stop_at_ms` ON `${TABLE_NAME}` (`alarm_stop_at_ms`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "recording_schedules",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "schedule_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "program_reminders",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` TEXT NOT NULL, `channel_name` TEXT NOT NULL, `program_title` TEXT NOT NULL, `program_start_time` INTEGER NOT NULL, `remind_at` INTEGER NOT NULL, `lead_time_minutes` INTEGER NOT NULL, `is_dismissed` INTEGER NOT NULL, `notified_at` INTEGER, `created_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programStartTime",
+ "columnName": "program_start_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "remindAt",
+ "columnName": "remind_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "leadTimeMinutes",
+ "columnName": "lead_time_minutes",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isDismissed",
+ "columnName": "is_dismissed",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "notifiedAt",
+ "columnName": "notified_at",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_program_reminders_provider_id_remind_at",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "remind_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_provider_id_remind_at` ON `${TABLE_NAME}` (`provider_id`, `remind_at`)"
+ },
+ {
+ "name": "index_program_reminders_is_dismissed_notified_at_remind_at",
+ "unique": false,
+ "columnNames": [
+ "is_dismissed",
+ "notified_at",
+ "remind_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_is_dismissed_notified_at_remind_at` ON `${TABLE_NAME}` (`is_dismissed`, `notified_at`, `remind_at`)"
+ },
+ {
+ "name": "index_program_reminders_provider_id_channel_id_program_start_time",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "program_start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_provider_id_channel_id_program_start_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `program_start_time`)"
+ },
+ {
+ "name": "index_program_reminders_provider_id_channel_id_program_title_program_start_time",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "program_title",
+ "program_start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_program_reminders_provider_id_channel_id_program_title_program_start_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `program_title`, `program_start_time`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_storage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `tree_uri` TEXT, `display_name` TEXT, `output_directory` TEXT, `available_bytes` INTEGER, `is_writable` INTEGER NOT NULL, `file_name_pattern` TEXT NOT NULL, `retention_days` INTEGER, `max_simultaneous_recordings` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "treeUri",
+ "columnName": "tree_uri",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "displayName",
+ "columnName": "display_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputDirectory",
+ "columnName": "output_directory",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "availableBytes",
+ "columnName": "available_bytes",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "isWritable",
+ "columnName": "is_writable",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "fileNamePattern",
+ "columnName": "file_name_pattern",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retentionDays",
+ "columnName": "retention_days",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "maxSimultaneousRecordings",
+ "columnName": "max_simultaneous_recordings",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ }
+ }
+ ],
+ "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, '24487bb8174187903ca8732c577dde47')"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/data/schemas/com.streamvault.data.local.StreamVaultDatabase/42.json b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/42.json
new file mode 100644
index 00000000..13d48f28
--- /dev/null
+++ b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/42.json
@@ -0,0 +1,4224 @@
+{
+ "formatVersion": 1,
+ "database": {
+ "version": 42,
+ "identityHash": "efbd6dee5e1cd9ed7c0ee9afd41edec7",
+ "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, `stalker_mac_address` TEXT NOT NULL, `stalker_device_profile` TEXT NOT NULL, `stalker_device_timezone` TEXT NOT NULL, `stalker_device_locale` TEXT NOT NULL, `is_active` INTEGER NOT NULL, `max_connections` INTEGER NOT NULL, `expiration_date` INTEGER, `api_version` TEXT, `allowed_output_formats_json` TEXT NOT NULL, `epg_sync_mode` TEXT NOT NULL, `xtream_fast_sync_enabled` INTEGER NOT NULL, `m3u_vod_classification_enabled` INTEGER NOT NULL, `status` TEXT NOT NULL, `last_synced_at` INTEGER NOT NULL, `created_at` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "serverUrl",
+ "columnName": "server_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "username",
+ "columnName": "username",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "password",
+ "columnName": "password",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "m3uUrl",
+ "columnName": "m3u_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgUrl",
+ "columnName": "epg_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerMacAddress",
+ "columnName": "stalker_mac_address",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceProfile",
+ "columnName": "stalker_device_profile",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceTimezone",
+ "columnName": "stalker_device_timezone",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceLocale",
+ "columnName": "stalker_device_locale",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isActive",
+ "columnName": "is_active",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "maxConnections",
+ "columnName": "max_connections",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "expirationDate",
+ "columnName": "expiration_date",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "apiVersion",
+ "columnName": "api_version",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "allowedOutputFormatsJson",
+ "columnName": "allowed_output_formats_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSyncMode",
+ "columnName": "epg_sync_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xtreamFastSyncEnabled",
+ "columnName": "xtream_fast_sync_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "m3uVodClassificationEnabled",
+ "columnName": "m3u_vod_classification_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSyncedAt",
+ "columnName": "last_synced_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_providers_server_url_username_stalker_mac_address",
+ "unique": true,
+ "columnNames": [
+ "server_url",
+ "username",
+ "stalker_mac_address"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_providers_server_url_username_stalker_mac_address` ON `${TABLE_NAME}` (`server_url`, `username`, `stalker_mac_address`)"
+ }
+ ]
+ },
+ {
+ "tableName": "channels",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `logo_url` TEXT, `group_title` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `epg_channel_id` TEXT, `number` INTEGER NOT NULL, `catch_up_supported` INTEGER NOT NULL, `catch_up_days` INTEGER NOT NULL, `catchUpSource` TEXT, `provider_id` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `logical_group_id` TEXT NOT NULL, `error_count` INTEGER NOT NULL, `quality_options_json` TEXT, `sync_fingerprint` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logoUrl",
+ "columnName": "logo_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupTitle",
+ "columnName": "group_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgChannelId",
+ "columnName": "epg_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "number",
+ "columnName": "number",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSupported",
+ "columnName": "catch_up_supported",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpDays",
+ "columnName": "catch_up_days",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSource",
+ "columnName": "catchUpSource",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logicalGroupId",
+ "columnName": "logical_group_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "errorCount",
+ "columnName": "error_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "qualityOptionsJson",
+ "columnName": "quality_options_json",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channels_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_category_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id_category_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_stream_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "stream_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channels_provider_id_stream_id` ON `${TABLE_NAME}` (`provider_id`, `stream_id`)"
+ },
+ {
+ "name": "index_channels_logical_group_id",
+ "unique": false,
+ "columnNames": [
+ "logical_group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_logical_group_id` ON `${TABLE_NAME}` (`logical_group_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_category_id_logical_group_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id",
+ "logical_group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id_category_id_logical_group_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`, `logical_group_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channel_preferences",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `channel_id` INTEGER NOT NULL, `aspect_ratio` TEXT, `audio_video_offset_ms` INTEGER, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`channel_id`) REFERENCES `channels`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "aspectRatio",
+ "columnName": "aspect_ratio",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "audioVideoOffsetMs",
+ "columnName": "audio_video_offset_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_preferences_channel_id",
+ "unique": true,
+ "columnNames": [
+ "channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channel_preferences_channel_id` ON `${TABLE_NAME}` (`channel_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "channels",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "channel_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channels_fts",
+ "createSql": "CREATE VIRTUAL TABLE IF NOT EXISTS `${TABLE_NAME}` USING FTS4(`name` TEXT NOT NULL, content=`channels`)",
+ "fields": [
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": []
+ },
+ "ftsVersion": "FTS4",
+ "ftsOptions": {
+ "tokenizer": "simple",
+ "tokenizerArgs": [],
+ "contentTable": "channels",
+ "languageIdColumnName": "",
+ "matchInfo": "FTS4",
+ "notIndexedColumns": [],
+ "prefixSizes": [],
+ "preferredOrder": "ASC"
+ },
+ "contentSyncTriggers": [
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_BEFORE_UPDATE BEFORE UPDATE ON `channels` BEGIN DELETE FROM `channels_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_BEFORE_DELETE BEFORE DELETE ON `channels` BEGIN DELETE FROM `channels_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_AFTER_UPDATE AFTER UPDATE ON `channels` BEGIN INSERT INTO `channels_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_AFTER_INSERT AFTER INSERT ON `channels` BEGIN INSERT INTO `channels_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END"
+ ]
+ },
+ {
+ "tableName": "movies",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `container_extension` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `duration` TEXT, `duration_seconds` INTEGER NOT NULL, `rating` REAL NOT NULL, `year` TEXT, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `provider_id` INTEGER NOT NULL, `watch_progress` INTEGER NOT NULL, `watch_count` INTEGER NOT NULL, `last_watched_at` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, `added_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "duration",
+ "columnName": "duration",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "durationSeconds",
+ "columnName": "duration_seconds",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "year",
+ "columnName": "year",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchProgress",
+ "columnName": "watch_progress",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchCount",
+ "columnName": "watch_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastWatchedAt",
+ "columnName": "last_watched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "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, `sync_fingerprint` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "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
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "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, `sync_fingerprint` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "parentId",
+ "columnName": "parent_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_categories_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_categories_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_categories_provider_id_type",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_categories_provider_id_type` ON `${TABLE_NAME}` (`provider_id`, `type`)"
+ },
+ {
+ "name": "index_categories_provider_id_category_id_type",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "category_id",
+ "type"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_categories_provider_id_category_id_type` ON `${TABLE_NAME}` (`provider_id`, `category_id`, `type`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channel_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `logo_url` TEXT, `group_title` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `epg_channel_id` TEXT, `number` INTEGER NOT NULL, `catch_up_supported` INTEGER NOT NULL, `catch_up_days` INTEGER NOT NULL, `catchUpSource` TEXT, `is_adult` INTEGER NOT NULL, `logical_group_id` TEXT NOT NULL, `error_count` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `stream_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logoUrl",
+ "columnName": "logo_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupTitle",
+ "columnName": "group_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgChannelId",
+ "columnName": "epg_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "number",
+ "columnName": "number",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSupported",
+ "columnName": "catch_up_supported",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpDays",
+ "columnName": "catch_up_days",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSource",
+ "columnName": "catchUpSource",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logicalGroupId",
+ "columnName": "logical_group_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "errorCount",
+ "columnName": "error_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "stream_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_channel_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "movie_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `container_extension` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `duration` TEXT, `duration_seconds` INTEGER NOT NULL, `rating` REAL NOT NULL, `year` TEXT, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, `added_at` INTEGER NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `stream_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "duration",
+ "columnName": "duration",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "durationSeconds",
+ "columnName": "duration_seconds",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "year",
+ "columnName": "year",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "stream_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_movie_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_movie_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "series_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `series_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `rating` REAL NOT NULL, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `episode_run_time` TEXT, `last_modified` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `series_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "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": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "series_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_series_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_series_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "category_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `parent_id` INTEGER, `type` TEXT NOT NULL, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `category_id`, `type`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "parentId",
+ "columnName": "parent_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "category_id",
+ "type"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_category_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_category_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_category_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_category_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ },
+ {
+ "name": "index_category_import_stage_provider_id_type",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_category_import_stage_provider_id_type` ON `${TABLE_NAME}` (`provider_id`, `type`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "programs",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` TEXT NOT NULL, `title` TEXT NOT NULL, `description` TEXT NOT NULL, `start_time` INTEGER NOT NULL, `end_time` INTEGER NOT NULL, `lang` TEXT NOT NULL, `rating` TEXT, `image_url` TEXT, `genre` TEXT, `category` TEXT, `has_archive` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "startTime",
+ "columnName": "start_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "endTime",
+ "columnName": "end_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lang",
+ "columnName": "lang",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "imageUrl",
+ "columnName": "image_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "category",
+ "columnName": "category",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "hasArchive",
+ "columnName": "has_archive",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_programs_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_programs_provider_id_channel_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_channel_id` ON `${TABLE_NAME}` (`provider_id`, `channel_id`)"
+ },
+ {
+ "name": "index_programs_provider_id_end_time_channel_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "end_time",
+ "channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_end_time_channel_id` ON `${TABLE_NAME}` (`provider_id`, `end_time`, `channel_id`)"
+ },
+ {
+ "name": "index_programs_provider_id_start_time_end_time",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "start_time",
+ "end_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_start_time_end_time` ON `${TABLE_NAME}` (`provider_id`, `start_time`, `end_time`)"
+ },
+ {
+ "name": "index_programs_start_time",
+ "unique": false,
+ "columnNames": [
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_start_time` ON `${TABLE_NAME}` (`start_time`)"
+ },
+ {
+ "name": "index_programs_provider_id_channel_id_start_time",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_channel_id_start_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `start_time`)"
+ },
+ {
+ "name": "index_programs_provider_id_channel_id_start_time_end_time",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "start_time",
+ "end_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_programs_provider_id_channel_id_start_time_end_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `start_time`, `end_time`)"
+ }
+ ]
+ },
+ {
+ "tableName": "favorites",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `content_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `position` INTEGER NOT NULL, `group_id` INTEGER, `added_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`group_id`) REFERENCES `virtual_groups`(`id`) ON UPDATE NO ACTION ON DELETE SET NULL )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentId",
+ "columnName": "content_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "position",
+ "columnName": "position",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "groupId",
+ "columnName": "group_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_favorites_provider_id_content_id_content_type_group_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "content_id",
+ "content_type",
+ "group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_favorites_provider_id_content_id_content_type_group_id` ON `${TABLE_NAME}` (`provider_id`, `content_id`, `content_type`, `group_id`)"
+ },
+ {
+ "name": "index_favorites_provider_id_content_type_group_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type",
+ "group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_favorites_provider_id_content_type_group_id` ON `${TABLE_NAME}` (`provider_id`, `content_type`, `group_id`)"
+ },
+ {
+ "name": "index_favorites_group_id_position",
+ "unique": false,
+ "columnNames": [
+ "group_id",
+ "position"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_favorites_group_id_position` ON `${TABLE_NAME}` (`group_id`, `position`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "virtual_groups",
+ "onDelete": "SET NULL",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "group_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "virtual_groups",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `icon_emoji` TEXT, `position` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `content_type` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "iconEmoji",
+ "columnName": "icon_emoji",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "position",
+ "columnName": "position",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_virtual_groups_provider_id_content_type",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_virtual_groups_provider_id_content_type` ON `${TABLE_NAME}` (`provider_id`, `content_type`)"
+ },
+ {
+ "name": "index_virtual_groups_position",
+ "unique": false,
+ "columnNames": [
+ "position"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_virtual_groups_position` ON `${TABLE_NAME}` (`position`)"
+ },
+ {
+ "name": "index_virtual_groups_content_type",
+ "unique": false,
+ "columnNames": [
+ "content_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_virtual_groups_content_type` ON `${TABLE_NAME}` (`content_type`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "playback_history",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `content_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `title` TEXT NOT NULL, `poster_url` TEXT, `stream_url` TEXT NOT NULL, `resume_position_ms` INTEGER NOT NULL, `total_duration_ms` INTEGER NOT NULL, `last_watched_at` INTEGER NOT NULL, `watch_count` INTEGER NOT NULL, `watched_status` TEXT NOT NULL, `series_id` INTEGER, `season_number` INTEGER, `episode_number` INTEGER, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentId",
+ "columnName": "content_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "resumePositionMs",
+ "columnName": "resume_position_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalDurationMs",
+ "columnName": "total_duration_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastWatchedAt",
+ "columnName": "last_watched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchCount",
+ "columnName": "watch_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchedStatus",
+ "columnName": "watched_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesId",
+ "columnName": "series_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "seasonNumber",
+ "columnName": "season_number",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "episodeNumber",
+ "columnName": "episode_number",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_playback_history_content_id_content_type_provider_id",
+ "unique": true,
+ "columnNames": [
+ "content_id",
+ "content_type",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_playback_history_content_id_content_type_provider_id` ON `${TABLE_NAME}` (`content_id`, `content_type`, `provider_id`)"
+ },
+ {
+ "name": "index_playback_history_last_watched_at",
+ "unique": false,
+ "columnNames": [
+ "last_watched_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_history_last_watched_at` ON `${TABLE_NAME}` (`last_watched_at`)"
+ },
+ {
+ "name": "index_playback_history_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_history_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "tmdb_identity",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`tmdb_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `canonical_provider_id` INTEGER NOT NULL, `first_seen_at` INTEGER NOT NULL, PRIMARY KEY(`tmdb_id`, `content_type`), FOREIGN KEY(`canonical_provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "canonicalProviderId",
+ "columnName": "canonical_provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "firstSeenAt",
+ "columnName": "first_seen_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "tmdb_id",
+ "content_type"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_tmdb_identity_content_type",
+ "unique": false,
+ "columnNames": [
+ "content_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_tmdb_identity_content_type` ON `${TABLE_NAME}` (`content_type`)"
+ },
+ {
+ "name": "index_tmdb_identity_canonical_provider_id",
+ "unique": false,
+ "columnNames": [
+ "canonical_provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_tmdb_identity_canonical_provider_id` ON `${TABLE_NAME}` (`canonical_provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "canonical_provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "search_history",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `query` TEXT NOT NULL, `content_scope` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `used_at` INTEGER NOT NULL, `use_count` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "query",
+ "columnName": "query",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentScope",
+ "columnName": "content_scope",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "usedAt",
+ "columnName": "used_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "useCount",
+ "columnName": "use_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_search_history_content_scope_provider_id_used_at",
+ "unique": false,
+ "columnNames": [
+ "content_scope",
+ "provider_id",
+ "used_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_search_history_content_scope_provider_id_used_at` ON `${TABLE_NAME}` (`content_scope`, `provider_id`, `used_at`)"
+ },
+ {
+ "name": "index_search_history_used_at",
+ "unique": false,
+ "columnNames": [
+ "used_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_search_history_used_at` ON `${TABLE_NAME}` (`used_at`)"
+ },
+ {
+ "name": "index_search_history_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_search_history_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_search_history_query_content_scope_provider_id",
+ "unique": true,
+ "columnNames": [
+ "query",
+ "content_scope",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_search_history_query_content_scope_provider_id` ON `${TABLE_NAME}` (`query`, `content_scope`, `provider_id`)"
+ }
+ ]
+ },
+ {
+ "tableName": "sync_metadata",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `last_live_sync` INTEGER NOT NULL, `last_live_success` INTEGER NOT NULL, `last_movie_sync` INTEGER NOT NULL, `last_series_sync` INTEGER NOT NULL, `last_series_success` INTEGER NOT NULL, `last_epg_sync` INTEGER NOT NULL, `last_epg_success` INTEGER NOT NULL, `last_movie_attempt` INTEGER NOT NULL, `last_movie_success` INTEGER NOT NULL, `last_movie_partial` INTEGER NOT NULL, `live_count` INTEGER NOT NULL, `movie_count` INTEGER NOT NULL, `series_count` INTEGER NOT NULL, `epg_count` INTEGER NOT NULL, `last_sync_status` TEXT NOT NULL, `movie_sync_mode` TEXT NOT NULL, `movie_warnings_count` INTEGER NOT NULL, `movie_catalog_stale` INTEGER NOT NULL, `live_avoid_full_until` INTEGER NOT NULL, `movie_avoid_full_until` INTEGER NOT NULL, `series_avoid_full_until` INTEGER NOT NULL, `live_sequential_failures_remembered` INTEGER NOT NULL, `live_healthy_sync_streak` INTEGER NOT NULL, `movie_parallel_failures_remembered` INTEGER NOT NULL, `movie_healthy_sync_streak` INTEGER NOT NULL, `series_sequential_failures_remembered` INTEGER NOT NULL, `series_healthy_sync_streak` INTEGER NOT NULL, PRIMARY KEY(`provider_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastLiveSync",
+ "columnName": "last_live_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastLiveSuccess",
+ "columnName": "last_live_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMovieSync",
+ "columnName": "last_movie_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSeriesSync",
+ "columnName": "last_series_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSeriesSuccess",
+ "columnName": "last_series_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastEpgSync",
+ "columnName": "last_epg_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastEpgSuccess",
+ "columnName": "last_epg_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMovieAttempt",
+ "columnName": "last_movie_attempt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMovieSuccess",
+ "columnName": "last_movie_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMoviePartial",
+ "columnName": "last_movie_partial",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveCount",
+ "columnName": "live_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieCount",
+ "columnName": "movie_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesCount",
+ "columnName": "series_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgCount",
+ "columnName": "epg_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSyncStatus",
+ "columnName": "last_sync_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieSyncMode",
+ "columnName": "movie_sync_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieWarningsCount",
+ "columnName": "movie_warnings_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieCatalogStale",
+ "columnName": "movie_catalog_stale",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveAvoidFullUntil",
+ "columnName": "live_avoid_full_until",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieAvoidFullUntil",
+ "columnName": "movie_avoid_full_until",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesAvoidFullUntil",
+ "columnName": "series_avoid_full_until",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveSequentialFailuresRemembered",
+ "columnName": "live_sequential_failures_remembered",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveHealthySyncStreak",
+ "columnName": "live_healthy_sync_streak",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieParallelFailuresRemembered",
+ "columnName": "movie_parallel_failures_remembered",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieHealthySyncStreak",
+ "columnName": "movie_healthy_sync_streak",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesSequentialFailuresRemembered",
+ "columnName": "series_sequential_failures_remembered",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesHealthySyncStreak",
+ "columnName": "series_healthy_sync_streak",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "movie_category_hydration",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `last_hydrated_at` INTEGER NOT NULL, `item_count` INTEGER NOT NULL, `last_status` TEXT NOT NULL, `last_error` TEXT, PRIMARY KEY(`provider_id`, `category_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastHydratedAt",
+ "columnName": "last_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemCount",
+ "columnName": "item_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastStatus",
+ "columnName": "last_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_movie_category_hydration_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_category_hydration_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "series_category_hydration",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `last_hydrated_at` INTEGER NOT NULL, `item_count` INTEGER NOT NULL, `last_status` TEXT NOT NULL, `last_error` TEXT, PRIMARY KEY(`provider_id`, `category_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastHydratedAt",
+ "columnName": "last_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemCount",
+ "columnName": "item_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastStatus",
+ "columnName": "last_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_series_category_hydration_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_category_hydration_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "epg_sources",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `url` TEXT NOT NULL, `enabled` INTEGER NOT NULL, `last_refresh_at` INTEGER NOT NULL, `last_success_at` INTEGER NOT NULL, `last_error` TEXT, `priority` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, `etag` TEXT, `last_modified_header` TEXT)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "url",
+ "columnName": "url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastRefreshAt",
+ "columnName": "last_refresh_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSuccessAt",
+ "columnName": "last_success_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "etag",
+ "columnName": "etag",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastModifiedHeader",
+ "columnName": "last_modified_header",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_epg_sources_url",
+ "unique": true,
+ "columnNames": [
+ "url"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_sources_url` ON `${TABLE_NAME}` (`url`)"
+ }
+ ]
+ },
+ {
+ "tableName": "provider_epg_sources",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `epg_source_id` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_provider_epg_sources_provider_id_epg_source_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_provider_epg_sources_provider_id_epg_source_id` ON `${TABLE_NAME}` (`provider_id`, `epg_source_id`)"
+ },
+ {
+ "name": "index_provider_epg_sources_epg_source_id",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_provider_epg_sources_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "epg_sources",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "epg_source_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "epg_channels",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `epg_source_id` INTEGER NOT NULL, `xmltv_channel_id` TEXT NOT NULL, `display_name` TEXT NOT NULL, `normalized_name` TEXT NOT NULL, `icon_url` TEXT, FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "displayName",
+ "columnName": "display_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "normalizedName",
+ "columnName": "normalized_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "iconUrl",
+ "columnName": "icon_url",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_epg_channels_epg_source_id_xmltv_channel_id",
+ "unique": true,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_channels_epg_source_id_xmltv_channel_id` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`)"
+ },
+ {
+ "name": "index_epg_channels_epg_source_id",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_channels_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
+ },
+ {
+ "name": "index_epg_channels_normalized_name",
+ "unique": false,
+ "columnNames": [
+ "normalized_name"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_channels_normalized_name` ON `${TABLE_NAME}` (`normalized_name`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "epg_sources",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "epg_source_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "epg_programmes",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `epg_source_id` INTEGER NOT NULL, `xmltv_channel_id` TEXT NOT NULL, `start_time` INTEGER NOT NULL, `end_time` INTEGER NOT NULL, `title` TEXT NOT NULL, `subtitle` TEXT, `description` TEXT NOT NULL, `category` TEXT, `lang` TEXT NOT NULL, `rating` TEXT, `image_url` TEXT, `episode_info` TEXT, FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "startTime",
+ "columnName": "start_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "endTime",
+ "columnName": "end_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "subtitle",
+ "columnName": "subtitle",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "category",
+ "columnName": "category",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lang",
+ "columnName": "lang",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "imageUrl",
+ "columnName": "image_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "episodeInfo",
+ "columnName": "episode_info",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_epg_programmes_epg_source_id_xmltv_channel_id_start_time",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id",
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id_xmltv_channel_id_start_time` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`, `start_time`)"
+ },
+ {
+ "name": "index_epg_programmes_epg_source_id_xmltv_channel_id_start_time_end_time",
+ "unique": true,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id",
+ "start_time",
+ "end_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id_xmltv_channel_id_start_time_end_time` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`, `start_time`, `end_time`)"
+ },
+ {
+ "name": "index_epg_programmes_epg_source_id",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
+ },
+ {
+ "name": "index_epg_programmes_start_time",
+ "unique": false,
+ "columnNames": [
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_start_time` ON `${TABLE_NAME}` (`start_time`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "epg_sources",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "epg_source_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channel_epg_mappings",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_channel_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `source_type` TEXT NOT NULL, `epg_source_id` INTEGER, `xmltv_channel_id` TEXT, `match_type` TEXT, `confidence` REAL NOT NULL, `matched_at` INTEGER NOT NULL, `failed_attempts` INTEGER NOT NULL, `source` TEXT, `is_manual_override` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerChannelId",
+ "columnName": "provider_channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sourceType",
+ "columnName": "source_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "matchType",
+ "columnName": "match_type",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "confidence",
+ "columnName": "confidence",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "matchedAt",
+ "columnName": "matched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failedAttempts",
+ "columnName": "failed_attempts",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "source",
+ "columnName": "source",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isManualOverride",
+ "columnName": "is_manual_override",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_epg_mappings_provider_id_provider_channel_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "provider_channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channel_epg_mappings_provider_id_provider_channel_id` ON `${TABLE_NAME}` (`provider_id`, `provider_channel_id`)"
+ },
+ {
+ "name": "index_channel_epg_mappings_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_epg_mappings_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "combined_m3u_profiles",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `enabled` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ }
+ },
+ {
+ "tableName": "combined_m3u_profile_members",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `profile_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, FOREIGN KEY(`profile_id`) REFERENCES `combined_m3u_profiles`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profileId",
+ "columnName": "profile_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_combined_m3u_profile_members_profile_id",
+ "unique": false,
+ "columnNames": [
+ "profile_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_profile_id` ON `${TABLE_NAME}` (`profile_id`)"
+ },
+ {
+ "name": "index_combined_m3u_profile_members_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_combined_m3u_profile_members_profile_id_provider_id",
+ "unique": true,
+ "columnNames": [
+ "profile_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_profile_id_provider_id` ON `${TABLE_NAME}` (`profile_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "combined_m3u_profiles",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "profile_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_schedules",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` INTEGER NOT NULL, `channel_name` TEXT NOT NULL, `stream_url` TEXT NOT NULL, `program_title` TEXT, `requested_start_ms` INTEGER NOT NULL, `requested_end_ms` INTEGER NOT NULL, `recurrence` TEXT NOT NULL, `recurring_rule_id` TEXT, `enabled` INTEGER NOT NULL, `is_manual` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "requestedStartMs",
+ "columnName": "requested_start_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "requestedEndMs",
+ "columnName": "requested_end_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurrence",
+ "columnName": "recurrence",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurringRuleId",
+ "columnName": "recurring_rule_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isManual",
+ "columnName": "is_manual",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_recording_schedules_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_recording_schedules_enabled_requested_start_ms",
+ "unique": false,
+ "columnNames": [
+ "enabled",
+ "requested_start_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_enabled_requested_start_ms` ON `${TABLE_NAME}` (`enabled`, `requested_start_ms`)"
+ },
+ {
+ "name": "index_recording_schedules_recurring_rule_id",
+ "unique": false,
+ "columnNames": [
+ "recurring_rule_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_recurring_rule_id` ON `${TABLE_NAME}` (`recurring_rule_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_runs",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `schedule_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` INTEGER NOT NULL, `channel_name` TEXT NOT NULL, `stream_url` TEXT NOT NULL, `program_title` TEXT, `scheduled_start_ms` INTEGER NOT NULL, `scheduled_end_ms` INTEGER NOT NULL, `recurrence` TEXT NOT NULL, `recurring_rule_id` TEXT, `status` TEXT NOT NULL, `source_type` TEXT NOT NULL, `resolved_url` TEXT, `headers_json` TEXT NOT NULL, `user_agent` TEXT, `expiration_time` INTEGER, `provider_label` TEXT, `output_uri` TEXT, `output_display_path` TEXT, `bytes_written` INTEGER NOT NULL, `average_throughput_bps` INTEGER NOT NULL, `retry_count` INTEGER NOT NULL, `last_progress_at_ms` INTEGER, `failure_category` TEXT NOT NULL, `failure_reason` TEXT, `terminal_at_ms` INTEGER, `started_at_ms` INTEGER, `ended_at_ms` INTEGER, `schedule_enabled` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `alarm_start_at_ms` INTEGER, `alarm_stop_at_ms` INTEGER, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`schedule_id`) REFERENCES `recording_schedules`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "scheduleId",
+ "columnName": "schedule_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "scheduledStartMs",
+ "columnName": "scheduled_start_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "scheduledEndMs",
+ "columnName": "scheduled_end_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurrence",
+ "columnName": "recurrence",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurringRuleId",
+ "columnName": "recurring_rule_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sourceType",
+ "columnName": "source_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "resolvedUrl",
+ "columnName": "resolved_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "headersJson",
+ "columnName": "headers_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userAgent",
+ "columnName": "user_agent",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "expirationTime",
+ "columnName": "expiration_time",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "providerLabel",
+ "columnName": "provider_label",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputUri",
+ "columnName": "output_uri",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputDisplayPath",
+ "columnName": "output_display_path",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "bytesWritten",
+ "columnName": "bytes_written",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "averageThroughputBytesPerSecond",
+ "columnName": "average_throughput_bps",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryCount",
+ "columnName": "retry_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastProgressAtMs",
+ "columnName": "last_progress_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "failureCategory",
+ "columnName": "failure_category",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failure_reason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "terminalAtMs",
+ "columnName": "terminal_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "startedAtMs",
+ "columnName": "started_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "endedAtMs",
+ "columnName": "ended_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "scheduleEnabled",
+ "columnName": "schedule_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "alarmStartAtMs",
+ "columnName": "alarm_start_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "alarmStopAtMs",
+ "columnName": "alarm_stop_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_recording_runs_schedule_id",
+ "unique": false,
+ "columnNames": [
+ "schedule_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_schedule_id` ON `${TABLE_NAME}` (`schedule_id`)"
+ },
+ {
+ "name": "index_recording_runs_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_recording_runs_status_scheduled_start_ms",
+ "unique": false,
+ "columnNames": [
+ "status",
+ "scheduled_start_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_status_scheduled_start_ms` ON `${TABLE_NAME}` (`status`, `scheduled_start_ms`)"
+ },
+ {
+ "name": "index_recording_runs_alarm_start_at_ms",
+ "unique": false,
+ "columnNames": [
+ "alarm_start_at_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_alarm_start_at_ms` ON `${TABLE_NAME}` (`alarm_start_at_ms`)"
+ },
+ {
+ "name": "index_recording_runs_alarm_stop_at_ms",
+ "unique": false,
+ "columnNames": [
+ "alarm_stop_at_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_alarm_stop_at_ms` ON `${TABLE_NAME}` (`alarm_stop_at_ms`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "recording_schedules",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "schedule_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "program_reminders",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` TEXT NOT NULL, `channel_name` TEXT NOT NULL, `program_title` TEXT NOT NULL, `program_start_time` INTEGER NOT NULL, `remind_at` INTEGER NOT NULL, `lead_time_minutes` INTEGER NOT NULL, `is_dismissed` INTEGER NOT NULL, `notified_at` INTEGER, `created_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programStartTime",
+ "columnName": "program_start_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "remindAt",
+ "columnName": "remind_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "leadTimeMinutes",
+ "columnName": "lead_time_minutes",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isDismissed",
+ "columnName": "is_dismissed",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "notifiedAt",
+ "columnName": "notified_at",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_program_reminders_provider_id_remind_at",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "remind_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_provider_id_remind_at` ON `${TABLE_NAME}` (`provider_id`, `remind_at`)"
+ },
+ {
+ "name": "index_program_reminders_is_dismissed_notified_at_remind_at",
+ "unique": false,
+ "columnNames": [
+ "is_dismissed",
+ "notified_at",
+ "remind_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_is_dismissed_notified_at_remind_at` ON `${TABLE_NAME}` (`is_dismissed`, `notified_at`, `remind_at`)"
+ },
+ {
+ "name": "index_program_reminders_provider_id_channel_id_program_start_time",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "program_start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_provider_id_channel_id_program_start_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `program_start_time`)"
+ },
+ {
+ "name": "index_program_reminders_provider_id_channel_id_program_title_program_start_time",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "program_title",
+ "program_start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_program_reminders_provider_id_channel_id_program_title_program_start_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `program_title`, `program_start_time`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_storage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `tree_uri` TEXT, `display_name` TEXT, `output_directory` TEXT, `available_bytes` INTEGER, `is_writable` INTEGER NOT NULL, `file_name_pattern` TEXT NOT NULL, `retention_days` INTEGER, `max_simultaneous_recordings` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "treeUri",
+ "columnName": "tree_uri",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "displayName",
+ "columnName": "display_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputDirectory",
+ "columnName": "output_directory",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "availableBytes",
+ "columnName": "available_bytes",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "isWritable",
+ "columnName": "is_writable",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "fileNamePattern",
+ "columnName": "file_name_pattern",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retentionDays",
+ "columnName": "retention_days",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "maxSimultaneousRecordings",
+ "columnName": "max_simultaneous_recordings",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ }
+ },
+ {
+ "tableName": "playback_compatibility_records",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `device_fingerprint` TEXT NOT NULL, `device_model` TEXT NOT NULL, `android_sdk` INTEGER NOT NULL, `stream_type` TEXT NOT NULL, `video_mime_type` TEXT NOT NULL, `resolution_bucket` TEXT NOT NULL, `decoder_name` TEXT NOT NULL, `surface_type` TEXT NOT NULL, `failure_type` TEXT NOT NULL, `last_failed_at` INTEGER NOT NULL, `last_succeeded_at` INTEGER NOT NULL, `failure_count` INTEGER NOT NULL, `success_count` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deviceFingerprint",
+ "columnName": "device_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deviceModel",
+ "columnName": "device_model",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "androidSdk",
+ "columnName": "android_sdk",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamType",
+ "columnName": "stream_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "videoMimeType",
+ "columnName": "video_mime_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "resolutionBucket",
+ "columnName": "resolution_bucket",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "decoderName",
+ "columnName": "decoder_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "surfaceType",
+ "columnName": "surface_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureType",
+ "columnName": "failure_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastFailedAt",
+ "columnName": "last_failed_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSucceededAt",
+ "columnName": "last_succeeded_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureCount",
+ "columnName": "failure_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "successCount",
+ "columnName": "success_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket_decoder_name_surface_type",
+ "unique": true,
+ "columnNames": [
+ "device_fingerprint",
+ "stream_type",
+ "video_mime_type",
+ "resolution_bucket",
+ "decoder_name",
+ "surface_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket_decoder_name_surface_type` ON `${TABLE_NAME}` (`device_fingerprint`, `stream_type`, `video_mime_type`, `resolution_bucket`, `decoder_name`, `surface_type`)"
+ },
+ {
+ "name": "index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket",
+ "unique": false,
+ "columnNames": [
+ "device_fingerprint",
+ "stream_type",
+ "video_mime_type",
+ "resolution_bucket"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket` ON `${TABLE_NAME}` (`device_fingerprint`, `stream_type`, `video_mime_type`, `resolution_bucket`)"
+ },
+ {
+ "name": "index_playback_compatibility_records_last_failed_at",
+ "unique": false,
+ "columnNames": [
+ "last_failed_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_compatibility_records_last_failed_at` ON `${TABLE_NAME}` (`last_failed_at`)"
+ },
+ {
+ "name": "index_playback_compatibility_records_last_succeeded_at",
+ "unique": false,
+ "columnNames": [
+ "last_succeeded_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_compatibility_records_last_succeeded_at` ON `${TABLE_NAME}` (`last_succeeded_at`)"
+ }
+ ]
+ }
+ ],
+ "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, 'efbd6dee5e1cd9ed7c0ee9afd41edec7')"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/data/schemas/com.streamvault.data.local.StreamVaultDatabase/43.json b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/43.json
new file mode 100644
index 00000000..9fc8e710
--- /dev/null
+++ b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/43.json
@@ -0,0 +1,4229 @@
+{
+ "formatVersion": 1,
+ "database": {
+ "version": 43,
+ "identityHash": "33ce9016a555227887e6423952f80f17",
+ "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, `stalker_mac_address` TEXT NOT NULL, `stalker_device_profile` TEXT NOT NULL, `stalker_device_timezone` TEXT NOT NULL, `stalker_device_locale` TEXT NOT NULL, `is_active` INTEGER NOT NULL, `max_connections` INTEGER NOT NULL, `expiration_date` INTEGER, `api_version` TEXT, `allowed_output_formats_json` TEXT NOT NULL, `epg_sync_mode` TEXT NOT NULL, `xtream_fast_sync_enabled` INTEGER NOT NULL, `m3u_vod_classification_enabled` INTEGER NOT NULL, `status` TEXT NOT NULL, `last_synced_at` INTEGER NOT NULL, `created_at` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "serverUrl",
+ "columnName": "server_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "username",
+ "columnName": "username",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "password",
+ "columnName": "password",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "m3uUrl",
+ "columnName": "m3u_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgUrl",
+ "columnName": "epg_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerMacAddress",
+ "columnName": "stalker_mac_address",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceProfile",
+ "columnName": "stalker_device_profile",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceTimezone",
+ "columnName": "stalker_device_timezone",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceLocale",
+ "columnName": "stalker_device_locale",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isActive",
+ "columnName": "is_active",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "maxConnections",
+ "columnName": "max_connections",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "expirationDate",
+ "columnName": "expiration_date",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "apiVersion",
+ "columnName": "api_version",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "allowedOutputFormatsJson",
+ "columnName": "allowed_output_formats_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSyncMode",
+ "columnName": "epg_sync_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xtreamFastSyncEnabled",
+ "columnName": "xtream_fast_sync_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "m3uVodClassificationEnabled",
+ "columnName": "m3u_vod_classification_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSyncedAt",
+ "columnName": "last_synced_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_providers_server_url_username_stalker_mac_address",
+ "unique": true,
+ "columnNames": [
+ "server_url",
+ "username",
+ "stalker_mac_address"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_providers_server_url_username_stalker_mac_address` ON `${TABLE_NAME}` (`server_url`, `username`, `stalker_mac_address`)"
+ }
+ ]
+ },
+ {
+ "tableName": "channels",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `logo_url` TEXT, `group_title` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `epg_channel_id` TEXT, `number` INTEGER NOT NULL, `catch_up_supported` INTEGER NOT NULL, `catch_up_days` INTEGER NOT NULL, `catchUpSource` TEXT, `provider_id` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `logical_group_id` TEXT NOT NULL, `error_count` INTEGER NOT NULL, `quality_options_json` TEXT, `sync_fingerprint` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logoUrl",
+ "columnName": "logo_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupTitle",
+ "columnName": "group_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgChannelId",
+ "columnName": "epg_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "number",
+ "columnName": "number",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSupported",
+ "columnName": "catch_up_supported",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpDays",
+ "columnName": "catch_up_days",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSource",
+ "columnName": "catchUpSource",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logicalGroupId",
+ "columnName": "logical_group_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "errorCount",
+ "columnName": "error_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "qualityOptionsJson",
+ "columnName": "quality_options_json",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channels_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_category_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id_category_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_stream_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "stream_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channels_provider_id_stream_id` ON `${TABLE_NAME}` (`provider_id`, `stream_id`)"
+ },
+ {
+ "name": "index_channels_logical_group_id",
+ "unique": false,
+ "columnNames": [
+ "logical_group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_logical_group_id` ON `${TABLE_NAME}` (`logical_group_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_category_id_logical_group_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id",
+ "logical_group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id_category_id_logical_group_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`, `logical_group_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channel_preferences",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `channel_id` INTEGER NOT NULL, `aspect_ratio` TEXT, `audio_video_offset_ms` INTEGER, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`channel_id`) REFERENCES `channels`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "aspectRatio",
+ "columnName": "aspect_ratio",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "audioVideoOffsetMs",
+ "columnName": "audio_video_offset_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_preferences_channel_id",
+ "unique": true,
+ "columnNames": [
+ "channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channel_preferences_channel_id` ON `${TABLE_NAME}` (`channel_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "channels",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "channel_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channels_fts",
+ "createSql": "CREATE VIRTUAL TABLE IF NOT EXISTS `${TABLE_NAME}` USING FTS4(`name` TEXT NOT NULL, content=`channels`)",
+ "fields": [
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": []
+ },
+ "ftsVersion": "FTS4",
+ "ftsOptions": {
+ "tokenizer": "simple",
+ "tokenizerArgs": [],
+ "contentTable": "channels",
+ "languageIdColumnName": "",
+ "matchInfo": "FTS4",
+ "notIndexedColumns": [],
+ "prefixSizes": [],
+ "preferredOrder": "ASC"
+ },
+ "contentSyncTriggers": [
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_BEFORE_UPDATE BEFORE UPDATE ON `channels` BEGIN DELETE FROM `channels_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_BEFORE_DELETE BEFORE DELETE ON `channels` BEGIN DELETE FROM `channels_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_AFTER_UPDATE AFTER UPDATE ON `channels` BEGIN INSERT INTO `channels_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_AFTER_INSERT AFTER INSERT ON `channels` BEGIN INSERT INTO `channels_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END"
+ ]
+ },
+ {
+ "tableName": "movies",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `container_extension` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `duration` TEXT, `duration_seconds` INTEGER NOT NULL, `rating` REAL NOT NULL, `year` TEXT, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `provider_id` INTEGER NOT NULL, `watch_progress` INTEGER NOT NULL, `watch_count` INTEGER NOT NULL, `last_watched_at` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, `added_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "duration",
+ "columnName": "duration",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "durationSeconds",
+ "columnName": "duration_seconds",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "year",
+ "columnName": "year",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchProgress",
+ "columnName": "watch_progress",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchCount",
+ "columnName": "watch_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastWatchedAt",
+ "columnName": "last_watched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "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, `provider_series_id` TEXT, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `rating` REAL NOT NULL, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `episode_run_time` TEXT, `last_modified` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesId",
+ "columnName": "series_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerSeriesId",
+ "columnName": "provider_series_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "episodeRunTime",
+ "columnName": "episode_run_time",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastModified",
+ "columnName": "last_modified",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "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, `sync_fingerprint` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "parentId",
+ "columnName": "parent_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_categories_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_categories_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_categories_provider_id_type",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_categories_provider_id_type` ON `${TABLE_NAME}` (`provider_id`, `type`)"
+ },
+ {
+ "name": "index_categories_provider_id_category_id_type",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "category_id",
+ "type"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_categories_provider_id_category_id_type` ON `${TABLE_NAME}` (`provider_id`, `category_id`, `type`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channel_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `logo_url` TEXT, `group_title` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `epg_channel_id` TEXT, `number` INTEGER NOT NULL, `catch_up_supported` INTEGER NOT NULL, `catch_up_days` INTEGER NOT NULL, `catchUpSource` TEXT, `is_adult` INTEGER NOT NULL, `logical_group_id` TEXT NOT NULL, `error_count` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `stream_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logoUrl",
+ "columnName": "logo_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupTitle",
+ "columnName": "group_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgChannelId",
+ "columnName": "epg_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "number",
+ "columnName": "number",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSupported",
+ "columnName": "catch_up_supported",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpDays",
+ "columnName": "catch_up_days",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSource",
+ "columnName": "catchUpSource",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logicalGroupId",
+ "columnName": "logical_group_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "errorCount",
+ "columnName": "error_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "stream_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_channel_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "movie_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `container_extension` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `duration` TEXT, `duration_seconds` INTEGER NOT NULL, `rating` REAL NOT NULL, `year` TEXT, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, `added_at` INTEGER NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `stream_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "duration",
+ "columnName": "duration",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "durationSeconds",
+ "columnName": "duration_seconds",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "year",
+ "columnName": "year",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "stream_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_movie_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_movie_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "series_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `series_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `rating` REAL NOT NULL, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `episode_run_time` TEXT, `last_modified` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `series_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "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": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "series_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_series_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_series_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "category_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `parent_id` INTEGER, `type` TEXT NOT NULL, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `category_id`, `type`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "parentId",
+ "columnName": "parent_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "category_id",
+ "type"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_category_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_category_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_category_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_category_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ },
+ {
+ "name": "index_category_import_stage_provider_id_type",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_category_import_stage_provider_id_type` ON `${TABLE_NAME}` (`provider_id`, `type`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "programs",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` TEXT NOT NULL, `title` TEXT NOT NULL, `description` TEXT NOT NULL, `start_time` INTEGER NOT NULL, `end_time` INTEGER NOT NULL, `lang` TEXT NOT NULL, `rating` TEXT, `image_url` TEXT, `genre` TEXT, `category` TEXT, `has_archive` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "startTime",
+ "columnName": "start_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "endTime",
+ "columnName": "end_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lang",
+ "columnName": "lang",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "imageUrl",
+ "columnName": "image_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "category",
+ "columnName": "category",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "hasArchive",
+ "columnName": "has_archive",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_programs_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_programs_provider_id_channel_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_channel_id` ON `${TABLE_NAME}` (`provider_id`, `channel_id`)"
+ },
+ {
+ "name": "index_programs_provider_id_end_time_channel_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "end_time",
+ "channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_end_time_channel_id` ON `${TABLE_NAME}` (`provider_id`, `end_time`, `channel_id`)"
+ },
+ {
+ "name": "index_programs_provider_id_start_time_end_time",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "start_time",
+ "end_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_start_time_end_time` ON `${TABLE_NAME}` (`provider_id`, `start_time`, `end_time`)"
+ },
+ {
+ "name": "index_programs_start_time",
+ "unique": false,
+ "columnNames": [
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_start_time` ON `${TABLE_NAME}` (`start_time`)"
+ },
+ {
+ "name": "index_programs_provider_id_channel_id_start_time",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_channel_id_start_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `start_time`)"
+ },
+ {
+ "name": "index_programs_provider_id_channel_id_start_time_end_time",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "start_time",
+ "end_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_programs_provider_id_channel_id_start_time_end_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `start_time`, `end_time`)"
+ }
+ ]
+ },
+ {
+ "tableName": "favorites",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `content_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `position` INTEGER NOT NULL, `group_id` INTEGER, `added_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`group_id`) REFERENCES `virtual_groups`(`id`) ON UPDATE NO ACTION ON DELETE SET NULL )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentId",
+ "columnName": "content_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "position",
+ "columnName": "position",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "groupId",
+ "columnName": "group_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_favorites_provider_id_content_id_content_type_group_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "content_id",
+ "content_type",
+ "group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_favorites_provider_id_content_id_content_type_group_id` ON `${TABLE_NAME}` (`provider_id`, `content_id`, `content_type`, `group_id`)"
+ },
+ {
+ "name": "index_favorites_provider_id_content_type_group_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type",
+ "group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_favorites_provider_id_content_type_group_id` ON `${TABLE_NAME}` (`provider_id`, `content_type`, `group_id`)"
+ },
+ {
+ "name": "index_favorites_group_id_position",
+ "unique": false,
+ "columnNames": [
+ "group_id",
+ "position"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_favorites_group_id_position` ON `${TABLE_NAME}` (`group_id`, `position`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "virtual_groups",
+ "onDelete": "SET NULL",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "group_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "virtual_groups",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `icon_emoji` TEXT, `position` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `content_type` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "iconEmoji",
+ "columnName": "icon_emoji",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "position",
+ "columnName": "position",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_virtual_groups_provider_id_content_type",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_virtual_groups_provider_id_content_type` ON `${TABLE_NAME}` (`provider_id`, `content_type`)"
+ },
+ {
+ "name": "index_virtual_groups_position",
+ "unique": false,
+ "columnNames": [
+ "position"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_virtual_groups_position` ON `${TABLE_NAME}` (`position`)"
+ },
+ {
+ "name": "index_virtual_groups_content_type",
+ "unique": false,
+ "columnNames": [
+ "content_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_virtual_groups_content_type` ON `${TABLE_NAME}` (`content_type`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "playback_history",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `content_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `title` TEXT NOT NULL, `poster_url` TEXT, `stream_url` TEXT NOT NULL, `resume_position_ms` INTEGER NOT NULL, `total_duration_ms` INTEGER NOT NULL, `last_watched_at` INTEGER NOT NULL, `watch_count` INTEGER NOT NULL, `watched_status` TEXT NOT NULL, `series_id` INTEGER, `season_number` INTEGER, `episode_number` INTEGER, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentId",
+ "columnName": "content_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "resumePositionMs",
+ "columnName": "resume_position_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalDurationMs",
+ "columnName": "total_duration_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastWatchedAt",
+ "columnName": "last_watched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchCount",
+ "columnName": "watch_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchedStatus",
+ "columnName": "watched_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesId",
+ "columnName": "series_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "seasonNumber",
+ "columnName": "season_number",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "episodeNumber",
+ "columnName": "episode_number",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_playback_history_content_id_content_type_provider_id",
+ "unique": true,
+ "columnNames": [
+ "content_id",
+ "content_type",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_playback_history_content_id_content_type_provider_id` ON `${TABLE_NAME}` (`content_id`, `content_type`, `provider_id`)"
+ },
+ {
+ "name": "index_playback_history_last_watched_at",
+ "unique": false,
+ "columnNames": [
+ "last_watched_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_history_last_watched_at` ON `${TABLE_NAME}` (`last_watched_at`)"
+ },
+ {
+ "name": "index_playback_history_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_history_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "tmdb_identity",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`tmdb_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `canonical_provider_id` INTEGER NOT NULL, `first_seen_at` INTEGER NOT NULL, PRIMARY KEY(`tmdb_id`, `content_type`), FOREIGN KEY(`canonical_provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "canonicalProviderId",
+ "columnName": "canonical_provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "firstSeenAt",
+ "columnName": "first_seen_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "tmdb_id",
+ "content_type"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_tmdb_identity_content_type",
+ "unique": false,
+ "columnNames": [
+ "content_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_tmdb_identity_content_type` ON `${TABLE_NAME}` (`content_type`)"
+ },
+ {
+ "name": "index_tmdb_identity_canonical_provider_id",
+ "unique": false,
+ "columnNames": [
+ "canonical_provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_tmdb_identity_canonical_provider_id` ON `${TABLE_NAME}` (`canonical_provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "canonical_provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "search_history",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `query` TEXT NOT NULL, `content_scope` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `used_at` INTEGER NOT NULL, `use_count` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "query",
+ "columnName": "query",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentScope",
+ "columnName": "content_scope",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "usedAt",
+ "columnName": "used_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "useCount",
+ "columnName": "use_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_search_history_content_scope_provider_id_used_at",
+ "unique": false,
+ "columnNames": [
+ "content_scope",
+ "provider_id",
+ "used_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_search_history_content_scope_provider_id_used_at` ON `${TABLE_NAME}` (`content_scope`, `provider_id`, `used_at`)"
+ },
+ {
+ "name": "index_search_history_used_at",
+ "unique": false,
+ "columnNames": [
+ "used_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_search_history_used_at` ON `${TABLE_NAME}` (`used_at`)"
+ },
+ {
+ "name": "index_search_history_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_search_history_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_search_history_query_content_scope_provider_id",
+ "unique": true,
+ "columnNames": [
+ "query",
+ "content_scope",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_search_history_query_content_scope_provider_id` ON `${TABLE_NAME}` (`query`, `content_scope`, `provider_id`)"
+ }
+ ]
+ },
+ {
+ "tableName": "sync_metadata",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `last_live_sync` INTEGER NOT NULL, `last_live_success` INTEGER NOT NULL, `last_movie_sync` INTEGER NOT NULL, `last_series_sync` INTEGER NOT NULL, `last_series_success` INTEGER NOT NULL, `last_epg_sync` INTEGER NOT NULL, `last_epg_success` INTEGER NOT NULL, `last_movie_attempt` INTEGER NOT NULL, `last_movie_success` INTEGER NOT NULL, `last_movie_partial` INTEGER NOT NULL, `live_count` INTEGER NOT NULL, `movie_count` INTEGER NOT NULL, `series_count` INTEGER NOT NULL, `epg_count` INTEGER NOT NULL, `last_sync_status` TEXT NOT NULL, `movie_sync_mode` TEXT NOT NULL, `movie_warnings_count` INTEGER NOT NULL, `movie_catalog_stale` INTEGER NOT NULL, `live_avoid_full_until` INTEGER NOT NULL, `movie_avoid_full_until` INTEGER NOT NULL, `series_avoid_full_until` INTEGER NOT NULL, `live_sequential_failures_remembered` INTEGER NOT NULL, `live_healthy_sync_streak` INTEGER NOT NULL, `movie_parallel_failures_remembered` INTEGER NOT NULL, `movie_healthy_sync_streak` INTEGER NOT NULL, `series_sequential_failures_remembered` INTEGER NOT NULL, `series_healthy_sync_streak` INTEGER NOT NULL, PRIMARY KEY(`provider_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastLiveSync",
+ "columnName": "last_live_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastLiveSuccess",
+ "columnName": "last_live_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMovieSync",
+ "columnName": "last_movie_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSeriesSync",
+ "columnName": "last_series_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSeriesSuccess",
+ "columnName": "last_series_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastEpgSync",
+ "columnName": "last_epg_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastEpgSuccess",
+ "columnName": "last_epg_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMovieAttempt",
+ "columnName": "last_movie_attempt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMovieSuccess",
+ "columnName": "last_movie_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMoviePartial",
+ "columnName": "last_movie_partial",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveCount",
+ "columnName": "live_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieCount",
+ "columnName": "movie_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesCount",
+ "columnName": "series_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgCount",
+ "columnName": "epg_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSyncStatus",
+ "columnName": "last_sync_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieSyncMode",
+ "columnName": "movie_sync_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieWarningsCount",
+ "columnName": "movie_warnings_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieCatalogStale",
+ "columnName": "movie_catalog_stale",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveAvoidFullUntil",
+ "columnName": "live_avoid_full_until",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieAvoidFullUntil",
+ "columnName": "movie_avoid_full_until",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesAvoidFullUntil",
+ "columnName": "series_avoid_full_until",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveSequentialFailuresRemembered",
+ "columnName": "live_sequential_failures_remembered",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveHealthySyncStreak",
+ "columnName": "live_healthy_sync_streak",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieParallelFailuresRemembered",
+ "columnName": "movie_parallel_failures_remembered",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieHealthySyncStreak",
+ "columnName": "movie_healthy_sync_streak",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesSequentialFailuresRemembered",
+ "columnName": "series_sequential_failures_remembered",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesHealthySyncStreak",
+ "columnName": "series_healthy_sync_streak",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "movie_category_hydration",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `last_hydrated_at` INTEGER NOT NULL, `item_count` INTEGER NOT NULL, `last_status` TEXT NOT NULL, `last_error` TEXT, PRIMARY KEY(`provider_id`, `category_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastHydratedAt",
+ "columnName": "last_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemCount",
+ "columnName": "item_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastStatus",
+ "columnName": "last_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_movie_category_hydration_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_category_hydration_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "series_category_hydration",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `last_hydrated_at` INTEGER NOT NULL, `item_count` INTEGER NOT NULL, `last_status` TEXT NOT NULL, `last_error` TEXT, PRIMARY KEY(`provider_id`, `category_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastHydratedAt",
+ "columnName": "last_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemCount",
+ "columnName": "item_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastStatus",
+ "columnName": "last_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_series_category_hydration_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_category_hydration_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "epg_sources",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `url` TEXT NOT NULL, `enabled` INTEGER NOT NULL, `last_refresh_at` INTEGER NOT NULL, `last_success_at` INTEGER NOT NULL, `last_error` TEXT, `priority` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, `etag` TEXT, `last_modified_header` TEXT)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "url",
+ "columnName": "url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastRefreshAt",
+ "columnName": "last_refresh_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSuccessAt",
+ "columnName": "last_success_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "etag",
+ "columnName": "etag",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastModifiedHeader",
+ "columnName": "last_modified_header",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_epg_sources_url",
+ "unique": true,
+ "columnNames": [
+ "url"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_sources_url` ON `${TABLE_NAME}` (`url`)"
+ }
+ ]
+ },
+ {
+ "tableName": "provider_epg_sources",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `epg_source_id` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_provider_epg_sources_provider_id_epg_source_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_provider_epg_sources_provider_id_epg_source_id` ON `${TABLE_NAME}` (`provider_id`, `epg_source_id`)"
+ },
+ {
+ "name": "index_provider_epg_sources_epg_source_id",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_provider_epg_sources_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "epg_sources",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "epg_source_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "epg_channels",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `epg_source_id` INTEGER NOT NULL, `xmltv_channel_id` TEXT NOT NULL, `display_name` TEXT NOT NULL, `normalized_name` TEXT NOT NULL, `icon_url` TEXT, FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "displayName",
+ "columnName": "display_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "normalizedName",
+ "columnName": "normalized_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "iconUrl",
+ "columnName": "icon_url",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_epg_channels_epg_source_id_xmltv_channel_id",
+ "unique": true,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_channels_epg_source_id_xmltv_channel_id` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`)"
+ },
+ {
+ "name": "index_epg_channels_epg_source_id",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_channels_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
+ },
+ {
+ "name": "index_epg_channels_normalized_name",
+ "unique": false,
+ "columnNames": [
+ "normalized_name"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_channels_normalized_name` ON `${TABLE_NAME}` (`normalized_name`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "epg_sources",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "epg_source_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "epg_programmes",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `epg_source_id` INTEGER NOT NULL, `xmltv_channel_id` TEXT NOT NULL, `start_time` INTEGER NOT NULL, `end_time` INTEGER NOT NULL, `title` TEXT NOT NULL, `subtitle` TEXT, `description` TEXT NOT NULL, `category` TEXT, `lang` TEXT NOT NULL, `rating` TEXT, `image_url` TEXT, `episode_info` TEXT, FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "startTime",
+ "columnName": "start_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "endTime",
+ "columnName": "end_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "subtitle",
+ "columnName": "subtitle",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "category",
+ "columnName": "category",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lang",
+ "columnName": "lang",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "imageUrl",
+ "columnName": "image_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "episodeInfo",
+ "columnName": "episode_info",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_epg_programmes_epg_source_id_xmltv_channel_id_start_time",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id",
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id_xmltv_channel_id_start_time` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`, `start_time`)"
+ },
+ {
+ "name": "index_epg_programmes_epg_source_id_xmltv_channel_id_start_time_end_time",
+ "unique": true,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id",
+ "start_time",
+ "end_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id_xmltv_channel_id_start_time_end_time` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`, `start_time`, `end_time`)"
+ },
+ {
+ "name": "index_epg_programmes_epg_source_id",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
+ },
+ {
+ "name": "index_epg_programmes_start_time",
+ "unique": false,
+ "columnNames": [
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_start_time` ON `${TABLE_NAME}` (`start_time`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "epg_sources",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "epg_source_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channel_epg_mappings",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_channel_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `source_type` TEXT NOT NULL, `epg_source_id` INTEGER, `xmltv_channel_id` TEXT, `match_type` TEXT, `confidence` REAL NOT NULL, `matched_at` INTEGER NOT NULL, `failed_attempts` INTEGER NOT NULL, `source` TEXT, `is_manual_override` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerChannelId",
+ "columnName": "provider_channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sourceType",
+ "columnName": "source_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "matchType",
+ "columnName": "match_type",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "confidence",
+ "columnName": "confidence",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "matchedAt",
+ "columnName": "matched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failedAttempts",
+ "columnName": "failed_attempts",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "source",
+ "columnName": "source",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isManualOverride",
+ "columnName": "is_manual_override",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_epg_mappings_provider_id_provider_channel_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "provider_channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channel_epg_mappings_provider_id_provider_channel_id` ON `${TABLE_NAME}` (`provider_id`, `provider_channel_id`)"
+ },
+ {
+ "name": "index_channel_epg_mappings_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_epg_mappings_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "combined_m3u_profiles",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `enabled` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ }
+ },
+ {
+ "tableName": "combined_m3u_profile_members",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `profile_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, FOREIGN KEY(`profile_id`) REFERENCES `combined_m3u_profiles`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profileId",
+ "columnName": "profile_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_combined_m3u_profile_members_profile_id",
+ "unique": false,
+ "columnNames": [
+ "profile_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_profile_id` ON `${TABLE_NAME}` (`profile_id`)"
+ },
+ {
+ "name": "index_combined_m3u_profile_members_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_combined_m3u_profile_members_profile_id_provider_id",
+ "unique": true,
+ "columnNames": [
+ "profile_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_profile_id_provider_id` ON `${TABLE_NAME}` (`profile_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "combined_m3u_profiles",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "profile_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_schedules",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` INTEGER NOT NULL, `channel_name` TEXT NOT NULL, `stream_url` TEXT NOT NULL, `program_title` TEXT, `requested_start_ms` INTEGER NOT NULL, `requested_end_ms` INTEGER NOT NULL, `recurrence` TEXT NOT NULL, `recurring_rule_id` TEXT, `enabled` INTEGER NOT NULL, `is_manual` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "requestedStartMs",
+ "columnName": "requested_start_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "requestedEndMs",
+ "columnName": "requested_end_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurrence",
+ "columnName": "recurrence",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurringRuleId",
+ "columnName": "recurring_rule_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isManual",
+ "columnName": "is_manual",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_recording_schedules_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_recording_schedules_enabled_requested_start_ms",
+ "unique": false,
+ "columnNames": [
+ "enabled",
+ "requested_start_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_enabled_requested_start_ms` ON `${TABLE_NAME}` (`enabled`, `requested_start_ms`)"
+ },
+ {
+ "name": "index_recording_schedules_recurring_rule_id",
+ "unique": false,
+ "columnNames": [
+ "recurring_rule_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_recurring_rule_id` ON `${TABLE_NAME}` (`recurring_rule_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_runs",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `schedule_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` INTEGER NOT NULL, `channel_name` TEXT NOT NULL, `stream_url` TEXT NOT NULL, `program_title` TEXT, `scheduled_start_ms` INTEGER NOT NULL, `scheduled_end_ms` INTEGER NOT NULL, `recurrence` TEXT NOT NULL, `recurring_rule_id` TEXT, `status` TEXT NOT NULL, `source_type` TEXT NOT NULL, `resolved_url` TEXT, `headers_json` TEXT NOT NULL, `user_agent` TEXT, `expiration_time` INTEGER, `provider_label` TEXT, `output_uri` TEXT, `output_display_path` TEXT, `bytes_written` INTEGER NOT NULL, `average_throughput_bps` INTEGER NOT NULL, `retry_count` INTEGER NOT NULL, `last_progress_at_ms` INTEGER, `failure_category` TEXT NOT NULL, `failure_reason` TEXT, `terminal_at_ms` INTEGER, `started_at_ms` INTEGER, `ended_at_ms` INTEGER, `schedule_enabled` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `alarm_start_at_ms` INTEGER, `alarm_stop_at_ms` INTEGER, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`schedule_id`) REFERENCES `recording_schedules`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "scheduleId",
+ "columnName": "schedule_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "scheduledStartMs",
+ "columnName": "scheduled_start_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "scheduledEndMs",
+ "columnName": "scheduled_end_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurrence",
+ "columnName": "recurrence",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurringRuleId",
+ "columnName": "recurring_rule_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sourceType",
+ "columnName": "source_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "resolvedUrl",
+ "columnName": "resolved_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "headersJson",
+ "columnName": "headers_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userAgent",
+ "columnName": "user_agent",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "expirationTime",
+ "columnName": "expiration_time",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "providerLabel",
+ "columnName": "provider_label",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputUri",
+ "columnName": "output_uri",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputDisplayPath",
+ "columnName": "output_display_path",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "bytesWritten",
+ "columnName": "bytes_written",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "averageThroughputBytesPerSecond",
+ "columnName": "average_throughput_bps",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryCount",
+ "columnName": "retry_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastProgressAtMs",
+ "columnName": "last_progress_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "failureCategory",
+ "columnName": "failure_category",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failure_reason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "terminalAtMs",
+ "columnName": "terminal_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "startedAtMs",
+ "columnName": "started_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "endedAtMs",
+ "columnName": "ended_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "scheduleEnabled",
+ "columnName": "schedule_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "alarmStartAtMs",
+ "columnName": "alarm_start_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "alarmStopAtMs",
+ "columnName": "alarm_stop_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_recording_runs_schedule_id",
+ "unique": false,
+ "columnNames": [
+ "schedule_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_schedule_id` ON `${TABLE_NAME}` (`schedule_id`)"
+ },
+ {
+ "name": "index_recording_runs_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_recording_runs_status_scheduled_start_ms",
+ "unique": false,
+ "columnNames": [
+ "status",
+ "scheduled_start_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_status_scheduled_start_ms` ON `${TABLE_NAME}` (`status`, `scheduled_start_ms`)"
+ },
+ {
+ "name": "index_recording_runs_alarm_start_at_ms",
+ "unique": false,
+ "columnNames": [
+ "alarm_start_at_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_alarm_start_at_ms` ON `${TABLE_NAME}` (`alarm_start_at_ms`)"
+ },
+ {
+ "name": "index_recording_runs_alarm_stop_at_ms",
+ "unique": false,
+ "columnNames": [
+ "alarm_stop_at_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_alarm_stop_at_ms` ON `${TABLE_NAME}` (`alarm_stop_at_ms`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "recording_schedules",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "schedule_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "program_reminders",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` TEXT NOT NULL, `channel_name` TEXT NOT NULL, `program_title` TEXT NOT NULL, `program_start_time` INTEGER NOT NULL, `remind_at` INTEGER NOT NULL, `lead_time_minutes` INTEGER NOT NULL, `is_dismissed` INTEGER NOT NULL, `notified_at` INTEGER, `created_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programStartTime",
+ "columnName": "program_start_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "remindAt",
+ "columnName": "remind_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "leadTimeMinutes",
+ "columnName": "lead_time_minutes",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isDismissed",
+ "columnName": "is_dismissed",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "notifiedAt",
+ "columnName": "notified_at",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_program_reminders_provider_id_remind_at",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "remind_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_provider_id_remind_at` ON `${TABLE_NAME}` (`provider_id`, `remind_at`)"
+ },
+ {
+ "name": "index_program_reminders_is_dismissed_notified_at_remind_at",
+ "unique": false,
+ "columnNames": [
+ "is_dismissed",
+ "notified_at",
+ "remind_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_is_dismissed_notified_at_remind_at` ON `${TABLE_NAME}` (`is_dismissed`, `notified_at`, `remind_at`)"
+ },
+ {
+ "name": "index_program_reminders_provider_id_channel_id_program_start_time",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "program_start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_provider_id_channel_id_program_start_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `program_start_time`)"
+ },
+ {
+ "name": "index_program_reminders_provider_id_channel_id_program_title_program_start_time",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "program_title",
+ "program_start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_program_reminders_provider_id_channel_id_program_title_program_start_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `program_title`, `program_start_time`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_storage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `tree_uri` TEXT, `display_name` TEXT, `output_directory` TEXT, `available_bytes` INTEGER, `is_writable` INTEGER NOT NULL, `file_name_pattern` TEXT NOT NULL, `retention_days` INTEGER, `max_simultaneous_recordings` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "treeUri",
+ "columnName": "tree_uri",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "displayName",
+ "columnName": "display_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputDirectory",
+ "columnName": "output_directory",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "availableBytes",
+ "columnName": "available_bytes",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "isWritable",
+ "columnName": "is_writable",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "fileNamePattern",
+ "columnName": "file_name_pattern",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retentionDays",
+ "columnName": "retention_days",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "maxSimultaneousRecordings",
+ "columnName": "max_simultaneous_recordings",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ }
+ },
+ {
+ "tableName": "playback_compatibility_records",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `device_fingerprint` TEXT NOT NULL, `device_model` TEXT NOT NULL, `android_sdk` INTEGER NOT NULL, `stream_type` TEXT NOT NULL, `video_mime_type` TEXT NOT NULL, `resolution_bucket` TEXT NOT NULL, `decoder_name` TEXT NOT NULL, `surface_type` TEXT NOT NULL, `failure_type` TEXT NOT NULL, `last_failed_at` INTEGER NOT NULL, `last_succeeded_at` INTEGER NOT NULL, `failure_count` INTEGER NOT NULL, `success_count` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deviceFingerprint",
+ "columnName": "device_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deviceModel",
+ "columnName": "device_model",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "androidSdk",
+ "columnName": "android_sdk",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamType",
+ "columnName": "stream_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "videoMimeType",
+ "columnName": "video_mime_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "resolutionBucket",
+ "columnName": "resolution_bucket",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "decoderName",
+ "columnName": "decoder_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "surfaceType",
+ "columnName": "surface_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureType",
+ "columnName": "failure_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastFailedAt",
+ "columnName": "last_failed_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSucceededAt",
+ "columnName": "last_succeeded_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureCount",
+ "columnName": "failure_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "successCount",
+ "columnName": "success_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket_decoder_name_surface_type",
+ "unique": true,
+ "columnNames": [
+ "device_fingerprint",
+ "stream_type",
+ "video_mime_type",
+ "resolution_bucket",
+ "decoder_name",
+ "surface_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket_decoder_name_surface_type` ON `${TABLE_NAME}` (`device_fingerprint`, `stream_type`, `video_mime_type`, `resolution_bucket`, `decoder_name`, `surface_type`)"
+ },
+ {
+ "name": "index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket",
+ "unique": false,
+ "columnNames": [
+ "device_fingerprint",
+ "stream_type",
+ "video_mime_type",
+ "resolution_bucket"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket` ON `${TABLE_NAME}` (`device_fingerprint`, `stream_type`, `video_mime_type`, `resolution_bucket`)"
+ },
+ {
+ "name": "index_playback_compatibility_records_last_failed_at",
+ "unique": false,
+ "columnNames": [
+ "last_failed_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_compatibility_records_last_failed_at` ON `${TABLE_NAME}` (`last_failed_at`)"
+ },
+ {
+ "name": "index_playback_compatibility_records_last_succeeded_at",
+ "unique": false,
+ "columnNames": [
+ "last_succeeded_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_compatibility_records_last_succeeded_at` ON `${TABLE_NAME}` (`last_succeeded_at`)"
+ }
+ ]
+ }
+ ],
+ "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, '33ce9016a555227887e6423952f80f17')"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/data/schemas/com.streamvault.data.local.StreamVaultDatabase/44.json b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/44.json
new file mode 100644
index 00000000..a0a455dd
--- /dev/null
+++ b/data/schemas/com.streamvault.data.local.StreamVaultDatabase/44.json
@@ -0,0 +1,4277 @@
+{
+ "formatVersion": 1,
+ "database": {
+ "version": 44,
+ "identityHash": "73adc609a133e7adfc18b554b1a8fd81",
+ "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, `stalker_mac_address` TEXT NOT NULL, `stalker_device_profile` TEXT NOT NULL, `stalker_device_timezone` TEXT NOT NULL, `stalker_device_locale` TEXT NOT NULL, `is_active` INTEGER NOT NULL, `max_connections` INTEGER NOT NULL, `expiration_date` INTEGER, `api_version` TEXT, `allowed_output_formats_json` TEXT NOT NULL, `epg_sync_mode` TEXT NOT NULL, `xtream_fast_sync_enabled` INTEGER NOT NULL, `m3u_vod_classification_enabled` INTEGER NOT NULL, `status` TEXT NOT NULL, `last_synced_at` INTEGER NOT NULL, `created_at` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "serverUrl",
+ "columnName": "server_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "username",
+ "columnName": "username",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "password",
+ "columnName": "password",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "m3uUrl",
+ "columnName": "m3u_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgUrl",
+ "columnName": "epg_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerMacAddress",
+ "columnName": "stalker_mac_address",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceProfile",
+ "columnName": "stalker_device_profile",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceTimezone",
+ "columnName": "stalker_device_timezone",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "stalkerDeviceLocale",
+ "columnName": "stalker_device_locale",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isActive",
+ "columnName": "is_active",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "maxConnections",
+ "columnName": "max_connections",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "expirationDate",
+ "columnName": "expiration_date",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "apiVersion",
+ "columnName": "api_version",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "allowedOutputFormatsJson",
+ "columnName": "allowed_output_formats_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSyncMode",
+ "columnName": "epg_sync_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xtreamFastSyncEnabled",
+ "columnName": "xtream_fast_sync_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "m3uVodClassificationEnabled",
+ "columnName": "m3u_vod_classification_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSyncedAt",
+ "columnName": "last_synced_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_providers_server_url_username_stalker_mac_address",
+ "unique": true,
+ "columnNames": [
+ "server_url",
+ "username",
+ "stalker_mac_address"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_providers_server_url_username_stalker_mac_address` ON `${TABLE_NAME}` (`server_url`, `username`, `stalker_mac_address`)"
+ }
+ ]
+ },
+ {
+ "tableName": "channels",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `logo_url` TEXT, `group_title` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `epg_channel_id` TEXT, `number` INTEGER NOT NULL, `catch_up_supported` INTEGER NOT NULL, `catch_up_days` INTEGER NOT NULL, `catchUpSource` TEXT, `provider_id` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `logical_group_id` TEXT NOT NULL, `error_count` INTEGER NOT NULL, `quality_options_json` TEXT, `sync_fingerprint` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logoUrl",
+ "columnName": "logo_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupTitle",
+ "columnName": "group_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgChannelId",
+ "columnName": "epg_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "number",
+ "columnName": "number",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSupported",
+ "columnName": "catch_up_supported",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpDays",
+ "columnName": "catch_up_days",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSource",
+ "columnName": "catchUpSource",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logicalGroupId",
+ "columnName": "logical_group_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "errorCount",
+ "columnName": "error_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "qualityOptionsJson",
+ "columnName": "quality_options_json",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channels_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_category_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id_category_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_stream_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "stream_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channels_provider_id_stream_id` ON `${TABLE_NAME}` (`provider_id`, `stream_id`)"
+ },
+ {
+ "name": "index_channels_logical_group_id",
+ "unique": false,
+ "columnNames": [
+ "logical_group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_logical_group_id` ON `${TABLE_NAME}` (`logical_group_id`)"
+ },
+ {
+ "name": "index_channels_provider_id_category_id_logical_group_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "category_id",
+ "logical_group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channels_provider_id_category_id_logical_group_id` ON `${TABLE_NAME}` (`provider_id`, `category_id`, `logical_group_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channel_preferences",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `channel_id` INTEGER NOT NULL, `aspect_ratio` TEXT, `audio_video_offset_ms` INTEGER, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`channel_id`) REFERENCES `channels`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "aspectRatio",
+ "columnName": "aspect_ratio",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "audioVideoOffsetMs",
+ "columnName": "audio_video_offset_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_preferences_channel_id",
+ "unique": true,
+ "columnNames": [
+ "channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channel_preferences_channel_id` ON `${TABLE_NAME}` (`channel_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "channels",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "channel_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channels_fts",
+ "createSql": "CREATE VIRTUAL TABLE IF NOT EXISTS `${TABLE_NAME}` USING FTS4(`name` TEXT NOT NULL, content=`channels`)",
+ "fields": [
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": []
+ },
+ "ftsVersion": "FTS4",
+ "ftsOptions": {
+ "tokenizer": "simple",
+ "tokenizerArgs": [],
+ "contentTable": "channels",
+ "languageIdColumnName": "",
+ "matchInfo": "FTS4",
+ "notIndexedColumns": [],
+ "prefixSizes": [],
+ "preferredOrder": "ASC"
+ },
+ "contentSyncTriggers": [
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_BEFORE_UPDATE BEFORE UPDATE ON `channels` BEGIN DELETE FROM `channels_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_BEFORE_DELETE BEFORE DELETE ON `channels` BEGIN DELETE FROM `channels_fts` WHERE `docid`=OLD.`rowid`; END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_AFTER_UPDATE AFTER UPDATE ON `channels` BEGIN INSERT INTO `channels_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END",
+ "CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_channels_fts_AFTER_INSERT AFTER INSERT ON `channels` BEGIN INSERT INTO `channels_fts`(`docid`, `name`) VALUES (NEW.`rowid`, NEW.`name`); END"
+ ]
+ },
+ {
+ "tableName": "movies",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `container_extension` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `duration` TEXT, `duration_seconds` INTEGER NOT NULL, `rating` REAL NOT NULL, `year` TEXT, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `provider_id` INTEGER NOT NULL, `watch_progress` INTEGER NOT NULL, `watch_count` INTEGER NOT NULL, `last_watched_at` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, `added_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "duration",
+ "columnName": "duration",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "durationSeconds",
+ "columnName": "duration_seconds",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "year",
+ "columnName": "year",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchProgress",
+ "columnName": "watch_progress",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchCount",
+ "columnName": "watch_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastWatchedAt",
+ "columnName": "last_watched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "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, `provider_series_id` TEXT, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `rating` REAL NOT NULL, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `episode_run_time` TEXT, `last_modified` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `is_user_protected` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesId",
+ "columnName": "series_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerSeriesId",
+ "columnName": "provider_series_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "episodeRunTime",
+ "columnName": "episode_run_time",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastModified",
+ "columnName": "last_modified",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "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, `sync_fingerprint` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "parentId",
+ "columnName": "parent_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserProtected",
+ "columnName": "is_user_protected",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_categories_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_categories_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_categories_provider_id_type",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_categories_provider_id_type` ON `${TABLE_NAME}` (`provider_id`, `type`)"
+ },
+ {
+ "name": "index_categories_provider_id_category_id_type",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "category_id",
+ "type"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_categories_provider_id_category_id_type` ON `${TABLE_NAME}` (`provider_id`, `category_id`, `type`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channel_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `logo_url` TEXT, `group_title` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `epg_channel_id` TEXT, `number` INTEGER NOT NULL, `catch_up_supported` INTEGER NOT NULL, `catch_up_days` INTEGER NOT NULL, `catchUpSource` TEXT, `is_adult` INTEGER NOT NULL, `logical_group_id` TEXT NOT NULL, `error_count` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `stream_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logoUrl",
+ "columnName": "logo_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupTitle",
+ "columnName": "group_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgChannelId",
+ "columnName": "epg_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "number",
+ "columnName": "number",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSupported",
+ "columnName": "catch_up_supported",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpDays",
+ "columnName": "catch_up_days",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "catchUpSource",
+ "columnName": "catchUpSource",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "logicalGroupId",
+ "columnName": "logical_group_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "errorCount",
+ "columnName": "error_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "stream_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_channel_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "movie_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `stream_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `stream_url` TEXT NOT NULL, `container_extension` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `duration` TEXT, `duration_seconds` INTEGER NOT NULL, `rating` REAL NOT NULL, `year` TEXT, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, `added_at` INTEGER NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `stream_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamId",
+ "columnName": "stream_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "backdropUrl",
+ "columnName": "backdrop_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "categoryName",
+ "columnName": "category_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "containerExtension",
+ "columnName": "container_extension",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "plot",
+ "columnName": "plot",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "cast",
+ "columnName": "cast",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "director",
+ "columnName": "director",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "releaseDate",
+ "columnName": "release_date",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "duration",
+ "columnName": "duration",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "durationSeconds",
+ "columnName": "duration_seconds",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "year",
+ "columnName": "year",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "youtubeTrailer",
+ "columnName": "youtube_trailer",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "stream_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_movie_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_movie_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "series_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `series_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `poster_url` TEXT, `backdrop_url` TEXT, `category_id` INTEGER, `category_name` TEXT, `plot` TEXT, `cast` TEXT, `director` TEXT, `genre` TEXT, `release_date` TEXT, `rating` REAL NOT NULL, `tmdb_id` INTEGER, `youtube_trailer` TEXT, `episode_run_time` TEXT, `last_modified` INTEGER NOT NULL, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `series_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "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": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "series_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_series_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_series_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "category_import_stage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`session_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `parent_id` INTEGER, `type` TEXT NOT NULL, `is_adult` INTEGER NOT NULL, `sync_fingerprint` TEXT NOT NULL, PRIMARY KEY(`session_id`, `provider_id`, `category_id`, `type`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "session_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "parentId",
+ "columnName": "parent_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isAdult",
+ "columnName": "is_adult",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "syncFingerprint",
+ "columnName": "sync_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "session_id",
+ "provider_id",
+ "category_id",
+ "type"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_category_import_stage_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_category_import_stage_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_category_import_stage_session_id_provider_id",
+ "unique": false,
+ "columnNames": [
+ "session_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_category_import_stage_session_id_provider_id` ON `${TABLE_NAME}` (`session_id`, `provider_id`)"
+ },
+ {
+ "name": "index_category_import_stage_provider_id_type",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_category_import_stage_provider_id_type` ON `${TABLE_NAME}` (`provider_id`, `type`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "programs",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` TEXT NOT NULL, `title` TEXT NOT NULL, `description` TEXT NOT NULL, `start_time` INTEGER NOT NULL, `end_time` INTEGER NOT NULL, `lang` TEXT NOT NULL, `rating` TEXT, `image_url` TEXT, `genre` TEXT, `category` TEXT, `has_archive` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "startTime",
+ "columnName": "start_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "endTime",
+ "columnName": "end_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lang",
+ "columnName": "lang",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "imageUrl",
+ "columnName": "image_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "genre",
+ "columnName": "genre",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "category",
+ "columnName": "category",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "hasArchive",
+ "columnName": "has_archive",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_programs_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_programs_provider_id_channel_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_channel_id` ON `${TABLE_NAME}` (`provider_id`, `channel_id`)"
+ },
+ {
+ "name": "index_programs_provider_id_end_time_channel_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "end_time",
+ "channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_end_time_channel_id` ON `${TABLE_NAME}` (`provider_id`, `end_time`, `channel_id`)"
+ },
+ {
+ "name": "index_programs_provider_id_start_time_end_time",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "start_time",
+ "end_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_start_time_end_time` ON `${TABLE_NAME}` (`provider_id`, `start_time`, `end_time`)"
+ },
+ {
+ "name": "index_programs_start_time",
+ "unique": false,
+ "columnNames": [
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_start_time` ON `${TABLE_NAME}` (`start_time`)"
+ },
+ {
+ "name": "index_programs_provider_id_channel_id_start_time",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_programs_provider_id_channel_id_start_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `start_time`)"
+ },
+ {
+ "name": "index_programs_provider_id_channel_id_start_time_end_time",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "start_time",
+ "end_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_programs_provider_id_channel_id_start_time_end_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `start_time`, `end_time`)"
+ }
+ ]
+ },
+ {
+ "tableName": "favorites",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `content_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `position` INTEGER NOT NULL, `group_id` INTEGER, `added_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`group_id`) REFERENCES `virtual_groups`(`id`) ON UPDATE NO ACTION ON DELETE SET NULL )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentId",
+ "columnName": "content_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "position",
+ "columnName": "position",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "groupId",
+ "columnName": "group_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "addedAt",
+ "columnName": "added_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_favorites_provider_id_content_id_content_type_group_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "content_id",
+ "content_type",
+ "group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_favorites_provider_id_content_id_content_type_group_id` ON `${TABLE_NAME}` (`provider_id`, `content_id`, `content_type`, `group_id`)"
+ },
+ {
+ "name": "index_favorites_provider_id_content_type_group_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type",
+ "group_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_favorites_provider_id_content_type_group_id` ON `${TABLE_NAME}` (`provider_id`, `content_type`, `group_id`)"
+ },
+ {
+ "name": "index_favorites_group_id_position",
+ "unique": false,
+ "columnNames": [
+ "group_id",
+ "position"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_favorites_group_id_position` ON `${TABLE_NAME}` (`group_id`, `position`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "virtual_groups",
+ "onDelete": "SET NULL",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "group_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "virtual_groups",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `icon_emoji` TEXT, `position` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `content_type` TEXT NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "iconEmoji",
+ "columnName": "icon_emoji",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "position",
+ "columnName": "position",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_virtual_groups_provider_id_content_type",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "content_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_virtual_groups_provider_id_content_type` ON `${TABLE_NAME}` (`provider_id`, `content_type`)"
+ },
+ {
+ "name": "index_virtual_groups_position",
+ "unique": false,
+ "columnNames": [
+ "position"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_virtual_groups_position` ON `${TABLE_NAME}` (`position`)"
+ },
+ {
+ "name": "index_virtual_groups_content_type",
+ "unique": false,
+ "columnNames": [
+ "content_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_virtual_groups_content_type` ON `${TABLE_NAME}` (`content_type`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "playback_history",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `content_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `title` TEXT NOT NULL, `poster_url` TEXT, `stream_url` TEXT NOT NULL, `resume_position_ms` INTEGER NOT NULL, `total_duration_ms` INTEGER NOT NULL, `last_watched_at` INTEGER NOT NULL, `watch_count` INTEGER NOT NULL, `watched_status` TEXT NOT NULL, `series_id` INTEGER, `season_number` INTEGER, `episode_number` INTEGER, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentId",
+ "columnName": "content_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "posterUrl",
+ "columnName": "poster_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "resumePositionMs",
+ "columnName": "resume_position_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalDurationMs",
+ "columnName": "total_duration_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastWatchedAt",
+ "columnName": "last_watched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchCount",
+ "columnName": "watch_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "watchedStatus",
+ "columnName": "watched_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesId",
+ "columnName": "series_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "seasonNumber",
+ "columnName": "season_number",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "episodeNumber",
+ "columnName": "episode_number",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_playback_history_content_id_content_type_provider_id",
+ "unique": true,
+ "columnNames": [
+ "content_id",
+ "content_type",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_playback_history_content_id_content_type_provider_id` ON `${TABLE_NAME}` (`content_id`, `content_type`, `provider_id`)"
+ },
+ {
+ "name": "index_playback_history_last_watched_at",
+ "unique": false,
+ "columnNames": [
+ "last_watched_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_history_last_watched_at` ON `${TABLE_NAME}` (`last_watched_at`)"
+ },
+ {
+ "name": "index_playback_history_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_history_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "tmdb_identity",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`tmdb_id` INTEGER NOT NULL, `content_type` TEXT NOT NULL, `canonical_provider_id` INTEGER NOT NULL, `first_seen_at` INTEGER NOT NULL, PRIMARY KEY(`tmdb_id`, `content_type`), FOREIGN KEY(`canonical_provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "tmdbId",
+ "columnName": "tmdb_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentType",
+ "columnName": "content_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "canonicalProviderId",
+ "columnName": "canonical_provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "firstSeenAt",
+ "columnName": "first_seen_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "tmdb_id",
+ "content_type"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_tmdb_identity_content_type",
+ "unique": false,
+ "columnNames": [
+ "content_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_tmdb_identity_content_type` ON `${TABLE_NAME}` (`content_type`)"
+ },
+ {
+ "name": "index_tmdb_identity_canonical_provider_id",
+ "unique": false,
+ "columnNames": [
+ "canonical_provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_tmdb_identity_canonical_provider_id` ON `${TABLE_NAME}` (`canonical_provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "canonical_provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "search_history",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `query` TEXT NOT NULL, `content_scope` TEXT NOT NULL, `provider_id` INTEGER NOT NULL, `used_at` INTEGER NOT NULL, `use_count` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "query",
+ "columnName": "query",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "contentScope",
+ "columnName": "content_scope",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "usedAt",
+ "columnName": "used_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "useCount",
+ "columnName": "use_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_search_history_content_scope_provider_id_used_at",
+ "unique": false,
+ "columnNames": [
+ "content_scope",
+ "provider_id",
+ "used_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_search_history_content_scope_provider_id_used_at` ON `${TABLE_NAME}` (`content_scope`, `provider_id`, `used_at`)"
+ },
+ {
+ "name": "index_search_history_used_at",
+ "unique": false,
+ "columnNames": [
+ "used_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_search_history_used_at` ON `${TABLE_NAME}` (`used_at`)"
+ },
+ {
+ "name": "index_search_history_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_search_history_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_search_history_query_content_scope_provider_id",
+ "unique": true,
+ "columnNames": [
+ "query",
+ "content_scope",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_search_history_query_content_scope_provider_id` ON `${TABLE_NAME}` (`query`, `content_scope`, `provider_id`)"
+ }
+ ]
+ },
+ {
+ "tableName": "sync_metadata",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `last_live_sync` INTEGER NOT NULL, `last_live_success` INTEGER NOT NULL, `last_movie_sync` INTEGER NOT NULL, `last_series_sync` INTEGER NOT NULL, `last_series_success` INTEGER NOT NULL, `last_epg_sync` INTEGER NOT NULL, `last_epg_success` INTEGER NOT NULL, `last_movie_attempt` INTEGER NOT NULL, `last_movie_success` INTEGER NOT NULL, `last_movie_partial` INTEGER NOT NULL, `live_count` INTEGER NOT NULL, `movie_count` INTEGER NOT NULL, `series_count` INTEGER NOT NULL, `epg_count` INTEGER NOT NULL, `last_sync_status` TEXT NOT NULL, `movie_sync_mode` TEXT NOT NULL, `movie_warnings_count` INTEGER NOT NULL, `movie_catalog_stale` INTEGER NOT NULL, `live_avoid_full_until` INTEGER NOT NULL, `movie_avoid_full_until` INTEGER NOT NULL, `series_avoid_full_until` INTEGER NOT NULL, `live_sequential_failures_remembered` INTEGER NOT NULL, `live_healthy_sync_streak` INTEGER NOT NULL, `movie_parallel_failures_remembered` INTEGER NOT NULL, `movie_healthy_sync_streak` INTEGER NOT NULL, `series_sequential_failures_remembered` INTEGER NOT NULL, `series_healthy_sync_streak` INTEGER NOT NULL, PRIMARY KEY(`provider_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastLiveSync",
+ "columnName": "last_live_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastLiveSuccess",
+ "columnName": "last_live_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMovieSync",
+ "columnName": "last_movie_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSeriesSync",
+ "columnName": "last_series_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSeriesSuccess",
+ "columnName": "last_series_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastEpgSync",
+ "columnName": "last_epg_sync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastEpgSuccess",
+ "columnName": "last_epg_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMovieAttempt",
+ "columnName": "last_movie_attempt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMovieSuccess",
+ "columnName": "last_movie_success",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastMoviePartial",
+ "columnName": "last_movie_partial",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveCount",
+ "columnName": "live_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieCount",
+ "columnName": "movie_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesCount",
+ "columnName": "series_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgCount",
+ "columnName": "epg_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSyncStatus",
+ "columnName": "last_sync_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieSyncMode",
+ "columnName": "movie_sync_mode",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieWarningsCount",
+ "columnName": "movie_warnings_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieCatalogStale",
+ "columnName": "movie_catalog_stale",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveAvoidFullUntil",
+ "columnName": "live_avoid_full_until",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieAvoidFullUntil",
+ "columnName": "movie_avoid_full_until",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesAvoidFullUntil",
+ "columnName": "series_avoid_full_until",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveSequentialFailuresRemembered",
+ "columnName": "live_sequential_failures_remembered",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "liveHealthySyncStreak",
+ "columnName": "live_healthy_sync_streak",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieParallelFailuresRemembered",
+ "columnName": "movie_parallel_failures_remembered",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "movieHealthySyncStreak",
+ "columnName": "movie_healthy_sync_streak",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesSequentialFailuresRemembered",
+ "columnName": "series_sequential_failures_remembered",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "seriesHealthySyncStreak",
+ "columnName": "series_healthy_sync_streak",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "movie_category_hydration",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `last_hydrated_at` INTEGER NOT NULL, `item_count` INTEGER NOT NULL, `last_status` TEXT NOT NULL, `last_error` TEXT, `last_loaded_page` INTEGER NOT NULL, `total_pages` INTEGER NOT NULL, `is_complete` INTEGER NOT NULL, `page_size` INTEGER NOT NULL, PRIMARY KEY(`provider_id`, `category_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastHydratedAt",
+ "columnName": "last_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemCount",
+ "columnName": "item_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastStatus",
+ "columnName": "last_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastLoadedPage",
+ "columnName": "last_loaded_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalPages",
+ "columnName": "total_pages",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isComplete",
+ "columnName": "is_complete",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "pageSize",
+ "columnName": "page_size",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_movie_category_hydration_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_movie_category_hydration_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "series_category_hydration",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`provider_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, `last_hydrated_at` INTEGER NOT NULL, `item_count` INTEGER NOT NULL, `last_status` TEXT NOT NULL, `last_error` TEXT, `last_loaded_page` INTEGER NOT NULL, `total_pages` INTEGER NOT NULL, `is_complete` INTEGER NOT NULL, `page_size` INTEGER NOT NULL, PRIMARY KEY(`provider_id`, `category_id`), FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "categoryId",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastHydratedAt",
+ "columnName": "last_hydrated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemCount",
+ "columnName": "item_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastStatus",
+ "columnName": "last_status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastLoadedPage",
+ "columnName": "last_loaded_page",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "totalPages",
+ "columnName": "total_pages",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isComplete",
+ "columnName": "is_complete",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "pageSize",
+ "columnName": "page_size",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "provider_id",
+ "category_id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_series_category_hydration_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_series_category_hydration_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "epg_sources",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `url` TEXT NOT NULL, `enabled` INTEGER NOT NULL, `last_refresh_at` INTEGER NOT NULL, `last_success_at` INTEGER NOT NULL, `last_error` TEXT, `priority` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, `etag` TEXT, `last_modified_header` TEXT)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "url",
+ "columnName": "url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastRefreshAt",
+ "columnName": "last_refresh_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSuccessAt",
+ "columnName": "last_success_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastError",
+ "columnName": "last_error",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "etag",
+ "columnName": "etag",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lastModifiedHeader",
+ "columnName": "last_modified_header",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_epg_sources_url",
+ "unique": true,
+ "columnNames": [
+ "url"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_sources_url` ON `${TABLE_NAME}` (`url`)"
+ }
+ ]
+ },
+ {
+ "tableName": "provider_epg_sources",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `epg_source_id` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_provider_epg_sources_provider_id_epg_source_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_provider_epg_sources_provider_id_epg_source_id` ON `${TABLE_NAME}` (`provider_id`, `epg_source_id`)"
+ },
+ {
+ "name": "index_provider_epg_sources_epg_source_id",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_provider_epg_sources_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "epg_sources",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "epg_source_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "epg_channels",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `epg_source_id` INTEGER NOT NULL, `xmltv_channel_id` TEXT NOT NULL, `display_name` TEXT NOT NULL, `normalized_name` TEXT NOT NULL, `icon_url` TEXT, FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "displayName",
+ "columnName": "display_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "normalizedName",
+ "columnName": "normalized_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "iconUrl",
+ "columnName": "icon_url",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_epg_channels_epg_source_id_xmltv_channel_id",
+ "unique": true,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_channels_epg_source_id_xmltv_channel_id` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`)"
+ },
+ {
+ "name": "index_epg_channels_epg_source_id",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_channels_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
+ },
+ {
+ "name": "index_epg_channels_normalized_name",
+ "unique": false,
+ "columnNames": [
+ "normalized_name"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_channels_normalized_name` ON `${TABLE_NAME}` (`normalized_name`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "epg_sources",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "epg_source_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "epg_programmes",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `epg_source_id` INTEGER NOT NULL, `xmltv_channel_id` TEXT NOT NULL, `start_time` INTEGER NOT NULL, `end_time` INTEGER NOT NULL, `title` TEXT NOT NULL, `subtitle` TEXT, `description` TEXT NOT NULL, `category` TEXT, `lang` TEXT NOT NULL, `rating` TEXT, `image_url` TEXT, `episode_info` TEXT, FOREIGN KEY(`epg_source_id`) REFERENCES `epg_sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "startTime",
+ "columnName": "start_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "endTime",
+ "columnName": "end_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "title",
+ "columnName": "title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "subtitle",
+ "columnName": "subtitle",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "category",
+ "columnName": "category",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lang",
+ "columnName": "lang",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rating",
+ "columnName": "rating",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "imageUrl",
+ "columnName": "image_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "episodeInfo",
+ "columnName": "episode_info",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_epg_programmes_epg_source_id_xmltv_channel_id_start_time",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id",
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id_xmltv_channel_id_start_time` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`, `start_time`)"
+ },
+ {
+ "name": "index_epg_programmes_epg_source_id_xmltv_channel_id_start_time_end_time",
+ "unique": true,
+ "columnNames": [
+ "epg_source_id",
+ "xmltv_channel_id",
+ "start_time",
+ "end_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id_xmltv_channel_id_start_time_end_time` ON `${TABLE_NAME}` (`epg_source_id`, `xmltv_channel_id`, `start_time`, `end_time`)"
+ },
+ {
+ "name": "index_epg_programmes_epg_source_id",
+ "unique": false,
+ "columnNames": [
+ "epg_source_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_epg_source_id` ON `${TABLE_NAME}` (`epg_source_id`)"
+ },
+ {
+ "name": "index_epg_programmes_start_time",
+ "unique": false,
+ "columnNames": [
+ "start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_epg_programmes_start_time` ON `${TABLE_NAME}` (`start_time`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "epg_sources",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "epg_source_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "channel_epg_mappings",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_channel_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `source_type` TEXT NOT NULL, `epg_source_id` INTEGER, `xmltv_channel_id` TEXT, `match_type` TEXT, `confidence` REAL NOT NULL, `matched_at` INTEGER NOT NULL, `failed_attempts` INTEGER NOT NULL, `source` TEXT, `is_manual_override` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerChannelId",
+ "columnName": "provider_channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sourceType",
+ "columnName": "source_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epgSourceId",
+ "columnName": "epg_source_id",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "xmltvChannelId",
+ "columnName": "xmltv_channel_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "matchType",
+ "columnName": "match_type",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "confidence",
+ "columnName": "confidence",
+ "affinity": "REAL",
+ "notNull": true
+ },
+ {
+ "fieldPath": "matchedAt",
+ "columnName": "matched_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failedAttempts",
+ "columnName": "failed_attempts",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "source",
+ "columnName": "source",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "isManualOverride",
+ "columnName": "is_manual_override",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_channel_epg_mappings_provider_id_provider_channel_id",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "provider_channel_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_channel_epg_mappings_provider_id_provider_channel_id` ON `${TABLE_NAME}` (`provider_id`, `provider_channel_id`)"
+ },
+ {
+ "name": "index_channel_epg_mappings_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_channel_epg_mappings_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "combined_m3u_profiles",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `enabled` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ }
+ },
+ {
+ "tableName": "combined_m3u_profile_members",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `profile_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, FOREIGN KEY(`profile_id`) REFERENCES `combined_m3u_profiles`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profileId",
+ "columnName": "profile_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_combined_m3u_profile_members_profile_id",
+ "unique": false,
+ "columnNames": [
+ "profile_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_profile_id` ON `${TABLE_NAME}` (`profile_id`)"
+ },
+ {
+ "name": "index_combined_m3u_profile_members_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_combined_m3u_profile_members_profile_id_provider_id",
+ "unique": true,
+ "columnNames": [
+ "profile_id",
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_combined_m3u_profile_members_profile_id_provider_id` ON `${TABLE_NAME}` (`profile_id`, `provider_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "combined_m3u_profiles",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "profile_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_schedules",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` INTEGER NOT NULL, `channel_name` TEXT NOT NULL, `stream_url` TEXT NOT NULL, `program_title` TEXT, `requested_start_ms` INTEGER NOT NULL, `requested_end_ms` INTEGER NOT NULL, `recurrence` TEXT NOT NULL, `recurring_rule_id` TEXT, `enabled` INTEGER NOT NULL, `is_manual` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "requestedStartMs",
+ "columnName": "requested_start_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "requestedEndMs",
+ "columnName": "requested_end_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurrence",
+ "columnName": "recurrence",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurringRuleId",
+ "columnName": "recurring_rule_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "enabled",
+ "columnName": "enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isManual",
+ "columnName": "is_manual",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_recording_schedules_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_recording_schedules_enabled_requested_start_ms",
+ "unique": false,
+ "columnNames": [
+ "enabled",
+ "requested_start_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_enabled_requested_start_ms` ON `${TABLE_NAME}` (`enabled`, `requested_start_ms`)"
+ },
+ {
+ "name": "index_recording_schedules_recurring_rule_id",
+ "unique": false,
+ "columnNames": [
+ "recurring_rule_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_schedules_recurring_rule_id` ON `${TABLE_NAME}` (`recurring_rule_id`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_runs",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `schedule_id` INTEGER NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` INTEGER NOT NULL, `channel_name` TEXT NOT NULL, `stream_url` TEXT NOT NULL, `program_title` TEXT, `scheduled_start_ms` INTEGER NOT NULL, `scheduled_end_ms` INTEGER NOT NULL, `recurrence` TEXT NOT NULL, `recurring_rule_id` TEXT, `status` TEXT NOT NULL, `source_type` TEXT NOT NULL, `resolved_url` TEXT, `headers_json` TEXT NOT NULL, `user_agent` TEXT, `expiration_time` INTEGER, `provider_label` TEXT, `output_uri` TEXT, `output_display_path` TEXT, `bytes_written` INTEGER NOT NULL, `average_throughput_bps` INTEGER NOT NULL, `retry_count` INTEGER NOT NULL, `last_progress_at_ms` INTEGER, `failure_category` TEXT NOT NULL, `failure_reason` TEXT, `terminal_at_ms` INTEGER, `started_at_ms` INTEGER, `ended_at_ms` INTEGER, `schedule_enabled` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `alarm_start_at_ms` INTEGER, `alarm_stop_at_ms` INTEGER, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`schedule_id`) REFERENCES `recording_schedules`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "scheduleId",
+ "columnName": "schedule_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamUrl",
+ "columnName": "stream_url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "scheduledStartMs",
+ "columnName": "scheduled_start_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "scheduledEndMs",
+ "columnName": "scheduled_end_ms",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurrence",
+ "columnName": "recurrence",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "recurringRuleId",
+ "columnName": "recurring_rule_id",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sourceType",
+ "columnName": "source_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "resolvedUrl",
+ "columnName": "resolved_url",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "headersJson",
+ "columnName": "headers_json",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userAgent",
+ "columnName": "user_agent",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "expirationTime",
+ "columnName": "expiration_time",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "providerLabel",
+ "columnName": "provider_label",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputUri",
+ "columnName": "output_uri",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputDisplayPath",
+ "columnName": "output_display_path",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "bytesWritten",
+ "columnName": "bytes_written",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "averageThroughputBytesPerSecond",
+ "columnName": "average_throughput_bps",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retryCount",
+ "columnName": "retry_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastProgressAtMs",
+ "columnName": "last_progress_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "failureCategory",
+ "columnName": "failure_category",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failure_reason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "terminalAtMs",
+ "columnName": "terminal_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "startedAtMs",
+ "columnName": "started_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "endedAtMs",
+ "columnName": "ended_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "scheduleEnabled",
+ "columnName": "schedule_enabled",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "priority",
+ "columnName": "priority",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "alarmStartAtMs",
+ "columnName": "alarm_start_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "alarmStopAtMs",
+ "columnName": "alarm_stop_at_ms",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_recording_runs_schedule_id",
+ "unique": false,
+ "columnNames": [
+ "schedule_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_schedule_id` ON `${TABLE_NAME}` (`schedule_id`)"
+ },
+ {
+ "name": "index_recording_runs_provider_id",
+ "unique": false,
+ "columnNames": [
+ "provider_id"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_provider_id` ON `${TABLE_NAME}` (`provider_id`)"
+ },
+ {
+ "name": "index_recording_runs_status_scheduled_start_ms",
+ "unique": false,
+ "columnNames": [
+ "status",
+ "scheduled_start_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_status_scheduled_start_ms` ON `${TABLE_NAME}` (`status`, `scheduled_start_ms`)"
+ },
+ {
+ "name": "index_recording_runs_alarm_start_at_ms",
+ "unique": false,
+ "columnNames": [
+ "alarm_start_at_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_alarm_start_at_ms` ON `${TABLE_NAME}` (`alarm_start_at_ms`)"
+ },
+ {
+ "name": "index_recording_runs_alarm_stop_at_ms",
+ "unique": false,
+ "columnNames": [
+ "alarm_stop_at_ms"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_recording_runs_alarm_stop_at_ms` ON `${TABLE_NAME}` (`alarm_stop_at_ms`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "recording_schedules",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "schedule_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "program_reminders",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `provider_id` INTEGER NOT NULL, `channel_id` TEXT NOT NULL, `channel_name` TEXT NOT NULL, `program_title` TEXT NOT NULL, `program_start_time` INTEGER NOT NULL, `remind_at` INTEGER NOT NULL, `lead_time_minutes` INTEGER NOT NULL, `is_dismissed` INTEGER NOT NULL, `notified_at` INTEGER, `created_at` INTEGER NOT NULL, FOREIGN KEY(`provider_id`) REFERENCES `providers`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "providerId",
+ "columnName": "provider_id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelId",
+ "columnName": "channel_id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "channelName",
+ "columnName": "channel_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programTitle",
+ "columnName": "program_title",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "programStartTime",
+ "columnName": "program_start_time",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "remindAt",
+ "columnName": "remind_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "leadTimeMinutes",
+ "columnName": "lead_time_minutes",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isDismissed",
+ "columnName": "is_dismissed",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "notifiedAt",
+ "columnName": "notified_at",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "created_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_program_reminders_provider_id_remind_at",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "remind_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_provider_id_remind_at` ON `${TABLE_NAME}` (`provider_id`, `remind_at`)"
+ },
+ {
+ "name": "index_program_reminders_is_dismissed_notified_at_remind_at",
+ "unique": false,
+ "columnNames": [
+ "is_dismissed",
+ "notified_at",
+ "remind_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_is_dismissed_notified_at_remind_at` ON `${TABLE_NAME}` (`is_dismissed`, `notified_at`, `remind_at`)"
+ },
+ {
+ "name": "index_program_reminders_provider_id_channel_id_program_start_time",
+ "unique": false,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "program_start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_program_reminders_provider_id_channel_id_program_start_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `program_start_time`)"
+ },
+ {
+ "name": "index_program_reminders_provider_id_channel_id_program_title_program_start_time",
+ "unique": true,
+ "columnNames": [
+ "provider_id",
+ "channel_id",
+ "program_title",
+ "program_start_time"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_program_reminders_provider_id_channel_id_program_title_program_start_time` ON `${TABLE_NAME}` (`provider_id`, `channel_id`, `program_title`, `program_start_time`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "providers",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "provider_id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "recording_storage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `tree_uri` TEXT, `display_name` TEXT, `output_directory` TEXT, `available_bytes` INTEGER, `is_writable` INTEGER NOT NULL, `file_name_pattern` TEXT NOT NULL, `retention_days` INTEGER, `max_simultaneous_recordings` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "treeUri",
+ "columnName": "tree_uri",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "displayName",
+ "columnName": "display_name",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "outputDirectory",
+ "columnName": "output_directory",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "availableBytes",
+ "columnName": "available_bytes",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "isWritable",
+ "columnName": "is_writable",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "fileNamePattern",
+ "columnName": "file_name_pattern",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retentionDays",
+ "columnName": "retention_days",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "maxSimultaneousRecordings",
+ "columnName": "max_simultaneous_recordings",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updated_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ }
+ },
+ {
+ "tableName": "playback_compatibility_records",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `device_fingerprint` TEXT NOT NULL, `device_model` TEXT NOT NULL, `android_sdk` INTEGER NOT NULL, `stream_type` TEXT NOT NULL, `video_mime_type` TEXT NOT NULL, `resolution_bucket` TEXT NOT NULL, `decoder_name` TEXT NOT NULL, `surface_type` TEXT NOT NULL, `failure_type` TEXT NOT NULL, `last_failed_at` INTEGER NOT NULL, `last_succeeded_at` INTEGER NOT NULL, `failure_count` INTEGER NOT NULL, `success_count` INTEGER NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deviceFingerprint",
+ "columnName": "device_fingerprint",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deviceModel",
+ "columnName": "device_model",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "androidSdk",
+ "columnName": "android_sdk",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "streamType",
+ "columnName": "stream_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "videoMimeType",
+ "columnName": "video_mime_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "resolutionBucket",
+ "columnName": "resolution_bucket",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "decoderName",
+ "columnName": "decoder_name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "surfaceType",
+ "columnName": "surface_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureType",
+ "columnName": "failure_type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastFailedAt",
+ "columnName": "last_failed_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "lastSucceededAt",
+ "columnName": "last_succeeded_at",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "failureCount",
+ "columnName": "failure_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "successCount",
+ "columnName": "success_count",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket_decoder_name_surface_type",
+ "unique": true,
+ "columnNames": [
+ "device_fingerprint",
+ "stream_type",
+ "video_mime_type",
+ "resolution_bucket",
+ "decoder_name",
+ "surface_type"
+ ],
+ "orders": [],
+ "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket_decoder_name_surface_type` ON `${TABLE_NAME}` (`device_fingerprint`, `stream_type`, `video_mime_type`, `resolution_bucket`, `decoder_name`, `surface_type`)"
+ },
+ {
+ "name": "index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket",
+ "unique": false,
+ "columnNames": [
+ "device_fingerprint",
+ "stream_type",
+ "video_mime_type",
+ "resolution_bucket"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket` ON `${TABLE_NAME}` (`device_fingerprint`, `stream_type`, `video_mime_type`, `resolution_bucket`)"
+ },
+ {
+ "name": "index_playback_compatibility_records_last_failed_at",
+ "unique": false,
+ "columnNames": [
+ "last_failed_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_compatibility_records_last_failed_at` ON `${TABLE_NAME}` (`last_failed_at`)"
+ },
+ {
+ "name": "index_playback_compatibility_records_last_succeeded_at",
+ "unique": false,
+ "columnNames": [
+ "last_succeeded_at"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_playback_compatibility_records_last_succeeded_at` ON `${TABLE_NAME}` (`last_succeeded_at`)"
+ }
+ ]
+ }
+ ],
+ "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, '73adc609a133e7adfc18b554b1a8fd81')"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/data/src/androidTest/java/com/streamvault/data/local/StreamVaultDatabaseMigrationTest.kt b/data/src/androidTest/java/com/streamvault/data/local/StreamVaultDatabaseMigrationTest.kt
index fda467a9..85d85b4e 100644
--- a/data/src/androidTest/java/com/streamvault/data/local/StreamVaultDatabaseMigrationTest.kt
+++ b/data/src/androidTest/java/com/streamvault/data/local/StreamVaultDatabaseMigrationTest.kt
@@ -84,12 +84,12 @@ class StreamVaultDatabaseMigrationTest {
}
@Test
- fun migrate1To39_fullChainValidatesLatestSchema() {
+ fun migrate1To42_fullChainValidatesLatestSchema() {
migrationTestHelper.createDatabase("streamvault-full-chain-test", 1).close()
migrationTestHelper.runMigrationsAndValidate(
"streamvault-full-chain-test",
- 39,
+ 42,
true,
StreamVaultDatabase.MIGRATION_1_2,
StreamVaultDatabase.MIGRATION_2_3,
@@ -128,10 +128,115 @@ class StreamVaultDatabaseMigrationTest {
StreamVaultDatabase.MIGRATION_35_36,
StreamVaultDatabase.MIGRATION_36_37,
StreamVaultDatabase.MIGRATION_37_38,
- StreamVaultDatabase.MIGRATION_38_39
+ StreamVaultDatabase.MIGRATION_38_39,
+ StreamVaultDatabase.MIGRATION_39_40,
+ StreamVaultDatabase.MIGRATION_40_41,
+ StreamVaultDatabase.MIGRATION_41_42,
+ StreamVaultDatabase.MIGRATION_42_43,
+ StreamVaultDatabase.MIGRATION_43_44
).close()
}
+ @Test
+ fun migrate40To41_addsAudioVideoOffsetColumn() {
+ migrationTestHelper.createDatabase("streamvault-40-41-test", 40).close()
+
+ val migratedDb = migrationTestHelper.runMigrationsAndValidate(
+ "streamvault-40-41-test",
+ 41,
+ true,
+ StreamVaultDatabase.MIGRATION_40_41
+ )
+
+ assertEquals(
+ 1,
+ countRows(
+ migratedDb,
+ "SELECT COUNT(*) FROM pragma_table_info('channel_preferences') WHERE name = 'audio_video_offset_ms'"
+ )
+ )
+
+ migratedDb.close()
+ }
+
+ @Test
+ fun migrate41To42_createsPlaybackCompatibilityRecordsTable() {
+ migrationTestHelper.createDatabase("streamvault-41-42-test", 41).close()
+
+ val migratedDb = migrationTestHelper.runMigrationsAndValidate(
+ "streamvault-41-42-test",
+ 42,
+ true,
+ StreamVaultDatabase.MIGRATION_41_42
+ )
+
+ assertEquals(
+ 1,
+ countRows(
+ migratedDb,
+ "SELECT COUNT(*) FROM sqlite_master WHERE type = 'table' AND name = 'playback_compatibility_records'"
+ )
+ )
+ assertEquals(
+ 1,
+ countRows(
+ migratedDb,
+ "SELECT COUNT(*) FROM pragma_table_info('playback_compatibility_records') WHERE name = 'decoder_name'"
+ )
+ )
+
+ migratedDb.close()
+ }
+
+ @Test
+ fun migrate42To43_addsProviderSeriesIdColumn() {
+ migrationTestHelper.createDatabase("streamvault-42-43-test", 42).close()
+
+ val migratedDb = migrationTestHelper.runMigrationsAndValidate(
+ "streamvault-42-43-test",
+ 43,
+ true,
+ StreamVaultDatabase.MIGRATION_42_43
+ )
+
+ assertEquals(
+ 1,
+ countRows(
+ migratedDb,
+ "SELECT COUNT(*) FROM pragma_table_info('series') WHERE name = 'provider_series_id'"
+ )
+ )
+
+ migratedDb.close()
+ }
+
+ @Test
+ fun migrate43To44_addsPagedVodHydrationColumns() {
+ migrationTestHelper.createDatabase("streamvault-43-44-test", 43).close()
+
+ val migratedDb = migrationTestHelper.runMigrationsAndValidate(
+ "streamvault-43-44-test",
+ 44,
+ true,
+ StreamVaultDatabase.MIGRATION_43_44
+ )
+
+ listOf("movie_category_hydration", "series_category_hydration").forEach { table ->
+ assertEquals(
+ 4,
+ countRows(
+ migratedDb,
+ """
+ SELECT COUNT(*) FROM pragma_table_info('$table')
+ WHERE name IN ('last_loaded_page', 'total_pages', 'is_complete', 'page_size')
+ """.trimIndent()
+ )
+ )
+ }
+
+ migratedDb.close()
+ }
+
@Test
fun migrate38To39_addsStalkerProviderColumnsAndUniqueIndex() {
migrationTestHelper.createDatabase("streamvault-38-39-test", 38).apply {
diff --git a/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt b/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt
index 009c213d..69b9ed06 100644
--- a/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt
+++ b/data/src/main/java/com/streamvault/data/local/StreamVaultDatabase.kt
@@ -43,9 +43,10 @@ import com.streamvault.data.local.entity.*
RecordingScheduleEntity::class,
RecordingRunEntity::class,
ProgramReminderEntity::class,
- RecordingStorageEntity::class
+ RecordingStorageEntity::class,
+ PlaybackCompatibilityRecordEntity::class
],
- version = 40,
+ version = 44,
exportSchema = true // ← was false; schema JSON now tracked in version control
)
@TypeConverters(RoomEnumConverters::class)
@@ -78,6 +79,7 @@ abstract class StreamVaultDatabase : RoomDatabase() {
abstract fun recordingRunDao(): RecordingRunDao
abstract fun programReminderDao(): ProgramReminderDao
abstract fun recordingStorageDao(): RecordingStorageDao
+ abstract fun playbackCompatibilityDao(): PlaybackCompatibilityDao
companion object {
/**
@@ -1873,5 +1875,110 @@ abstract class StreamVaultDatabase : RoomDatabase() {
database.execSQL("DROP TRIGGER IF EXISTS series_au")
}
}
+
+ /**
+ * Migration 40 → 41: add per-channel A/V sync override.
+ * Null means the channel follows the global player default.
+ */
+ val MIGRATION_40_41 = object : Migration(40, 41) {
+ override fun migrate(database: SupportSQLiteDatabase) {
+ database.execSQL("ALTER TABLE channel_preferences ADD COLUMN audio_video_offset_ms INTEGER DEFAULT NULL")
+ }
+ }
+
+ /**
+ * Migration 41 -> 42: remember playback decoder/surface combinations that fail
+ * silently on a device so Auto mode can avoid repeating them.
+ */
+ val MIGRATION_41_42 = object : Migration(41, 42) {
+ override fun migrate(database: SupportSQLiteDatabase) {
+ database.execSQL(
+ """
+ CREATE TABLE IF NOT EXISTS playback_compatibility_records (
+ id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
+ device_fingerprint TEXT NOT NULL,
+ device_model TEXT NOT NULL,
+ android_sdk INTEGER NOT NULL,
+ stream_type TEXT NOT NULL,
+ video_mime_type TEXT NOT NULL,
+ resolution_bucket TEXT NOT NULL,
+ decoder_name TEXT NOT NULL,
+ surface_type TEXT NOT NULL,
+ failure_type TEXT NOT NULL DEFAULT '',
+ last_failed_at INTEGER NOT NULL DEFAULT 0,
+ last_succeeded_at INTEGER NOT NULL DEFAULT 0,
+ failure_count INTEGER NOT NULL DEFAULT 0,
+ success_count INTEGER NOT NULL DEFAULT 0
+ )
+ """.trimIndent()
+ )
+ database.execSQL(
+ """
+ CREATE UNIQUE INDEX IF NOT EXISTS index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket_decoder_name_surface_type
+ ON playback_compatibility_records(device_fingerprint, stream_type, video_mime_type, resolution_bucket, decoder_name, surface_type)
+ """.trimIndent()
+ )
+ database.execSQL(
+ """
+ CREATE INDEX IF NOT EXISTS index_playback_compatibility_records_device_fingerprint_stream_type_video_mime_type_resolution_bucket
+ ON playback_compatibility_records(device_fingerprint, stream_type, video_mime_type, resolution_bucket)
+ """.trimIndent()
+ )
+ database.execSQL("CREATE INDEX IF NOT EXISTS index_playback_compatibility_records_last_failed_at ON playback_compatibility_records(last_failed_at)")
+ database.execSQL("CREATE INDEX IF NOT EXISTS index_playback_compatibility_records_last_succeeded_at ON playback_compatibility_records(last_succeeded_at)")
+ }
+ }
+
+ /**
+ * Migration 42 -> 43: preserve provider-native series identifiers so Stalker
+ * series details can round-trip composite portal IDs.
+ */
+ val MIGRATION_42_43 = object : Migration(42, 43) {
+ override fun migrate(database: SupportSQLiteDatabase) {
+ database.execSQL("ALTER TABLE series ADD COLUMN provider_series_id TEXT")
+ database.execSQL(
+ "UPDATE series SET provider_series_id = CAST(series_id AS TEXT) WHERE provider_series_id IS NULL"
+ )
+ }
+ }
+
+ /**
+ * Migration 43 -> 44: add page-aware VOD/series category hydration metadata
+ * for on-demand Stalker paging while preserving existing complete caches.
+ */
+ val MIGRATION_43_44 = object : Migration(43, 44) {
+ override fun migrate(database: SupportSQLiteDatabase) {
+ addPagedHydrationColumns(database, "movie_category_hydration")
+ addPagedHydrationColumns(database, "series_category_hydration")
+ }
+
+ private fun addPagedHydrationColumns(database: SupportSQLiteDatabase, tableName: String) {
+ database.execSQL("ALTER TABLE $tableName ADD COLUMN last_loaded_page INTEGER NOT NULL DEFAULT 0")
+ database.execSQL("ALTER TABLE $tableName ADD COLUMN total_pages INTEGER NOT NULL DEFAULT 0")
+ database.execSQL("ALTER TABLE $tableName ADD COLUMN is_complete INTEGER NOT NULL DEFAULT 0")
+ database.execSQL("ALTER TABLE $tableName ADD COLUMN page_size INTEGER NOT NULL DEFAULT 0")
+ database.execSQL(
+ """
+ UPDATE $tableName
+ SET last_loaded_page = CASE
+ WHEN last_status = 'SUCCESS' THEN 1
+ ELSE 0
+ END,
+ total_pages = CASE
+ WHEN last_status = 'SUCCESS' THEN 1
+ ELSE 0
+ END,
+ is_complete = CASE
+ WHEN last_status = 'SUCCESS' THEN 1
+ ELSE 0
+ END,
+ page_size = CASE
+ WHEN last_status = 'SUCCESS' THEN item_count
+ ELSE 0
+ END
+ """.trimIndent()
+ )
+ }
+ }
}
}
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.kt
index 8f700061..76ad2d74 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
@@ -9,6 +9,11 @@ data class RemoteIdMapping(
@ColumnInfo(name = "remote_id") val remoteId: Long
)
+data class SeriesRemoteIdMapping(
+ @ColumnInfo(name = "id") val id: Long,
+ @ColumnInfo(name = "remote_id") val remoteId: String
+)
+
data class TmdbIdMapping(
@ColumnInfo(name = "tmdb_id") val tmdbId: Long
)
@@ -175,6 +180,58 @@ abstract class ChannelDao {
limit: Int
): Flow<List<ChannelBrowseEntity>>
+ @Query(
+ """
+ SELECT id, stream_id, name, logo_url, group_title, category_id, category_name, stream_url,
+ epg_channel_id, number, catch_up_supported, catch_up_days, catchUpSource,
+ provider_id, is_adult, is_user_protected, logical_group_id, error_count
+ FROM channels
+ WHERE provider_id = :providerId
+ ORDER BY number ASC
+ LIMIT :limit OFFSET :offset
+ """
+ )
+ abstract suspend fun getByProviderBrowsePageOffset(providerId: Long, limit: Int, offset: Int): List<ChannelBrowseEntity>
+
+ @Query(
+ """
+ SELECT id, stream_id, name, logo_url, group_title, category_id, category_name, stream_url,
+ epg_channel_id, number, catch_up_supported, catch_up_days, catchUpSource,
+ provider_id, is_adult, is_user_protected, logical_group_id, error_count
+ FROM channels
+ WHERE provider_id = :providerId AND error_count = 0
+ ORDER BY number ASC
+ LIMIT :limit OFFSET :offset
+ """
+ )
+ abstract suspend fun getByProviderWithoutErrorsBrowsePageOffset(providerId: Long, limit: Int, offset: Int): List<ChannelBrowseEntity>
+
+ @Query(
+ """
+ SELECT id, stream_id, name, logo_url, group_title, category_id, category_name, stream_url,
+ epg_channel_id, number, catch_up_supported, catch_up_days, catchUpSource,
+ provider_id, is_adult, is_user_protected, logical_group_id, error_count
+ FROM channels
+ WHERE provider_id = :providerId AND category_id = :categoryId
+ ORDER BY number ASC
+ LIMIT :limit OFFSET :offset
+ """
+ )
+ abstract suspend fun getByCategoryBrowsePageOffset(providerId: Long, categoryId: Long, limit: Int, offset: Int): List<ChannelBrowseEntity>
+
+ @Query(
+ """
+ SELECT id, stream_id, name, logo_url, group_title, category_id, category_name, stream_url,
+ epg_channel_id, number, catch_up_supported, catch_up_days, catchUpSource,
+ provider_id, is_adult, is_user_protected, logical_group_id, error_count
+ FROM channels
+ WHERE provider_id = :providerId AND category_id = :categoryId AND error_count = 0
+ ORDER BY number ASC
+ LIMIT :limit OFFSET :offset
+ """
+ )
+ abstract suspend fun getByCategoryWithoutErrorsBrowsePageOffset(providerId: Long, categoryId: Long, limit: Int, offset: Int): List<ChannelBrowseEntity>
+
@Query("SELECT * FROM channels WHERE provider_id = :providerId AND category_id = :categoryId ORDER BY number ASC LIMIT :limit OFFSET :offset")
abstract fun getByCategoryPage(providerId: Long, categoryId: Long, limit: Int, offset: Int): Flow<List<ChannelEntity>>
@@ -354,13 +411,157 @@ interface ChannelPreferenceDao {
@Query("SELECT aspect_ratio FROM channel_preferences WHERE channel_id = :channelId LIMIT 1")
fun observeAspectRatio(channelId: Long): Flow<String?>
+ @Query("SELECT audio_video_offset_ms FROM channel_preferences WHERE channel_id = :channelId LIMIT 1")
+ fun observeAudioVideoOffset(channelId: Long): Flow<Int?>
+
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun upsert(preference: ChannelPreferenceEntity)
+ @Insert(onConflict = OnConflictStrategy.IGNORE)
+ suspend fun insertIgnore(preference: ChannelPreferenceEntity): Long
+
+ @Query("UPDATE channel_preferences SET aspect_ratio = :aspectRatio, updated_at = :updatedAt WHERE channel_id = :channelId")
+ suspend fun updateAspectRatio(channelId: Long, aspectRatio: String?, updatedAt: Long): Int
+
+ @Query("UPDATE channel_preferences SET audio_video_offset_ms = :offsetMs, updated_at = :updatedAt WHERE channel_id = :channelId")
+ suspend fun updateAudioVideoOffset(channelId: Long, offsetMs: Int?, updatedAt: Long): Int
+
+ @Transaction
+ suspend fun setAspectRatio(channelId: Long, aspectRatio: String) {
+ val updatedAt = System.currentTimeMillis()
+ if (updateAspectRatio(channelId, aspectRatio, updatedAt) == 0) {
+ val inserted = insertIgnore(
+ ChannelPreferenceEntity(
+ channelId = channelId,
+ aspectRatio = aspectRatio,
+ updatedAt = updatedAt
+ )
+ )
+ if (inserted == -1L) {
+ updateAspectRatio(channelId, aspectRatio, updatedAt)
+ }
+ }
+ }
+
+ @Transaction
+ suspend fun setAudioVideoOffset(channelId: Long, offsetMs: Int?) {
+ val updatedAt = System.currentTimeMillis()
+ if (updateAudioVideoOffset(channelId, offsetMs, updatedAt) == 0) {
+ val inserted = insertIgnore(
+ ChannelPreferenceEntity(
+ channelId = channelId,
+ audioVideoOffsetMs = offsetMs,
+ updatedAt = updatedAt
+ )
+ )
+ if (inserted == -1L) {
+ updateAudioVideoOffset(channelId, offsetMs, updatedAt)
+ }
+ }
+ }
+
@Query("DELETE FROM channel_preferences")
suspend fun deleteAll()
}
+@Dao
+interface PlaybackCompatibilityDao {
+ @Query(
+ """
+ SELECT * FROM playback_compatibility_records
+ WHERE device_fingerprint = :deviceFingerprint
+ AND stream_type = :streamType
+ AND video_mime_type = :videoMimeType
+ AND resolution_bucket = :resolutionBucket
+ ORDER BY failure_count DESC, last_failed_at DESC
+ """
+ )
+ suspend fun getKnownBadCandidates(
+ deviceFingerprint: String,
+ streamType: String,
+ videoMimeType: String,
+ resolutionBucket: String
+ ): List<PlaybackCompatibilityRecordEntity>
+
+ @Query(
+ """
+ INSERT INTO playback_compatibility_records(
+ device_fingerprint, device_model, android_sdk, stream_type, video_mime_type,
+ resolution_bucket, decoder_name, surface_type, failure_type, last_failed_at,
+ last_succeeded_at, failure_count, success_count
+ ) VALUES (
+ :deviceFingerprint, :deviceModel, :androidSdk, :streamType, :videoMimeType,
+ :resolutionBucket, :decoderName, :surfaceType, :failureType, :failedAt,
+ 0, 1, 0
+ )
+ ON CONFLICT(device_fingerprint, stream_type, video_mime_type, resolution_bucket, decoder_name, surface_type)
+ DO UPDATE SET
+ device_model = excluded.device_model,
+ android_sdk = excluded.android_sdk,
+ failure_type = excluded.failure_type,
+ last_failed_at = excluded.last_failed_at,
+ failure_count = playback_compatibility_records.failure_count + 1
+ """
+ )
+ suspend fun recordFailure(
+ deviceFingerprint: String,
+ deviceModel: String,
+ androidSdk: Int,
+ streamType: String,
+ videoMimeType: String,
+ resolutionBucket: String,
+ decoderName: String,
+ surfaceType: String,
+ failureType: String,
+ failedAt: Long
+ )
+
+ @Query(
+ """
+ INSERT INTO playback_compatibility_records(
+ device_fingerprint, device_model, android_sdk, stream_type, video_mime_type,
+ resolution_bucket, decoder_name, surface_type, failure_type, last_failed_at,
+ last_succeeded_at, failure_count, success_count
+ ) VALUES (
+ :deviceFingerprint, :deviceModel, :androidSdk, :streamType, :videoMimeType,
+ :resolutionBucket, :decoderName, :surfaceType, '', 0, :succeededAt, 0, 1
+ )
+ ON CONFLICT(device_fingerprint, stream_type, video_mime_type, resolution_bucket, decoder_name, surface_type)
+ DO UPDATE SET
+ device_model = excluded.device_model,
+ android_sdk = excluded.android_sdk,
+ last_succeeded_at = excluded.last_succeeded_at,
+ success_count = playback_compatibility_records.success_count + 1
+ """
+ )
+ suspend fun recordSuccess(
+ deviceFingerprint: String,
+ deviceModel: String,
+ androidSdk: Int,
+ streamType: String,
+ videoMimeType: String,
+ resolutionBucket: String,
+ decoderName: String,
+ surfaceType: String,
+ succeededAt: Long
+ )
+
+ @Query("DELETE FROM playback_compatibility_records WHERE last_failed_at < :olderThanMs AND last_succeeded_at < :olderThanMs")
+ suspend fun deleteOlderThan(olderThanMs: Long): Int
+
+ @Query(
+ """
+ DELETE FROM playback_compatibility_records
+ WHERE id NOT IN (
+ SELECT id FROM playback_compatibility_records
+ ORDER BY MAX(last_failed_at, last_succeeded_at) DESC
+ LIMIT :maxRecords
+ )
+ """
+ )
+ suspend fun keepMostRecent(maxRecords: Int): Int
+}
+
@Dao
interface TmdbIdentityDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
@@ -1097,6 +1298,17 @@ interface MovieDao {
restoreWatchProgress(providerId)
}
+ @Transaction
+ suspend fun upsertCategoryPage(providerId: Long, movies: List<MovieEntity>) {
+ if (movies.isEmpty()) return
+ val existingByRemoteId = getIdMappings(providerId).associate { it.remoteId to it.id }
+ val remapped = movies
+ .distinctBy { it.streamId }
+ .map { entity -> entity.copy(id = existingByRemoteId[entity.streamId] ?: 0L) }
+ insertAll(remapped)
+ restoreWatchProgress(providerId)
+ }
+
@Query("SELECT category_id, COUNT(*) as item_count FROM movies WHERE provider_id = :providerId AND category_id IS NOT NULL GROUP BY category_id")
fun getCategoryCounts(providerId: Long): Flow<List<CategoryCount>>
@@ -1746,6 +1958,9 @@ interface SeriesDao {
@Query("SELECT * FROM series WHERE provider_id = :providerId AND series_id = :seriesId LIMIT 1")
suspend fun getBySeriesId(providerId: Long, seriesId: Long): SeriesEntity?
+ @Query("SELECT * FROM series WHERE provider_id = :providerId AND provider_series_id = :providerSeriesId LIMIT 1")
+ suspend fun getByProviderSeriesId(providerId: Long, providerSeriesId: String): SeriesEntity?
+
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertAll(series: List<SeriesEntity>)
@@ -1755,11 +1970,23 @@ interface SeriesDao {
@Update
suspend fun updateAll(series: List<SeriesEntity>)
- @Query("SELECT id, series_id AS remote_id FROM series WHERE provider_id = :providerId")
- suspend fun getIdMappings(providerId: Long): List<RemoteIdMapping>
+ @Query(
+ """
+ SELECT id, COALESCE(NULLIF(provider_series_id, ''), CAST(series_id AS TEXT)) AS remote_id
+ FROM series
+ WHERE provider_id = :providerId
+ """
+ )
+ suspend fun getIdMappings(providerId: Long): List<SeriesRemoteIdMapping>
- @Query("SELECT id, series_id AS remote_id FROM series WHERE provider_id = :providerId AND category_id = :categoryId")
- suspend fun getIdMappingsByCategory(providerId: Long, categoryId: Long): List<RemoteIdMapping>
+ @Query(
+ """
+ SELECT id, COALESCE(NULLIF(provider_series_id, ''), CAST(series_id AS TEXT)) AS remote_id
+ FROM series
+ WHERE provider_id = :providerId AND category_id = :categoryId
+ """
+ )
+ suspend fun getIdMappingsByCategory(providerId: Long, categoryId: Long): List<SeriesRemoteIdMapping>
@Query("DELETE FROM series WHERE provider_id = :providerId")
suspend fun deleteByProvider(providerId: Long)
@@ -1773,31 +2000,51 @@ interface SeriesDao {
@Transaction
suspend fun replaceAll(providerId: Long, series: List<SeriesEntity>) {
val existingByRemoteId = getIdMappings(providerId).associate { it.remoteId to it.id }
+ fun SeriesEntity.remoteKey(): String = providerSeriesId?.takeIf { it.isNotBlank() } ?: seriesId.toString()
val remapped = series
- .distinctBy { it.seriesId }
- .map { entity -> entity.copy(id = existingByRemoteId[entity.seriesId] ?: 0L) }
+ .distinctBy { it.remoteKey() }
+ .map { entity -> entity.copy(id = existingByRemoteId[entity.remoteKey()] ?: 0L) }
deleteByProvider(providerId)
insertAll(remapped)
}
- @Query("DELETE FROM series WHERE provider_id = :providerId AND category_id = :categoryId AND series_id NOT IN (:remoteIds)")
- suspend fun deleteMissingByCategory(providerId: Long, categoryId: Long, remoteIds: List<Long>)
+ @Query(
+ """
+ DELETE FROM series
+ WHERE provider_id = :providerId
+ AND category_id = :categoryId
+ AND COALESCE(NULLIF(provider_series_id, ''), CAST(series_id AS TEXT)) NOT IN (:remoteIds)
+ """
+ )
+ suspend fun deleteMissingByCategory(providerId: Long, categoryId: Long, remoteIds: List<String>)
@Transaction
suspend fun replaceCategory(providerId: Long, categoryId: Long, series: List<SeriesEntity>) {
val existingByRemoteId = getIdMappingsByCategory(providerId, categoryId).associate { it.remoteId to it.id }
+ fun SeriesEntity.remoteKey(): String = providerSeriesId?.takeIf { it.isNotBlank() } ?: seriesId.toString()
val remapped = series
- .distinctBy { it.seriesId }
- .map { entity -> entity.copy(id = existingByRemoteId[entity.seriesId] ?: 0L) }
+ .distinctBy { it.remoteKey() }
+ .map { entity -> entity.copy(id = existingByRemoteId[entity.remoteKey()] ?: 0L) }
if (remapped.isEmpty()) {
deleteByProviderAndCategory(providerId, categoryId)
} else {
insertAll(remapped)
- deleteMissingByCategory(providerId, categoryId, remapped.map { it.seriesId })
+ deleteMissingByCategory(providerId, categoryId, remapped.map { it.remoteKey() })
}
}
+ @Transaction
+ suspend fun upsertCategoryPage(providerId: Long, series: List<SeriesEntity>) {
+ if (series.isEmpty()) return
+ val existingByRemoteId = getIdMappings(providerId).associate { it.remoteId to it.id }
+ fun SeriesEntity.remoteKey(): String = providerSeriesId?.takeIf { it.isNotBlank() } ?: seriesId.toString()
+ val remapped = series
+ .distinctBy { it.remoteKey() }
+ .map { entity -> entity.copy(id = existingByRemoteId[entity.remoteKey()] ?: 0L) }
+ insertAll(remapped)
+ }
+
@Query("SELECT category_id, COUNT(*) as item_count FROM series WHERE provider_id = :providerId AND category_id IS NOT NULL GROUP BY category_id")
fun getCategoryCounts(providerId: Long): Flow<List<CategoryCount>>
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.kt
index 2e2b13e4..a79664fa 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
@@ -130,9 +130,47 @@ data class ChannelPreferenceEntity(
val id: Long = 0,
@ColumnInfo(name = "channel_id") val channelId: Long,
@ColumnInfo(name = "aspect_ratio") val aspectRatio: String? = null,
+ @ColumnInfo(name = "audio_video_offset_ms") val audioVideoOffsetMs: Int? = null,
@ColumnInfo(name = "updated_at") val updatedAt: Long = System.currentTimeMillis()
)
+@Entity(
+ tableName = "playback_compatibility_records",
+ indices = [
+ Index(
+ value = [
+ "device_fingerprint",
+ "stream_type",
+ "video_mime_type",
+ "resolution_bucket",
+ "decoder_name",
+ "surface_type"
+ ],
+ unique = true
+ ),
+ Index(value = ["device_fingerprint", "stream_type", "video_mime_type", "resolution_bucket"]),
+ Index(value = ["last_failed_at"]),
+ Index(value = ["last_succeeded_at"])
+ ]
+)
+data class PlaybackCompatibilityRecordEntity(
+ @PrimaryKey(autoGenerate = true)
+ val id: Long = 0,
+ @ColumnInfo(name = "device_fingerprint") val deviceFingerprint: String,
+ @ColumnInfo(name = "device_model") val deviceModel: String,
+ @ColumnInfo(name = "android_sdk") val androidSdk: Int,
+ @ColumnInfo(name = "stream_type") val streamType: String,
+ @ColumnInfo(name = "video_mime_type") val videoMimeType: String,
+ @ColumnInfo(name = "resolution_bucket") val resolutionBucket: String,
+ @ColumnInfo(name = "decoder_name") val decoderName: String,
+ @ColumnInfo(name = "surface_type") val surfaceType: String,
+ @ColumnInfo(name = "failure_type") val failureType: String = "",
+ @ColumnInfo(name = "last_failed_at") val lastFailedAt: Long = 0L,
+ @ColumnInfo(name = "last_succeeded_at") val lastSucceededAt: Long = 0L,
+ @ColumnInfo(name = "failure_count") val failureCount: Int = 0,
+ @ColumnInfo(name = "success_count") val successCount: Int = 0
+)
+
@Entity(
tableName = "movies",
foreignKeys = [ForeignKey(
@@ -219,6 +257,7 @@ data class SeriesEntity(
@PrimaryKey(autoGenerate = true)
val id: Long = 0,
@ColumnInfo(name = "series_id") val seriesId: Long = 0,
+ @ColumnInfo(name = "provider_series_id") val providerSeriesId: String? = null,
val name: String,
@ColumnInfo(name = "poster_url") val posterUrl: String? = null,
@ColumnInfo(name = "backdrop_url") val backdropUrl: String? = null,
@@ -243,6 +282,7 @@ data class SeriesEntity(
data class SeriesBrowseEntity(
val id: Long = 0,
@ColumnInfo(name = "series_id") val seriesId: Long = 0,
+ @ColumnInfo(name = "provider_series_id") val providerSeriesId: String? = null,
val name: String,
@ColumnInfo(name = "poster_url") val posterUrl: String? = null,
@ColumnInfo(name = "category_id") val categoryId: Long? = null,
@@ -764,7 +804,11 @@ data class MovieCategoryHydrationEntity(
@ColumnInfo(name = "last_hydrated_at") val lastHydratedAt: Long = 0L,
@ColumnInfo(name = "item_count") val itemCount: Int = 0,
@ColumnInfo(name = "last_status") val lastStatus: String = "IDLE",
- @ColumnInfo(name = "last_error") val lastError: String? = null
+ @ColumnInfo(name = "last_error") val lastError: String? = null,
+ @ColumnInfo(name = "last_loaded_page") val lastLoadedPage: Int = 0,
+ @ColumnInfo(name = "total_pages") val totalPages: Int = 0,
+ @ColumnInfo(name = "is_complete") val isComplete: Boolean = false,
+ @ColumnInfo(name = "page_size") val pageSize: Int = 0
)
@Entity(
@@ -784,7 +828,11 @@ data class SeriesCategoryHydrationEntity(
@ColumnInfo(name = "last_hydrated_at") val lastHydratedAt: Long = 0L,
@ColumnInfo(name = "item_count") val itemCount: Int = 0,
@ColumnInfo(name = "last_status") val lastStatus: String = "IDLE",
- @ColumnInfo(name = "last_error") val lastError: String? = null
+ @ColumnInfo(name = "last_error") val lastError: String? = null,
+ @ColumnInfo(name = "last_loaded_page") val lastLoadedPage: Int = 0,
+ @ColumnInfo(name = "total_pages") val totalPages: Int = 0,
+ @ColumnInfo(name = "is_complete") val isComplete: Boolean = false,
+ @ColumnInfo(name = "page_size") val pageSize: Int = 0
)
// ── External EPG Source ────────────────────────────────────────────
diff --git a/data/src/main/java/com/streamvault/data/manager/BackupManagerImpl.kt b/data/src/main/java/com/streamvault/data/manager/BackupManagerImpl.kt
index a976b73f..409a614e 100644
--- a/data/src/main/java/com/streamvault/data/manager/BackupManagerImpl.kt
+++ b/data/src/main/java/com/streamvault/data/manager/BackupManagerImpl.kt
@@ -77,7 +77,9 @@ class BackupManagerImpl @Inject constructor(
"liveTvQuickFilterVisibility" to (preferencesRepository.liveTvQuickFilterVisibility.first() ?: "always"),
"playerMediaSessionEnabled" to preferencesRepository.playerMediaSessionEnabled.first().toString(),
"playerDecoderMode" to preferencesRepository.playerDecoderMode.first().name,
+ "playerSurfaceMode" to preferencesRepository.playerSurfaceMode.first().name,
"playerPlaybackSpeed" to preferencesRepository.playerPlaybackSpeed.first().toString(),
+ "playerAudioVideoOffsetMs" to preferencesRepository.playerAudioVideoOffsetMs.first().toString(),
"preferredAudioLanguage" to (preferencesRepository.preferredAudioLanguage.first() ?: "auto"),
"playerSubtitleTextScale" to preferencesRepository.playerSubtitleTextScale.first().toString(),
"playerSubtitleTextColor" to preferencesRepository.playerSubtitleTextColor.first().toString(),
@@ -346,7 +348,17 @@ class BackupManagerImpl @Inject constructor(
preferencesRepository.setPlayerDecoderMode(decoderMode)
}
}
+ prefs["playerSurfaceMode"]?.takeIf { it.isNotBlank() }?.let { savedMode ->
+ val surfaceMode = com.streamvault.domain.model.PlayerSurfaceMode.entries
+ .firstOrNull { entry -> entry.name == savedMode }
+ if (surfaceMode != null) {
+ preferencesRepository.setPlayerSurfaceMode(surfaceMode)
+ }
+ }
prefs["playerPlaybackSpeed"]?.toFloatOrNull()?.let { preferencesRepository.setPlayerPlaybackSpeed(it) }
+ prefs["playerAudioVideoOffsetMs"]?.toIntOrNull()?.let {
+ preferencesRepository.setPlayerAudioVideoOffsetMs(it)
+ }
preferencesRepository.setPreferredAudioLanguage(prefs["preferredAudioLanguage"])
prefs["playerSubtitleTextScale"]?.toFloatOrNull()?.let { preferencesRepository.setPlayerSubtitleTextScale(it) }
prefs["playerSubtitleTextColor"]?.toIntOrNull()?.let { preferencesRepository.setPlayerSubtitleTextColor(it) }
diff --git a/data/src/main/java/com/streamvault/data/mapper/EntityMappers.kt b/data/src/main/java/com/streamvault/data/mapper/EntityMappers.kt
index 433e79f7..2acec49c 100644
--- a/data/src/main/java/com/streamvault/data/mapper/EntityMappers.kt
+++ b/data/src/main/java/com/streamvault/data/mapper/EntityMappers.kt
@@ -244,7 +244,8 @@ fun SeriesEntity.toDomain() = Series(
providerId = providerId,
isAdult = isAdult,
isUserProtected = isUserProtected,
- seriesId = seriesId
+ seriesId = seriesId,
+ providerSeriesId = providerSeriesId
)
fun SeriesBrowseEntity.toDomain() = Series(
@@ -267,12 +268,16 @@ fun SeriesBrowseEntity.toDomain() = Series(
providerId = providerId,
isAdult = isAdult,
isUserProtected = isUserProtected,
- seriesId = seriesId
+ seriesId = seriesId,
+ providerSeriesId = providerSeriesId
)
fun Series.toEntity() = SeriesEntity(
id = id,
seriesId = seriesId.takeIf { it > 0 } ?: id,
+ providerSeriesId = providerSeriesId?.takeIf { it.isNotBlank() }
+ ?: seriesId.takeIf { it > 0 }?.toString()
+ ?: id.takeIf { it > 0 }?.toString(),
name = name,
posterUrl = posterUrl,
backdropUrl = backdropUrl,
diff --git a/data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt b/data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt
index f74934f5..80fed44b 100644
--- a/data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt
+++ b/data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt
@@ -16,16 +16,17 @@ import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.datastore.preferences.preferencesDataStore
import com.streamvault.data.local.dao.ChannelPreferenceDao
import com.streamvault.data.local.dao.SearchHistoryDao
-import com.streamvault.data.local.entity.ChannelPreferenceEntity
import com.streamvault.domain.model.GroupedChannelLabelMode
import com.streamvault.domain.model.ChannelNumberingMode
import com.streamvault.domain.model.CategorySortMode
import com.streamvault.domain.model.ContentType
import com.streamvault.domain.model.DecoderMode
import com.streamvault.domain.model.ActiveLiveSource
+import com.streamvault.domain.model.AppTimeFormat
import com.streamvault.domain.model.LiveChannelGroupingMode
import com.streamvault.domain.model.LiveChannelObservedQuality
import com.streamvault.domain.model.LiveVariantPreferenceMode
+import com.streamvault.domain.model.PlayerSurfaceMode
import com.streamvault.domain.model.SearchHistoryScope
import com.streamvault.domain.manager.ParentalPinVerifier
import com.streamvault.domain.manager.ParentalControlSessionState
@@ -46,6 +47,17 @@ import dagger.hilt.android.qualifiers.ApplicationContext
@Singleton
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "user_preferences")
+private fun sanitizePlaybackTimerMinutes(minutes: Int): Int = when (minutes) {
+ 0, 15, 30, 45, 60, 90, 120 -> minutes
+ in Int.MIN_VALUE..7 -> 0
+ in 8..22 -> 15
+ in 23..37 -> 30
+ in 38..52 -> 45
+ in 53..75 -> 60
+ in 76..105 -> 90
+ else -> 120
+}
+
@Singleton
class PreferencesRepository @Inject constructor(
@ApplicationContext private val context: Context,
@@ -53,6 +65,8 @@ class PreferencesRepository @Inject constructor(
private val searchHistoryDao: SearchHistoryDao
) : ParentalControlSessionStore, ParentalPinVerifier {
companion object {
+ private const val AUDIO_VIDEO_OFFSET_MIN_MS = -2_000
+ private const val AUDIO_VIDEO_OFFSET_MAX_MS = 2_000
private const val PIN_SALT_BYTES = 16
private const val PIN_HASH_ITERATIONS = 120_000
private const val PIN_HASH_KEY_BITS = 256
@@ -73,6 +87,7 @@ class PreferencesRepository @Inject constructor(
val PARENTAL_PIN_SALT = stringPreferencesKey("parental_pin_salt")
val DEFAULT_CATEGORY_ID = longPreferencesKey("default_category_id")
val APP_LANGUAGE = stringPreferencesKey("app_language")
+ val APP_TIME_FORMAT = stringPreferencesKey("app_time_format")
val LIVE_TV_CHANNEL_MODE = stringPreferencesKey("live_tv_channel_mode")
val SHOW_LIVE_SOURCE_SWITCHER = booleanPreferencesKey("show_live_source_switcher")
val SHOW_ALL_CHANNELS_CATEGORY = booleanPreferencesKey("show_all_channels_category")
@@ -86,6 +101,7 @@ class PreferencesRepository @Inject constructor(
val LIVE_VARIANT_SELECTIONS = stringPreferencesKey("live_variant_selections")
val LIVE_VARIANT_OBSERVATIONS = stringPreferencesKey("live_variant_observations")
val VOD_VIEW_MODE = stringPreferencesKey("vod_view_mode")
+ val VOD_INFINITE_SCROLL = booleanPreferencesKey("vod_infinite_scroll")
val GUIDE_DENSITY = stringPreferencesKey("guide_density")
val GUIDE_CHANNEL_MODE = stringPreferencesKey("guide_channel_mode")
val GUIDE_DEFAULT_CATEGORY_ID = longPreferencesKey("guide_default_category_id")
@@ -100,7 +116,9 @@ class PreferencesRepository @Inject constructor(
val PLAYER_MUTED = booleanPreferencesKey("player_muted")
val PLAYER_MEDIA_SESSION_ENABLED = booleanPreferencesKey("player_media_session_enabled")
val PLAYER_DECODER_MODE = stringPreferencesKey("player_decoder_mode")
+ val PLAYER_SURFACE_MODE = stringPreferencesKey("player_surface_mode")
val PLAYER_PLAYBACK_SPEED = stringPreferencesKey("player_playback_speed")
+ val PLAYER_AUDIO_VIDEO_OFFSET_MS = intPreferencesKey("player_av_offset_ms")
val PREFERRED_AUDIO_LANGUAGE = stringPreferencesKey("preferred_audio_language")
val PLAYER_SUBTITLE_TEXT_SCALE = stringPreferencesKey("player_subtitle_text_scale")
val PLAYER_SUBTITLE_TEXT_COLOR = intPreferencesKey("player_subtitle_text_color")
@@ -113,6 +131,8 @@ class PreferencesRepository @Inject constructor(
val PLAYER_ETHERNET_MAX_VIDEO_HEIGHT = intPreferencesKey("player_ethernet_max_video_height")
val PLAYER_TIMESHIFT_ENABLED = booleanPreferencesKey("player_timeshift_enabled")
val PLAYER_TIMESHIFT_DEPTH_MINUTES = intPreferencesKey("player_timeshift_depth_minutes")
+ val DEFAULT_STOP_PLAYBACK_TIMER_MINUTES = intPreferencesKey("default_stop_playback_timer_minutes")
+ val DEFAULT_IDLE_STANDBY_TIMER_MINUTES = intPreferencesKey("default_idle_standby_timer_minutes")
val LAST_SPEED_TEST_MEGABITS = stringPreferencesKey("last_speed_test_megabits")
val LAST_SPEED_TEST_TIMESTAMP = longPreferencesKey("last_speed_test_timestamp")
val LAST_SPEED_TEST_TRANSPORT = stringPreferencesKey("last_speed_test_transport")
@@ -125,6 +145,7 @@ class PreferencesRepository @Inject constructor(
val XTREAM_TEXT_IMPORT_GENERATION = longPreferencesKey("xtream_text_import_generation")
val ZAP_AUTO_REVERT = booleanPreferencesKey("zap_auto_revert")
val PREVENT_STANDBY_DURING_PLAYBACK = booleanPreferencesKey("prevent_standby_during_playback")
+ val AUTO_PLAY_NEXT_EPISODE = booleanPreferencesKey("auto_play_next_episode")
val AUTO_CHECK_APP_UPDATES = booleanPreferencesKey("auto_check_app_updates")
val AUTO_DOWNLOAD_APP_UPDATES = booleanPreferencesKey("auto_download_app_updates")
val RECORDING_WIFI_ONLY = booleanPreferencesKey("recording_wifi_only")
@@ -244,6 +265,12 @@ class PreferencesRepository @Inject constructor(
?: DecoderMode.AUTO
}
+ val playerSurfaceMode: Flow<PlayerSurfaceMode> = context.dataStore.data.map { preferences ->
+ preferences[PreferencesKeys.PLAYER_SURFACE_MODE]
+ ?.let { saved -> PlayerSurfaceMode.entries.firstOrNull { it.name == saved } }
+ ?: PlayerSurfaceMode.AUTO
+ }
+
val playerPlaybackSpeed: Flow<Float> = context.dataStore.data.map { preferences ->
preferences[PreferencesKeys.PLAYER_PLAYBACK_SPEED]
?.toFloatOrNull()
@@ -251,6 +278,11 @@ class PreferencesRepository @Inject constructor(
?: 1f
}
+ val playerAudioVideoOffsetMs: Flow<Int> = context.dataStore.data.map { preferences ->
+ (preferences[PreferencesKeys.PLAYER_AUDIO_VIDEO_OFFSET_MS] ?: 0)
+ .coerceIn(AUDIO_VIDEO_OFFSET_MIN_MS, AUDIO_VIDEO_OFFSET_MAX_MS)
+ }
+
val preferredAudioLanguage: Flow<String?> = context.dataStore.data.map { preferences ->
preferences[PreferencesKeys.PREFERRED_AUDIO_LANGUAGE]
?.trim()
@@ -310,6 +342,14 @@ class PreferencesRepository @Inject constructor(
}
}
+ val defaultStopPlaybackTimerMinutes: Flow<Int> = context.dataStore.data.map { preferences ->
+ sanitizePlaybackTimerMinutes(preferences[PreferencesKeys.DEFAULT_STOP_PLAYBACK_TIMER_MINUTES] ?: 0)
+ }
+
+ val defaultIdleStandbyTimerMinutes: Flow<Int> = context.dataStore.data.map { preferences ->
+ sanitizePlaybackTimerMinutes(preferences[PreferencesKeys.DEFAULT_IDLE_STANDBY_TIMER_MINUTES] ?: 0)
+ }
+
val lastSpeedTestMegabits: Flow<Double?> = context.dataStore.data.map { preferences ->
preferences[PreferencesKeys.LAST_SPEED_TEST_MEGABITS]?.toDoubleOrNull()
}
@@ -434,6 +474,10 @@ class PreferencesRepository @Inject constructor(
preferences[PreferencesKeys.PREVENT_STANDBY_DURING_PLAYBACK] ?: true
}
+ val autoPlayNextEpisode: Flow<Boolean> = context.dataStore.data.map { preferences ->
+ preferences[PreferencesKeys.AUTO_PLAY_NEXT_EPISODE] ?: true
+ }
+
val autoCheckAppUpdates: Flow<Boolean> = context.dataStore.data.map { preferences ->
preferences[PreferencesKeys.AUTO_CHECK_APP_UPDATES] ?: true
}
@@ -547,6 +591,12 @@ class PreferencesRepository @Inject constructor(
}
}
+ suspend fun setAutoPlayNextEpisode(enabled: Boolean) {
+ context.dataStore.edit { preferences ->
+ preferences[PreferencesKeys.AUTO_PLAY_NEXT_EPISODE] = enabled
+ }
+ }
+
suspend fun setAutoCheckAppUpdates(enabled: Boolean) {
context.dataStore.edit { preferences ->
preferences[PreferencesKeys.AUTO_CHECK_APP_UPDATES] = enabled
@@ -692,12 +742,25 @@ class PreferencesRepository @Inject constructor(
}
}
+ suspend fun setPlayerSurfaceMode(mode: PlayerSurfaceMode) {
+ context.dataStore.edit { preferences ->
+ preferences[PreferencesKeys.PLAYER_SURFACE_MODE] = mode.name
+ }
+ }
+
suspend fun setPlayerPlaybackSpeed(speed: Float) {
context.dataStore.edit { preferences ->
preferences[PreferencesKeys.PLAYER_PLAYBACK_SPEED] = speed.coerceIn(0.5f, 2f).toString()
}
}
+ suspend fun setPlayerAudioVideoOffsetMs(offsetMs: Int) {
+ context.dataStore.edit { preferences ->
+ preferences[PreferencesKeys.PLAYER_AUDIO_VIDEO_OFFSET_MS] =
+ offsetMs.coerceIn(AUDIO_VIDEO_OFFSET_MIN_MS, AUDIO_VIDEO_OFFSET_MAX_MS)
+ }
+ }
+
suspend fun setPreferredAudioLanguage(languageTag: String?) {
context.dataStore.edit { preferences ->
val normalized = languageTag
@@ -792,6 +855,18 @@ class PreferencesRepository @Inject constructor(
}
}
+ suspend fun setDefaultStopPlaybackTimerMinutes(minutes: Int) {
+ context.dataStore.edit { preferences ->
+ preferences[PreferencesKeys.DEFAULT_STOP_PLAYBACK_TIMER_MINUTES] = sanitizePlaybackTimerMinutes(minutes)
+ }
+ }
+
+ suspend fun setDefaultIdleStandbyTimerMinutes(minutes: Int) {
+ context.dataStore.edit { preferences ->
+ preferences[PreferencesKeys.DEFAULT_IDLE_STANDBY_TIMER_MINUTES] = sanitizePlaybackTimerMinutes(minutes)
+ }
+ }
+
suspend fun setLastSpeedTestResult(
megabitsPerSecond: Double?,
measuredAtMs: Long?,
@@ -998,6 +1073,16 @@ class PreferencesRepository @Inject constructor(
}
}
+ val appTimeFormat: Flow<AppTimeFormat> = context.dataStore.data.map { preferences ->
+ AppTimeFormat.fromStorage(preferences[PreferencesKeys.APP_TIME_FORMAT])
+ }
+
+ suspend fun setAppTimeFormat(format: AppTimeFormat) {
+ context.dataStore.edit { preferences ->
+ preferences[PreferencesKeys.APP_TIME_FORMAT] = format.storageValue
+ }
+ }
+
val liveTvChannelMode: Flow<String?> = context.dataStore.data.map { preferences ->
preferences[PreferencesKeys.LIVE_TV_CHANNEL_MODE]
}
@@ -1176,6 +1261,16 @@ class PreferencesRepository @Inject constructor(
}
}
+ val vodInfiniteScroll: Flow<Boolean> = context.dataStore.data.map { preferences ->
+ preferences[PreferencesKeys.VOD_INFINITE_SCROLL] ?: false
+ }
+
+ suspend fun setVodInfiniteScroll(enabled: Boolean) {
+ context.dataStore.edit { preferences ->
+ preferences[PreferencesKeys.VOD_INFINITE_SCROLL] = enabled
+ }
+ }
+
val guideDensity: Flow<String?> = context.dataStore.data.map { preferences ->
preferences[PreferencesKeys.GUIDE_DENSITY]
}
@@ -1413,19 +1508,28 @@ class PreferencesRepository @Inject constructor(
}
suspend fun setAspectRatioForChannel(channelId: Long, ratio: String) {
- channelPreferenceDao.upsert(
- ChannelPreferenceEntity(
- channelId = channelId,
- aspectRatio = ratio,
- updatedAt = System.currentTimeMillis()
- )
- )
+ channelPreferenceDao.setAspectRatio(channelId, ratio)
val key = stringPreferencesKey("aspect_ratio_$channelId")
context.dataStore.edit { preferences ->
preferences.remove(key)
}
}
+ fun observeAudioVideoOffsetForChannel(channelId: Long): Flow<Int?> =
+ channelPreferenceDao.observeAudioVideoOffset(channelId)
+ .map { offset -> offset?.coerceIn(AUDIO_VIDEO_OFFSET_MIN_MS, AUDIO_VIDEO_OFFSET_MAX_MS) }
+
+ suspend fun setAudioVideoOffsetForChannel(channelId: Long, offsetMs: Int) {
+ channelPreferenceDao.setAudioVideoOffset(
+ channelId = channelId,
+ offsetMs = offsetMs.coerceIn(AUDIO_VIDEO_OFFSET_MIN_MS, AUDIO_VIDEO_OFFSET_MAX_MS)
+ )
+ }
+
+ suspend fun clearAudioVideoOffsetForChannel(channelId: Long) {
+ channelPreferenceDao.setAudioVideoOffset(channelId = channelId, offsetMs = null)
+ }
+
suspend fun clearAllRecentData() {
channelPreferenceDao.deleteAll()
searchHistoryDao.deleteAll()
diff --git a/data/src/main/java/com/streamvault/data/remote/stalker/OkHttpStalkerApiService.kt b/data/src/main/java/com/streamvault/data/remote/stalker/OkHttpStalkerApiService.kt
index 1f9f5c52..4db779a8 100644
--- a/data/src/main/java/com/streamvault/data/remote/stalker/OkHttpStalkerApiService.kt
+++ b/data/src/main/java/com/streamvault/data/remote/stalker/OkHttpStalkerApiService.kt
@@ -1,8 +1,14 @@
package com.streamvault.data.remote.stalker
import android.util.Log
+import com.google.gson.JsonObject as GsonJsonObject
+import com.google.gson.JsonParser
+import com.google.gson.stream.JsonReader
+import com.google.gson.stream.JsonToken
import com.streamvault.domain.model.Result
import java.io.IOException
+import java.io.InputStream
+import java.io.InputStreamReader
import java.net.URI
import java.net.URLEncoder
import java.security.MessageDigest
@@ -14,6 +20,7 @@ import java.time.ZoneOffset
import java.time.format.DateTimeFormatter
import java.time.format.DateTimeFormatterBuilder
import java.time.format.ResolverStyle
+import java.util.Base64
import java.util.Locale
import javax.inject.Inject
import javax.inject.Singleton
@@ -134,6 +141,25 @@ class OkHttpStalkerApiService @Inject constructor(
)
}
+ override suspend fun streamLiveStreams(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ onItem: suspend (StalkerItemRecord) -> Unit
+ ): Result<Int> = runApiCall("Failed to load live channels") {
+ requestStreamingItems(
+ url = session.loadUrl,
+ profile = profile,
+ referer = session.portalReferer,
+ token = session.token,
+ query = mapOf(
+ "type" to "itv",
+ "action" to "get_all_channels",
+ "JsHttpRequest" to "1-xml"
+ ),
+ onItem = onItem
+ )
+ }
+
override suspend fun getVodCategories(
session: StalkerSession,
profile: StalkerDeviceProfile
@@ -168,6 +194,25 @@ class OkHttpStalkerApiService @Inject constructor(
).filterNot { it.isSeries }
}
+ override suspend fun getVodStreamsPage(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ categoryId: String?,
+ page: Int
+ ): Result<StalkerPagedItems> = runApiCall("Failed to load movies") {
+ fetchPagedItemPage(
+ session = session,
+ profile = profile,
+ page = page,
+ baseQuery = buildMap {
+ put("type", "vod")
+ put("action", "get_ordered_list")
+ put("JsHttpRequest", "1-xml")
+ categoryId?.takeIf { it.isNotBlank() }?.let { put("category", it) }
+ }
+ ).let { paged -> paged.copy(items = paged.items.filterNot { it.isSeries }) }
+ }
+
override suspend fun getSeriesCategories(
session: StalkerSession,
profile: StalkerDeviceProfile
@@ -202,6 +247,25 @@ class OkHttpStalkerApiService @Inject constructor(
)
}
+ override suspend fun getSeriesPage(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ categoryId: String?,
+ page: Int
+ ): Result<StalkerPagedItems> = runApiCall("Failed to load series") {
+ fetchPagedItemPage(
+ session = session,
+ profile = profile,
+ page = page,
+ baseQuery = buildMap {
+ put("type", "series")
+ put("action", "get_ordered_list")
+ put("JsHttpRequest", "1-xml")
+ categoryId?.takeIf { it.isNotBlank() }?.let { put("category", it) }
+ }
+ )
+ }
+
override suspend fun getSeriesDetails(
session: StalkerSession,
profile: StalkerDeviceProfile,
@@ -221,13 +285,13 @@ class OkHttpStalkerApiService @Inject constructor(
"episode_id" to "0"
)
)
+ val seedEntries = seriesPayload.extractItemEntries()
val seriesItems = seriesPayload.toItemRecords()
- val series = seriesItems.firstOrNull()
+ val series = seriesItems.firstOrNull { item -> !item.looksLikeSeasonShell() }
?: StalkerItemRecord(
id = seriesId,
- name = "Series $seriesId"
+ name = ""
)
- val seedEntries = seriesPayload.extractItemEntries()
val seasonRows = seedEntries
.mapNotNull { entry ->
entry.findString("season_id")
@@ -237,6 +301,10 @@ class OkHttpStalkerApiService @Inject constructor(
}
}
.distinctBy { it.first }
+ val shellSeasonRows = seedEntries.mapIndexedNotNull { index, entry ->
+ entry.toSeasonShellRecord(index + 1)
+ ?.let { season -> season.seasonNumber.toString() to entry }
+ }
val seasons = if (seasonRows.isNotEmpty()) {
seasonRows.map { (seasonId, entry) ->
@@ -256,6 +324,24 @@ class OkHttpStalkerApiService @Inject constructor(
)
entry.toSeasonRecord(episodesPayload.extractItemEntries())
}
+ } else if (shellSeasonRows.isNotEmpty()) {
+ shellSeasonRows.map { (seasonId, entry) ->
+ val episodesPayload = requestJson(
+ url = session.loadUrl,
+ profile = profile,
+ referer = session.portalReferer,
+ token = session.token,
+ query = mapOf(
+ "type" to "series",
+ "action" to "get_ordered_list",
+ "JsHttpRequest" to "1-xml",
+ "movie_id" to seriesId,
+ "season_id" to seasonId,
+ "episode_id" to "0"
+ )
+ )
+ entry.toSeasonRecord(episodesPayload.extractItemEntries())
+ }
} else {
listOf(
StalkerSeasonRecord(
@@ -297,19 +383,22 @@ class OkHttpStalkerApiService @Inject constructor(
profile: StalkerDeviceProfile,
channelId: String
): Result<List<StalkerProgramRecord>> = runApiCall("Failed to load EPG") {
- requestJson(
+ // Legacy buffered API kept for compatibility; route through the streaming path
+ // and cap the in-memory list so a misbehaving portal cannot OOM the caller.
+ val buffer = ArrayList<StalkerProgramRecord>()
+ requestStreamingPrograms(
url = session.loadUrl,
profile = profile,
referer = session.portalReferer,
token = session.token,
- query = mapOf(
- "type" to "itv",
- "action" to "get_epg_info",
- "JsHttpRequest" to "1-xml",
- "ch_id" to channelId,
- "period" to "6"
- )
- ).toProgramRecords(channelId)
+ channelIdOverride = channelId,
+ query = perChannelEpgQuery(channelId, periodHours = 6)
+ ) { program ->
+ if (buffer.size < MAX_INLINE_EPG_RECORDS) {
+ buffer.add(program)
+ }
+ }
+ buffer
}
override suspend fun getBulkEpg(
@@ -317,30 +406,90 @@ class OkHttpStalkerApiService @Inject constructor(
profile: StalkerDeviceProfile,
periodHours: Int
): Result<List<StalkerProgramRecord>> = runApiCall("Failed to load bulk EPG") {
- requestJson(
+ // Legacy buffered API kept for compatibility; route through the streaming path
+ // and cap the in-memory list so a misbehaving portal cannot OOM the caller.
+ val buffer = ArrayList<StalkerProgramRecord>()
+ requestStreamingPrograms(
url = session.loadUrl,
profile = profile,
referer = session.portalReferer,
token = session.token,
- query = mapOf(
- "type" to "itv",
- "action" to "get_epg_info",
- "JsHttpRequest" to "1-xml",
- "period" to periodHours.coerceAtLeast(1).toString()
- )
- ).toProgramRecords()
+ channelIdOverride = null,
+ query = bulkEpgQuery(periodHours)
+ ) { program ->
+ if (buffer.size < MAX_INLINE_EPG_RECORDS) {
+ buffer.add(program)
+ }
+ }
+ buffer
+ }
+
+ override suspend fun streamBulkEpg(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ periodHours: Int,
+ onProgram: suspend (StalkerProgramRecord) -> Unit
+ ): Result<Int> = runApiCall("Failed to load bulk EPG") {
+ requestStreamingPrograms(
+ url = session.loadUrl,
+ profile = profile,
+ referer = session.portalReferer,
+ token = session.token,
+ channelIdOverride = null,
+ query = bulkEpgQuery(periodHours),
+ onProgram = onProgram
+ )
+ }
+
+ override suspend fun streamEpg(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ channelId: String,
+ periodHours: Int,
+ onProgram: suspend (StalkerProgramRecord) -> Unit
+ ): Result<Int> = runApiCall("Failed to load EPG") {
+ requestStreamingPrograms(
+ url = session.loadUrl,
+ profile = profile,
+ referer = session.portalReferer,
+ token = session.token,
+ channelIdOverride = channelId,
+ query = perChannelEpgQuery(channelId, periodHours),
+ onProgram = onProgram
+ )
}
+ private fun bulkEpgQuery(periodHours: Int): Map<String, String> = mapOf(
+ "type" to "itv",
+ "action" to "get_epg_info",
+ "JsHttpRequest" to "1-xml",
+ "period" to periodHours.coerceAtLeast(1).toString()
+ )
+
+ private fun perChannelEpgQuery(channelId: String, periodHours: Int): Map<String, String> = mapOf(
+ "type" to "itv",
+ "action" to "get_epg_info",
+ "JsHttpRequest" to "1-xml",
+ "ch_id" to channelId,
+ "period" to periodHours.coerceAtLeast(1).toString()
+ )
+
override suspend fun createLink(
session: StalkerSession,
profile: StalkerDeviceProfile,
kind: StalkerStreamKind,
- cmd: String
+ cmd: String,
+ seriesNumber: Int?
): Result<String> = runApiCall("Failed to resolve playback link") {
val type = when (kind) {
StalkerStreamKind.LIVE -> "itv"
StalkerStreamKind.MOVIE, StalkerStreamKind.EPISODE -> "vod"
}
+ val seriesSelector = if (kind == StalkerStreamKind.EPISODE) {
+ seriesNumber?.takeIf { it > 0 }?.toString() ?: "0"
+ } else {
+ "0"
+ }
val payload = requestJson(
url = session.loadUrl,
profile = profile,
@@ -351,7 +500,7 @@ class OkHttpStalkerApiService @Inject constructor(
"action" to "create_link",
"JsHttpRequest" to "1-xml",
"cmd" to cmd,
- "series" to "0",
+ "series" to seriesSelector,
"forced_storage" to "0",
"disable_ad" to "0",
"download" to "0"
@@ -392,6 +541,29 @@ class OkHttpStalkerApiService @Inject constructor(
return items
}
+ private suspend fun fetchPagedItemPage(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ baseQuery: Map<String, String>,
+ page: Int
+ ): StalkerPagedItems {
+ val safePage = page.coerceAtLeast(1).coerceAtMost(MAX_PAGE_COUNT)
+ val payload = requestJson(
+ url = session.loadUrl,
+ profile = profile,
+ referer = session.portalReferer,
+ token = session.token,
+ query = baseQuery + ("p" to safePage.toString())
+ )
+ val items = payload.toItemRecords()
+ return StalkerPagedItems(
+ items = items,
+ page = safePage,
+ totalPages = payload.totalPages(),
+ pageSize = payload.pageSize(items.size)
+ )
+ }
+
private suspend fun fetchAllLiveChannels(
session: StalkerSession,
profile: StalkerDeviceProfile
@@ -469,6 +641,311 @@ class OkHttpStalkerApiService @Inject constructor(
}
}
+ private suspend fun requestStreamingItems(
+ url: String,
+ profile: StalkerDeviceProfile,
+ referer: String,
+ query: Map<String, String>,
+ token: String,
+ onItem: suspend (StalkerItemRecord) -> Unit
+ ): Int = withContext(Dispatchers.IO) {
+ val action = query["action"]
+ val request = Request.Builder()
+ .url(buildUrl(url, query))
+ .header("User-Agent", profile.userAgent)
+ .header("X-User-Agent", profile.xUserAgent)
+ .header("Referer", referer)
+ .header("Accept", "*/*")
+ .header("Cookie", "mac=${profile.macAddress}; stb_lang=${profile.locale}; timezone=${profile.timezone}")
+ .header("Authorization", "Bearer $token")
+ .get()
+ .build()
+
+ runCatching {
+ executeStreamingRequest(request, action, onItem)
+ }.recoverCatching { error ->
+ val alternateUrl = siblingLoadUrl(url)
+ ?.takeIf { it != url }
+ ?: throw error
+ Log.w(
+ TAG,
+ "Retrying streamed Stalker ${action.orEmpty()} via alternate endpoint $alternateUrl after ${error.message}"
+ )
+ val alternateRequest = request.newBuilder()
+ .url(buildUrl(alternateUrl, query))
+ .header("Referer", StalkerUrlFactory.portalReferer(alternateUrl))
+ .build()
+ executeStreamingRequest(alternateRequest, action, onItem)
+ }.getOrElse { throw it }
+ }
+
+ private suspend fun executeStreamingRequest(
+ request: Request,
+ action: String?,
+ onItem: suspend (StalkerItemRecord) -> Unit
+ ): Int {
+ return okHttpClient.newCall(request).execute().use { response ->
+ if (!response.isSuccessful) {
+ throw IOException("Portal request failed with HTTP ${response.code}.")
+ }
+ val body = response.body ?: throw IOException("Portal returned an empty response${actionSuffix(action)}.")
+ val charset = body.contentType()?.charset(Charsets.UTF_8) ?: Charsets.UTF_8
+ val reader = JsonReader(InputStreamReader(body.byteStream(), charset))
+ reader.isLenient = true
+ try {
+ streamStalkerItems(reader, onItem).also { count ->
+ if (count == 0) {
+ throw IOException("Portal returned an empty response${actionSuffix(action)}.")
+ }
+ }
+ } catch (error: IllegalStateException) {
+ throw IOException("Portal returned unreadable JSON${actionSuffix(action)}.", error)
+ }
+ }
+ }
+
+ private suspend fun streamStalkerItems(
+ reader: JsonReader,
+ onItem: suspend (StalkerItemRecord) -> Unit
+ ): Int {
+ return when (reader.peek()) {
+ JsonToken.BEGIN_ARRAY -> streamItemArray(reader, onItem)
+ JsonToken.BEGIN_OBJECT -> streamItemObject(reader, onItem)
+ JsonToken.NULL -> {
+ reader.nextNull()
+ 0
+ }
+ else -> {
+ reader.skipValue()
+ 0
+ }
+ }
+ }
+
+ private suspend fun streamItemObject(
+ reader: JsonReader,
+ onItem: suspend (StalkerItemRecord) -> Unit
+ ): Int {
+ var count = 0
+ reader.beginObject()
+ while (reader.hasNext()) {
+ when (reader.nextName()) {
+ "error" -> {
+ val error = reader.nextStringOrSkip()
+ if (!error.isNullOrBlank() && !error.equals("null", ignoreCase = true)) {
+ throw IOException(error)
+ }
+ }
+ "js", "data", "items" -> count += streamStalkerItems(reader, onItem)
+ else -> reader.skipValue()
+ }
+ }
+ reader.endObject()
+ return count
+ }
+
+ private suspend fun streamItemArray(
+ reader: JsonReader,
+ onItem: suspend (StalkerItemRecord) -> Unit
+ ): Int {
+ var count = 0
+ reader.beginArray()
+ while (reader.hasNext()) {
+ if (reader.peek() == JsonToken.BEGIN_OBJECT) {
+ val element = JsonParser.parseReader(reader)
+ val item = element.asJsonObjectOrNull()?.toItemRecord()
+ if (item != null) {
+ onItem(item)
+ count++
+ }
+ } else {
+ count += streamStalkerItems(reader, onItem)
+ }
+ }
+ reader.endArray()
+ return count
+ }
+
+ /**
+ * Issues a streamed Stalker request that emits [StalkerProgramRecord]s instead of building
+ * a Gson tree of the entire response. This is the heap-safe path used for `get_epg_info`,
+ * which on some portals returns >30 MB of JSON regardless of the requested period.
+ */
+ private suspend fun requestStreamingPrograms(
+ url: String,
+ profile: StalkerDeviceProfile,
+ referer: String,
+ query: Map<String, String>,
+ token: String,
+ channelIdOverride: String?,
+ onProgram: suspend (StalkerProgramRecord) -> Unit
+ ): Int = withContext(Dispatchers.IO) {
+ val action = query["action"]
+ val request = Request.Builder()
+ .url(buildUrl(url, query))
+ .header("User-Agent", profile.userAgent)
+ .header("X-User-Agent", profile.xUserAgent)
+ .header("Referer", referer)
+ .header("Accept", "*/*")
+ .header("Cookie", "mac=${profile.macAddress}; stb_lang=${profile.locale}; timezone=${profile.timezone}")
+ .header("Authorization", "Bearer $token")
+ .get()
+ .build()
+
+ runCatching {
+ executeStreamingPrograms(request, action, channelIdOverride, onProgram)
+ }.recoverCatching { error ->
+ val alternateUrl = siblingLoadUrl(url)
+ ?.takeIf { it != url }
+ ?: throw error
+ Log.w(
+ TAG,
+ "Retrying streamed Stalker EPG ${action.orEmpty()} via alternate endpoint $alternateUrl after ${error.message}"
+ )
+ val alternateRequest = request.newBuilder()
+ .url(buildUrl(alternateUrl, query))
+ .header("Referer", StalkerUrlFactory.portalReferer(alternateUrl))
+ .build()
+ executeStreamingPrograms(alternateRequest, action, channelIdOverride, onProgram)
+ }.getOrElse { throw it }
+ }
+
+ private suspend fun executeStreamingPrograms(
+ request: Request,
+ action: String?,
+ channelIdOverride: String?,
+ onProgram: suspend (StalkerProgramRecord) -> Unit
+ ): Int {
+ return okHttpClient.newCall(request).execute().use { response ->
+ if (!response.isSuccessful) {
+ throw IOException("Portal request failed with HTTP ${response.code}.")
+ }
+ val body = response.body ?: throw IOException("Portal returned an empty response${actionSuffix(action)}.")
+ val charset = body.contentType()?.charset(Charsets.UTF_8) ?: Charsets.UTF_8
+ val limited = ByteSizeLimitInputStream(
+ delegate = body.byteStream(),
+ maxBytes = MAX_EPG_BYTES,
+ onOverflow = {
+ "Portal EPG payload exceeded ${MAX_EPG_BYTES} bytes${actionSuffix(action)}."
+ }
+ )
+ val reader = JsonReader(InputStreamReader(limited, charset))
+ reader.isLenient = true
+ try {
+ streamStalkerPrograms(reader, channelIdOverride, onProgram)
+ } catch (error: IllegalStateException) {
+ throw IOException("Portal returned unreadable JSON${actionSuffix(action)}.", error)
+ }
+ }
+ }
+
+ private suspend fun streamStalkerPrograms(
+ reader: JsonReader,
+ channelIdOverride: String?,
+ onProgram: suspend (StalkerProgramRecord) -> Unit
+ ): Int {
+ return when (reader.peek()) {
+ JsonToken.BEGIN_ARRAY -> streamProgramArray(reader, channelIdOverride, onProgram)
+ JsonToken.BEGIN_OBJECT -> streamProgramObject(reader, channelIdOverride, onProgram)
+ JsonToken.NULL -> {
+ reader.nextNull()
+ 0
+ }
+ else -> {
+ reader.skipValue()
+ 0
+ }
+ }
+ }
+
+ private suspend fun streamProgramObject(
+ reader: JsonReader,
+ channelIdOverride: String?,
+ onProgram: suspend (StalkerProgramRecord) -> Unit
+ ): Int {
+ var count = 0
+ reader.beginObject()
+ var sawEnvelope = false
+ while (reader.hasNext()) {
+ val name = reader.nextName()
+ when (name) {
+ "error" -> {
+ val error = reader.nextStringOrSkip()
+ if (!error.isNullOrBlank() && !error.equals("null", ignoreCase = true)) {
+ throw IOException(error)
+ }
+ }
+ "js", "data", "items" -> {
+ sawEnvelope = true
+ count += streamStalkerPrograms(reader, channelIdOverride, onProgram)
+ }
+ else -> {
+ // Some portals return the bulk EPG as an object whose keys are channel IDs
+ // mapped to arrays of program objects. When we have not already descended
+ // into an envelope key and there is no caller-supplied override, treat the
+ // key as the channel ID and walk the array.
+ if (!sawEnvelope && channelIdOverride == null && reader.peek() == JsonToken.BEGIN_ARRAY) {
+ count += streamProgramArray(reader, name, onProgram)
+ } else {
+ reader.skipValue()
+ }
+ }
+ }
+ }
+ reader.endObject()
+ return count
+ }
+
+ private suspend fun streamProgramArray(
+ reader: JsonReader,
+ channelIdOverride: String?,
+ onProgram: suspend (StalkerProgramRecord) -> Unit
+ ): Int {
+ var count = 0
+ reader.beginArray()
+ while (reader.hasNext()) {
+ if (reader.peek() == JsonToken.BEGIN_OBJECT) {
+ val element = JsonParser.parseReader(reader)
+ val program = element.asJsonObjectOrNull()?.toProgramRecord(channelIdOverride)
+ if (program != null) {
+ onProgram(program)
+ count++
+ }
+ } else {
+ count += streamStalkerPrograms(reader, channelIdOverride, onProgram)
+ }
+ }
+ reader.endArray()
+ return count
+ }
+
+ private fun GsonJsonObject.toProgramRecord(channelIdOverride: String?): StalkerProgramRecord? {
+ val resolvedChannelId = channelIdOverride
+ ?: findString("ch_id")
+ ?: findString("channel_id")
+ ?: findString("id_channel")
+ ?: findString("xmltv_id")
+ ?: findString("epg_id")
+ ?: return null
+ val startMillis = findString("start_timestamp")?.toLongOrNull()?.times(1000L)
+ ?: findString("time")?.let(::parseDateTime)
+ ?: return null
+ val endMillis = findString("stop_timestamp")?.toLongOrNull()?.times(1000L)
+ ?: findString("time_to")?.let(::parseDateTime)
+ ?: (startMillis + (findString("duration")?.toLongOrNull()?.times(60_000L) ?: DEFAULT_PROGRAM_DURATION_MILLIS))
+ val title = findString("name") ?: findString("title") ?: return null
+ return StalkerProgramRecord(
+ id = findString("id") ?: "$resolvedChannelId:$startMillis",
+ channelId = resolvedChannelId,
+ title = title,
+ description = findString("descr") ?: findString("description") ?: "",
+ startTimeMillis = startMillis,
+ endTimeMillis = endMillis,
+ hasArchive = findBoolean("has_archive") == true || findString("has_archive") == "1",
+ isNowPlaying = findBoolean("now_playing") == true || findString("now_playing") == "1"
+ )
+ }
+
private fun siblingLoadUrl(url: String): String? {
val normalized = StalkerUrlFactory.normalizePortalUrl(url)
val lower = normalized.lowercase(Locale.ROOT)
@@ -560,13 +1037,19 @@ class OkHttpStalkerApiService @Inject constructor(
private fun JsonElement.totalPages(): Int {
val payload = payloadObjectOrNull() ?: return 1
val totalItems = payload["total_items"]?.primitiveContentOrNull()?.toIntOrNull() ?: return 1
- val pageSize = payload["max_page_items"]?.primitiveContentOrNull()?.toIntOrNull()
- ?.takeIf { it > 0 }
- ?: payload["data"]?.jsonArrayOrNull()?.size?.takeIf { it > 0 }
+ val pageSize = pageSize(payload["data"]?.jsonArrayOrNull()?.size ?: 0).takeIf { it > 0 }
?: return 1
return ((totalItems + pageSize - 1) / pageSize).coerceAtLeast(1).coerceAtMost(MAX_PAGE_COUNT)
}
+ private fun JsonElement.pageSize(fallback: Int): Int {
+ val payload = payloadObjectOrNull() ?: return fallback
+ return payload["max_page_items"]?.primitiveContentOrNull()?.toIntOrNull()
+ ?.takeIf { it > 0 }
+ ?: payload["data"]?.jsonArrayOrNull()?.size?.takeIf { it > 0 }
+ ?: fallback
+ }
+
private fun JsonElement.toProviderProfile(): StalkerProviderProfile {
val payload = payloadObjectOrNull()
return StalkerProviderProfile(
@@ -654,20 +1137,98 @@ class OkHttpStalkerApiService @Inject constructor(
)
}
+ private fun GsonJsonObject.toItemRecord(): StalkerItemRecord? {
+ val id = findString("id")
+ ?: findString("ch_id")
+ ?: findString("video_id")
+ ?: findString("series_id")
+ ?: return null
+ val name = findString("name")
+ ?: findString("title")
+ ?: return null
+ return StalkerItemRecord(
+ id = id,
+ name = name,
+ categoryId = findString("tv_genre_id")
+ ?: findString("category_id")
+ ?: findString("genre_id"),
+ categoryName = findString("category_name"),
+ number = findString("number")?.toIntOrNull() ?: 0,
+ logoUrl = sanitizeUrl(findString("logo"))
+ ?: sanitizeUrl(findString("screenshot_uri"))
+ ?: sanitizeUrl(findString("cover")),
+ epgChannelId = findString("xmltv_id") ?: findString("epg_id"),
+ cmd = findString("cmd"),
+ streamUrl = sanitizeUrl(findString("cmd")),
+ plot = findString("description") ?: findString("plot"),
+ cast = findString("actors"),
+ director = findString("director"),
+ genre = findString("genres_str") ?: findString("genre"),
+ releaseDate = findString("year")
+ ?.takeIf { it.length == 4 }
+ ?: findString("released") ?: findString("added"),
+ rating = findString("rating_imdb")?.toFloatOrNull()
+ ?: findString("rating")?.toFloatOrNull()
+ ?: 0f,
+ tmdbId = findString("tmdb_id")?.toLongOrNull(),
+ youtubeTrailer = findString("trailer_url"),
+ backdropUrl = sanitizeUrl(findString("backdrop_path")),
+ containerExtension = extractContainerExtension(
+ findString("cmd"),
+ findString("container_extension")
+ ),
+ addedAt = findString("added")?.toLongOrNull() ?: 0L,
+ isAdult = findBoolean("censored") == true,
+ isSeries = findBoolean("is_series") == true || findString("is_series") == "1"
+ )
+ }
+
+ private fun StalkerItemRecord.looksLikeSeasonShell(): Boolean {
+ val normalizedName = name.trim()
+ if (normalizedName.startsWith("Season ", ignoreCase = true)) {
+ return true
+ }
+ return id.contains(':') && isSeries.not() && cmd.isNullOrBlank().not()
+ }
+
private fun JsonObject.toSeasonRecord(episodeEntries: List<JsonObject>): StalkerSeasonRecord {
val seasonNumber = findString("season_id")?.toIntOrNull()
?: findString("season_number")?.toIntOrNull()
+ ?: extractSeasonNumberFromCmd(findString("cmd"))
?: 1
val seasonName = findString("title")
?: findString("name")
?: "Season $seasonNumber"
+ val explicitEpisodes = episodeEntries.mapIndexedNotNull { index, entry ->
+ entry.toEpisodeRecord(index + 1, seasonNumber)
+ }
return StalkerSeasonRecord(
seasonNumber = seasonNumber,
name = seasonName,
coverUrl = sanitizeUrl(findString("screenshot_uri")) ?: sanitizeUrl(findString("cover")),
- episodes = episodeEntries.mapIndexedNotNull { index, entry ->
- entry.toEpisodeRecord(index + 1, seasonNumber)
- }
+ episodes = explicitEpisodes.takeUnless { it.isEmpty() || it.isSeasonShellOnly() }
+ ?: buildEpisodesFromSeriesShell(seasonNumber, seasonName)
+ )
+ }
+
+ private fun JsonObject.toSeasonShellRecord(fallbackSeasonNumber: Int): StalkerSeasonRecord? {
+ val episodeNumbers = extractSeasonShellEpisodeNumbers()
+ if (episodeNumbers.isEmpty()) {
+ return null
+ }
+ val seasonNumber = findString("season_id")?.toIntOrNull()
+ ?: findString("season_number")?.toIntOrNull()
+ ?: extractSeasonNumberFromCmd(findString("cmd"))
+ ?: findString("name")?.filter(Char::isDigit)?.toIntOrNull()
+ ?: fallbackSeasonNumber
+ val seasonName = findString("title")
+ ?: findString("name")
+ ?: "Season $seasonNumber"
+ return StalkerSeasonRecord(
+ seasonNumber = seasonNumber,
+ name = seasonName,
+ coverUrl = sanitizeUrl(findString("screenshot_uri")) ?: sanitizeUrl(findString("cover")),
+ episodes = buildEpisodesFromSeriesShell(seasonNumber, seasonName)
)
}
@@ -703,6 +1264,66 @@ class OkHttpStalkerApiService @Inject constructor(
)
}
+ private fun JsonObject.buildEpisodesFromSeriesShell(
+ fallbackSeasonNumber: Int,
+ fallbackSeasonName: String
+ ): List<StalkerEpisodeRecord> {
+ val episodeNumbers = extractSeasonShellEpisodeNumbers()
+ if (episodeNumbers.isEmpty()) {
+ return emptyList()
+ }
+ val seasonName = fallbackSeasonName.ifBlank { "Season $fallbackSeasonNumber" }
+ return episodeNumbers.map { episodeNumber ->
+ StalkerEpisodeRecord(
+ id = "${findString("id") ?: findString("series_id") ?: "season:$fallbackSeasonNumber"}:$episodeNumber",
+ title = "$seasonName Episode $episodeNumber",
+ episodeNumber = episodeNumber,
+ seasonNumber = fallbackSeasonNumber,
+ cmd = findString("cmd"),
+ coverUrl = sanitizeUrl(findString("screenshot_uri")) ?: sanitizeUrl(findString("cover")),
+ plot = findString("description") ?: findString("plot"),
+ durationSeconds = findString("duration")?.toIntOrNull() ?: 0,
+ releaseDate = findString("added"),
+ rating = findString("rating_imdb")?.toFloatOrNull()
+ ?: findString("rating")?.toFloatOrNull()
+ ?: 0f,
+ containerExtension = extractContainerExtension(findString("cmd"), findString("container_extension"))
+ )
+ }
+ }
+
+ private fun JsonObject.extractSeasonShellEpisodeNumbers(): List<Int> {
+ val seriesArray = this["series"]?.jsonArrayOrNull() ?: return emptyList()
+ return seriesArray.mapIndexedNotNull { index, element ->
+ element.primitiveContentOrNull()?.toIntOrNull()
+ ?: element.jsonObjectOrNull()?.findString("series_number")?.toIntOrNull()
+ ?: element.jsonObjectOrNull()?.findString("episode_number")?.toIntOrNull()
+ ?: (index + 1)
+ }
+ }
+
+ private fun List<StalkerEpisodeRecord>.isSeasonShellOnly(): Boolean {
+ if (size != 1) {
+ return false
+ }
+ val entry = first()
+ return entry.episodeNumber <= 1 && entry.title.startsWith("Season ", ignoreCase = true)
+ }
+
+ private fun extractSeasonNumberFromCmd(cmd: String?): Int? {
+ val decoded = decodeBase64JsonPayload(cmd) ?: return null
+ return decoded.findString("season_num")?.toIntOrNull()
+ ?: decoded.findString("season_id")?.toIntOrNull()
+ }
+
+ private fun decodeBase64JsonPayload(cmd: String?): GsonJsonObject? {
+ val value = cmd?.trim()?.takeIf { it.isNotBlank() } ?: return null
+ return runCatching {
+ val decoded = String(Base64.getDecoder().decode(value), Charsets.UTF_8)
+ JsonParser.parseString(decoded).asJsonObject
+ }.getOrNull()
+ }
+
private fun JsonElement.toProgramRecords(channelId: String? = null): List<StalkerProgramRecord> {
return extractListElements().mapNotNull { entry ->
val resolvedChannelId = channelId ?: entry.findProgramChannelId() ?: return@mapNotNull null
@@ -784,6 +1405,44 @@ class OkHttpStalkerApiService @Inject constructor(
}
}
+ private fun GsonJsonObject.findString(key: String): String? {
+ val element = get(key) ?: return null
+ if (!element.isJsonPrimitive) return null
+ return element.asJsonPrimitive
+ .takeUnless { it.isJsonNull }
+ ?.asString
+ ?.trim()
+ ?.takeIf { it.isNotBlank() }
+ }
+
+ private fun GsonJsonObject.findBoolean(key: String): Boolean? {
+ val value = findString(key)?.lowercase(Locale.ROOT) ?: return null
+ return when (value) {
+ "1", "true", "yes" -> true
+ "0", "false", "no" -> false
+ else -> null
+ }
+ }
+
+ private fun com.google.gson.JsonElement.asJsonObjectOrNull(): GsonJsonObject? =
+ if (isJsonObject) asJsonObject else null
+
+ private fun JsonReader.nextStringOrSkip(): String? {
+ return when (peek()) {
+ JsonToken.STRING,
+ JsonToken.NUMBER,
+ JsonToken.BOOLEAN -> nextString()
+ JsonToken.NULL -> {
+ nextNull()
+ null
+ }
+ else -> {
+ skipValue()
+ null
+ }
+ }
+ }
+
private fun JsonElement.jsonArrayOrNull(): JsonArray? = when (this) {
is JsonArray -> this
else -> null
@@ -859,6 +1518,10 @@ class OkHttpStalkerApiService @Inject constructor(
private const val TAG = "OkHttpStalkerApi"
private const val MAX_PAGE_COUNT = 200
private const val DEFAULT_PROGRAM_DURATION_MILLIS = 30 * 60_000L
+ /** Hard ceiling for the streamed `get_epg_info` body; anything larger is treated as a portal fault. */
+ private const val MAX_EPG_BYTES = 64L * 1024L * 1024L
+ /** Records retained by the legacy buffered [getBulkEpg]/[getEpg] APIs to keep callers heap-safe. */
+ private const val MAX_INLINE_EPG_RECORDS = 1500
private const val DEFAULT_VERSION_STRING =
"ImageDescription: 0.2.18-r23-250; ImageDate: Wed Oct 31 15:22:54 EEST 2018; PORTAL version: 5.6.2; API Version: JS API version: 343; STB API version: 146; Player Engine version: 0x58c"
}
@@ -946,3 +1609,44 @@ private val STALKER_DATE_FORMATTERS: List<DateTimeFormatter> = listOf(
.toFormatter(Locale.ROOT)
.withResolverStyle(ResolverStyle.SMART)
)
+
+
+/**
+ * InputStream wrapper that throws [IOException] when more than [maxBytes] bytes are read from
+ * [delegate]. Used to bound the streamed get_epg_info response so a misbehaving portal
+ * cannot push the device into low-memory or OOM territory.
+ */
+private class ByteSizeLimitInputStream(
+ private val delegate: InputStream,
+ private val maxBytes: Long,
+ private val onOverflow: () -> String
+) : InputStream() {
+ private var bytesRead: Long = 0
+
+ override fun read(): Int {
+ val value = delegate.read()
+ if (value >= 0) {
+ bytesRead += 1
+ checkLimit()
+ }
+ return value
+ }
+
+ override fun read(b: ByteArray, off: Int, len: Int): Int {
+ val n = delegate.read(b, off, len)
+ if (n > 0) {
+ bytesRead += n
+ checkLimit()
+ }
+ return n
+ }
+
+ override fun available(): Int = delegate.available()
+ override fun close() = delegate.close()
+
+ private fun checkLimit() {
+ if (bytesRead > maxBytes) {
+ throw IOException(onOverflow())
+ }
+ }
+}
diff --git a/data/src/main/java/com/streamvault/data/remote/stalker/StalkerApiService.kt b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerApiService.kt
index de917070..102b2326 100644
--- a/data/src/main/java/com/streamvault/data/remote/stalker/StalkerApiService.kt
+++ b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerApiService.kt
@@ -62,6 +62,15 @@ data class StalkerItemRecord(
val isSeries: Boolean = false
)
+data class StalkerPagedItems(
+ val items: List<StalkerItemRecord>,
+ val page: Int,
+ val totalPages: Int,
+ val pageSize: Int
+) {
+ val isComplete: Boolean get() = page >= totalPages
+}
+
data class StalkerSeriesDetails(
val series: StalkerItemRecord,
val seasons: List<StalkerSeasonRecord>
@@ -113,6 +122,12 @@ interface StalkerApiService {
categoryId: String?
): Result<List<StalkerItemRecord>>
+ suspend fun streamLiveStreams(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ onItem: suspend (StalkerItemRecord) -> Unit
+ ): Result<Int>
+
suspend fun getVodCategories(
session: StalkerSession,
profile: StalkerDeviceProfile
@@ -124,6 +139,13 @@ interface StalkerApiService {
categoryId: String?
): Result<List<StalkerItemRecord>>
+ suspend fun getVodStreamsPage(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ categoryId: String?,
+ page: Int
+ ): Result<StalkerPagedItems>
+
suspend fun getSeriesCategories(
session: StalkerSession,
profile: StalkerDeviceProfile
@@ -135,6 +157,13 @@ interface StalkerApiService {
categoryId: String?
): Result<List<StalkerItemRecord>>
+ suspend fun getSeriesPage(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ categoryId: String?,
+ page: Int
+ ): Result<StalkerPagedItems>
+
suspend fun getSeriesDetails(
session: StalkerSession,
profile: StalkerDeviceProfile,
@@ -160,10 +189,38 @@ interface StalkerApiService {
periodHours: Int = 6
): Result<List<StalkerProgramRecord>>
+ /**
+ * Streams the bulk Stalker EPG payload one program at a time.
+ *
+ * Many portals return a single very large JSON body for `get_epg_info` regardless of `period`/`ch_id`.
+ * Building a full Gson tree of that payload is what causes the EPG OOM on TV devices, so this path
+ * walks the response with `JsonReader` and emits records via [onProgram] without ever holding the
+ * full payload in memory.
+ */
+ suspend fun streamBulkEpg(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ periodHours: Int = 6,
+ onProgram: suspend (StalkerProgramRecord) -> Unit
+ ): Result<Int>
+
+ /**
+ * Streams a per-channel Stalker EPG response. Mirrors [streamBulkEpg]; the [channelId] is forwarded
+ * as the portal's `ch_id` query parameter.
+ */
+ suspend fun streamEpg(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ channelId: String,
+ periodHours: Int = 6,
+ onProgram: suspend (StalkerProgramRecord) -> Unit
+ ): Result<Int>
+
suspend fun createLink(
session: StalkerSession,
profile: StalkerDeviceProfile,
kind: StalkerStreamKind,
- cmd: String
+ cmd: String,
+ seriesNumber: Int? = null
): Result<String>
}
diff --git a/data/src/main/java/com/streamvault/data/remote/stalker/StalkerProvider.kt b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerProvider.kt
index 3e19847a..bb84768b 100644
--- a/data/src/main/java/com/streamvault/data/remote/stalker/StalkerProvider.kt
+++ b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerProvider.kt
@@ -17,6 +17,7 @@ import com.streamvault.domain.model.Series
import com.streamvault.domain.provider.IptvProvider
import com.streamvault.domain.util.ChannelNormalizer
import java.net.URI
+import java.util.Base64
import java.util.Locale
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
@@ -27,6 +28,15 @@ data class StalkerPlaybackInfo(
val userAgent: String? = null
)
+data class StalkerPagedResult<T>(
+ val items: List<T>,
+ val page: Int,
+ val totalPages: Int,
+ val pageSize: Int
+) {
+ val isComplete: Boolean get() = page >= totalPages
+}
+
class StalkerProvider(
override val providerId: Long,
private val api: StalkerApiService,
@@ -102,6 +112,24 @@ class StalkerProvider(
items.mapNotNull(::toChannel)
}
+ suspend fun streamLiveStreams(onChannel: suspend (Channel) -> Unit): Result<Int> {
+ return when (val authResult = ensureAuthenticated()) {
+ is Result.Success -> {
+ val (session, _) = authResult.data
+ val result = api.streamLiveStreams(session, currentDeviceProfile()) { item ->
+ toChannel(item)?.let { channel -> onChannel(channel) }
+ }
+ when (result) {
+ is Result.Success -> Result.success(result.data)
+ is Result.Error -> Result.error(result.message, result.exception)
+ is Result.Loading -> Result.error("Unexpected loading state")
+ }
+ }
+ is Result.Error -> Result.error(authResult.message, authResult.exception)
+ is Result.Loading -> Result.error("Unexpected loading state")
+ }
+ }
+
override suspend fun getVodCategories(): Result<List<Category>> =
mapCategories(ContentType.MOVIE) { session, profile ->
api.getVodCategories(session, profile)
@@ -114,6 +142,18 @@ class StalkerProvider(
items.mapNotNull(::toMovie)
}
+ suspend fun getVodStreamsPage(categoryId: Long?, page: Int): Result<StalkerPagedResult<Movie>> =
+ mapPagedItems(ContentType.MOVIE, categoryId) { session, profile, rawCategoryId ->
+ api.getVodStreamsPage(session, profile, rawCategoryId, page)
+ }.mapData { paged ->
+ StalkerPagedResult(
+ items = paged.items.mapNotNull(::toMovie),
+ page = paged.page,
+ totalPages = paged.totalPages,
+ pageSize = paged.pageSize
+ )
+ }
+
override suspend fun getVodInfo(vodId: Long): Result<Movie> {
return when (val moviesResult = getVodStreams(null)) {
is Result.Success -> moviesResult.data
@@ -138,11 +178,34 @@ class StalkerProvider(
items.mapNotNull(::toSeries)
}
- override suspend fun getSeriesInfo(seriesId: Long): Result<Series> {
+ suspend fun getSeriesListPage(categoryId: Long?, page: Int): Result<StalkerPagedResult<Series>> =
+ mapPagedItems(ContentType.SERIES, categoryId) { session, profile, rawCategoryId ->
+ api.getSeriesPage(session, profile, rawCategoryId, page)
+ }.mapData { paged ->
+ StalkerPagedResult(
+ items = paged.items.mapNotNull(::toSeries),
+ page = paged.page,
+ totalPages = paged.totalPages,
+ pageSize = paged.pageSize
+ )
+ }
+
+ suspend fun isWildcardCategory(type: ContentType, categoryId: Long): Boolean {
+ val normalizedType = when (type) {
+ ContentType.SERIES_EPISODE -> ContentType.SERIES
+ else -> type
+ }
+ return resolveRawCategoryId(normalizedType, categoryId)?.trim() == "*" ||
+ categoryId == syntheticCategoryId(normalizedType, "*")
+ }
+
+ override suspend fun getSeriesInfo(seriesId: Long): Result<Series> = getSeriesInfo(seriesId.toString())
+
+ suspend fun getSeriesInfo(providerSeriesId: String): Result<Series> {
return when (val authResult = ensureAuthenticated()) {
is Result.Success -> {
val (session, _) = authResult.data
- when (val detailsResult = api.getSeriesDetails(session, currentDeviceProfile(), seriesId.toString())) {
+ when (val detailsResult = api.getSeriesDetails(session, currentDeviceProfile(), providerSeriesId)) {
is Result.Success -> Result.success(detailsResult.data.toSeries())
is Result.Error -> Result.error(detailsResult.message, detailsResult.exception)
is Result.Loading -> Result.error("Unexpected loading state")
@@ -183,6 +246,47 @@ class StalkerProvider(
}
}
+ /**
+ * Streams the bulk EPG payload one program at a time. Use this in place of [getBulkEpg]
+ * when the caller can flush programs incrementally; it avoids materialising the full
+ * portal response (which can exceed 30 MB on some Stalker servers).
+ */
+ suspend fun streamBulkEpg(
+ periodHours: Int = 6,
+ onProgram: suspend (Program) -> Unit
+ ): Result<Int> {
+ return when (val authResult = ensureAuthenticated()) {
+ is Result.Success -> {
+ val (session, _) = authResult.data
+ api.streamBulkEpg(session, currentDeviceProfile(), periodHours) { record ->
+ onProgram(record.toProgram())
+ }
+ }
+ is Result.Error -> Result.error(authResult.message, authResult.exception)
+ is Result.Loading -> Result.error("Unexpected loading state")
+ }
+ }
+
+ /**
+ * Streams a per-channel EPG payload. Mirrors [getEpg] but does not buffer the result.
+ */
+ suspend fun streamEpg(
+ channelId: String,
+ periodHours: Int = 6,
+ onProgram: suspend (Program) -> Unit
+ ): Result<Int> {
+ return when (val authResult = ensureAuthenticated()) {
+ is Result.Success -> {
+ val (session, _) = authResult.data
+ api.streamEpg(session, currentDeviceProfile(), channelId, periodHours) { record ->
+ onProgram(record.toProgram())
+ }
+ }
+ is Result.Error -> Result.error(authResult.message, authResult.exception)
+ is Result.Loading -> Result.error("Unexpected loading state")
+ }
+ }
+
override suspend fun getShortEpg(channelId: String, limit: Int): Result<List<Program>> {
return when (val authResult = ensureAuthenticated()) {
is Result.Success -> {
@@ -198,7 +302,11 @@ class StalkerProvider(
}
}
- suspend fun resolvePlaybackInfo(kind: StalkerStreamKind, cmd: String): Result<StalkerPlaybackInfo> {
+ suspend fun resolvePlaybackInfo(
+ kind: StalkerStreamKind,
+ cmd: String,
+ seriesNumber: Int? = null
+ ): Result<StalkerPlaybackInfo> {
return when (val authResult = ensureAuthenticated()) {
is Result.Success -> {
val (session, _) = authResult.data
@@ -215,7 +323,7 @@ class StalkerProvider(
)
)
}
- when (val linkResult = api.createLink(session, profile, kind, cmd)) {
+ when (val linkResult = api.createLink(session, profile, kind, cmd, seriesNumber)) {
is Result.Success -> Result.success(
StalkerPlaybackInfo(
url = repairCreateLinkUrl(kind, linkResult.data, directUrl),
@@ -232,8 +340,12 @@ class StalkerProvider(
}
}
- suspend fun resolvePlaybackUrl(kind: StalkerStreamKind, cmd: String): Result<String> =
- resolvePlaybackInfo(kind, cmd).mapData(StalkerPlaybackInfo::url)
+ suspend fun resolvePlaybackUrl(
+ kind: StalkerStreamKind,
+ cmd: String,
+ seriesNumber: Int? = null
+ ): Result<String> =
+ resolvePlaybackInfo(kind, cmd, seriesNumber).mapData(StalkerPlaybackInfo::url)
override suspend fun buildStreamUrl(streamId: Long, containerExtension: String?): String {
throw UnsupportedOperationException("Stalker stream URLs require a command token context.")
@@ -295,6 +407,22 @@ class StalkerProvider(
}
}
+ private suspend fun mapPagedItems(
+ type: ContentType,
+ categoryId: Long?,
+ loader: suspend (StalkerSession, StalkerDeviceProfile, String?) -> Result<StalkerPagedItems>
+ ): Result<StalkerPagedItems> {
+ return when (val authResult = ensureAuthenticated()) {
+ is Result.Success -> {
+ val (session, _) = authResult.data
+ val rawCategoryId = resolveRawCategoryId(type, categoryId)
+ loader(session, currentDeviceProfile(), rawCategoryId)
+ }
+ is Result.Error -> Result.error(authResult.message, authResult.exception)
+ is Result.Loading -> Result.error("Unexpected loading state")
+ }
+ }
+
private suspend fun ensureAuthenticated(): Result<Pair<StalkerSession, StalkerProviderProfile>> =
authMutex.withLock {
val cachedSession = sessionCache
@@ -562,17 +690,24 @@ class StalkerProvider(
isAdult = item.isAdult || AdultContentClassifier.isAdultCategoryName(category.name),
isUserProtected = false,
lastModified = item.addedAt,
- seriesId = item.id.toLongOrNull() ?: numericId
+ seriesId = item.id.toLongOrNull() ?: numericId,
+ providerSeriesId = item.id
)
}
private fun StalkerSeriesDetails.toSeries(): Series {
- val baseSeries = toSeries(series) ?: Series(
- id = 0L,
- name = series.name.ifBlank { "Series ${series.id}" },
- providerId = providerId,
- seriesId = series.id.toLongOrNull() ?: stableItemId(ContentType.SERIES, series.id)
- )
+ val mappedSeries = toSeries(series)
+ val baseSeries = if (mappedSeries != null) {
+ mappedSeries.copy(name = series.name)
+ } else {
+ Series(
+ id = 0L,
+ name = series.name,
+ providerId = providerId,
+ seriesId = series.id.toLongOrNull() ?: stableItemId(ContentType.SERIES, series.id),
+ providerSeriesId = series.id
+ )
+ }
val mappedSeasons = seasons
.sortedBy { it.seasonNumber }
.map { season ->
@@ -610,7 +745,8 @@ class StalkerProvider(
kind = StalkerStreamKind.EPISODE,
itemId = numericId,
cmd = resolvedCmd,
- containerExtension = containerExtension
+ containerExtension = containerExtension,
+ seriesNumber = seasonShellEpisodeSelector(resolvedCmd, episodeNumber)
)
} ?: directStreamUrl.orEmpty()
return Episode(
@@ -633,6 +769,26 @@ class StalkerProvider(
)
}
+ private fun seasonShellEpisodeSelector(cmd: String, episodeNumber: Int): Int? {
+ if (episodeNumber <= 0) {
+ return null
+ }
+ val decoded = runCatching {
+ String(Base64.getDecoder().decode(cmd.trim()), Charsets.UTF_8)
+ }.getOrNull() ?: return null
+ val normalized = decoded.lowercase(Locale.ROOT)
+ if (!normalized.contains("\"type\":\"series\"")) {
+ return null
+ }
+ if (!normalized.contains("\"season_num\"") && !normalized.contains("\"season_id\"")) {
+ return null
+ }
+ if (normalized.contains("\"episode_number\"") || normalized.contains("\"series_number\"")) {
+ return null
+ }
+ return episodeNumber
+ }
+
private fun StalkerProgramRecord.toProgram(): Program =
Program(
id = id.toLongOrNull() ?: stableItemId(ContentType.LIVE, id),
diff --git a/data/src/main/java/com/streamvault/data/remote/stalker/StalkerUrlFactory.kt b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerUrlFactory.kt
index 06562d75..6164903b 100644
--- a/data/src/main/java/com/streamvault/data/remote/stalker/StalkerUrlFactory.kt
+++ b/data/src/main/java/com/streamvault/data/remote/stalker/StalkerUrlFactory.kt
@@ -16,7 +16,8 @@ data class StalkerStreamToken(
val kind: StalkerStreamKind,
val itemId: Long,
val cmd: String,
- val containerExtension: String? = null
+ val containerExtension: String? = null,
+ val seriesNumber: Int? = null
)
object StalkerUrlFactory {
@@ -66,7 +67,8 @@ object StalkerUrlFactory {
kind: StalkerStreamKind,
itemId: Long,
cmd: String,
- containerExtension: String? = null
+ containerExtension: String? = null,
+ seriesNumber: Int? = null
): String {
val query = buildList {
add("cmd=${encode(cmd)}")
@@ -74,6 +76,8 @@ object StalkerUrlFactory {
?.removePrefix(".")
?.takeIf { it.isNotBlank() }
?.let { ext -> add("ext=${encode(ext.lowercase(Locale.ROOT))}") }
+ seriesNumber?.takeIf { it > 0 }
+ ?.let { episode -> add("series=${encode(episode.toString())}") }
}.joinToString("&")
return "$INTERNAL_SCHEME://$providerId/${kind.pathSegment}/$itemId?$query"
}
@@ -89,12 +93,14 @@ object StalkerUrlFactory {
val query = parseQuery(uri.rawQuery)
val cmd = query["cmd"] ?: return null
val ext = query["ext"]?.trim()?.takeIf { it.isNotBlank() }
+ val seriesNumber = query["series"]?.toIntOrNull()?.takeIf { it > 0 }
return StalkerStreamToken(
providerId = providerId,
kind = kind,
itemId = itemId,
cmd = cmd,
- containerExtension = ext
+ containerExtension = ext,
+ seriesNumber = seriesNumber
)
}
diff --git a/data/src/main/java/com/streamvault/data/remote/xtream/XtreamStreamUrlResolver.kt b/data/src/main/java/com/streamvault/data/remote/xtream/XtreamStreamUrlResolver.kt
index ae53f6f1..ff78c0bf 100644
--- a/data/src/main/java/com/streamvault/data/remote/xtream/XtreamStreamUrlResolver.kt
+++ b/data/src/main/java/com/streamvault/data/remote/xtream/XtreamStreamUrlResolver.kt
@@ -127,7 +127,8 @@ class XtreamStreamUrlResolver @Inject constructor(
)
}
val playbackInfo = when (
- val resolvedResult = getOrCreateStalkerProvider(resolvedProvider).resolvePlaybackInfo(token.kind, token.cmd)
+ val resolvedResult = getOrCreateStalkerProvider(resolvedProvider)
+ .resolvePlaybackInfo(token.kind, token.cmd, token.seriesNumber)
) {
is com.streamvault.domain.model.Result.Success -> resolvedResult.data
else -> return null
diff --git a/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt
index 2a3d6d47..b97e3bf0 100644
--- a/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt
+++ b/data/src/main/java/com/streamvault/data/repository/ChannelRepositoryImpl.kt
@@ -7,6 +7,7 @@ import com.streamvault.data.local.dao.FavoriteDao
import com.streamvault.data.local.entity.CategoryEntity
import com.streamvault.data.local.entity.ChannelBrowseEntity
import com.streamvault.data.local.entity.ChannelEntity
+import com.streamvault.data.local.entity.CategoryCount
import com.streamvault.data.mapper.toDomain
import com.streamvault.data.preferences.PreferencesRepository
import com.streamvault.data.remote.xtream.XtreamStreamUrlResolver
@@ -29,6 +30,8 @@ import com.streamvault.domain.model.StreamType
import com.streamvault.domain.repository.ChannelRepository
import com.streamvault.domain.util.ChannelNormalizer
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.withContext
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.combine
@@ -41,6 +44,7 @@ import javax.inject.Inject
import javax.inject.Singleton
@Singleton
+@OptIn(ExperimentalCoroutinesApi::class)
class ChannelRepositoryImpl @Inject constructor(
private val channelDao: ChannelDao,
private val categoryDao: CategoryDao,
@@ -73,6 +77,9 @@ class ChannelRepositoryImpl @Inject constructor(
override fun getChannels(providerId: Long): Flow<List<Channel>> =
observeChannels(channelDao.getByProvider(providerId), providerId)
+ override fun getChannelCount(providerId: Long): Flow<Int> =
+ channelDao.getCount(providerId)
+
override fun getChannelsByCategory(providerId: Long, categoryId: Long): Flow<List<Channel>> =
observeChannels(channelFlow(providerId, categoryId), providerId)
@@ -105,6 +112,42 @@ class ChannelRepositoryImpl @Inject constructor(
observeChannels(channelFlowWithoutErrorsPage(providerId, categoryId, limit), providerId)
.map(::sortChannelsByNumber)
+ override suspend fun getChannelsByCategoryPageOffset(
+ providerId: Long,
+ categoryId: Long,
+ limit: Int,
+ offset: Int
+ ): List<Channel> = channelPageOneShot(providerId, categoryId, limit, offset, withoutErrors = false)
+
+ override suspend fun getChannelsWithoutErrorsPageOffset(
+ providerId: Long,
+ categoryId: Long,
+ limit: Int,
+ offset: Int
+ ): List<Channel> = channelPageOneShot(providerId, categoryId, limit, offset, withoutErrors = true)
+
+ private suspend fun channelPageOneShot(
+ providerId: Long,
+ categoryId: Long,
+ limit: Int,
+ offset: Int,
+ withoutErrors: Boolean
+ ): List<Channel> = withContext(Dispatchers.Default) {
+ val settings = currentPresentationSettings()
+ val level = preferencesRepository.parentalControlLevel.first()
+ val unlockedCats = parentalControlManager.unlockedCategoriesForProvider(providerId).first()
+ val entities = if (categoryId == ChannelRepository.ALL_CHANNELS_ID) {
+ if (withoutErrors) channelDao.getByProviderWithoutErrorsBrowsePageOffset(providerId, limit, offset)
+ else channelDao.getByProviderBrowsePageOffset(providerId, limit, offset)
+ } else {
+ if (withoutErrors) channelDao.getByCategoryWithoutErrorsBrowsePageOffset(providerId, categoryId, limit, offset)
+ else channelDao.getByCategoryBrowsePageOffset(providerId, categoryId, limit, offset)
+ }
+ val filtered = applyVisibilityFilter(entities, level, unlockedCats)
+ val presented = buildPresentedChannels(filtered, settings, unlockedCats)
+ applyNumbering(presented, settings.numberingMode, offset)
+ }
+
override fun searchChannelsByCategory(providerId: Long, categoryId: Long, query: String): Flow<List<Channel>> =
searchChannelEntities(providerId, categoryId, query, CATEGORY_SEARCH_LIMIT)
.let { flow -> observeChannels(flow, providerId) }
@@ -113,15 +156,16 @@ class ChannelRepositoryImpl @Inject constructor(
combine(
categoryDao.getByProviderAndType(providerId, ContentType.LIVE.name),
preferencesRepository.liveChannelGroupingMode.flatMapLatest { groupingMode ->
- if (groupingMode == LiveChannelGroupingMode.GROUPED) {
+ val countFlow: Flow<List<CategoryCount>> = if (groupingMode == LiveChannelGroupingMode.GROUPED) {
channelDao.getGroupedCategoryCounts(providerId)
} else {
channelDao.getCategoryCounts(providerId)
}
+ countFlow
},
preferencesRepository.parentalControlLevel,
parentalControlManager.unlockedCategoriesForProvider(providerId)
- ) { categories: List<CategoryEntity>, categoryCounts, level: Int, unlockedCats: Set<Long> ->
+ ) { categories: List<CategoryEntity>, categoryCounts: List<CategoryCount>, 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)
@@ -590,10 +634,11 @@ class ChannelRepositoryImpl @Inject constructor(
private fun applyNumbering(
channels: List<Channel>,
- numberingMode: ChannelNumberingMode
+ numberingMode: ChannelNumberingMode,
+ offset: Int = 0
): List<Channel> = when (numberingMode) {
ChannelNumberingMode.GROUP -> channels.mapIndexed { index, channel ->
- channel.copy(number = index + 1)
+ channel.copy(number = offset + index + 1)
}
ChannelNumberingMode.PROVIDER -> channels
ChannelNumberingMode.HIDDEN -> channels.map { it.copy(number = 0) }
diff --git a/data/src/main/java/com/streamvault/data/repository/EpgRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/EpgRepositoryImpl.kt
index beca0200..aa12f6bd 100644
--- a/data/src/main/java/com/streamvault/data/repository/EpgRepositoryImpl.kt
+++ b/data/src/main/java/com/streamvault/data/repository/EpgRepositoryImpl.kt
@@ -28,6 +28,7 @@ import kotlinx.coroutines.flow.shareIn
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext
+import kotlinx.coroutines.yield
import okhttp3.OkHttpClient
import okhttp3.Request
import java.io.FilterInputStream
@@ -61,6 +62,7 @@ class EpgRepositoryImpl @Inject constructor(
companion object {
private const val MAX_EPG_SIZE_BYTES = NetworkTimeoutConfig.EPG_MAX_SIZE_BYTES
+ private const val EPG_PROGRAM_BATCH_SIZE = 500
private const val NOW_AND_NEXT_LOOKBACK_MS = 60L * 60L * 1000L
private const val NOW_AND_NEXT_LOOKAHEAD_MS = 2L * 60L * 60L * 1000L
private const val NOW_AND_NEXT_REFRESH_INTERVAL_MS = 60L * 1000L
@@ -215,7 +217,16 @@ class EpgRepositoryImpl @Inject constructor(
withContext(Dispatchers.IO) {
providerRefreshMutex(providerId).withLock {
val stagingProviderId = -providerId
- val batch = ArrayList<ProgramEntity>(500)
+ val batch = ArrayList<ProgramEntity>(EPG_PROGRAM_BATCH_SIZE)
+ suspend fun flushBatch() {
+ if (batch.isEmpty()) return
+ val rows = batch.toList()
+ batch.clear()
+ transactionRunner.inTransaction {
+ programDao.insertAll(rows)
+ }
+ yield()
+ }
try {
val request = Request.Builder()
.url(epgUrl)
@@ -238,50 +249,46 @@ class EpgRepositoryImpl @Inject constructor(
transactionRunner.inTransaction {
programDao.deleteByProvider(stagingProviderId)
+ }
- body.byteStream().use { rawStream ->
- val alreadyDecompressed = contentEncoding?.contains("gzip", ignoreCase = true) == true
- // Decompress Content-Encoding: gzip manually since we requested
- // Accept-Encoding: identity to disable OkHttp's transparent decompression.
- val httpStream: InputStream = if (alreadyDecompressed) {
- GZIPInputStream(rawStream)
- } else {
- rawStream
- }
- // Cap total bytes read even when Content-Length is absent (chunked transfer)
- val limitedStream = object : FilterInputStream(httpStream) {
- private var bytesRead = 0L
- override fun read(): Int {
- if (bytesRead >= MAX_EPG_SIZE_BYTES) throw IOException("EPG response too large (>200 MB)")
- return super.read().also { if (it >= 0) bytesRead++ }
- }
- override fun read(b: ByteArray, off: Int, len: Int): Int {
- if (bytesRead >= MAX_EPG_SIZE_BYTES) throw IOException("EPG response too large (>200 MB)")
- return super.read(b, off, len).also { if (it > 0) bytesRead += it }
- }
+ body.byteStream().use { rawStream ->
+ val alreadyDecompressed = contentEncoding?.contains("gzip", ignoreCase = true) == true
+ // Decompress Content-Encoding: gzip manually since we requested
+ // Accept-Encoding: identity to disable OkHttp's transparent decompression.
+ val httpStream: InputStream = if (alreadyDecompressed) {
+ GZIPInputStream(rawStream)
+ } else {
+ rawStream
+ }
+ // Cap total bytes read even when Content-Length is absent (chunked transfer)
+ val limitedStream = object : FilterInputStream(httpStream) {
+ private var bytesRead = 0L
+ override fun read(): Int {
+ if (bytesRead >= MAX_EPG_SIZE_BYTES) throw IOException("EPG response too large (>200 MB)")
+ return super.read().also { if (it >= 0) bytesRead++ }
}
- val xmlInput: InputStream = if (alreadyDecompressed) {
- limitedStream
- } else {
- xmltvParser.maybeDecompressGzip(epgUrl, limitedStream)
+ override fun read(b: ByteArray, off: Int, len: Int): Int {
+ if (bytesRead >= MAX_EPG_SIZE_BYTES) throw IOException("EPG response too large (>200 MB)")
+ return super.read(b, off, len).also { if (it > 0) bytesRead += it }
}
- xmlInput.use {
- xmltvParser.parseStreaming(xmlInput) { program ->
- batch.add(program.copy(providerId = stagingProviderId).toEntity())
- if (batch.size >= 500) {
- programDao.insertAll(batch.toList())
- batch.clear()
- }
+ }
+ val xmlInput: InputStream = if (alreadyDecompressed) {
+ limitedStream
+ } else {
+ xmltvParser.maybeDecompressGzip(epgUrl, limitedStream)
+ }
+ xmlInput.use {
+ xmltvParser.parseStreaming(xmlInput) { program ->
+ batch.add(program.copy(providerId = stagingProviderId).toEntity())
+ if (batch.size >= EPG_PROGRAM_BATCH_SIZE) {
+ flushBatch()
}
}
}
-
- if (batch.isNotEmpty()) {
- programDao.insertAll(batch.toList())
- batch.clear()
- }
}
+ flushBatch()
+
transactionRunner.inTransaction {
programDao.deleteByProvider(providerId)
programDao.moveToProvider(stagingProviderId, providerId)
diff --git a/data/src/main/java/com/streamvault/data/repository/MovieRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/MovieRepositoryImpl.kt
index 67d77ddd..6c555c33 100644
--- a/data/src/main/java/com/streamvault/data/repository/MovieRepositoryImpl.kt
+++ b/data/src/main/java/com/streamvault/data/repository/MovieRepositoryImpl.kt
@@ -44,7 +44,9 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.channelFlow
import kotlinx.coroutines.flow.combine
+import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.emitAll
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.first
@@ -82,9 +84,11 @@ class MovieRepositoryImpl @Inject constructor(
const val MIN_SEARCH_QUERY_LENGTH = 2
const val BROWSE_WINDOW_BUFFER = 80
const val XTREAM_MOVIE_HYDRATION_TIMEOUT_MILLIS = 60_000L
- const val XTREAM_CATEGORY_HYDRATION_CONCURRENCY = 2
+ const val XTREAM_CATEGORY_HYDRATION_CONCURRENCY = 1
const val XTREAM_EMPTY_CATEGORY_RETRY_COOLDOWN_MILLIS = 30_000L
const val CURSOR_BATCH_SIZE = 40
+ const val STALKER_PREVIEW_REQUIRED_COUNT_THRESHOLD = 24
+ const val STALKER_PREVIEW_MAX_REMOTE_PAGES = 2
}
private data class CachedXtreamProvider(
@@ -184,17 +188,34 @@ class MovieRepositoryImpl @Inject constructor(
}.flatMapLatest { (filteredCategories, level) ->
if (filteredCategories.isEmpty()) {
flowOf(emptyMap())
- } else {
- filteredCategories.forEach { category ->
- triggerXtreamCategoryHydration(
- providerId = providerId,
- categoryId = category.categoryId,
- fetchIfMissing = true,
- refreshStaleInBackground = true
- )
+ } else channelFlow {
+ val provider = providerDao.getById(providerId)
+ val previewCategories = if (provider?.type == ProviderType.STALKER_PORTAL) {
+ val stalkerProvider = createStalkerProvider(providerId, provider)
+ filteredCategories.filterNot { category ->
+ stalkerProvider.isWildcardCategory(ContentType.MOVIE, category.categoryId)
+ }
+ } else {
+ filteredCategories
+ }
+ if (previewCategories.isEmpty()) {
+ send(emptyMap())
+ return@channelFlow
+ }
+ previewCategories.forEach { category ->
+ launch(Dispatchers.IO) {
+ ensureXtreamCategoryLoaded(
+ providerId = providerId,
+ categoryId = category.categoryId,
+ fetchIfMissing = true,
+ refreshStaleInBackground = false,
+ requiredCount = limitPerCategory,
+ allowStalkerWildcard = false
+ )
+ }
}
// SQL LIMIT applied per-category — avoids loading the full catalog into memory
- val categoryGroupFlows: List<Flow<Pair<Long?, List<Movie>>>> = filteredCategories.map { cat ->
+ val categoryGroupFlows: List<Flow<Pair<Long?, List<Movie>>>> = previewCategories.map { cat ->
movieDao.getByCategoryPreview(providerId, cat.categoryId, limitPerCategory)
.map { entities ->
val items = if (level >= 3) entities.filter { !it.isUserProtected } else entities
@@ -203,6 +224,8 @@ class MovieRepositoryImpl @Inject constructor(
}
combine(categoryGroupFlows) { pairs ->
pairs.associate { it.first to it.second }
+ }.collect { previews ->
+ send(previews)
}
}
}
@@ -304,7 +327,8 @@ class MovieRepositoryImpl @Inject constructor(
query.providerId,
it,
fetchIfMissing = true,
- refreshStaleInBackground = true
+ refreshStaleInBackground = true,
+ requiredCount = browseFetchLimit(query)
)
}
emit(fetchMovieBrowseResult(query))
@@ -547,7 +571,7 @@ class MovieRepositoryImpl @Inject constructor(
query.sortBy == LibrarySortBy.RATING || query.filterBy.type == LibraryFilterType.TOP_RATED -> {
query.categoryId?.let { categoryId ->
flow {
- ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchIfMissing = true, refreshStaleInBackground = true)
+ ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchIfMissing = true, refreshStaleInBackground = true, requiredCount = fetchLimit)
emitAll(
combine(
movieDao.getTopRatedByCategoryPreview(query.providerId, categoryId, fetchLimit),
@@ -562,7 +586,7 @@ class MovieRepositoryImpl @Inject constructor(
query.sortBy == LibrarySortBy.RELEASE || query.sortBy == LibrarySortBy.UPDATED || query.filterBy.type == LibraryFilterType.RECENTLY_UPDATED -> {
query.categoryId?.let { categoryId ->
flow {
- ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchIfMissing = true, refreshStaleInBackground = true)
+ ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchIfMissing = true, refreshStaleInBackground = true, requiredCount = fetchLimit)
emitAll(
combine(
movieDao.getFreshByCategoryPreview(query.providerId, categoryId, fetchLimit),
@@ -577,7 +601,7 @@ class MovieRepositoryImpl @Inject constructor(
else -> {
query.categoryId?.let { categoryId ->
flow {
- ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchIfMissing = true, refreshStaleInBackground = true)
+ ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchIfMissing = true, refreshStaleInBackground = true, requiredCount = fetchLimit)
emitAll(
combine(
movieDao.getByCategoryPage(query.providerId, categoryId, fetchLimit, 0),
@@ -601,7 +625,7 @@ class MovieRepositoryImpl @Inject constructor(
query.sortBy in setOf(LibrarySortBy.LIBRARY, LibrarySortBy.TITLE) -> {
query.categoryId?.let { categoryId ->
flow {
- ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchIfMissing = true, refreshStaleInBackground = true)
+ ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchIfMissing = true, refreshStaleInBackground = true, requiredCount = fetchLimit)
emitAll(
combine(
movieDao.getFavoritesByCategoryPage(query.providerId, categoryId, fetchLimit, 0),
@@ -623,7 +647,7 @@ class MovieRepositoryImpl @Inject constructor(
query.sortBy in setOf(LibrarySortBy.LIBRARY, LibrarySortBy.TITLE) -> {
query.categoryId?.let { categoryId ->
flow {
- ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchIfMissing = true, refreshStaleInBackground = true)
+ ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchIfMissing = true, refreshStaleInBackground = true, requiredCount = fetchLimit)
emitAll(
combine(
movieDao.getInProgressByCategoryPage(query.providerId, categoryId, fetchLimit, 0),
@@ -645,7 +669,7 @@ class MovieRepositoryImpl @Inject constructor(
query.sortBy in setOf(LibrarySortBy.LIBRARY, LibrarySortBy.TITLE) -> {
query.categoryId?.let { categoryId ->
flow {
- ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchIfMissing = true, refreshStaleInBackground = true)
+ ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchIfMissing = true, refreshStaleInBackground = true, requiredCount = fetchLimit)
emitAll(
combine(
movieDao.getUnwatchedByCategoryPage(query.providerId, categoryId, fetchLimit, 0),
@@ -667,7 +691,7 @@ class MovieRepositoryImpl @Inject constructor(
query.sortBy == LibrarySortBy.WATCH_COUNT -> {
query.categoryId?.let { categoryId ->
flow {
- ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchIfMissing = true, refreshStaleInBackground = true)
+ ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchIfMissing = true, refreshStaleInBackground = true, requiredCount = fetchLimit)
emitAll(
combine(
movieDao.getByWatchCountCategoryPage(query.providerId, categoryId, fetchLimit, 0),
@@ -688,10 +712,29 @@ class MovieRepositoryImpl @Inject constructor(
}
val categoryId = query.categoryId
- return fastFlow ?: if (categoryId == null) {
- getMovies(query.providerId)
- } else {
- getMoviesByCategory(query.providerId, categoryId)
+ return fastFlow ?: flow {
+ categoryId?.let {
+ ensureXtreamCategoryLoaded(
+ query.providerId,
+ it,
+ fetchIfMissing = true,
+ refreshStaleInBackground = true,
+ requiredCount = fetchLimit
+ )
+ }
+ val source = if (categoryId == null) {
+ movieDao.getByProviderPage(query.providerId, fetchLimit, 0)
+ } else {
+ movieDao.getByCategoryPage(query.providerId, categoryId, fetchLimit, 0)
+ }
+ emitAll(
+ combine(
+ source,
+ preferencesRepository.parentalControlLevel
+ ) { entities, level ->
+ if (level >= 3) entities.filter { !it.isUserProtected } else entities
+ }.map { entities -> entities.map { it.toDomain() } }
+ )
}
}
@@ -774,11 +817,21 @@ class MovieRepositoryImpl @Inject constructor(
).drop(query.offset).take(query.limit)
}
+ val hasMoreRemote = query.categoryId?.let { categoryId ->
+ val provider = providerDao.getById(query.providerId)
+ if (provider?.type == ProviderType.STALKER_PORTAL) {
+ movieCategoryHydrationDao.get(query.providerId, categoryId)?.let { !it.isComplete } ?: false
+ } else {
+ false
+ }
+ } ?: false
+
return PagedResult(
items = items,
totalCount = totalCount,
offset = query.offset,
- limit = query.limit
+ limit = query.limit,
+ hasMoreRemote = hasMoreRemote
)
}
@@ -971,7 +1024,9 @@ class MovieRepositoryImpl @Inject constructor(
categoryId: Long,
fetchIfMissing: Boolean = true,
refreshStaleInBackground: Boolean = false,
- forceRefresh: Boolean = false
+ forceRefresh: Boolean = false,
+ requiredCount: Int = SEARCH_RESULT_LIMIT,
+ allowStalkerWildcard: Boolean = true
) {
val key = "$providerId:$categoryId"
val provider = providerDao.getById(providerId) ?: return
@@ -979,6 +1034,18 @@ class MovieRepositoryImpl @Inject constructor(
val localCount = movieDao.getCountByCategory(providerId, categoryId).first()
val hydration = movieCategoryHydrationDao.get(providerId, categoryId)
+ if (provider.type == ProviderType.STALKER_PORTAL) {
+ hydrateStalkerMovieCategoryToCount(
+ providerId = providerId,
+ categoryId = categoryId,
+ provider = provider,
+ requiredCount = requiredCount,
+ localCount = localCount,
+ hydration = hydration,
+ allowWildcard = allowStalkerWildcard
+ )
+ return
+ }
val hasFreshHydration = hydration?.isFresh() == true &&
(localCount > 0 || hydration.itemCount == 0) &&
!forceRefresh
@@ -1019,7 +1086,9 @@ class MovieRepositoryImpl @Inject constructor(
providerId: Long,
categoryId: Long,
fetchIfMissing: Boolean,
- refreshStaleInBackground: Boolean
+ refreshStaleInBackground: Boolean,
+ requiredCount: Int = SEARCH_RESULT_LIMIT,
+ allowStalkerWildcard: Boolean = true
) {
val key = "$providerId:$categoryId"
if (!backgroundRefreshes.add(key)) return
@@ -1031,14 +1100,23 @@ class MovieRepositoryImpl @Inject constructor(
}
val localCount = movieDao.getCountByCategory(providerId, categoryId).first()
val hydration = movieCategoryHydrationDao.get(providerId, categoryId)
+ if (provider.type == ProviderType.STALKER_PORTAL) {
+ hydrateStalkerMovieCategoryToCount(
+ providerId = providerId,
+ categoryId = categoryId,
+ provider = provider,
+ requiredCount = requiredCount,
+ localCount = localCount,
+ hydration = hydration,
+ allowWildcard = allowStalkerWildcard
+ )
+ return@launch
+ }
if (hydration?.isFresh() == true && (localCount > 0 || hydration.itemCount == 0)) return@launch
if (localCount == 0 && hydration?.isEmptyRetryCoolingDown() == true) return@launch
if (localCount == 0 && !fetchIfMissing) return@launch
if (localCount > 0 && !refreshStaleInBackground && !fetchIfMissing) return@launch
- if (!shouldUsePersistedCategoryHydration(provider, providerId) &&
- provider.type != ProviderType.STALKER_PORTAL &&
- localCount > 0
- ) {
+ if (!shouldUsePersistedCategoryHydration(provider, providerId) && localCount > 0) {
return@launch
}
hydrateXtreamCategory(providerId, categoryId, provider, forceRefresh = localCount > 0)
@@ -1066,10 +1144,10 @@ class MovieRepositoryImpl @Inject constructor(
runCatching {
val result = withTimeout(XTREAM_MOVIE_HYDRATION_TIMEOUT_MILLIS) {
- when (provider.type) {
- ProviderType.XTREAM_CODES -> getOrCreateXtreamProvider(providerId, provider).getVodStreams(categoryId)
- ProviderType.STALKER_PORTAL -> createStalkerProvider(providerId, provider).getVodStreams(categoryId)
- ProviderType.M3U -> return@withTimeout Success(emptyList())
+ if (provider.type == ProviderType.XTREAM_CODES) {
+ getOrCreateXtreamProvider(providerId, provider).getVodStreams(categoryId)
+ } else {
+ return@withTimeout Success(emptyList())
}
}
when (result) {
@@ -1085,7 +1163,11 @@ class MovieRepositoryImpl @Inject constructor(
lastHydratedAt = System.currentTimeMillis(),
itemCount = localCount,
lastStatus = "EMPTY_RETRY",
- lastError = "Xtream category returned an empty result; retry pending."
+ lastError = "Xtream category returned an empty result; retry pending.",
+ lastLoadedPage = 0,
+ totalPages = 0,
+ isComplete = false,
+ pageSize = 0
)
)
freshXtreamCategories.remove(key)
@@ -1099,7 +1181,11 @@ class MovieRepositoryImpl @Inject constructor(
lastHydratedAt = System.currentTimeMillis(),
itemCount = entities.size,
lastStatus = "SUCCESS",
- lastError = null
+ lastError = null,
+ lastLoadedPage = 1,
+ totalPages = 1,
+ isComplete = true,
+ pageSize = entities.size
)
)
}
@@ -1116,13 +1202,96 @@ class MovieRepositoryImpl @Inject constructor(
lastHydratedAt = hydration?.lastHydratedAt ?: 0L,
itemCount = localCount,
lastStatus = "ERROR",
- lastError = error.message
+ lastError = error.message,
+ lastLoadedPage = hydration?.lastLoadedPage ?: 0,
+ totalPages = hydration?.totalPages ?: 0,
+ isComplete = hydration?.isComplete ?: false,
+ pageSize = hydration?.pageSize ?: 0
)
)
}
}
}
+ private suspend fun hydrateStalkerMovieCategoryToCount(
+ providerId: Long,
+ categoryId: Long,
+ provider: ProviderEntity,
+ requiredCount: Int,
+ localCount: Int? = null,
+ hydration: MovieCategoryHydrationEntity? = null,
+ allowWildcard: Boolean = true
+ ) {
+ val key = "$providerId:$categoryId"
+ val lock = xtreamCategoryLoadLocks.getOrPut(key) { Mutex() }
+ lock.withLock {
+ val stalkerProvider = createStalkerProvider(providerId, provider)
+ if (!allowWildcard && stalkerProvider.isWildcardCategory(ContentType.MOVIE, categoryId)) return
+ var currentCount = localCount ?: movieDao.getCountByCategory(providerId, categoryId).first()
+ var currentHydration = hydration ?: movieCategoryHydrationDao.get(providerId, categoryId)
+ if (currentHydration?.isComplete == true || currentCount >= requiredCount) return
+ if (currentCount == 0 && currentHydration?.isEmptyRetryCoolingDown() == true) return
+
+ val isPreviewLoad = requiredCount <= STALKER_PREVIEW_REQUIRED_COUNT_THRESHOLD
+ var nextPage = ((currentHydration?.lastLoadedPage ?: 0) + 1).coerceAtLeast(1)
+ // The cached totalPages can under-report when the preview hydrate stored
+ // it from a partial response. Skip the pre-fetch guard on the first
+ // iteration so we always perform at least one real fetch that refreshes
+ // totalPages; subsequent iterations use the in-loop updated value.
+ var firstIteration = true
+ while (currentCount < requiredCount) {
+ if (isPreviewLoad && nextPage > STALKER_PREVIEW_MAX_REMOTE_PAGES) break
+ val totalPages = currentHydration?.totalPages ?: 0
+ if (!firstIteration && totalPages > 0 && nextPage > totalPages) break
+ firstIteration = false
+ when (val result = stalkerProvider.getVodStreamsPage(categoryId, nextPage)) {
+ is Success -> {
+ val entities = result.data.items.map { movie -> movie.toEntity() }
+ val pageComplete = result.data.isComplete || entities.isEmpty()
+ transactionRunner.inTransaction {
+ movieDao.upsertCategoryPage(providerId, entities)
+ val updatedCount = movieDao.getCountByCategory(providerId, categoryId).first()
+ currentCount = updatedCount
+ currentHydration = MovieCategoryHydrationEntity(
+ providerId = providerId,
+ categoryId = categoryId,
+ lastHydratedAt = System.currentTimeMillis(),
+ itemCount = updatedCount,
+ lastStatus = "SUCCESS",
+ lastError = null,
+ lastLoadedPage = result.data.page,
+ totalPages = result.data.totalPages,
+ isComplete = pageComplete,
+ pageSize = result.data.pageSize
+ )
+ movieCategoryHydrationDao.upsert(currentHydration!!)
+ }
+ if (pageComplete) break
+ nextPage = result.data.page + 1
+ }
+ is Result.Error -> {
+ movieCategoryHydrationDao.upsert(
+ MovieCategoryHydrationEntity(
+ providerId = providerId,
+ categoryId = categoryId,
+ lastHydratedAt = currentHydration?.lastHydratedAt ?: 0L,
+ itemCount = currentCount,
+ lastStatus = "ERROR",
+ lastError = result.message,
+ lastLoadedPage = currentHydration?.lastLoadedPage ?: 0,
+ totalPages = currentHydration?.totalPages ?: 0,
+ isComplete = currentHydration?.isComplete ?: false,
+ pageSize = currentHydration?.pageSize ?: 0
+ )
+ )
+ break
+ }
+ is Result.Loading -> break
+ }
+ }
+ }
+ }
+
private suspend fun shouldUsePersistedCategoryHydration(provider: ProviderEntity, providerId: Long): Boolean {
return syncMetadataRepository.getMetadata(providerId)?.movieSyncMode == VodSyncMode.LAZY_BY_CATEGORY
}
@@ -1197,3 +1366,4 @@ class MovieRepositoryImpl @Inject constructor(
return progressMs >= (totalDurationMs * 0.95f).toLong()
}
}
+
diff --git a/data/src/main/java/com/streamvault/data/repository/PlaybackCompatibilityRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/PlaybackCompatibilityRepositoryImpl.kt
new file mode 100644
index 00000000..fc56bb42
--- /dev/null
+++ b/data/src/main/java/com/streamvault/data/repository/PlaybackCompatibilityRepositoryImpl.kt
@@ -0,0 +1,80 @@
+package com.streamvault.data.repository
+
+import com.streamvault.data.local.dao.PlaybackCompatibilityDao
+import com.streamvault.data.local.entity.PlaybackCompatibilityRecordEntity
+import com.streamvault.domain.model.PlaybackCompatibilityKey
+import com.streamvault.domain.model.PlaybackCompatibilityRecord
+import com.streamvault.domain.repository.PlaybackCompatibilityRepository
+import javax.inject.Inject
+import javax.inject.Singleton
+
+@Singleton
+class PlaybackCompatibilityRepositoryImpl @Inject constructor(
+ private val dao: PlaybackCompatibilityDao
+) : PlaybackCompatibilityRepository {
+
+ override suspend fun getKnownBadRecords(
+ deviceFingerprint: String,
+ streamType: String,
+ videoMimeType: String,
+ resolutionBucket: String
+ ): List<PlaybackCompatibilityRecord> {
+ return dao.getKnownBadCandidates(deviceFingerprint, streamType, videoMimeType, resolutionBucket)
+ .map { it.toDomain() }
+ .filter(PlaybackCompatibilityRecord::isKnownBad)
+ }
+
+ override suspend fun recordFailure(key: PlaybackCompatibilityKey, failureType: String, at: Long) {
+ dao.recordFailure(
+ deviceFingerprint = key.deviceFingerprint,
+ deviceModel = key.deviceModel,
+ androidSdk = key.androidSdk,
+ streamType = key.streamType,
+ videoMimeType = key.videoMimeType,
+ resolutionBucket = key.resolutionBucket,
+ decoderName = key.decoderName,
+ surfaceType = key.surfaceType,
+ failureType = failureType,
+ failedAt = at
+ )
+ prune()
+ }
+
+ override suspend fun recordSuccess(key: PlaybackCompatibilityKey, at: Long) {
+ dao.recordSuccess(
+ deviceFingerprint = key.deviceFingerprint,
+ deviceModel = key.deviceModel,
+ androidSdk = key.androidSdk,
+ streamType = key.streamType,
+ videoMimeType = key.videoMimeType,
+ resolutionBucket = key.resolutionBucket,
+ decoderName = key.decoderName,
+ surfaceType = key.surfaceType,
+ succeededAt = at
+ )
+ }
+
+ override suspend fun prune(maxRecords: Int, olderThanMs: Long) {
+ dao.deleteOlderThan(olderThanMs)
+ dao.keepMostRecent(maxRecords)
+ }
+
+ private fun PlaybackCompatibilityRecordEntity.toDomain(): PlaybackCompatibilityRecord =
+ PlaybackCompatibilityRecord(
+ key = PlaybackCompatibilityKey(
+ deviceFingerprint = deviceFingerprint,
+ deviceModel = deviceModel,
+ androidSdk = androidSdk,
+ streamType = streamType,
+ videoMimeType = videoMimeType,
+ resolutionBucket = resolutionBucket,
+ decoderName = decoderName,
+ surfaceType = surfaceType
+ ),
+ failureType = failureType,
+ lastFailedAt = lastFailedAt,
+ lastSucceededAt = lastSucceededAt,
+ failureCount = failureCount,
+ successCount = successCount
+ )
+}
diff --git a/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt
index 5e7e55f2..d6cc3025 100644
--- a/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt
+++ b/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt
@@ -25,6 +25,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.coroutineScope
+import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
@@ -47,6 +48,7 @@ class ProviderRepositoryImpl @Inject constructor(
) : ProviderRepository {
private companion object {
const val XTREAM_GUIDE_BATCH_CONCURRENCY = 4
+ const val BACKGROUND_EPG_START_DELAY_MS = 15_000L
}
private val repositoryScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
@@ -708,9 +710,12 @@ class ProviderRepositoryImpl @Inject constructor(
if (provider.epgSyncMode != ProviderEpgSyncMode.BACKGROUND) {
return
}
- repositoryScope.launch {
- syncManager.scheduleBackgroundEpgSync(providerId)
- }
+ // The previous implementation launched a coroutine that slept for 15s and then
+ // scheduled the worker. That kept a coroutine alive (and held onto its captures)
+ // even when the user immediately backed out of the screen. WorkManager's own
+ // initialDelay is the right place for that wait — it's persisted, cancellable,
+ // and doesn't pin any process state.
+ syncManager.scheduleBackgroundEpgSync(providerId)
}
private fun normalizeXtreamPrograms(
diff --git a/data/src/main/java/com/streamvault/data/repository/SeriesRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/SeriesRepositoryImpl.kt
index 2fd15cba..a0bfe497 100644
--- a/data/src/main/java/com/streamvault/data/repository/SeriesRepositoryImpl.kt
+++ b/data/src/main/java/com/streamvault/data/repository/SeriesRepositoryImpl.kt
@@ -20,7 +20,9 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.TimeoutCancellationException
import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.channelFlow
import kotlinx.coroutines.flow.combine
+import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.emitAll
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flatMapLatest
@@ -61,9 +63,11 @@ class SeriesRepositoryImpl @Inject constructor(
const val MIN_SEARCH_QUERY_LENGTH = 2
const val BROWSE_WINDOW_BUFFER = 80
const val XTREAM_SERIES_CATEGORY_TIMEOUT_MILLIS = 60_000L
- const val XTREAM_CATEGORY_HYDRATION_CONCURRENCY = 2
+ const val XTREAM_CATEGORY_HYDRATION_CONCURRENCY = 1
const val XTREAM_EMPTY_CATEGORY_RETRY_COOLDOWN_MILLIS = 30_000L
const val CURSOR_BATCH_SIZE = 40
+ const val STALKER_PREVIEW_REQUIRED_COUNT_THRESHOLD = 24
+ const val STALKER_PREVIEW_MAX_REMOTE_PAGES = 2
}
private data class CachedXtreamProvider(
@@ -174,16 +178,36 @@ class SeriesRepositoryImpl @Inject constructor(
}.flatMapLatest { (filteredCategories, level) ->
if (filteredCategories.isEmpty()) {
flowOf(emptyMap())
- } else {
+ } else channelFlow {
val provider = providerDao.getById(providerId)
+ val previewCategories = if (provider?.type == ProviderType.STALKER_PORTAL) {
+ val stalkerProvider = createStalkerProvider(providerId, provider)
+ filteredCategories.filterNot { category ->
+ stalkerProvider.isWildcardCategory(ContentType.SERIES, category.categoryId)
+ }
+ } else {
+ filteredCategories
+ }
+ if (previewCategories.isEmpty()) {
+ send(emptyMap())
+ return@channelFlow
+ }
if (provider != null &&
(provider.type == ProviderType.XTREAM_CODES || provider.type == ProviderType.STALKER_PORTAL)
) {
- filteredCategories.forEach { category ->
- triggerSeriesCategoryHydration(providerId, category.categoryId, provider)
+ previewCategories.forEach { category ->
+ launch(Dispatchers.IO) {
+ ensureXtreamCategoryLoaded(
+ providerId = providerId,
+ categoryId = category.categoryId,
+ requiredCount = limitPerCategory,
+ refreshStaleInBackground = false,
+ allowStalkerWildcard = false
+ )
+ }
}
}
- val categoryGroupFlows: List<Flow<Pair<Long?, List<Series>>>> = filteredCategories.map { cat ->
+ val categoryGroupFlows: List<Flow<Pair<Long?, List<Series>>>> = previewCategories.map { cat ->
seriesDao.getByCategoryPreview(providerId, cat.categoryId, limitPerCategory)
.map { entities ->
val items = if (level >= 3) entities.filter { !it.isUserProtected } else entities
@@ -192,6 +216,8 @@ class SeriesRepositoryImpl @Inject constructor(
}
combine(categoryGroupFlows) { pairs ->
pairs.associate { it.first to it.second }
+ }.collect { previews ->
+ send(previews)
}
}
}
@@ -246,7 +272,7 @@ class SeriesRepositoryImpl @Inject constructor(
override fun browseSeries(query: LibraryBrowseQuery): Flow<PagedResult<Series>> {
return flow {
- query.categoryId?.let { ensureXtreamCategoryLoaded(query.providerId, it) }
+ query.categoryId?.let { ensureXtreamCategoryLoaded(query.providerId, it, browseFetchLimit(query)) }
emit(fetchSeriesBrowseResult(query))
}
}
@@ -291,7 +317,9 @@ class SeriesRepositoryImpl @Inject constructor(
val remoteResult = try {
when (provider.type) {
ProviderType.XTREAM_CODES -> getOrCreateXtreamProvider(providerId, provider).getSeriesInfo(seriesEntity.seriesId)
- ProviderType.STALKER_PORTAL -> createStalkerProvider(providerId, provider).getSeriesInfo(seriesEntity.seriesId)
+ ProviderType.STALKER_PORTAL -> createStalkerProvider(providerId, provider).getSeriesInfo(
+ seriesEntity.providerSeriesId?.takeIf { it.isNotBlank() } ?: seriesEntity.seriesId.toString()
+ )
ProviderType.M3U -> return Result.success(buildSeriesWithPersistedEpisodes(seriesEntity))
}
} catch (e: Exception) {
@@ -317,7 +345,8 @@ class SeriesRepositoryImpl @Inject constructor(
tmdbId = remoteSeries.tmdbId ?: seriesEntity.tmdbId,
youtubeTrailer = remoteSeries.youtubeTrailer ?: seriesEntity.youtubeTrailer,
episodeRunTime = remoteSeries.episodeRunTime ?: seriesEntity.episodeRunTime,
- lastModified = if (remoteSeries.lastModified > 0) remoteSeries.lastModified else seriesEntity.lastModified
+ lastModified = if (remoteSeries.lastModified > 0) remoteSeries.lastModified else seriesEntity.lastModified,
+ providerSeriesId = remoteSeries.providerSeriesId?.takeIf { it.isNotBlank() } ?: seriesEntity.providerSeriesId
)
seriesDao.update(updatedSeries)
@@ -468,7 +497,7 @@ class SeriesRepositoryImpl @Inject constructor(
query.sortBy == LibrarySortBy.RATING || query.filterBy.type == LibraryFilterType.TOP_RATED -> {
query.categoryId?.let { categoryId ->
flow {
- ensureXtreamCategoryLoaded(query.providerId, categoryId)
+ ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchLimit)
emitAll(
combine(
seriesDao.getTopRatedByCategoryPreview(query.providerId, categoryId, fetchLimit),
@@ -483,7 +512,7 @@ class SeriesRepositoryImpl @Inject constructor(
query.sortBy == LibrarySortBy.RELEASE || query.sortBy == LibrarySortBy.UPDATED || query.filterBy.type == LibraryFilterType.RECENTLY_UPDATED -> {
query.categoryId?.let { categoryId ->
flow {
- ensureXtreamCategoryLoaded(query.providerId, categoryId)
+ ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchLimit)
emitAll(
combine(
seriesDao.getFreshByCategoryPreview(query.providerId, categoryId, fetchLimit),
@@ -498,7 +527,7 @@ class SeriesRepositoryImpl @Inject constructor(
else -> {
query.categoryId?.let { categoryId ->
flow {
- ensureXtreamCategoryLoaded(query.providerId, categoryId)
+ ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchLimit)
emitAll(
combine(
seriesDao.getByCategoryPage(query.providerId, categoryId, fetchLimit, 0),
@@ -522,7 +551,7 @@ class SeriesRepositoryImpl @Inject constructor(
query.sortBy in setOf(LibrarySortBy.LIBRARY, LibrarySortBy.TITLE) -> {
query.categoryId?.let { categoryId ->
flow {
- ensureXtreamCategoryLoaded(query.providerId, categoryId)
+ ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchLimit)
emitAll(
combine(
seriesDao.getFavoritesByCategoryPage(query.providerId, categoryId, fetchLimit, 0),
@@ -544,7 +573,7 @@ class SeriesRepositoryImpl @Inject constructor(
query.sortBy in setOf(LibrarySortBy.LIBRARY, LibrarySortBy.TITLE) -> {
query.categoryId?.let { categoryId ->
flow {
- ensureXtreamCategoryLoaded(query.providerId, categoryId)
+ ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchLimit)
emitAll(
combine(
seriesDao.getInProgressByCategoryPage(query.providerId, categoryId, fetchLimit, 0),
@@ -566,7 +595,7 @@ class SeriesRepositoryImpl @Inject constructor(
query.sortBy in setOf(LibrarySortBy.LIBRARY, LibrarySortBy.TITLE) -> {
query.categoryId?.let { categoryId ->
flow {
- ensureXtreamCategoryLoaded(query.providerId, categoryId)
+ ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchLimit)
emitAll(
combine(
seriesDao.getUnwatchedByCategoryPage(query.providerId, categoryId, fetchLimit, 0),
@@ -588,7 +617,7 @@ class SeriesRepositoryImpl @Inject constructor(
query.sortBy == LibrarySortBy.WATCH_COUNT -> {
query.categoryId?.let { categoryId ->
flow {
- ensureXtreamCategoryLoaded(query.providerId, categoryId)
+ ensureXtreamCategoryLoaded(query.providerId, categoryId, fetchLimit)
emitAll(
combine(
seriesDao.getByWatchCountCategoryPage(query.providerId, categoryId, fetchLimit, 0),
@@ -609,10 +638,21 @@ class SeriesRepositoryImpl @Inject constructor(
}
val categoryId = query.categoryId
- return fastFlow ?: if (categoryId == null) {
- getSeries(query.providerId)
- } else {
- getSeriesByCategory(query.providerId, categoryId)
+ return fastFlow ?: flow {
+ categoryId?.let { ensureXtreamCategoryLoaded(query.providerId, it, fetchLimit) }
+ val source = if (categoryId == null) {
+ seriesDao.getByProviderPage(query.providerId, fetchLimit, 0)
+ } else {
+ seriesDao.getByCategoryPage(query.providerId, categoryId, fetchLimit, 0)
+ }
+ emitAll(
+ combine(
+ source,
+ preferencesRepository.parentalControlLevel
+ ) { entities, level ->
+ if (level >= 3) entities.filter { !it.isUserProtected } else entities
+ }.map { entities -> entities.map { it.toDomain() } }
+ )
}
}
@@ -701,11 +741,21 @@ class SeriesRepositoryImpl @Inject constructor(
).drop(query.offset).take(query.limit)
}
+ val hasMoreRemote = query.categoryId?.let { categoryId ->
+ val provider = providerDao.getById(query.providerId)
+ if (provider?.type == ProviderType.STALKER_PORTAL) {
+ seriesCategoryHydrationDao.get(query.providerId, categoryId)?.let { !it.isComplete } ?: false
+ } else {
+ false
+ }
+ } ?: false
+
return PagedResult(
items = items,
totalCount = totalCount,
offset = query.offset,
- limit = query.limit
+ limit = query.limit,
+ hasMoreRemote = hasMoreRemote
)
}
@@ -881,13 +931,31 @@ class SeriesRepositoryImpl @Inject constructor(
}
}
- private suspend fun ensureXtreamCategoryLoaded(providerId: Long, categoryId: Long) {
+ private suspend fun ensureXtreamCategoryLoaded(
+ providerId: Long,
+ categoryId: Long,
+ requiredCount: Int = SEARCH_RESULT_LIMIT,
+ refreshStaleInBackground: Boolean = true,
+ allowStalkerWildcard: Boolean = true
+ ) {
val key = "$providerId:$categoryId"
val provider = providerDao.getById(providerId) ?: return
if (provider.type != ProviderType.XTREAM_CODES && provider.type != ProviderType.STALKER_PORTAL) return
val localCount = seriesDao.getCountByCategory(providerId, categoryId).first()
val hydration = seriesCategoryHydrationDao.get(providerId, categoryId)
+ if (provider.type == ProviderType.STALKER_PORTAL) {
+ hydrateStalkerSeriesCategoryToCount(
+ providerId = providerId,
+ categoryId = categoryId,
+ provider = provider,
+ requiredCount = requiredCount,
+ localCount = localCount,
+ hydration = hydration,
+ allowWildcard = allowStalkerWildcard
+ )
+ return
+ }
val isFresh = hydration?.isFresh() == true && (localCount > 0 || hydration.itemCount == 0)
if (isFresh) {
@@ -896,9 +964,14 @@ class SeriesRepositoryImpl @Inject constructor(
}
// Stale but has cached data — show immediately, refresh in background
+ if (localCount > 0 && refreshStaleInBackground) {
+ loadedXtreamCategories.add(key)
+ triggerSeriesCategoryHydration(providerId, categoryId, provider, requiredCount)
+ return
+ }
+
if (localCount > 0) {
loadedXtreamCategories.add(key)
- triggerSeriesCategoryHydration(providerId, categoryId, provider)
return
}
@@ -909,7 +982,9 @@ class SeriesRepositoryImpl @Inject constructor(
private fun triggerSeriesCategoryHydration(
providerId: Long,
categoryId: Long,
- provider: ProviderEntity
+ provider: ProviderEntity,
+ requiredCount: Int = SEARCH_RESULT_LIMIT,
+ allowStalkerWildcard: Boolean = true
) {
val key = "$providerId:$categoryId"
if (!backgroundRefreshes.add(key)) return
@@ -918,7 +993,19 @@ class SeriesRepositoryImpl @Inject constructor(
val localCount = seriesDao.getCountByCategory(providerId, categoryId).first()
val hydration = seriesCategoryHydrationDao.get(providerId, categoryId)
if (localCount == 0 && hydration?.isEmptyRetryCoolingDown() == true) return@launch
- hydrateSeriesCategory(providerId, categoryId, provider)
+ if (provider.type == ProviderType.STALKER_PORTAL) {
+ hydrateStalkerSeriesCategoryToCount(
+ providerId = providerId,
+ categoryId = categoryId,
+ provider = provider,
+ requiredCount = requiredCount,
+ localCount = localCount,
+ hydration = hydration,
+ allowWildcard = allowStalkerWildcard
+ )
+ } else {
+ hydrateSeriesCategory(providerId, categoryId, provider)
+ }
} finally {
backgroundRefreshes.remove(key)
}
@@ -942,10 +1029,10 @@ class SeriesRepositoryImpl @Inject constructor(
runCatching {
val result = withXtreamSeriesCategoryTimeout(categoryId) {
- when (provider.type) {
- ProviderType.XTREAM_CODES -> getOrCreateXtreamProvider(providerId, provider).getSeriesList(categoryId)
- ProviderType.STALKER_PORTAL -> createStalkerProvider(providerId, provider).getSeriesList(categoryId)
- ProviderType.M3U -> return@withXtreamSeriesCategoryTimeout Success(emptyList())
+ if (provider.type == ProviderType.XTREAM_CODES) {
+ getOrCreateXtreamProvider(providerId, provider).getSeriesList(categoryId)
+ } else {
+ return@withXtreamSeriesCategoryTimeout Success(emptyList())
}
}
when (result) {
@@ -960,7 +1047,11 @@ class SeriesRepositoryImpl @Inject constructor(
lastHydratedAt = System.currentTimeMillis(),
itemCount = localCount,
lastStatus = "EMPTY_RETRY",
- lastError = "Xtream category returned an empty result; retry pending."
+ lastError = "Xtream category returned an empty result; retry pending.",
+ lastLoadedPage = 0,
+ totalPages = 0,
+ isComplete = false,
+ pageSize = 0
)
)
loadedXtreamCategories.remove(key)
@@ -974,7 +1065,11 @@ class SeriesRepositoryImpl @Inject constructor(
lastHydratedAt = System.currentTimeMillis(),
itemCount = entities.size,
lastStatus = "SUCCESS",
- lastError = null
+ lastError = null,
+ lastLoadedPage = 1,
+ totalPages = 1,
+ isComplete = true,
+ pageSize = entities.size
)
)
loadedXtreamCategories.add(key)
@@ -991,13 +1086,93 @@ class SeriesRepositoryImpl @Inject constructor(
lastHydratedAt = hydration?.lastHydratedAt ?: 0L,
itemCount = currentCount,
lastStatus = "ERROR",
- lastError = error.message
+ lastError = error.message,
+ lastLoadedPage = hydration?.lastLoadedPage ?: 0,
+ totalPages = hydration?.totalPages ?: 0,
+ isComplete = hydration?.isComplete ?: false,
+ pageSize = hydration?.pageSize ?: 0
)
)
}
}
}
+ private suspend fun hydrateStalkerSeriesCategoryToCount(
+ providerId: Long,
+ categoryId: Long,
+ provider: ProviderEntity,
+ requiredCount: Int,
+ localCount: Int? = null,
+ hydration: SeriesCategoryHydrationEntity? = null,
+ allowWildcard: Boolean = true
+ ) {
+ val key = "$providerId:$categoryId"
+ val lock = xtreamCategoryLoadLocks.getOrPut(key) { Mutex() }
+ lock.withLock {
+ val stalkerProvider = createStalkerProvider(providerId, provider)
+ if (!allowWildcard && stalkerProvider.isWildcardCategory(ContentType.SERIES, categoryId)) return
+ var currentCount = localCount ?: seriesDao.getCountByCategory(providerId, categoryId).first()
+ var currentHydration = hydration ?: seriesCategoryHydrationDao.get(providerId, categoryId)
+ if (currentHydration?.isComplete == true || currentCount >= requiredCount) return
+ if (currentCount == 0 && currentHydration?.isEmptyRetryCoolingDown() == true) return
+
+ val isPreviewLoad = requiredCount <= STALKER_PREVIEW_REQUIRED_COUNT_THRESHOLD
+ var nextPage = ((currentHydration?.lastLoadedPage ?: 0) + 1).coerceAtLeast(1)
+ // The cached totalPages can under-report when the preview hydrate stored
+ // it from a partial response. Skip the pre-fetch guard on the first
+ // iteration so we always perform at least one real fetch that refreshes
+ // totalPages; subsequent iterations use the in-loop updated value.
+ var firstIteration = true
+ while (currentCount < requiredCount) {
+ if (isPreviewLoad && nextPage > STALKER_PREVIEW_MAX_REMOTE_PAGES) break
+ val totalPages = currentHydration?.totalPages ?: 0
+ if (!firstIteration && totalPages > 0 && nextPage > totalPages) break
+ firstIteration = false
+ when (val result = stalkerProvider.getSeriesListPage(categoryId, nextPage)) {
+ is Success -> {
+ val entities = result.data.items.map { series -> series.toEntity() }
+ val pageComplete = result.data.isComplete || entities.isEmpty()
+ seriesDao.upsertCategoryPage(providerId, entities)
+ currentCount = seriesDao.getCountByCategory(providerId, categoryId).first()
+ currentHydration = SeriesCategoryHydrationEntity(
+ providerId = providerId,
+ categoryId = categoryId,
+ lastHydratedAt = System.currentTimeMillis(),
+ itemCount = currentCount,
+ lastStatus = "SUCCESS",
+ lastError = null,
+ lastLoadedPage = result.data.page,
+ totalPages = result.data.totalPages,
+ isComplete = pageComplete,
+ pageSize = result.data.pageSize
+ )
+ seriesCategoryHydrationDao.upsert(currentHydration!!)
+ if (pageComplete) break
+ nextPage = result.data.page + 1
+ }
+ is Result.Error -> {
+ seriesCategoryHydrationDao.upsert(
+ SeriesCategoryHydrationEntity(
+ providerId = providerId,
+ categoryId = categoryId,
+ lastHydratedAt = currentHydration?.lastHydratedAt ?: 0L,
+ itemCount = currentCount,
+ lastStatus = "ERROR",
+ lastError = result.message,
+ lastLoadedPage = currentHydration?.lastLoadedPage ?: 0,
+ totalPages = currentHydration?.totalPages ?: 0,
+ isComplete = currentHydration?.isComplete ?: false,
+ pageSize = currentHydration?.pageSize ?: 0
+ )
+ )
+ break
+ }
+ is Result.Loading -> break
+ }
+ }
+ }
+ }
+
private fun SeriesCategoryHydrationEntity.isFresh(now: Long = System.currentTimeMillis()): Boolean {
if (lastStatus != "SUCCESS") return false
return !ContentCachePolicy.shouldRefresh(lastHydratedAt, ContentCachePolicy.SERIES_CATEGORY_TTL_MILLIS, now)
diff --git a/data/src/main/java/com/streamvault/data/sync/BackgroundEpgSyncWorker.kt b/data/src/main/java/com/streamvault/data/sync/BackgroundEpgSyncWorker.kt
index 3017551a..fd7a046f 100644
--- a/data/src/main/java/com/streamvault/data/sync/BackgroundEpgSyncWorker.kt
+++ b/data/src/main/java/com/streamvault/data/sync/BackgroundEpgSyncWorker.kt
@@ -1,5 +1,6 @@
package com.streamvault.data.sync
+import android.app.ActivityManager
import android.content.Context
import android.database.sqlite.SQLiteException
import android.util.Log
@@ -36,12 +37,23 @@ class BackgroundEpgSyncWorker(
return Result.failure()
}
+ // Defer the run when the device is currently under memory pressure. The streamed
+ // Stalker EPG path is heap-frugal but the surrounding sync work (channel inserts,
+ // EPG resolution) can still allocate; retrying later avoids piling onto a stressed
+ // system. WorkManager will re-enqueue with backoff.
+ if (isDeviceLowOnMemory()) {
+ Log.w(TAG, "Deferring background EPG sync for provider $providerId: device low on memory")
+ return Result.retry()
+ }
+
+ val force = inputData.getBoolean(KEY_FORCE_REFRESH, false)
+
return try {
val entryPoint = EntryPointAccessors.fromApplication(
applicationContext,
BackgroundEpgSyncWorkerEntryPoint::class.java
)
- when (val result = entryPoint.syncManager().syncEpg(providerId, force = true)) {
+ when (val result = entryPoint.syncManager().syncEpg(providerId, force = force)) {
is com.streamvault.domain.model.Result.Success -> Result.success()
is com.streamvault.domain.model.Result.Error -> {
if (result.message.contains("not found", ignoreCase = true)) {
@@ -60,6 +72,16 @@ class BackgroundEpgSyncWorker(
}
}
+ private fun isDeviceLowOnMemory(): Boolean {
+ val activityManager = applicationContext.getSystemService(Context.ACTIVITY_SERVICE)
+ as? ActivityManager ?: return false
+ val info = ActivityManager.MemoryInfo()
+ return runCatching {
+ activityManager.getMemoryInfo(info)
+ info.lowMemory
+ }.getOrDefault(false)
+ }
+
private fun shouldRetry(error: Throwable?): Boolean {
return when (error) {
is java.io.IOException -> true
@@ -72,19 +94,37 @@ class BackgroundEpgSyncWorker(
companion object {
private const val TAG = "BackgroundEpgWorker"
private const val KEY_PROVIDER_ID = "provider_id"
+ private const val KEY_FORCE_REFRESH = "force_refresh"
private const val INVALID_PROVIDER_ID = -1L
private const val UNIQUE_WORK_PREFIX = "background-epg-sync-"
+ /**
+ * Default delay before the first background EPG sync runs after enqueue. This
+ * replaces the in-process [kotlinx.coroutines.delay] previously used by the
+ * provider repository, which kept a coroutine alive for the duration of the wait.
+ */
+ private const val DEFAULT_INITIAL_DELAY_SECONDS = 30L
- fun enqueue(context: Context, providerId: Long) {
+ fun enqueue(
+ context: Context,
+ providerId: Long,
+ force: Boolean = false,
+ initialDelaySeconds: Long = DEFAULT_INITIAL_DELAY_SECONDS
+ ) {
if (providerId <= 0L) return
val request = OneTimeWorkRequestBuilder<BackgroundEpgSyncWorker>()
- .setInputData(Data.Builder().putLong(KEY_PROVIDER_ID, providerId).build())
+ .setInputData(
+ Data.Builder()
+ .putLong(KEY_PROVIDER_ID, providerId)
+ .putBoolean(KEY_FORCE_REFRESH, force)
+ .build()
+ )
.setConstraints(
Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.setRequiresBatteryNotLow(true)
.build()
)
+ .setInitialDelay(initialDelaySeconds.coerceAtLeast(0L), TimeUnit.SECONDS)
.setBackoffCriteria(
BackoffPolicy.EXPONENTIAL,
WorkRequest.MIN_BACKOFF_MILLIS,
diff --git a/data/src/main/java/com/streamvault/data/sync/SyncManager.kt b/data/src/main/java/com/streamvault/data/sync/SyncManager.kt
index c11afba3..af27d3b8 100644
--- a/data/src/main/java/com/streamvault/data/sync/SyncManager.kt
+++ b/data/src/main/java/com/streamvault/data/sync/SyncManager.kt
@@ -98,6 +98,21 @@ private const val XTREAM_AVOID_FULL_CATALOG_COOLDOWN_MILLIS = 6 * 60 * 60 * 1000
private const val XTREAM_MOVIE_REQUEST_TIMEOUT_MILLIS = 60_000L
private const val XTREAM_SERIES_REQUEST_TIMEOUT_MILLIS = 60_000L
private const val STALKER_GUIDE_PROGRAM_BATCH_SIZE = 500
+/**
+ * Maximum number of programs we will accept from a single per-channel `get_epg_info`
+ * call before treating the response as a portal that ignores `ch_id` and returns the
+ * full bulk EPG. Probed real-world portals return at most ~150 programs/channel for a
+ * 6h period; 5 000 leaves ample headroom while still catching multi-megabyte payloads.
+ */
+private const val STALKER_PER_CHANNEL_RECORD_SANITY_CAP = 5_000
+
+/**
+ * Sentinel exception raised inside the streamed per-channel EPG callback when we detect
+ * that the portal is returning the bulk payload regardless of the requested `ch_id`.
+ * Caught and converted into a warning by [SyncManager.syncStalkerPortalEpg].
+ */
+private class StalkerBrokenPerChannelEpgException(channelName: String) :
+ RuntimeException("Stalker portal returned bulk-shaped EPG for per-channel request ($channelName)")
enum class SyncRepairSection {
LIVE,
@@ -882,22 +897,11 @@ class SyncManager @Inject constructor(
if (force || ContentCachePolicy.shouldRefresh(metadata.lastLiveSuccess, ContentCachePolicy.CATALOG_TTL_MILLIS, now)) {
progress(provider.id, onProgress, "Downloading Live TV...")
val hiddenLiveCategoryIds = preferencesRepository.getHiddenCategoryIds(provider.id, ContentType.LIVE).first()
- val liveCatalogResult = loadStalkerLiveCatalog(api, provider, onProgress)
- val liveCatalog = mergeVisibleLiveSyncWithHiddenStoredContent(
- providerId = provider.id,
- visibleCategories = liveCatalogResult.categories,
- visibleChannels = liveCatalogResult.channels.map { it.toEntity() },
- hiddenLiveCategoryIds = hiddenLiveCategoryIds
- )
- val acceptedCount = syncCatalogStore.replaceLiveCatalog(
- providerId = provider.id,
- categories = liveCatalog.categories,
- channels = liveCatalog.channels
- )
+ val liveCatalogResult = syncStalkerLiveCatalogStaged(api, provider, hiddenLiveCategoryIds, onProgress)
metadata = metadata.copy(
lastLiveSync = now,
lastLiveSuccess = now,
- liveCount = acceptedCount
+ liveCount = liveCatalogResult.acceptedCount
)
syncMetadataRepository.updateMetadata(metadata)
warnings += liveCatalogResult.warnings
@@ -1224,60 +1228,82 @@ class SyncManager @Inject constructor(
}
runCatching {
- requireResult(
- api.getBulkEpg(),
- "Failed to load bulk Stalker guide"
- )
- }.onSuccess { programs ->
- programs
- .asSequence()
- .mapNotNull { program ->
- val resolvedChannelKey = aliasToChannelKey[program.channelId] ?: return@mapNotNull null
- bulkCoveredChannelKeys += resolvedChannelKey
- program.copy(
- providerId = provider.id,
- channelId = resolvedChannelKey
- ).toEntity()
+ // Stream the bulk EPG payload program-by-program; the previous buffered API
+ // could materialise >30 MB JSON trees on certain Stalker portals which led to
+ // OOM crashes when re-entering content screens.
+ api.streamBulkEpg(periodHours = 6) { program ->
+ val resolvedChannelKey = aliasToChannelKey[program.channelId] ?: return@streamBulkEpg
+ if (program.endTime <= program.startTime) return@streamBulkEpg
+ bulkCoveredChannelKeys += resolvedChannelKey
+ insertBuffer += program.copy(
+ providerId = provider.id,
+ channelId = resolvedChannelKey
+ ).toEntity()
+ if (insertBuffer.size >= STALKER_GUIDE_PROGRAM_BATCH_SIZE) {
+ flushPrograms()
}
- .forEach { entity ->
- insertBuffer += entity
- if (insertBuffer.size >= STALKER_GUIDE_PROGRAM_BATCH_SIZE) {
- flushPrograms()
- }
+ }.let { result ->
+ if (result is com.streamvault.domain.model.Result.Error) {
+ throw result.exception ?: IllegalStateException(result.message)
}
+ }
}.onFailure { error ->
Log.d(TAG, "Bulk Stalker portal EPG fetch unavailable for provider ${provider.id}", error)
}
val fallbackGuideRequests = guideRequests.filterNot { request -> request.channelKey in bulkCoveredChannelKeys }
+ // Some portals ignore `ch_id` and return the entire bulk EPG for every per-channel
+ // request. After the first per-channel call we sample the response shape; if it
+ // looks like the portal is repeatedly emitting the bulk payload we abort the
+ // per-channel loop to avoid downloading the same multi-megabyte payload N times.
+ var ignorePerChannelGuide = false
+
fallbackGuideRequests.forEachIndexed { index, request ->
+ if (ignorePerChannelGuide) return@forEachIndexed
progress(provider.id, onProgress, "Downloading portal EPG... ${index + 1} of ${fallbackGuideRequests.size}")
runCatching {
- requireResult(
- api.getEpg(request.channelKey),
- "Failed to load Stalker guide for ${request.channelName}"
- )
- }.onSuccess { programs ->
- programs
- .asSequence()
- .filter { program -> program.endTime > program.startTime }
- .forEach { program ->
- insertBuffer += program.copy(
- providerId = provider.id,
- channelId = request.channelKey
- ).toEntity()
- if (insertBuffer.size >= STALKER_GUIDE_PROGRAM_BATCH_SIZE) {
- flushPrograms()
- }
+ var perChannelRecordCount = 0
+ val foreignChannelIds = HashSet<String>()
+ val streamResult = api.streamEpg(request.channelKey) { program ->
+ if (program.endTime <= program.startTime) return@streamEpg
+ if (program.channelId != request.channelKey) {
+ foreignChannelIds += program.channelId
+ }
+ insertBuffer += program.copy(
+ providerId = provider.id,
+ channelId = request.channelKey
+ ).toEntity()
+ perChannelRecordCount++
+ if (perChannelRecordCount >= STALKER_PER_CHANNEL_RECORD_SANITY_CAP || foreignChannelIds.size > 1) {
+ // Bail out of this single response — the portal is clearly returning
+ // the bulk payload again. The outer loop will then disable any
+ // remaining per-channel calls.
+ throw StalkerBrokenPerChannelEpgException(request.channelName)
}
+ if (insertBuffer.size >= STALKER_GUIDE_PROGRAM_BATCH_SIZE) {
+ flushPrograms()
+ }
+ }
+ if (streamResult is com.streamvault.domain.model.Result.Error) {
+ throw streamResult.exception ?: IllegalStateException(streamResult.message)
+ }
}.onFailure { error ->
- failedChannels += request.channelName
- Log.w(
- TAG,
- "Stalker portal EPG fetch failed for provider ${provider.id} channel ${request.channelKey}",
- error
- )
+ if (error is StalkerBrokenPerChannelEpgException) {
+ ignorePerChannelGuide = true
+ Log.w(
+ TAG,
+ "Stalker portal returned bulk-shaped payload for per-channel EPG request " +
+ "(${request.channelKey}); skipping remaining per-channel guide calls."
+ )
+ } else {
+ failedChannels += request.channelName
+ Log.w(
+ TAG,
+ "Stalker portal EPG fetch failed for provider ${provider.id} channel ${request.channelKey}",
+ error
+ )
+ }
}
}
@@ -1495,19 +1521,12 @@ class SyncManager @Inject constructor(
progress(provider.id, onProgress, "Retrying Live TV...")
val api = createStalkerSyncProvider(provider)
val hiddenLiveCategoryIds = preferencesRepository.getHiddenCategoryIds(provider.id, ContentType.LIVE).first()
- val liveCatalogResult = loadStalkerLiveCatalog(api, provider, onProgress)
- val liveCatalog = mergeVisibleLiveSyncWithHiddenStoredContent(
- providerId = provider.id,
- visibleCategories = liveCatalogResult.categories,
- visibleChannels = liveCatalogResult.channels.map { it.toEntity() },
- hiddenLiveCategoryIds = hiddenLiveCategoryIds
- )
- val acceptedCount = syncCatalogStore.replaceLiveCatalog(provider.id, liveCatalog.categories, liveCatalog.channels)
+ val liveCatalogResult = syncStalkerLiveCatalogStaged(api, provider, hiddenLiveCategoryIds, onProgress)
val metadata = (syncMetadataRepository.getMetadata(provider.id) ?: SyncMetadata(provider.id))
.copy(
lastLiveSync = now,
lastLiveSuccess = now,
- liveCount = acceptedCount
+ liveCount = liveCatalogResult.acceptedCount
)
syncMetadataRepository.updateMetadata(metadata)
}
@@ -2253,6 +2272,121 @@ class SyncManager @Inject constructor(
val warnings: List<String> = emptyList()
)
+ private data class StagedStalkerLiveCatalogResult(
+ val acceptedCount: Int,
+ val warnings: List<String> = emptyList()
+ )
+
+ private suspend fun syncStalkerLiveCatalogStaged(
+ api: StalkerProvider,
+ provider: Provider,
+ hiddenLiveCategoryIds: Set<Long>,
+ onProgress: ((String) -> Unit)?
+ ): StagedStalkerLiveCatalogResult {
+ val warnings = mutableListOf<String>()
+ var categoriesErrorMessage: String? = null
+ val preferredCategories = when (val categoriesResult = api.getLiveCategories()) {
+ is com.streamvault.domain.model.Result.Success -> categoriesResult.data
+ .map { it.toEntity(provider.id) }
+ .filterNot { category -> category.categoryId in hiddenLiveCategoryIds }
+ is com.streamvault.domain.model.Result.Error -> {
+ Log.w(
+ TAG,
+ "Stalker live categories failed for provider ${provider.id}; streaming bulk live channels with fallback categories: ${categoriesResult.message}",
+ categoriesResult.exception
+ )
+ warnings += "Live categories failed; recovered using bulk live channels."
+ categoriesErrorMessage = categoriesResult.message
+ null
+ }
+ is com.streamvault.domain.model.Result.Loading -> throw IllegalStateException("Unexpected loading state")
+ }
+
+ progress(provider.id, onProgress, "Loading live channels...")
+ val fallbackCollector = FallbackCategoryCollector(provider.id, ContentType.LIVE)
+ val seenStreamIds = HashSet<Long>()
+ val batch = ArrayList<Channel>(XTREAM_FALLBACK_STAGE_BATCH_SIZE)
+ var stagedSessionId: Long? = null
+ var acceptedCount = 0
+
+ suspend fun flushBatch() {
+ if (batch.isEmpty()) return
+ val staged = catalogStager.stageChannelItems(
+ providerId = provider.id,
+ items = batch,
+ seenStreamIds = seenStreamIds,
+ fallbackCollector = fallbackCollector,
+ sessionId = stagedSessionId
+ )
+ stagedSessionId = staged.sessionId
+ acceptedCount += staged.acceptedCount
+ batch.clear()
+ }
+
+ try {
+ when (val streamResult = api.streamLiveStreams { channel ->
+ if (channel.categoryId != null && channel.categoryId in hiddenLiveCategoryIds) {
+ return@streamLiveStreams
+ }
+ batch += channel
+ if (batch.size >= XTREAM_FALLBACK_STAGE_BATCH_SIZE) {
+ flushBatch()
+ }
+ }) {
+ is com.streamvault.domain.model.Result.Success -> flushBatch()
+ is com.streamvault.domain.model.Result.Error -> {
+ val profileDiagnostic = stalkerCatalogAccessDiagnostic(
+ api = api,
+ primaryMessage = categoriesErrorMessage.orEmpty(),
+ fallbackMessage = streamResult.message
+ )
+ throw IllegalStateException(
+ buildString {
+ append(streamResult.message.ifBlank { "Failed to load live channels" })
+ profileDiagnostic?.let {
+ append(' ')
+ append(it)
+ }
+ },
+ streamResult.exception
+ )
+ }
+ is com.streamvault.domain.model.Result.Loading -> throw IllegalStateException("Unexpected loading state")
+ }
+
+ val sessionId = stagedSessionId
+ if (acceptedCount == 0 || sessionId == null) {
+ throw IllegalStateException("Stalker bulk live catalog returned no usable channels.")
+ }
+
+ if (hiddenLiveCategoryIds.isNotEmpty()) {
+ mergeHiddenChannelsIntoStaging(provider.id, sessionId, hiddenLiveCategoryIds)
+ }
+ val hiddenCategories = if (hiddenLiveCategoryIds.isNotEmpty()) {
+ categoryDao.getByProviderAndTypeSync(provider.id, ContentType.LIVE.name)
+ .filter { category -> category.categoryId in hiddenLiveCategoryIds }
+ } else {
+ emptyList()
+ }
+ val categories = (
+ mergePreferredAndFallbackCategories(
+ preferredCategories,
+ fallbackCollector.entities().takeIf { it.isNotEmpty() }
+ ).orEmpty() + hiddenCategories
+ )
+ .distinctBy { it.categoryId to it.type }
+ .takeIf { it.isNotEmpty() }
+ syncCatalogStore.applyStagedLiveCatalog(provider.id, sessionId, categories)
+ return StagedStalkerLiveCatalogResult(acceptedCount, warnings)
+ } catch (error: CancellationException) {
+ stagedSessionId?.let { syncCatalogStore.discardStagedImport(provider.id, it) }
+ throw error
+ } catch (error: Exception) {
+ stagedSessionId?.let { syncCatalogStore.discardStagedImport(provider.id, it) }
+ throw error
+ }
+ }
+
private suspend fun loadStalkerLiveCatalog(
api: StalkerProvider,
provider: Provider,
diff --git a/data/src/test/java/com/streamvault/data/remote/stalker/OkHttpStalkerApiServiceTest.kt b/data/src/test/java/com/streamvault/data/remote/stalker/OkHttpStalkerApiServiceTest.kt
index 6a9160e7..fc1a56bc 100644
--- a/data/src/test/java/com/streamvault/data/remote/stalker/OkHttpStalkerApiServiceTest.kt
+++ b/data/src/test/java/com/streamvault/data/remote/stalker/OkHttpStalkerApiServiceTest.kt
@@ -72,6 +72,53 @@ class OkHttpStalkerApiServiceTest {
assertThat(success.data).isEqualTo("http://cdn.example.com/live/stream.ts")
}
+ @Test
+ fun createLink_uses_episode_number_as_series_selector_for_stalker_shell_episode() = runTest {
+ var requestedSeries: String? = null
+ val service = OkHttpStalkerApiService(
+ okHttpClient = OkHttpClient.Builder()
+ .addInterceptor { chain ->
+ val request = chain.request()
+ requestedSeries = request.url.queryParameter("series")
+ Response.Builder()
+ .request(request)
+ .protocol(Protocol.HTTP_1_1)
+ .code(200)
+ .message("OK")
+ .body(
+ """{"js":{"cmd":"ffmpeg http://cdn.example.com/series/episode11.mkv"}}"""
+ .toResponseBody("application/json".toMediaType())
+ )
+ .build()
+ }
+ .build(),
+ json = Json { ignoreUnknownKeys = true }
+ )
+
+ val result = service.createLink(
+ session = StalkerSession(
+ loadUrl = "https://portal.example.com/server/load.php",
+ portalReferer = "https://portal.example.com/c/",
+ token = "token-123"
+ ),
+ profile = buildStalkerDeviceProfile(
+ portalUrl = "https://portal.example.com/c",
+ macAddress = "00:1A:79:12:34:56",
+ deviceProfile = "MAG250",
+ timezone = "UTC",
+ locale = "en"
+ ),
+ kind = StalkerStreamKind.EPISODE,
+ cmd = "eyJzZXJpZXNfaWQiOjUzOTk5LCJzZWFzb25fbnVtIjoxLCJ0eXBlIjoic2VyaWVzIn0=",
+ seriesNumber = 11
+ )
+
+ assertThat(result).isInstanceOf(Result.Success::class.java)
+ assertThat(requestedSeries).isEqualTo("11")
+ val success = result as Result.Success
+ assertThat(success.data).isEqualTo("http://cdn.example.com/series/episode11.mkv")
+ }
+
@Test
fun authenticate_reads_json_from_callback_wrapper_and_control_char_noise() = runTest {
val service = OkHttpStalkerApiService(
@@ -224,6 +271,45 @@ class OkHttpStalkerApiServiceTest {
assertThat(requestedActions).containsExactly("get_all_channels")
}
+ @Test
+ fun streamLiveStreams_emits_bulk_channels_from_js_data_without_list_materialization() = runTest {
+ val service = OkHttpStalkerApiService(
+ okHttpClient = fakeClient(
+ "get_all_channels" to """
+ {"js":{"data":[
+ {"id":"100","name":"News","tv_genre_id":"10","cmd":"ffmpeg http://example.com/news.ts"},
+ {"id":"101","name":"Sports","tv_genre_id":"11","cmd":"ffmpeg http://example.com/sports.ts"}
+ ]}}
+ """.trimIndent()
+ ),
+ json = Json { ignoreUnknownKeys = true }
+ )
+ val streamed = mutableListOf<StalkerItemRecord>()
+
+ val result = service.streamLiveStreams(
+ session = StalkerSession(
+ loadUrl = "https://portal.example.com/server/load.php",
+ portalReferer = "https://portal.example.com/c/",
+ token = "token-123"
+ ),
+ profile = buildStalkerDeviceProfile(
+ portalUrl = "https://portal.example.com/c",
+ macAddress = "00:1A:79:12:34:56",
+ deviceProfile = "MAG250",
+ timezone = "UTC",
+ locale = "en"
+ )
+ ) { item ->
+ streamed += item
+ }
+
+ assertThat(result).isInstanceOf(Result.Success::class.java)
+ val success = result as Result.Success
+ assertThat(success.data).isEqualTo(2)
+ assertThat(streamed.map { it.name }).containsExactly("News", "Sports").inOrder()
+ assertThat(streamed.map { it.categoryId }).containsExactly("10", "11").inOrder()
+ }
+
@Test
fun getLiveStreams_falls_back_to_paged_get_ordered_list_when_all_channels_is_unavailable() = runTest {
val requestedUrls = mutableListOf<String>()
@@ -285,6 +371,60 @@ class OkHttpStalkerApiServiceTest {
)
}
+ @Test
+ fun getSeriesPage_requests_only_requested_page_and_reports_total_pages() = runTest {
+ val requestedUrls = mutableListOf<String>()
+ val service = OkHttpStalkerApiService(
+ okHttpClient = OkHttpClient.Builder()
+ .addInterceptor { chain ->
+ val request = chain.request()
+ requestedUrls += request.url.toString()
+ val page = request.url.queryParameter("p")
+ check(page == "3") { "Unexpected page '$page'" }
+ Response.Builder()
+ .request(request)
+ .protocol(Protocol.HTTP_1_1)
+ .code(200)
+ .message("OK")
+ .body(
+ """
+ {"js":{"total_items":"45","max_page_items":"15","data":[{"id":"300","name":"Drama","category_id":"147"}]}}
+ """.trimIndent().toResponseBody("application/json".toMediaType())
+ )
+ .build()
+ }
+ .build(),
+ json = Json { ignoreUnknownKeys = true }
+ )
+
+ val result = service.getSeriesPage(
+ session = StalkerSession(
+ loadUrl = "https://portal.example.com/server/load.php",
+ portalReferer = "https://portal.example.com/c/",
+ token = "token-123"
+ ),
+ profile = buildStalkerDeviceProfile(
+ portalUrl = "https://portal.example.com/c",
+ macAddress = "00:1A:79:12:34:56",
+ deviceProfile = "MAG250",
+ timezone = "UTC",
+ locale = "en"
+ ),
+ categoryId = "147",
+ page = 3
+ )
+
+ assertThat(result).isInstanceOf(Result.Success::class.java)
+ val success = result as Result.Success
+ assertThat(success.data.items.map { it.name }).containsExactly("Drama")
+ assertThat(success.data.page).isEqualTo(3)
+ assertThat(success.data.totalPages).isEqualTo(3)
+ assertThat(success.data.isComplete).isTrue()
+ assertThat(requestedUrls).containsExactly(
+ "https://portal.example.com/server/load.php?type=series&action=get_ordered_list&JsHttpRequest=1-xml&category=147&p=3"
+ )
+ }
+
@Test
fun getBulkEpg_parses_channel_ids_from_bulk_response_rows() = runTest {
val service = OkHttpStalkerApiService(
@@ -321,6 +461,102 @@ class OkHttpStalkerApiServiceTest {
assertThat(success.data.map { it.title }).containsExactly("Morning News", "Live Sports")
}
+ @Test
+ fun getSeriesDetails_expands_season_shell_rows_into_episode_placeholders() = runTest {
+ val service = OkHttpStalkerApiService(
+ okHttpClient = fakeClient(
+ "get_ordered_list" to """
+ {"js":{"total_items":1,"max_page_items":14,"data":[{"id":"55000:1","name":"Season 1","description":"Doc","series":[1,2,3,4],"cmd":"eyJzZXJpZXNfaWQiOjU1MDAwLCJzZWFzb25fbnVtIjoxLCJ0eXBlIjoic2VyaWVzIn0=","screenshot_uri":"https://img.example.com/season1.jpg"}]}}
+ """.trimIndent()
+ ),
+ json = Json { ignoreUnknownKeys = true }
+ )
+
+ val result = service.getSeriesDetails(
+ session = StalkerSession(
+ loadUrl = "https://portal.example.com/server/load.php",
+ portalReferer = "https://portal.example.com/c/",
+ token = "token-123"
+ ),
+ profile = buildStalkerDeviceProfile(
+ portalUrl = "https://portal.example.com/c",
+ macAddress = "00:1A:79:12:34:56",
+ deviceProfile = "MAG250",
+ timezone = "UTC",
+ locale = "en"
+ ),
+ seriesId = "55000:55000"
+ )
+
+ assertThat(result).isInstanceOf(Result.Success::class.java)
+ val success = result as Result.Success
+ assertThat(success.data.series.name).isEmpty()
+ assertThat(success.data.seasons).hasSize(1)
+ val season = success.data.seasons.single()
+ assertThat(season.seasonNumber).isEqualTo(1)
+ assertThat(season.episodes.map { it.episodeNumber }).containsExactly(1, 2, 3, 4).inOrder()
+ assertThat(season.episodes.first().cmd).isEqualTo("eyJzZXJpZXNfaWQiOjU1MDAwLCJzZWFzb25fbnVtIjoxLCJ0eXBlIjoic2VyaWVzIn0=")
+ }
+
+ @Test
+ fun getSeriesDetails_fetches_shell_season_page_for_explicit_episode_cmds() = runTest {
+ val requestedSeasonIds = mutableListOf<String>()
+ val service = OkHttpStalkerApiService(
+ okHttpClient = OkHttpClient.Builder()
+ .addInterceptor { chain ->
+ val request = chain.request()
+ val action = request.url.queryParameter("action").orEmpty()
+ val seasonId = request.url.queryParameter("season_id").orEmpty()
+ val body = when {
+ action != "get_ordered_list" -> error("Unexpected action '$action'")
+ seasonId == "0" -> """
+ {"js":{"total_items":1,"max_page_items":14,"data":[{"id":"55000:1","name":"Season 1","description":"Doc","series":[1,2,3,4],"cmd":"eyJzZXJpZXNfaWQiOjU1MDAwLCJzZWFzb25fbnVtIjoxLCJ0eXBlIjoic2VyaWVzIn0=","screenshot_uri":"https://img.example.com/season1.jpg"}]}}
+ """.trimIndent()
+ seasonId == "1" -> {
+ requestedSeasonIds += seasonId
+ """
+ {"js":{"total_items":1,"max_page_items":14,"data":[{"id":"episode-1","name":"Episode 1","series_number":"1","season_id":"1","cmd":"ffmpeg http://example.com/episode1.mp4","screenshot_uri":"https://img.example.com/episode1.jpg"}]}}
+ """.trimIndent()
+ }
+ else -> error("Unexpected season_id '$seasonId'")
+ }
+ Response.Builder()
+ .request(request)
+ .protocol(Protocol.HTTP_1_1)
+ .code(200)
+ .message("OK")
+ .body(body.toResponseBody("application/json".toMediaType()))
+ .build()
+ }
+ .build(),
+ json = Json { ignoreUnknownKeys = true }
+ )
+
+ val result = service.getSeriesDetails(
+ session = StalkerSession(
+ loadUrl = "https://portal.example.com/server/load.php",
+ portalReferer = "https://portal.example.com/c/",
+ token = "token-123"
+ ),
+ profile = buildStalkerDeviceProfile(
+ portalUrl = "https://portal.example.com/c",
+ macAddress = "00:1A:79:12:34:56",
+ deviceProfile = "MAG250",
+ timezone = "UTC",
+ locale = "en"
+ ),
+ seriesId = "55000:55000"
+ )
+
+ assertThat(result).isInstanceOf(Result.Success::class.java)
+ val success = result as Result.Success
+ assertThat(requestedSeasonIds).containsExactly("1")
+ assertThat(success.data.seasons).hasSize(1)
+ val season = success.data.seasons.single()
+ assertThat(season.episodes).hasSize(1)
+ assertThat(season.episodes.single().cmd).isEqualTo("ffmpeg http://example.com/episode1.mp4")
+ }
+
private fun fakeClient(vararg responses: Pair<String, String>): OkHttpClient {
val byAction = responses.toMap()
return OkHttpClient.Builder()
@@ -338,4 +574,4 @@ class OkHttpStalkerApiServiceTest {
}
.build()
}
-}
\ No newline at end of file
+}
diff --git a/data/src/test/java/com/streamvault/data/remote/xtream/XtreamStreamUrlResolverTest.kt b/data/src/test/java/com/streamvault/data/remote/xtream/XtreamStreamUrlResolverTest.kt
index 6dbe84e1..8b6925cc 100644
--- a/data/src/test/java/com/streamvault/data/remote/xtream/XtreamStreamUrlResolverTest.kt
+++ b/data/src/test/java/com/streamvault/data/remote/xtream/XtreamStreamUrlResolverTest.kt
@@ -8,6 +8,7 @@ import com.streamvault.data.remote.stalker.StalkerCategoryRecord
import com.streamvault.data.remote.stalker.StalkerDeviceProfile
import com.streamvault.data.remote.stalker.StalkerEpisodeRecord
import com.streamvault.data.remote.stalker.StalkerItemRecord
+import com.streamvault.data.remote.stalker.StalkerPagedItems
import com.streamvault.data.remote.stalker.StalkerProgramRecord
import com.streamvault.data.remote.stalker.StalkerProviderProfile
import com.streamvault.data.remote.stalker.StalkerSeasonRecord
@@ -274,6 +275,44 @@ class XtreamStreamUrlResolverTest {
assertThat(fakeStalkerApiService.createLinkCalls).isEqualTo(0)
}
+ @Test
+ fun resolveWithMetadata_passes_stalker_episode_series_selector_to_create_link() = runBlocking {
+ val fakeStalkerApiService = FakeStalkerApiService().apply {
+ createLinkResponse = "http://portal.example.com/play/movie.php?stream=1672828.mkv"
+ }
+ val resolver = XtreamStreamUrlResolver(
+ providerDao = FakeProviderDao(
+ ProviderEntity(
+ id = 14,
+ name = "Stalker",
+ type = ProviderType.STALKER_PORTAL,
+ serverUrl = "https://portal.example.com",
+ stalkerMacAddress = "00:1A:79:12:34:56",
+ stalkerDeviceProfile = "MAG250",
+ stalkerDeviceTimezone = "UTC",
+ stalkerDeviceLocale = "en"
+ )
+ ),
+ credentialCrypto = credentialCrypto,
+ stalkerApiService = fakeStalkerApiService
+ )
+ val internalUrl = StalkerUrlFactory.buildInternalStreamUrl(
+ providerId = 14,
+ kind = StalkerStreamKind.EPISODE,
+ itemId = 77,
+ cmd = "eyJzZXJpZXNfaWQiOjUzOTk5LCJzZWFzb25fbnVtIjoxLCJ0eXBlIjoic2VyaWVzIn0=",
+ containerExtension = "mkv",
+ seriesNumber = 11
+ )
+
+ val resolved = resolver.resolveWithMetadata(internalUrl)
+
+ assertThat(resolved?.url).isEqualTo("http://portal.example.com/play/movie.php?stream=1672828.mkv")
+ assertThat(fakeStalkerApiService.authenticateCalls).isEqualTo(1)
+ assertThat(fakeStalkerApiService.createLinkCalls).isEqualTo(1)
+ assertThat(fakeStalkerApiService.lastCreateLinkSeriesNumber).isEqualTo(11)
+ }
+
@Test
fun resolveWithMetadata_repairs_stale_direct_stalker_live_url_and_applies_headers() = runBlocking {
val fakeStalkerApiService = FakeStalkerApiService()
@@ -334,6 +373,7 @@ class XtreamStreamUrlResolverTest {
private class FakeStalkerApiService : StalkerApiService {
var authenticateCalls: Int = 0
var createLinkCalls: Int = 0
+ var lastCreateLinkSeriesNumber: Int? = null
var createLinkResponse: String = "http://edge.example.com/live/77.m3u8?exp=1774017000"
override suspend fun authenticate(profile: StalkerDeviceProfile): Result<Pair<StalkerSession, StalkerProviderProfile>> {
@@ -358,6 +398,12 @@ class XtreamStreamUrlResolverTest {
categoryId: String?
): Result<List<StalkerItemRecord>> = Result.success(emptyList())
+ override suspend fun streamLiveStreams(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ onItem: suspend (StalkerItemRecord) -> Unit
+ ): Result<Int> = Result.success(0)
+
override suspend fun getVodCategories(
session: StalkerSession,
profile: StalkerDeviceProfile
@@ -369,6 +415,15 @@ class XtreamStreamUrlResolverTest {
categoryId: String?
): Result<List<StalkerItemRecord>> = Result.success(emptyList())
+ override suspend fun getVodStreamsPage(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ categoryId: String?,
+ page: Int
+ ): Result<StalkerPagedItems> = Result.success(
+ StalkerPagedItems(items = emptyList(), page = page, totalPages = page, pageSize = 0)
+ )
+
override suspend fun getSeriesCategories(
session: StalkerSession,
profile: StalkerDeviceProfile
@@ -380,6 +435,15 @@ class XtreamStreamUrlResolverTest {
categoryId: String?
): Result<List<StalkerItemRecord>> = Result.success(emptyList())
+ override suspend fun getSeriesPage(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ categoryId: String?,
+ page: Int
+ ): Result<StalkerPagedItems> = Result.success(
+ StalkerPagedItems(items = emptyList(), page = page, totalPages = page, pageSize = 0)
+ )
+
override suspend fun getSeriesDetails(
session: StalkerSession,
profile: StalkerDeviceProfile,
@@ -410,13 +474,30 @@ class XtreamStreamUrlResolverTest {
periodHours: Int
): Result<List<StalkerProgramRecord>> = Result.success(emptyList())
+ override suspend fun streamBulkEpg(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ periodHours: Int,
+ onProgram: suspend (StalkerProgramRecord) -> Unit
+ ): Result<Int> = Result.success(0)
+
+ override suspend fun streamEpg(
+ session: StalkerSession,
+ profile: StalkerDeviceProfile,
+ channelId: String,
+ periodHours: Int,
+ onProgram: suspend (StalkerProgramRecord) -> Unit
+ ): Result<Int> = Result.success(0)
+
override suspend fun createLink(
session: StalkerSession,
profile: StalkerDeviceProfile,
kind: StalkerStreamKind,
- cmd: String
+ cmd: String,
+ seriesNumber: Int?
): Result<String> {
createLinkCalls += 1
+ lastCreateLinkSeriesNumber = seriesNumber
return Result.success(createLinkResponse)
}
}
diff --git a/data/src/test/java/com/streamvault/data/repository/ChannelRepositoryImplTest.kt b/data/src/test/java/com/streamvault/data/repository/ChannelRepositoryImplTest.kt
index d5241d25..7474f7fc 100644
--- a/data/src/test/java/com/streamvault/data/repository/ChannelRepositoryImplTest.kt
+++ b/data/src/test/java/com/streamvault/data/repository/ChannelRepositoryImplTest.kt
@@ -144,6 +144,43 @@ class ChannelRepositoryImplTest {
assertThat(result.first().number).isEqualTo(0)
}
+ @Test
+ fun `offset pages keep group numbering relative to full list`() = runTest {
+ whenever(channelDao.getByProviderWithoutErrorsBrowsePageOffset(7L, 60, 60)).thenReturn(
+ listOf(
+ ChannelBrowseEntity(
+ id = 61L,
+ streamId = 161L,
+ name = "Sixty One",
+ streamUrl = "https://stream/61",
+ number = 1,
+ providerId = 7L
+ ),
+ ChannelBrowseEntity(
+ id = 62L,
+ streamId = 162L,
+ name = "Sixty Two",
+ streamUrl = "https://stream/62",
+ number = 2,
+ providerId = 7L
+ )
+ )
+ )
+ whenever(preferencesRepository.liveChannelNumberingMode).thenReturn(flowOf(ChannelNumberingMode.GROUP))
+ whenever(parentalControlManager.unlockedCategoriesForProvider(7L)).thenReturn(flowOf(emptySet()))
+
+ val repository = createRepository()
+
+ val result = repository.getChannelsWithoutErrorsPageOffset(
+ providerId = 7L,
+ categoryId = com.streamvault.domain.repository.ChannelRepository.ALL_CHANNELS_ID,
+ limit = 60,
+ offset = 60
+ )
+
+ assertThat(result.map { it.number }).containsExactly(61, 62).inOrder()
+ }
+
@Test
fun `searchChannels returns empty list when sqlite throws for malformed fts query`() = runTest {
whenever(channelDao.search(eq(7L), any(), any())).thenReturn(
diff --git a/data/src/test/java/com/streamvault/data/repository/EpgRepositoryImplTest.kt b/data/src/test/java/com/streamvault/data/repository/EpgRepositoryImplTest.kt
index f49997a9..5eba01a6 100644
--- a/data/src/test/java/com/streamvault/data/repository/EpgRepositoryImplTest.kt
+++ b/data/src/test/java/com/streamvault/data/repository/EpgRepositoryImplTest.kt
@@ -436,8 +436,9 @@ class EpgRepositoryImplTest {
}
@Test
- fun `refreshEpg keeps staging inserts inside a transaction`() = runTest {
+ fun `refreshEpg stages batches in short transactions outside parser transaction`() = runTest {
val insertTransactionDepths = mutableListOf<Int>()
+ val parserCallbackTransactionDepths = mutableListOf<Int>()
var transactionDepth = 0
var transactionCount = 0
val trackingTransactionRunner = object : DatabaseTransactionRunner {
@@ -459,6 +460,7 @@ class EpgRepositoryImplTest {
val onProgram = invocation.getArgument<suspend (Program) -> Unit>(1)
runBlocking {
repeat(600) { index ->
+ parserCallbackTransactionDepths += transactionDepth
onProgram(
Program(
providerId = 7L,
@@ -485,7 +487,9 @@ class EpgRepositoryImplTest {
val result = repository.refreshEpg(7L, "https://example.com/epg.xml")
assertThat(result.isSuccess).isTrue()
- assertThat(transactionCount).isEqualTo(2)
+ assertThat(transactionCount).isEqualTo(4)
+ assertThat(parserCallbackTransactionDepths).hasSize(600)
+ assertThat(parserCallbackTransactionDepths.all { it == 0 }).isTrue()
assertThat(insertTransactionDepths).isNotEmpty()
assertThat(insertTransactionDepths.all { it > 0 }).isTrue()
}
diff --git a/data/src/test/java/com/streamvault/data/repository/MovieRepositoryImplTest.kt b/data/src/test/java/com/streamvault/data/repository/MovieRepositoryImplTest.kt
index 781217d8..8cfecf5a 100644
--- a/data/src/test/java/com/streamvault/data/repository/MovieRepositoryImplTest.kt
+++ b/data/src/test/java/com/streamvault/data/repository/MovieRepositoryImplTest.kt
@@ -20,6 +20,7 @@ import com.streamvault.data.remote.stalker.StalkerProviderProfile
import com.streamvault.data.remote.stalker.StalkerSession
import com.streamvault.data.remote.stalker.StalkerCategoryRecord
import com.streamvault.data.remote.stalker.StalkerItemRecord
+import com.streamvault.data.remote.stalker.StalkerPagedItems
import com.streamvault.data.remote.dto.XtreamCategory
import com.streamvault.data.remote.dto.XtreamStream
import com.streamvault.data.remote.stalker.StalkerApiService
@@ -271,16 +272,21 @@ class MovieRepositoryImplTest {
whenever(stalkerApiService.getVodCategories(any(), any())).thenReturn(
Result.success(listOf(StalkerCategoryRecord(id = "42", name = "Action")))
)
- whenever(stalkerApiService.getVodStreams(any(), any(), anyOrNull())).thenReturn(
+ whenever(stalkerApiService.getVodStreamsPage(any(), any(), anyOrNull(), eq(1))).thenReturn(
Result.success(
- listOf(
- StalkerItemRecord(
- id = "101",
- name = "Movie",
- categoryId = "42",
- cmd = "ffmpeg http://example.com/movie.mp4",
- containerExtension = "mp4"
- )
+ StalkerPagedItems(
+ items = listOf(
+ StalkerItemRecord(
+ id = "101",
+ name = "Movie",
+ categoryId = "42",
+ cmd = "ffmpeg http://example.com/movie.mp4",
+ containerExtension = "mp4"
+ )
+ ),
+ page = 1,
+ totalPages = 1,
+ pageSize = 1
)
)
)
@@ -289,7 +295,60 @@ class MovieRepositoryImplTest {
repository.getMoviesByCategory(7L, 42L).first()
- verify(movieDao).replaceCategory(eq(7L), eq(42L), any())
+ verify(movieDao).upsertCategoryPage(eq(7L), any())
+ verify(movieDao, never()).replaceCategory(eq(7L), eq(42L), any())
+ }
+
+ @Test
+ fun `stalker movie preview loads only first page`() = runTest {
+ whenever(preferencesRepository.parentalControlLevel).thenReturn(flowOf(0))
+ whenever(movieDao.getCountByCategory(7L, 42L)).thenReturn(flowOf(0), flowOf(18))
+ whenever(movieDao.getByCategoryPreview(7L, 42L, 18)).thenReturn(flowOf(emptyList()))
+ whenever(movieCategoryHydrationDao.get(7L, 42L)).thenReturn(null)
+ whenever(categoryDao.getByProviderAndType(7L, ContentType.MOVIE.name)).thenReturn(
+ flowOf(listOf(com.streamvault.data.local.entity.CategoryEntity(providerId = 7L, categoryId = 42L, name = "Action", type = ContentType.MOVIE)))
+ )
+ whenever(providerDao.getById(7L)).thenReturn(
+ ProviderEntity(
+ id = 7L,
+ name = "Stalker",
+ type = ProviderType.STALKER_PORTAL,
+ serverUrl = "http://example.com",
+ stalkerMacAddress = "00:11:22:33:44:55",
+ status = ProviderStatus.ACTIVE
+ )
+ )
+ whenever(stalkerApiService.authenticate(any())).thenReturn(
+ Result.success(
+ StalkerSession(
+ loadUrl = "http://example.com/stalker_portal/server/load.php",
+ portalReferer = "http://example.com/stalker_portal/c/",
+ token = "token"
+ ) to StalkerProviderProfile(accountName = "Stalker")
+ )
+ )
+ whenever(stalkerApiService.getVodCategories(any(), any())).thenReturn(
+ Result.success(listOf(StalkerCategoryRecord(id = "42", name = "Action")))
+ )
+ whenever(stalkerApiService.getVodStreamsPage(any(), any(), anyOrNull(), eq(1))).thenReturn(
+ Result.success(
+ StalkerPagedItems(
+ items = (1..18).map { index ->
+ StalkerItemRecord(id = "10$index", name = "Movie $index", categoryId = "42")
+ },
+ page = 1,
+ totalPages = 2,
+ pageSize = 50
+ )
+ )
+ )
+
+ val repository = createRepository()
+
+ repository.getCategoryPreviewRows(7L, listOf(42L), 18).first()
+
+ verify(stalkerApiService).getVodStreamsPage(any(), any(), anyOrNull(), eq(1))
+ verify(stalkerApiService, never()).getVodStreamsPage(any(), any(), anyOrNull(), eq(2))
}
@Test
diff --git a/data/src/test/java/com/streamvault/data/repository/SeriesRepositoryImplTest.kt b/data/src/test/java/com/streamvault/data/repository/SeriesRepositoryImplTest.kt
index 4c51c18b..0fdcc0d7 100644
--- a/data/src/test/java/com/streamvault/data/repository/SeriesRepositoryImplTest.kt
+++ b/data/src/test/java/com/streamvault/data/repository/SeriesRepositoryImplTest.kt
@@ -13,8 +13,12 @@ import com.streamvault.data.local.entity.SeriesEntity
import com.streamvault.data.local.entity.ProviderEntity
import com.streamvault.data.preferences.PreferencesRepository
import com.streamvault.data.remote.stalker.StalkerCategoryRecord
+import com.streamvault.data.remote.stalker.StalkerEpisodeRecord
import com.streamvault.data.remote.stalker.StalkerItemRecord
+import com.streamvault.data.remote.stalker.StalkerPagedItems
import com.streamvault.data.remote.stalker.StalkerProviderProfile
+import com.streamvault.data.remote.stalker.StalkerSeasonRecord
+import com.streamvault.data.remote.stalker.StalkerSeriesDetails
import com.streamvault.data.remote.stalker.StalkerSession
import com.streamvault.data.remote.dto.XtreamCategory
import com.streamvault.data.remote.dto.XtreamSeriesItem
@@ -39,6 +43,7 @@ import org.mockito.kotlin.eq
import org.mockito.kotlin.mock
import org.mockito.kotlin.never
import org.mockito.kotlin.verify
+import org.mockito.kotlin.verifyNoInteractions
import org.mockito.kotlin.whenever
class SeriesRepositoryImplTest {
@@ -128,15 +133,20 @@ class SeriesRepositoryImplTest {
whenever(stalkerApiService.getSeriesCategories(any(), any())).thenReturn(
Result.success(listOf(StalkerCategoryRecord(id = "77", name = "Drama")))
)
- whenever(stalkerApiService.getSeries(any(), any(), anyOrNull())).thenReturn(
+ whenever(stalkerApiService.getSeriesPage(any(), any(), anyOrNull(), eq(1))).thenReturn(
Result.success(
- listOf(
- StalkerItemRecord(
- id = "301",
- name = "Series",
- categoryId = "77",
- isSeries = true
- )
+ StalkerPagedItems(
+ items = listOf(
+ StalkerItemRecord(
+ id = "301",
+ name = "Series",
+ categoryId = "77",
+ isSeries = true
+ )
+ ),
+ page = 1,
+ totalPages = 1,
+ pageSize = 1
)
)
)
@@ -148,8 +158,61 @@ class SeriesRepositoryImplTest {
val result = repository.getSeriesByCategory(7L, 77L).first()
assertThat(result).isEmpty()
- verify(seriesDao).replaceCategory(eq(7L), eq(77L), any())
- verify(episodeDao).deleteOrphans()
+ verify(seriesDao).upsertCategoryPage(eq(7L), any())
+ verify(seriesDao, never()).replaceCategory(eq(7L), eq(77L), any())
+ verifyNoInteractions(episodeDao)
+ }
+
+ @Test
+ fun `stalker series preview loads only first page`() = runTest {
+ whenever(preferencesRepository.parentalControlLevel).thenReturn(flowOf(0))
+ whenever(seriesDao.getCountByCategory(7L, 77L)).thenReturn(flowOf(0), flowOf(18))
+ whenever(seriesDao.getByCategoryPreview(7L, 77L, 18)).thenReturn(flowOf(emptyList()))
+ whenever(seriesCategoryHydrationDao.get(7L, 77L)).thenReturn(null)
+ whenever(categoryDao.getByProviderAndType(7L, ContentType.SERIES.name)).thenReturn(
+ flowOf(listOf(com.streamvault.data.local.entity.CategoryEntity(providerId = 7L, categoryId = 77L, name = "Drama", type = ContentType.SERIES)))
+ )
+ whenever(providerDao.getById(7L)).thenReturn(
+ ProviderEntity(
+ id = 7L,
+ name = "Stalker",
+ type = ProviderType.STALKER_PORTAL,
+ serverUrl = "http://example.com",
+ stalkerMacAddress = "00:11:22:33:44:55",
+ status = ProviderStatus.ACTIVE
+ )
+ )
+ whenever(stalkerApiService.authenticate(any())).thenReturn(
+ Result.success(
+ StalkerSession(
+ loadUrl = "http://example.com/stalker_portal/server/load.php",
+ portalReferer = "http://example.com/stalker_portal/c/",
+ token = "token"
+ ) to StalkerProviderProfile(accountName = "Stalker")
+ )
+ )
+ whenever(stalkerApiService.getSeriesCategories(any(), any())).thenReturn(
+ Result.success(listOf(StalkerCategoryRecord(id = "77", name = "Drama")))
+ )
+ whenever(stalkerApiService.getSeriesPage(any(), any(), anyOrNull(), eq(1))).thenReturn(
+ Result.success(
+ StalkerPagedItems(
+ items = (1..18).map { index ->
+ StalkerItemRecord(id = "30$index", name = "Series $index", categoryId = "77", isSeries = true)
+ },
+ page = 1,
+ totalPages = 2,
+ pageSize = 50
+ )
+ )
+ )
+
+ val repository = createRepository()
+
+ repository.getCategoryPreviewRows(7L, listOf(77L), 18).first()
+
+ verify(stalkerApiService).getSeriesPage(any(), any(), anyOrNull(), eq(1))
+ verify(stalkerApiService, never()).getSeriesPage(any(), any(), anyOrNull(), eq(2))
}
@Test
@@ -258,6 +321,70 @@ class SeriesRepositoryImplTest {
assertThat(series.posterUrl).isEqualTo("https://img.example.test/poster.jpg")
}
+ @Test
+ fun `getSeriesDetails uses provider series id for stalker details`() = runTest {
+ val seriesEntity = SeriesEntity(
+ id = 15L,
+ seriesId = 256103980L,
+ providerSeriesId = "55000:55000",
+ name = "Stored Series",
+ providerId = 7L
+ )
+ whenever(seriesDao.getById(15L)).thenReturn(seriesEntity)
+ whenever(providerDao.getById(7L)).thenReturn(
+ ProviderEntity(
+ id = 7L,
+ name = "Stalker",
+ type = ProviderType.STALKER_PORTAL,
+ serverUrl = "http://example.com",
+ stalkerMacAddress = "00:11:22:33:44:55",
+ status = ProviderStatus.ACTIVE
+ )
+ )
+ whenever(stalkerApiService.authenticate(any())).thenReturn(
+ Result.success(
+ StalkerSession(
+ loadUrl = "http://example.com/stalker_portal/server/load.php",
+ portalReferer = "http://example.com/stalker_portal/c/",
+ token = "token"
+ ) to StalkerProviderProfile(accountName = "Stalker")
+ )
+ )
+ whenever(stalkerApiService.getSeriesDetails(any(), any(), eq("55000:55000"))).thenReturn(
+ Result.success(
+ StalkerSeriesDetails(
+ series = StalkerItemRecord(id = "55000:55000", name = "", isSeries = true),
+ seasons = listOf(
+ StalkerSeasonRecord(
+ seasonNumber = 1,
+ name = "Season 1",
+ episodes = listOf(
+ StalkerEpisodeRecord(
+ id = "55000:1:1",
+ title = "Episode 1",
+ episodeNumber = 1,
+ seasonNumber = 1,
+ cmd = "cmd"
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ whenever(episodeDao.getBySeriesSync(15L)).thenReturn(emptyList())
+
+ val repository = createRepository()
+
+ val result = repository.getSeriesDetails(7L, 15L)
+
+ assertThat(result).isInstanceOf(com.streamvault.domain.model.Result.Success::class.java)
+ val series = (result as com.streamvault.domain.model.Result.Success).data
+ assertThat(series.name).isEqualTo("Stored Series")
+ verify(stalkerApiService).getSeriesDetails(any(), any(), eq("55000:55000"))
+ verifyNoInteractions(xtreamApiService)
+ }
+
@Test
fun `searchSeries returns empty list when sqlite throws for malformed fts query`() = runTest {
whenever(preferencesRepository.parentalControlLevel).thenReturn(flowOf(0))
diff --git a/data/src/test/java/com/streamvault/data/sync/SyncManagerTest.kt b/data/src/test/java/com/streamvault/data/sync/SyncManagerTest.kt
index f0ed7105..7fe98235 100644
--- a/data/src/test/java/com/streamvault/data/sync/SyncManagerTest.kt
+++ b/data/src/test/java/com/streamvault/data/sync/SyncManagerTest.kt
@@ -54,6 +54,7 @@ import org.mockito.kotlin.anyOrNull
import org.mockito.kotlin.atLeast
import org.mockito.kotlin.atLeastOnce
import org.mockito.kotlin.argumentCaptor
+import org.mockito.kotlin.doSuspendableAnswer
import org.mockito.kotlin.eq
import org.mockito.kotlin.mock
import org.mockito.kotlin.reset
@@ -230,6 +231,18 @@ class SyncManagerTest {
org.mockito.kotlin.whenever(catalogSyncDao.getChannelStages(any(), any())).thenReturn(emptyList())
org.mockito.kotlin.whenever(catalogSyncDao.getMovieStages(any(), any())).thenReturn(emptyList())
org.mockito.kotlin.whenever(catalogSyncDao.getSeriesStages(any(), any())).thenReturn(emptyList())
+ // Default stubs for the streamed Stalker API methods. The tests in this file
+ // generally don't stress live-stream streaming directly; without these defaults
+ // the unstubbed mock returns null which crashes the `when (val streamResult)`
+ // exhaustiveness check in SyncManager with NoWhenBranchMatchedException.
+ org.mockito.kotlin.whenever(stalkerApiService.streamLiveStreams(any(), any(), any()))
+ .thenReturn(Result.success(0))
+ org.mockito.kotlin.whenever(
+ stalkerApiService.streamBulkEpg(any(), any(), any(), any())
+ ).thenReturn(Result.success(0))
+ org.mockito.kotlin.whenever(
+ stalkerApiService.streamEpg(any(), any(), any(), any(), any())
+ ).thenReturn(Result.success(0))
}
}
@@ -521,15 +534,13 @@ class SyncManagerTest {
org.mockito.kotlin.whenever(stalkerApiService.getLiveCategories(any(), any())).thenReturn(
Result.success(listOf(StalkerCategoryRecord(id = "10", name = "News")))
)
- org.mockito.kotlin.whenever(stalkerApiService.getLiveStreams(any(), any(), anyOrNull())).thenReturn(
- Result.success(
- listOf(
- StalkerItemRecord(
- id = "100",
- name = "News",
- categoryId = "10",
- cmd = "ffmpeg http://example.com/live.ts"
- )
+ stalkerApiService.stubStreamLiveStreams(
+ listOf(
+ StalkerItemRecord(
+ id = "100",
+ name = "News",
+ categoryId = "10",
+ cmd = "ffmpeg http://example.com/live.ts"
)
)
)
@@ -549,9 +560,9 @@ class SyncManagerTest {
assertThat(metadata?.seriesCount).isEqualTo(0)
verify(stalkerApiService).getVodCategories(any(), any())
verify(stalkerApiService).getSeriesCategories(any(), any())
- verify(stalkerApiService).getLiveStreams(any(), any(), anyOrNull())
+ verify(stalkerApiService).streamLiveStreams(any(), any(), any())
verify(stalkerApiService, org.mockito.kotlin.times(0)).getLiveStreams(any(), any(), eq("10"))
- verify(stalkerApiService, org.mockito.kotlin.times(0)).getEpg(any(), any(), any())
+ verify(stalkerApiService, org.mockito.kotlin.times(0)).streamEpg(any(), any(), any(), any(), any())
verify(stalkerApiService, org.mockito.kotlin.times(0)).getVodStreams(any(), any(), anyOrNull())
verify(stalkerApiService, org.mockito.kotlin.times(0)).getSeries(any(), any(), anyOrNull())
}
@@ -579,16 +590,14 @@ class SyncManagerTest {
org.mockito.kotlin.whenever(stalkerApiService.getLiveCategories(any(), any())).thenReturn(
Result.error("Portal returned an empty response for get_genres.")
)
- org.mockito.kotlin.whenever(stalkerApiService.getLiveStreams(any(), any(), anyOrNull())).thenReturn(
- Result.success(
- listOf(
- StalkerItemRecord(
- id = "100",
- name = "News",
- categoryId = "10",
- categoryName = "News",
- cmd = "ffmpeg http://example.com/live.ts"
- )
+ stalkerApiService.stubStreamLiveStreams(
+ listOf(
+ StalkerItemRecord(
+ id = "100",
+ name = "News",
+ categoryId = "10",
+ categoryName = "News",
+ cmd = "ffmpeg http://example.com/live.ts"
)
)
)
@@ -602,7 +611,7 @@ class SyncManagerTest {
verify(catalogSyncDao, atLeastOnce()).insertCategoryStages(categoryStagesCaptor.capture())
assertThat(categoryStagesCaptor.allValues.flatten().any { it.type == com.streamvault.domain.model.ContentType.LIVE && it.name == "News" }).isTrue()
verify(stalkerApiService).getLiveCategories(any(), any())
- verify(stalkerApiService).getLiveStreams(any(), any(), anyOrNull())
+ verify(stalkerApiService).streamLiveStreams(any(), any(), any())
}
@Test
@@ -632,9 +641,7 @@ class SyncManagerTest {
org.mockito.kotlin.whenever(stalkerApiService.getLiveCategories(any(), any())).thenReturn(
Result.error("Portal returned an empty response for get_genres.")
)
- org.mockito.kotlin.whenever(stalkerApiService.getLiveStreams(any(), any(), anyOrNull())).thenReturn(
- Result.error("Portal returned an empty response for get_ordered_list.")
- )
+ stalkerApiService.stubStreamLiveStreamsError("Portal returned an empty response for get_ordered_list.")
val result = manager.sync(providerId = 1L, force = false)
@@ -668,15 +675,13 @@ class SyncManagerTest {
org.mockito.kotlin.whenever(stalkerApiService.getLiveCategories(any(), any())).thenReturn(
Result.success(listOf(StalkerCategoryRecord(id = "10", name = "News")))
)
- org.mockito.kotlin.whenever(stalkerApiService.getLiveStreams(any(), any(), anyOrNull())).thenReturn(
- Result.success(
- listOf(
- StalkerItemRecord(
- id = "100",
- name = "News",
- categoryId = "10",
- cmd = "ffmpeg http://example.com/live.ts"
- )
+ stalkerApiService.stubStreamLiveStreams(
+ listOf(
+ StalkerItemRecord(
+ id = "100",
+ name = "News",
+ categoryId = "10",
+ cmd = "ffmpeg http://example.com/live.ts"
)
)
)
@@ -691,17 +696,16 @@ class SyncManagerTest {
)
)
)
- org.mockito.kotlin.whenever(stalkerApiService.getEpg(any(), any(), eq("100"))).thenReturn(
- Result.success(
- listOf(
- StalkerProgramRecord(
- id = "p1",
- channelId = "100",
- title = "Morning News",
- description = "Top stories",
- startTimeMillis = 1_700_000_000_000L,
- endTimeMillis = 1_700_000_360_000L
- )
+ stalkerApiService.stubStreamEpg(
+ channelId = "100",
+ programs = listOf(
+ StalkerProgramRecord(
+ id = "p1",
+ channelId = "100",
+ title = "Morning News",
+ description = "Top stories",
+ startTimeMillis = 1_700_000_000_000L,
+ endTimeMillis = 1_700_000_360_000L
)
)
)
@@ -717,9 +721,9 @@ class SyncManagerTest {
assertThat(insertedProgramsCaptor.firstValue.first().providerId).isEqualTo(1L)
val metadata = syncMetadataRepo.getMetadata(1L)
assertThat(metadata?.epgCount).isEqualTo(1)
- verify(stalkerApiService).getLiveStreams(any(), any(), anyOrNull())
+ verify(stalkerApiService).streamLiveStreams(any(), any(), any())
verify(stalkerApiService, org.mockito.kotlin.times(0)).getLiveStreams(any(), any(), eq("10"))
- verify(stalkerApiService).getEpg(any(), any(), eq("100"))
+ verify(stalkerApiService).streamEpg(any(), any(), eq("100"), any(), any())
}
@Test
@@ -746,15 +750,13 @@ class SyncManagerTest {
org.mockito.kotlin.whenever(stalkerApiService.getLiveCategories(any(), any())).thenReturn(
Result.success(listOf(StalkerCategoryRecord(id = "10", name = "News")))
)
- org.mockito.kotlin.whenever(stalkerApiService.getLiveStreams(any(), any(), anyOrNull())).thenReturn(
- Result.success(
- listOf(
- StalkerItemRecord(
- id = "100",
- name = "News",
- categoryId = "10",
- cmd = "ffmpeg http://example.com/live.ts"
- )
+ stalkerApiService.stubStreamLiveStreams(
+ listOf(
+ StalkerItemRecord(
+ id = "100",
+ name = "News",
+ categoryId = "10",
+ cmd = "ffmpeg http://example.com/live.ts"
)
)
)
@@ -769,19 +771,18 @@ class SyncManagerTest {
)
)
)
- org.mockito.kotlin.whenever(stalkerApiService.getEpg(any(), any(), eq("100"))).thenReturn(
- Result.success(
- (1..505).map { index ->
- StalkerProgramRecord(
- id = "p$index",
- channelId = "100",
- title = "Program $index",
- description = "Desc $index",
- startTimeMillis = 1_700_000_000_000L + index * 60_000L,
- endTimeMillis = 1_700_000_030_000L + index * 60_000L
- )
- }
- )
+ stalkerApiService.stubStreamEpg(
+ channelId = "100",
+ programs = (1..505).map { index ->
+ StalkerProgramRecord(
+ id = "p$index",
+ channelId = "100",
+ title = "Program $index",
+ description = "Desc $index",
+ startTimeMillis = 1_700_000_000_000L + index * 60_000L,
+ endTimeMillis = 1_700_000_030_000L + index * 60_000L
+ )
+ }
)
org.mockito.kotlin.whenever(programDao.countByProvider(1L)).thenReturn(505)
@@ -823,17 +824,16 @@ class SyncManagerTest {
)
)
)
- org.mockito.kotlin.whenever(stalkerApiService.getEpg(any(), any(), eq("100"))).thenReturn(
- Result.success(
- listOf(
- StalkerProgramRecord(
- id = "p1",
- channelId = "100",
- title = "Morning News",
- description = "Top stories",
- startTimeMillis = 1_700_000_000_000L,
- endTimeMillis = 1_700_000_360_000L
- )
+ stalkerApiService.stubStreamEpg(
+ channelId = "100",
+ programs = listOf(
+ StalkerProgramRecord(
+ id = "p1",
+ channelId = "100",
+ title = "Morning News",
+ description = "Top stories",
+ startTimeMillis = 1_700_000_000_000L,
+ endTimeMillis = 1_700_000_360_000L
)
)
)
@@ -842,7 +842,7 @@ class SyncManagerTest {
val result = manager.retrySection(providerId = 1L, section = SyncRepairSection.EPG)
assertThat(result).isInstanceOf(Result.Success::class.java)
- verify(stalkerApiService).getEpg(any(), any(), eq("100"))
+ verify(stalkerApiService).streamEpg(any(), any(), eq("100"), any(), any())
verify(programDao).insertAll(any())
val metadata = syncMetadataRepo.getMetadata(1L)
assertThat(metadata?.epgCount).isEqualTo(1)
@@ -876,31 +876,29 @@ class SyncManagerTest {
ChannelGuideSyncEntity(streamId = 102L, name = "Sports", epgChannelId = "sports-guide-id")
)
)
- org.mockito.kotlin.whenever(stalkerApiService.getEpg(any(), any(), eq("shared-guide-id"))).thenReturn(
- Result.success(
- listOf(
- StalkerProgramRecord(
- id = "p1",
- channelId = "shared-guide-id",
- title = "Morning News",
- description = "Top stories",
- startTimeMillis = 1_700_000_000_000L,
- endTimeMillis = 1_700_000_360_000L
- )
+ stalkerApiService.stubStreamEpg(
+ channelId = "shared-guide-id",
+ programs = listOf(
+ StalkerProgramRecord(
+ id = "p1",
+ channelId = "shared-guide-id",
+ title = "Morning News",
+ description = "Top stories",
+ startTimeMillis = 1_700_000_000_000L,
+ endTimeMillis = 1_700_000_360_000L
)
)
)
- org.mockito.kotlin.whenever(stalkerApiService.getEpg(any(), any(), eq("sports-guide-id"))).thenReturn(
- Result.success(
- listOf(
- StalkerProgramRecord(
- id = "p2",
- channelId = "sports-guide-id",
- title = "Live Sports",
- description = "Match coverage",
- startTimeMillis = 1_700_000_000_000L,
- endTimeMillis = 1_700_000_360_000L
- )
+ stalkerApiService.stubStreamEpg(
+ channelId = "sports-guide-id",
+ programs = listOf(
+ StalkerProgramRecord(
+ id = "p2",
+ channelId = "sports-guide-id",
+ title = "Live Sports",
+ description = "Match coverage",
+ startTimeMillis = 1_700_000_000_000L,
+ endTimeMillis = 1_700_000_360_000L
)
)
)
@@ -909,8 +907,8 @@ class SyncManagerTest {
val result = manager.retrySection(providerId = 1L, section = SyncRepairSection.EPG)
assertThat(result).isInstanceOf(Result.Success::class.java)
- verify(stalkerApiService, org.mockito.kotlin.times(1)).getEpg(any(), any(), eq("shared-guide-id"))
- verify(stalkerApiService, org.mockito.kotlin.times(1)).getEpg(any(), any(), eq("sports-guide-id"))
+ verify(stalkerApiService, org.mockito.kotlin.times(1)).streamEpg(any(), any(), eq("shared-guide-id"), any(), any())
+ verify(stalkerApiService, org.mockito.kotlin.times(1)).streamEpg(any(), any(), eq("sports-guide-id"), any(), any())
}
@Test
@@ -940,31 +938,28 @@ class SyncManagerTest {
ChannelGuideSyncEntity(streamId = 102L, name = "Sports", epgChannelId = "sports-guide-id")
)
)
- org.mockito.kotlin.whenever(stalkerApiService.getBulkEpg(any(), any(), eq(6))).thenReturn(
- Result.success(
- listOf(
- StalkerProgramRecord(
- id = "p1",
- channelId = "shared-guide-id",
- title = "Morning News",
- description = "Top stories",
- startTimeMillis = 1_700_000_000_000L,
- endTimeMillis = 1_700_000_360_000L
- )
+ stalkerApiService.stubStreamBulkEpg(
+ programs = listOf(
+ StalkerProgramRecord(
+ id = "p1",
+ channelId = "shared-guide-id",
+ title = "Morning News",
+ description = "Top stories",
+ startTimeMillis = 1_700_000_000_000L,
+ endTimeMillis = 1_700_000_360_000L
)
)
)
- org.mockito.kotlin.whenever(stalkerApiService.getEpg(any(), any(), eq("sports-guide-id"))).thenReturn(
- Result.success(
- listOf(
- StalkerProgramRecord(
- id = "p2",
- channelId = "sports-guide-id",
- title = "Live Sports",
- description = "Match coverage",
- startTimeMillis = 1_700_000_000_000L,
- endTimeMillis = 1_700_000_360_000L
- )
+ stalkerApiService.stubStreamEpg(
+ channelId = "sports-guide-id",
+ programs = listOf(
+ StalkerProgramRecord(
+ id = "p2",
+ channelId = "sports-guide-id",
+ title = "Live Sports",
+ description = "Match coverage",
+ startTimeMillis = 1_700_000_000_000L,
+ endTimeMillis = 1_700_000_360_000L
)
)
)
@@ -973,9 +968,9 @@ class SyncManagerTest {
val result = manager.retrySection(providerId = 1L, section = SyncRepairSection.EPG)
assertThat(result).isInstanceOf(Result.Success::class.java)
- verify(stalkerApiService, org.mockito.kotlin.times(1)).getBulkEpg(any(), any(), eq(6))
- verify(stalkerApiService, org.mockito.kotlin.times(0)).getEpg(any(), any(), eq("shared-guide-id"))
- verify(stalkerApiService, org.mockito.kotlin.times(1)).getEpg(any(), any(), eq("sports-guide-id"))
+ verify(stalkerApiService, org.mockito.kotlin.times(1)).streamBulkEpg(any(), any(), eq(6), any())
+ verify(stalkerApiService, org.mockito.kotlin.times(0)).streamEpg(any(), any(), eq("shared-guide-id"), any(), any())
+ verify(stalkerApiService, org.mockito.kotlin.times(1)).streamEpg(any(), any(), eq("sports-guide-id"), any(), any())
}
@Test
@@ -1008,17 +1003,16 @@ class SyncManagerTest {
)
)
)
- org.mockito.kotlin.whenever(stalkerApiService.getEpg(any(), any(), eq("100"))).thenReturn(
- Result.success(
- listOf(
- StalkerProgramRecord(
- id = "p1",
- channelId = "100",
- title = "Morning News",
- description = "Top stories",
- startTimeMillis = 1_700_000_000_000L,
- endTimeMillis = 1_700_000_360_000L
- )
+ stalkerApiService.stubStreamEpg(
+ channelId = "100",
+ programs = listOf(
+ StalkerProgramRecord(
+ id = "p1",
+ channelId = "100",
+ title = "Morning News",
+ description = "Top stories",
+ startTimeMillis = 1_700_000_000_000L,
+ endTimeMillis = 1_700_000_360_000L
)
)
)
@@ -1027,8 +1021,8 @@ class SyncManagerTest {
val result = manager.retrySection(providerId = 1L, section = SyncRepairSection.EPG)
assertThat(result).isInstanceOf(Result.Success::class.java)
- verify(stalkerApiService, org.mockito.kotlin.times(1)).getEpg(any(), any(), eq("100"))
- verify(stalkerApiService, org.mockito.kotlin.times(0)).getEpg(any(), any(), eq("No details available"))
+ verify(stalkerApiService, org.mockito.kotlin.times(1)).streamEpg(any(), any(), eq("100"), any(), any())
+ verify(stalkerApiService, org.mockito.kotlin.times(0)).streamEpg(any(), any(), eq("No details available"), any(), any())
}
@Test
@@ -1333,3 +1327,80 @@ class SyncManagerTest {
catchUp = null, catchUpDays = null, catchUpSource = null, timeshift = null, url = url
)
}
+
+
+/**
+ * Stubs the streaming bulk-EPG path used by [SyncManager.syncStalkerPortalEpg].
+ * The test feeds [programs] through the captured callback and reports the count
+ * back as the [Result.success] payload, mirroring the production [streamBulkEpg]
+ * contract. Use this helper instead of mocking the legacy buffered [getBulkEpg].
+ */
+private suspend fun com.streamvault.data.remote.stalker.StalkerApiService.stubStreamBulkEpg(
+ programs: List<com.streamvault.data.remote.stalker.StalkerProgramRecord>,
+ periodHours: Int = 6
+) {
+ org.mockito.kotlin.whenever(
+ streamBulkEpg(
+ org.mockito.kotlin.any(),
+ org.mockito.kotlin.any(),
+ org.mockito.kotlin.eq(periodHours),
+ org.mockito.kotlin.any()
+ )
+ ).doSuspendableAnswer { invocation ->
+ @Suppress("UNCHECKED_CAST")
+ val cb = invocation.arguments[3] as suspend (com.streamvault.data.remote.stalker.StalkerProgramRecord) -> Unit
+ programs.forEach { cb(it) }
+ com.streamvault.domain.model.Result.success(programs.size)
+ }
+}
+
+/** Stubs the streaming live-channel path. Emits [items] through the captured callback. */
+private suspend fun com.streamvault.data.remote.stalker.StalkerApiService.stubStreamLiveStreams(
+ items: List<com.streamvault.data.remote.stalker.StalkerItemRecord>
+) {
+ org.mockito.kotlin.whenever(
+ streamLiveStreams(
+ org.mockito.kotlin.any(),
+ org.mockito.kotlin.any(),
+ org.mockito.kotlin.any()
+ )
+ ).doSuspendableAnswer { invocation ->
+ @Suppress("UNCHECKED_CAST")
+ val cb = invocation.arguments[2] as suspend (com.streamvault.data.remote.stalker.StalkerItemRecord) -> Unit
+ items.forEach { cb(it) }
+ com.streamvault.domain.model.Result.success(items.size)
+ }
+}
+
+/** Stubs the streaming live-channel path to return an error result without emitting items. */
+private suspend fun com.streamvault.data.remote.stalker.StalkerApiService.stubStreamLiveStreamsError(message: String) {
+ org.mockito.kotlin.whenever(
+ streamLiveStreams(
+ org.mockito.kotlin.any(),
+ org.mockito.kotlin.any(),
+ org.mockito.kotlin.any()
+ )
+ ).doSuspendableAnswer { com.streamvault.domain.model.Result.error(message) }
+}
+
+/** Counterpart to [stubStreamBulkEpg] for the per-channel streamed EPG path. */
+private suspend fun com.streamvault.data.remote.stalker.StalkerApiService.stubStreamEpg(
+ channelId: String,
+ programs: List<com.streamvault.data.remote.stalker.StalkerProgramRecord>,
+ periodHours: Int = 6
+) {
+ org.mockito.kotlin.whenever(
+ streamEpg(
+ org.mockito.kotlin.any(),
+ org.mockito.kotlin.any(),
+ org.mockito.kotlin.eq(channelId),
+ org.mockito.kotlin.eq(periodHours),
+ org.mockito.kotlin.any()
+ )
+ ).doSuspendableAnswer { invocation ->
+ @Suppress("UNCHECKED_CAST")
+ val cb = invocation.arguments[4] as suspend (com.streamvault.data.remote.stalker.StalkerProgramRecord) -> Unit
+ programs.forEach { cb(it) }
+ com.streamvault.domain.model.Result.success(programs.size)
+ }
+}
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 5684e510..f061dd2a 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -1,6 +1,39 @@
# Changelog
All notable product changes are recorded in this document.
+
+## [1.0.9] - 2026-04-25
+
+### Added
+
+#### Player
+- A/V sync offset controls — global and per-channel overrides; accessible from the channel info overlay (live) and player controls overlay (VOD).
+- Compatibility Mode — improved decoder/surface fallback for stalled video playback.
+- Video Surface selection — choose Auto, SurfaceView, or TextureView in Playback settings for device-specific rendering issues.
+- Time format preference (System default, 12-hour, 24-hour) in Settings.
+- Sleep timers — Stop Playback After and Allow Standby After Idle, with presets, countdowns, and warning overlays; defaults saved in Playback settings.
+- Auto-Play Next Episode for series — 10-second **Up Next** countdown with Play Now and Cancel; toggle in Playback settings (on by default).
+
+#### VOD
+- Infinite scroll preference for Movies and Series — auto-load more rows and posters while browsing, or keep a manual Load More button.
+
+### Fixed
+
+- Fixed excessive live TV buffering from 1.0.8 — minimum buffer threshold reduced to 8 seconds (was effectively 30 seconds).
+- Fixed inconsistent AM/PM and 24-hour timestamps — selected time format now applied consistently across Guide, Player overlays, Home, History, Dashboard, and Settings.
+- Fixed EPG guide cutting off at 60 channels per category — additional channels now load automatically on scroll.
+- Fixed a crash when opening Settings → EPG Sources on some devices by making the EPG source and provider list item keys unique.
+- Fixed background EPG sync from stalling Live TV category loading after provider add.
+- Fixed Stalker live sync loading large `get_all_channels` catalogs in a streaming, batched path to avoid out-of-memory crashes.
+- Fixed Stalker live sync when portal category requests fail — the app now stages bulk live channels first and recovers fallback categories instead of leaving Live TV empty.
+- Fixed Stalker native EPG fallback on portals that ignore per-channel `ch_id` requests and keep returning the full bulk guide — sync now detects the broken response shape and stops repeating the large download loop.
+- Fixed modern VOD/series shelves to load on demand in smaller visible batches, with paged Stalker category loading and throttled Xtream category previews.
+- Fixed Stalker series details using local numeric IDs instead of provider-native series IDs, which broke series info loading on portals that use composite IDs.
+- Fixed Stalker series titles being overwritten by season-shell or numeric fallback names when detail payloads omitted the real title.
+- Fixed shell-only Stalker series seasons to follow up with derived `season_id` requests and use explicit episode commands when the portal provides them.
+- Fixed shell-based Stalker episode playback on stricter portals by passing the episode number into `create_link` instead of always using `series=0`.
+
+---
## [1.0.8] - 2026-04-22
### Added
diff --git a/domain/src/main/java/com/streamvault/domain/model/AppTimeFormat.kt b/domain/src/main/java/com/streamvault/domain/model/AppTimeFormat.kt
new file mode 100644
index 00000000..17be07c8
--- /dev/null
+++ b/domain/src/main/java/com/streamvault/domain/model/AppTimeFormat.kt
@@ -0,0 +1,12 @@
+package com.streamvault.domain.model
+
+enum class AppTimeFormat(val storageValue: String) {
+ SYSTEM("system"),
+ TWELVE_HOUR("12h"),
+ TWENTY_FOUR_HOUR("24h");
+
+ companion object {
+ fun fromStorage(value: String?): AppTimeFormat =
+ entries.firstOrNull { it.storageValue == value } ?: SYSTEM
+ }
+}
\ No newline at end of file
diff --git a/domain/src/main/java/com/streamvault/domain/model/ExternalSubtitle.kt b/domain/src/main/java/com/streamvault/domain/model/ExternalSubtitle.kt
new file mode 100644
index 00000000..3a4bc5f3
--- /dev/null
+++ b/domain/src/main/java/com/streamvault/domain/model/ExternalSubtitle.kt
@@ -0,0 +1,14 @@
+package com.streamvault.domain.model
+
+data class ExternalSubtitle(
+ val id: String,
+ val language: String,
+ val displayLanguage: String,
+ val releaseName: String,
+ val source: ExternalSubtitleSource,
+ val downloadId: String = id
+)
+
+enum class ExternalSubtitleSource {
+ OPENSUBTITLES
+}
diff --git a/domain/src/main/java/com/streamvault/domain/model/LibraryBrowseQuery.kt b/domain/src/main/java/com/streamvault/domain/model/LibraryBrowseQuery.kt
index bf5b8c0f..519febdd 100644
--- a/domain/src/main/java/com/streamvault/domain/model/LibraryBrowseQuery.kt
+++ b/domain/src/main/java/com/streamvault/domain/model/LibraryBrowseQuery.kt
@@ -42,7 +42,15 @@ data class PagedResult<T>(
val items: List<T>,
val totalCount: Int,
val offset: Int,
- val limit: Int
+ val limit: Int,
+ /**
+ * True when the repository knows there are more items available remotely
+ * that are not yet reflected in [totalCount]. This is used for partially
+ * cached sources (e.g. paged Stalker categories) so callers can offer
+ * "load more" affordances even when the local cache appears full
+ * relative to its own count.
+ */
+ val hasMoreRemote: Boolean = false
) {
init {
require(totalCount >= 0) { "totalCount must be non-negative" }
@@ -50,7 +58,7 @@ data class PagedResult<T>(
require(limit > 0) { "limit must be positive" }
}
- val hasNextPage: Boolean get() = offset + items.size < totalCount
+ val hasNextPage: Boolean get() = offset + items.size < totalCount || hasMoreRemote
val hasPreviousPage: Boolean get() = offset > 0
val currentPage: Int get() = if (limit > 0) offset / limit else 0
val totalPages: Int get() = if (limit > 0) (totalCount + limit - 1) / limit else 0
diff --git a/domain/src/main/java/com/streamvault/domain/model/PlaybackCompatibilityModels.kt b/domain/src/main/java/com/streamvault/domain/model/PlaybackCompatibilityModels.kt
new file mode 100644
index 00000000..c2bcd0fd
--- /dev/null
+++ b/domain/src/main/java/com/streamvault/domain/model/PlaybackCompatibilityModels.kt
@@ -0,0 +1,25 @@
+package com.streamvault.domain.model
+
+data class PlaybackCompatibilityKey(
+ val deviceFingerprint: String,
+ val deviceModel: String,
+ val androidSdk: Int,
+ val streamType: String,
+ val videoMimeType: String,
+ val resolutionBucket: String,
+ val decoderName: String,
+ val surfaceType: String
+)
+
+data class PlaybackCompatibilityRecord(
+ val key: PlaybackCompatibilityKey,
+ val failureType: String,
+ val lastFailedAt: Long,
+ val lastSucceededAt: Long,
+ val failureCount: Int,
+ val successCount: Int
+) {
+ val isKnownBad: Boolean
+ get() = failureCount >= 2 && lastFailedAt >= lastSucceededAt
+}
+
diff --git a/domain/src/main/java/com/streamvault/domain/model/Series.kt b/domain/src/main/java/com/streamvault/domain/model/Series.kt
index 618bf307..ccce020b 100644
--- a/domain/src/main/java/com/streamvault/domain/model/Series.kt
+++ b/domain/src/main/java/com/streamvault/domain/model/Series.kt
@@ -22,7 +22,8 @@ data class Series(
val lastModified: Long = 0L,
val isAdult: Boolean = false,
val isUserProtected: Boolean = false,
- val seriesId: Long = 0L
+ val seriesId: Long = 0L,
+ val providerSeriesId: String? = null
) {
init {
require(rating in 0f..10f) { "rating must be between 0 and 10" }
diff --git a/domain/src/main/java/com/streamvault/domain/model/StreamInfo.kt b/domain/src/main/java/com/streamvault/domain/model/StreamInfo.kt
index 50b28d83..a2c179d5 100644
--- a/domain/src/main/java/com/streamvault/domain/model/StreamInfo.kt
+++ b/domain/src/main/java/com/streamvault/domain/model/StreamInfo.kt
@@ -65,5 +65,12 @@ enum class StreamType {
enum class DecoderMode {
AUTO,
HARDWARE,
- SOFTWARE
+ SOFTWARE,
+ COMPATIBILITY
+}
+
+enum class PlayerSurfaceMode {
+ AUTO,
+ SURFACE_VIEW,
+ TEXTURE_VIEW
}
diff --git a/domain/src/main/java/com/streamvault/domain/repository/ChannelRepository.kt b/domain/src/main/java/com/streamvault/domain/repository/ChannelRepository.kt
index 13351cdb..c6473f28 100644
--- a/domain/src/main/java/com/streamvault/domain/repository/ChannelRepository.kt
+++ b/domain/src/main/java/com/streamvault/domain/repository/ChannelRepository.kt
@@ -8,11 +8,14 @@ import kotlinx.coroutines.flow.Flow
interface ChannelRepository {
fun getChannels(providerId: Long): Flow<List<Channel>>
+ fun getChannelCount(providerId: Long): Flow<Int>
fun getChannelsByCategory(providerId: Long, categoryId: Long): Flow<List<Channel>>
fun getChannelsByCategoryPage(providerId: Long, categoryId: Long, limit: Int): Flow<List<Channel>>
fun getChannelsByNumber(providerId: Long, categoryId: Long = ALL_CHANNELS_ID): Flow<List<Channel>>
fun getChannelsWithoutErrors(providerId: Long, categoryId: Long = ALL_CHANNELS_ID): Flow<List<Channel>>
fun getChannelsWithoutErrorsPage(providerId: Long, categoryId: Long = ALL_CHANNELS_ID, limit: Int): Flow<List<Channel>>
+ suspend fun getChannelsByCategoryPageOffset(providerId: Long, categoryId: Long, limit: Int, offset: Int): List<Channel>
+ suspend fun getChannelsWithoutErrorsPageOffset(providerId: Long, categoryId: Long, limit: Int, offset: Int): List<Channel>
fun searchChannelsByCategory(providerId: Long, categoryId: Long, query: String): Flow<List<Channel>>
fun searchChannelsByCategoryPaged(providerId: Long, categoryId: Long, query: String, limit: Int): Flow<List<Channel>>
fun getCategories(providerId: Long): Flow<List<Category>>
diff --git a/domain/src/main/java/com/streamvault/domain/repository/ExternalSubtitleRepository.kt b/domain/src/main/java/com/streamvault/domain/repository/ExternalSubtitleRepository.kt
new file mode 100644
index 00000000..6a9b1887
--- /dev/null
+++ b/domain/src/main/java/com/streamvault/domain/repository/ExternalSubtitleRepository.kt
@@ -0,0 +1,21 @@
+package com.streamvault.domain.repository
+
+import com.streamvault.domain.model.ContentType
+import com.streamvault.domain.model.ExternalSubtitle
+import java.io.File
+
+interface ExternalSubtitleRepository {
+
+ suspend fun search(
+ contentType: ContentType,
+ title: String,
+ year: Int?,
+ tmdbId: Long?,
+ parentTmdbId: Long?,
+ seasonNumber: Int?,
+ episodeNumber: Int?,
+ language: String
+ ): Result<List<ExternalSubtitle>>
+
+ suspend fun downloadToCache(subtitle: ExternalSubtitle): Result<File>
+}
diff --git a/domain/src/main/java/com/streamvault/domain/repository/PlaybackCompatibilityRepository.kt b/domain/src/main/java/com/streamvault/domain/repository/PlaybackCompatibilityRepository.kt
new file mode 100644
index 00000000..9d35697c
--- /dev/null
+++ b/domain/src/main/java/com/streamvault/domain/repository/PlaybackCompatibilityRepository.kt
@@ -0,0 +1,24 @@
+package com.streamvault.domain.repository
+
+import com.streamvault.domain.model.PlaybackCompatibilityKey
+import com.streamvault.domain.model.PlaybackCompatibilityRecord
+
+interface PlaybackCompatibilityRepository {
+ suspend fun getKnownBadRecords(
+ deviceFingerprint: String,
+ streamType: String,
+ videoMimeType: String,
+ resolutionBucket: String
+ ): List<PlaybackCompatibilityRecord>
+
+ suspend fun recordFailure(key: PlaybackCompatibilityKey, failureType: String, at: Long = System.currentTimeMillis())
+
+ suspend fun recordSuccess(key: PlaybackCompatibilityKey, at: Long = System.currentTimeMillis())
+
+ suspend fun prune(maxRecords: Int = 250, olderThanMs: Long = System.currentTimeMillis() - DEFAULT_RETENTION_MS)
+
+ companion object {
+ const val DEFAULT_RETENTION_MS: Long = 90L * 24L * 60L * 60L * 1000L
+ }
+}
+
diff --git a/domain/src/main/java/com/streamvault/domain/usecase/SearchExternalSubtitles.kt b/domain/src/main/java/com/streamvault/domain/usecase/SearchExternalSubtitles.kt
new file mode 100644
index 00000000..5e122a15
--- /dev/null
+++ b/domain/src/main/java/com/streamvault/domain/usecase/SearchExternalSubtitles.kt
@@ -0,0 +1,30 @@
+package com.streamvault.domain.usecase
+
+import com.streamvault.domain.model.ContentType
+import com.streamvault.domain.model.ExternalSubtitle
+import com.streamvault.domain.repository.ExternalSubtitleRepository
+import javax.inject.Inject
+
+class SearchExternalSubtitles @Inject constructor(
+ private val repository: ExternalSubtitleRepository
+) {
+ suspend operator fun invoke(
+ contentType: ContentType,
+ title: String,
+ year: Int?,
+ tmdbId: Long?,
+ parentTmdbId: Long?,
+ seasonNumber: Int?,
+ episodeNumber: Int?,
+ language: String
+ ): Result<List<ExternalSubtitle>> = repository.search(
+ contentType = contentType,
+ title = title,
+ year = year,
+ tmdbId = tmdbId,
+ parentTmdbId = parentTmdbId,
+ seasonNumber = seasonNumber,
+ episodeNumber = episodeNumber,
+ language = language
+ )
+}
diff --git a/domain/src/test/java/com/streamvault/domain/usecase/SearchContentTest.kt b/domain/src/test/java/com/streamvault/domain/usecase/SearchContentTest.kt
index 84bd26bf..e2210c24 100644
--- a/domain/src/test/java/com/streamvault/domain/usecase/SearchContentTest.kt
+++ b/domain/src/test/java/com/streamvault/domain/usecase/SearchContentTest.kt
@@ -118,11 +118,14 @@ private class FakeChannelRepository(
) : ChannelRepository {
override fun searchChannels(providerId: Long, query: String): Flow<List<Channel>> = searchFlow ?: flowOf(searchResults)
override fun getChannels(providerId: Long): Flow<List<Channel>> = unsupported()
+ override fun getChannelCount(providerId: Long): Flow<Int> = unsupported()
override fun getChannelsByCategory(providerId: Long, categoryId: Long): Flow<List<Channel>> = unsupported()
override fun getChannelsByCategoryPage(providerId: Long, categoryId: Long, limit: Int): Flow<List<Channel>> = unsupported()
override fun getChannelsByNumber(providerId: Long, categoryId: Long): Flow<List<Channel>> = unsupported()
override fun getChannelsWithoutErrors(providerId: Long, categoryId: Long): Flow<List<Channel>> = unsupported()
override fun getChannelsWithoutErrorsPage(providerId: Long, categoryId: Long, limit: Int): Flow<List<Channel>> = unsupported()
+ override suspend fun getChannelsByCategoryPageOffset(providerId: Long, categoryId: Long, limit: Int, offset: Int): List<Channel> = error("Not used in test")
+ override suspend fun getChannelsWithoutErrorsPageOffset(providerId: Long, categoryId: Long, limit: Int, offset: Int): List<Channel> = error("Not used in test")
override fun searchChannelsByCategory(providerId: Long, categoryId: Long, query: String): Flow<List<Channel>> = unsupported()
override fun searchChannelsByCategoryPaged(providerId: Long, categoryId: Long, query: String, limit: Int): Flow<List<Channel>> = unsupported()
override fun getCategories(providerId: Long): Flow<List<Category>> = unsupported()
diff --git a/player/src/main/java/com/streamvault/player/Media3PlayerEngine.kt b/player/src/main/java/com/streamvault/player/Media3PlayerEngine.kt
index be719629..16d3de49 100644
--- a/player/src/main/java/com/streamvault/player/Media3PlayerEngine.kt
+++ b/player/src/main/java/com/streamvault/player/Media3PlayerEngine.kt
@@ -1,6 +1,7 @@
package com.streamvault.player
import android.content.Context
+import android.os.Build
import android.os.Handler
import android.util.Log
import androidx.annotation.MainThread
@@ -20,17 +21,25 @@ import androidx.media3.exoplayer.ExoPlayer
import androidx.media3.exoplayer.Renderer
import androidx.media3.exoplayer.ScrubbingModeParameters
import androidx.media3.exoplayer.analytics.AnalyticsListener
+import androidx.media3.exoplayer.audio.AudioSink
import androidx.media3.exoplayer.mediacodec.MediaCodecInfo
import androidx.media3.exoplayer.mediacodec.MediaCodecSelector
import androidx.media3.exoplayer.video.MediaCodecVideoRenderer
+import androidx.media3.exoplayer.video.VideoFrameMetadataListener
import androidx.media3.exoplayer.video.VideoRendererEventListener
import androidx.media3.session.MediaSession
import com.streamvault.domain.model.DecoderMode
+import com.streamvault.domain.model.PlaybackCompatibilityKey
+import com.streamvault.domain.model.PlayerSurfaceMode
import com.streamvault.domain.model.StreamInfo
import com.streamvault.domain.model.VideoFormat
+import com.streamvault.domain.repository.PlaybackCompatibilityRepository
import com.streamvault.player.audio.PlayerAudioFocusController
+import com.streamvault.player.playback.ActiveDecoderPolicy
import com.streamvault.player.playback.DefaultDecoderPreferencePolicy
import com.streamvault.player.playback.DefaultPlaybackCompatibilityProfile
+import com.streamvault.player.playback.AudioVideoOffsetAudioSink
+import com.streamvault.player.playback.PlaybackCodecSelector
import com.streamvault.player.playback.PlaybackCompatibilityProfile
import com.streamvault.player.playback.PlaybackErrorCategory
import com.streamvault.player.playback.PlaybackLogSanitizer
@@ -43,6 +52,7 @@ import com.streamvault.player.playback.PlayerTimeoutProfile
import com.streamvault.player.playback.PreloadCoordinator
import com.streamvault.player.playback.ResolvedStreamType
import com.streamvault.player.playback.StreamTypeResolver
+import com.streamvault.player.playback.VideoStallDetector
import com.streamvault.player.stats.PlayerStatsCollector
import com.streamvault.player.timeshift.DefaultLiveTimeshiftManager
import com.streamvault.player.timeshift.LiveTimeshiftBackend
@@ -54,6 +64,7 @@ import com.streamvault.player.ui.PlayerViewBinder
import com.streamvault.player.ui.SubtitleStyleController
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
+import java.util.concurrent.atomic.AtomicLong
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
@@ -73,12 +84,15 @@ import okhttp3.OkHttpClient
@OptIn(UnstableApi::class)
class Media3PlayerEngine @Inject constructor(
@param:ApplicationContext private val context: Context,
- private val okHttpClient: OkHttpClient
+ private val okHttpClient: OkHttpClient,
+ private val playbackCompatibilityRepository: PlaybackCompatibilityRepository
) : PlayerEngine {
companion object {
private const val TAG = "Media3PlayerEngine"
private const val AUDIO_RENDERER_RECOVERY_COOLDOWN_MS = 15_000L
+ private const val MEDIA_SESSION_ID_PREFIX = "streamvault"
+ private val nextMediaSessionInstanceId = AtomicLong(1L)
}
var constrainResolutionForMultiView: Boolean = false
@@ -87,7 +101,7 @@ class Media3PlayerEngine @Inject constructor(
field = value
audioFocusController.bypassAudioFocus = value
}
- var mediaSessionId: String = "streamvault-main"
+ var mediaSessionId: String = "$MEDIA_SESSION_ID_PREFIX-${nextMediaSessionInstanceId.getAndIncrement()}"
var enableMediaSession: Boolean = true
set(value) {
if (field == value) return
@@ -118,6 +132,13 @@ class Media3PlayerEngine @Inject constructor(
private var mediaSession: MediaSession? = null
private var requestedDecoderMode: DecoderMode = DecoderMode.AUTO
private var activeDecoderMode: DecoderMode = DecoderMode.HARDWARE
+ private var requestedSurfaceMode: PlayerSurfaceMode = PlayerSurfaceMode.AUTO
+ private var activeDecoderPolicy: ActiveDecoderPolicy = ActiveDecoderPolicy.AUTO
+ private var recoveryDecoderPolicyOverride: ActiveDecoderPolicy? = null
+ private var knownBadDecoderNames: Set<String> = emptySet()
+ private var selectedVideoDecoderName: String = "Unknown"
+ private var videoStallCount = 0
+ private var videoStallRecoveryAttempt = 0
private var lastStreamInfo: StreamInfo? = null
private var lastMediaId: String? = null
private var currentResolvedStreamType: ResolvedStreamType = ResolvedStreamType.UNKNOWN
@@ -156,6 +177,13 @@ class Media3PlayerEngine @Inject constructor(
private val _playbackSpeed = MutableStateFlow(1f)
override val playbackSpeed: StateFlow<Float> = _playbackSpeed.asStateFlow()
+ private val audioVideoOffsetUs = AtomicLong(0L)
+ private val _audioVideoOffsetMs = MutableStateFlow(0)
+ override val audioVideoOffsetMs: StateFlow<Int> = _audioVideoOffsetMs.asStateFlow()
+
+ private val _renderSurfaceType = MutableStateFlow(PlayerRenderSurfaceType.SURFACE_VIEW)
+ override val renderSurfaceType: StateFlow<PlayerRenderSurfaceType> = _renderSurfaceType.asStateFlow()
+
private val liveTimeshiftManager = DefaultLiveTimeshiftManager(context, okHttpClient)
private val _timeshiftState = MutableStateFlow(LiveTimeshiftState())
override val timeshiftState: StateFlow<LiveTimeshiftState> = _timeshiftState.asStateFlow()
@@ -201,6 +229,7 @@ class Media3PlayerEngine @Inject constructor(
private val preloadCoordinator = PreloadCoordinator()
private val compatibilityProfile: PlaybackCompatibilityProfile = DefaultPlaybackCompatibilityProfile
private val decoderPreferencePolicy = DefaultDecoderPreferencePolicy()
+ private val videoStallDetector = VideoStallDetector()
// All reads/writes on Dispatchers.Main.immediate (engine scope).
@get:MainThread private var activeLiveTimeshiftStreamInfo: StreamInfo? = null
@get:MainThread private var activeLiveTimeshiftChannelKey: String? = null
@@ -211,11 +240,35 @@ class Media3PlayerEngine @Inject constructor(
private var lastAudioRendererRecoveryAtMs: Long = 0L
init {
+ startEngineCollectors()
+ }
+
+ private fun startEngineCollectors() {
scope.launch {
liveTimeshiftManager.state.collectLatest {
syncTimeshiftState()
}
}
+ scope.launch {
+ while (true) {
+ delay(1_000L)
+ val stats = _playerStats.value
+ val stalled = videoStallDetector.shouldReportStall(
+ playbackState = _playbackState.value,
+ isPlaying = _isPlaying.value,
+ currentPositionMs = _currentPosition.value,
+ bufferedDurationMs = stats.bufferedDurationMs
+ )
+ _playerStats.value = _playerStats.value.copy(
+ lastVideoFrameAgoMs = videoStallDetector.lastVideoFrameAgoMs(),
+ videoStallCount = videoStallCount,
+ videoDecoderName = selectedVideoDecoderName,
+ activeDecoderPolicy = activeDecoderPolicy.name,
+ renderSurfaceType = _renderSurfaceType.value.name
+ )
+ if (stalled) handleVideoStall()
+ }
+ }
}
override fun prepare(streamInfo: StreamInfo) {
@@ -323,6 +376,17 @@ class Media3PlayerEngine @Inject constructor(
}
}
+ override fun setSurfaceMode(mode: PlayerSurfaceMode) {
+ if (requestedSurfaceMode == mode) return
+ requestedSurfaceMode = mode
+ updateRenderSurfaceForMode()
+ lastStreamInfo?.let { streamInfo ->
+ val wasPlaying = exoPlayer?.playWhenReady == true
+ val position = exoPlayer?.currentPosition
+ prepareInternal(streamInfo, preserveRetryState = false, seekPositionMs = position, autoPlay = wasPlaying)
+ }
+ }
+
override fun setMediaSessionEnabled(enabled: Boolean) {
enableMediaSession = enabled
}
@@ -341,6 +405,12 @@ class Media3PlayerEngine @Inject constructor(
exoPlayer?.playbackParameters = PlaybackParameters(clamped)
}
+ override fun setAudioVideoOffsetMs(offsetMs: Int) {
+ val clamped = offsetMs.coerceIn(AUDIO_VIDEO_OFFSET_MIN_MS, AUDIO_VIDEO_OFFSET_MAX_MS)
+ _audioVideoOffsetMs.value = clamped
+ audioVideoOffsetUs.set(clamped * 1_000L)
+ }
+
@MainThread
override fun startLiveTimeshift(streamInfo: StreamInfo, channelKey: String, config: TimeshiftConfig) {
activeLiveTimeshiftStreamInfo = streamInfo
@@ -437,6 +507,35 @@ class Media3PlayerEngine @Inject constructor(
exoPlayer?.let { trackController.selectSubtitleTrack(it, trackId) }
}
+ override fun addExternalSubtitle(subtitleUri: android.net.Uri, language: String) {
+ val player = exoPlayer ?: return
+ val streamInfo = lastStreamInfo ?: return
+ val retryPolicy = currentRetryPolicy ?: return
+ val position = player.currentPosition
+ val wasPlaying = player.playWhenReady
+
+ val (_, mainMediaSource) = mediaSourceFactory.create(
+ streamInfo = streamInfo,
+ resolvedStreamType = currentResolvedStreamType,
+ retryPolicy = retryPolicy,
+ preload = false
+ )
+ val subtitleConfig = androidx.media3.common.MediaItem.SubtitleConfiguration.Builder(subtitleUri)
+ .setMimeType(androidx.media3.common.MimeTypes.APPLICATION_SUBRIP)
+ .setLanguage(language)
+ .setSelectionFlags(C.SELECTION_FLAG_DEFAULT)
+ .build()
+ val subtitleSource = androidx.media3.exoplayer.source.SingleSampleMediaSource.Factory(
+ androidx.media3.datasource.DefaultDataSource.Factory(context)
+ ).createMediaSource(subtitleConfig, C.TIME_UNSET)
+ val merged = androidx.media3.exoplayer.source.MergingMediaSource(mainMediaSource, subtitleSource)
+
+ player.setMediaSource(merged, position)
+ player.prepare()
+ player.playWhenReady = wasPlaying
+ Log.i(TAG, "addExternalSubtitle language=$language uri=$subtitleUri")
+ }
+
override fun toggleMute() {
audioFocusController.toggleMute()
}
@@ -515,6 +614,12 @@ class Media3PlayerEngine @Inject constructor(
_mediaTitle.value = null
trackController.resetSelections()
statsCollector.reset()
+ videoStallDetector.reset()
+ selectedVideoDecoderName = "Unknown"
+ videoStallCount = 0
+ videoStallRecoveryAttempt = 0
+ recoveryDecoderPolicyOverride = null
+ knownBadDecoderNames = emptySet()
activeLiveTimeshiftStreamInfo = null
activeLiveTimeshiftChannelKey = null
isPlayingTimeshiftSnapshot = false
@@ -522,12 +627,7 @@ class Media3PlayerEngine @Inject constructor(
scope.cancel()
// Replace with a fresh scope so the singleton engine remains functional on re-entry.
scope = CoroutineScope(Dispatchers.Main.immediate + SupervisorJob())
- // Re-launch the timeshift state collector on the new scope.
- scope.launch {
- liveTimeshiftManager.state.collectLatest {
- syncTimeshiftState()
- }
- }
+ startEngineCollectors()
// File cleanup runs outside the engine scope — orphans are also cleaned on next app start
CoroutineScope(Dispatchers.IO).launch { liveTimeshiftManager.stopSession() }
}
@@ -558,17 +658,30 @@ class Media3PlayerEngine @Inject constructor(
_mediaTitle.value = null
trackController.resetSelections()
statsCollector.reset()
+ videoStallDetector.reset()
+ if (!preserveRetryState) {
+ videoStallRecoveryAttempt = 0
+ }
+ selectedVideoDecoderName = "Unknown"
currentResolvedStreamType = StreamTypeResolver.resolve(streamInfo)
currentTimeoutProfile = PlayerTimeoutProfile.resolve(streamInfo, currentResolvedStreamType, preload = false)
currentRetryContext = PlaybackRetryContext(currentResolvedStreamType, currentTimeoutProfile)
currentRetryPolicy = PlayerRetryPolicy(currentRetryContext!!) { playbackStarted }
+ if (!preserveRetryState) {
+ recoveryDecoderPolicyOverride = null
+ }
+ activeDecoderPolicy = recoveryDecoderPolicyOverride ?: resolveActiveDecoderPolicy(requestedDecoderMode)
+ updateRenderSurfaceForMode()
+ refreshKnownBadCompatibilityRecords()
val preferredDecoderMode = decoderPreferencePolicy.preferredMode(requestedDecoderMode, mediaId)
val isLiveBuffer = currentResolvedStreamType in setOf(
ResolvedStreamType.HLS, ResolvedStreamType.MPEG_TS_LIVE, ResolvedStreamType.RTSP
)
- val needsRecreate = activeDecoderMode != preferredDecoderMode || isLiveBuffer != currentBufferIsLive
+ val needsRecreate = activeDecoderMode != preferredDecoderMode ||
+ isLiveBuffer != currentBufferIsLive ||
+ requestedDecoderMode == DecoderMode.COMPATIBILITY
activeDecoderMode = preferredDecoderMode
currentBufferIsLive = isLiveBuffer
if (needsRecreate) {
@@ -577,11 +690,17 @@ class Media3PlayerEngine @Inject constructor(
Log.i(
TAG,
- "prepare resolvedStreamType=$currentResolvedStreamType timeoutProfile=$currentTimeoutProfile decoderPreference=$activeDecoderMode target=${PlaybackLogSanitizer.sanitizeUrl(streamInfo.url)}"
+ "prepare resolvedStreamType=$currentResolvedStreamType timeoutProfile=$currentTimeoutProfile decoderPreference=$activeDecoderMode activePolicy=$activeDecoderPolicy surface=${_renderSurfaceType.value} target=${PlaybackLogSanitizer.sanitizeUrl(streamInfo.url)}"
)
val player = getOrCreatePlayer()
trackController.applyInitialParameters(player, constrainResolutionForMultiView)
+ if (activeDecoderPolicy == ActiveDecoderPolicy.COMPATIBILITY) {
+ player.trackSelectionParameters = player.trackSelectionParameters
+ .buildUpon()
+ .setMaxVideoSize(Int.MAX_VALUE, 720)
+ .build()
+ }
player.playbackParameters = PlaybackParameters(_playbackSpeed.value)
val mediaSource = preloadCoordinator.tryReuse(mediaId, streamInfo, currentResolvedStreamType)
@@ -645,13 +764,23 @@ class Media3PlayerEngine @Inject constructor(
private fun createPlayer(): ExoPlayer {
val renderersFactory = buildRenderersFactory()
- val maxBufferMs = if (currentBufferIsLive == true) 30_000 else 120_000
+ val compatibilityMode = activeDecoderPolicy == ActiveDecoderPolicy.COMPATIBILITY
+ val minBufferMs = when {
+ compatibilityMode && currentBufferIsLive == true -> 15_000
+ currentBufferIsLive == true -> 8_000
+ else -> 50_000
+ }
+ val maxBufferMs = when {
+ compatibilityMode && currentBufferIsLive == true -> 45_000
+ currentBufferIsLive == true -> 30_000
+ else -> 120_000
+ }
val loadControl = DefaultLoadControl.Builder()
.setBufferDurationsMs(
- 30_000,
+ minBufferMs,
maxBufferMs,
- 2_500,
- 10_000
+ 1_500,
+ 5_000
)
.setPrioritizeTimeOverSizeThresholds(true)
.build()
@@ -676,59 +805,92 @@ class Media3PlayerEngine @Inject constructor(
.apply {
videoScalingMode = C.VIDEO_SCALING_MODE_SCALE_TO_FIT
playbackParameters = PlaybackParameters(_playbackSpeed.value)
+ setVideoFrameMetadataListener(VideoFrameMetadataListener { _, _, _, _ ->
+ videoStallDetector.onVideoFrameRendered()
+ })
addAnalyticsListener(createAnalyticsListener())
addListener(createPlayerListener())
}
}
private fun buildRenderersFactory(): DefaultRenderersFactory {
- val baseFactory = if (compatibilityProfile.shouldDisableDecoderReuseWorkaround()) {
- object : DefaultRenderersFactory(context) {
- override fun buildVideoRenderers(
- context: Context,
- extensionRendererMode: Int,
- mediaCodecSelector: MediaCodecSelector,
- enableDecoderFallback: Boolean,
- eventHandler: Handler,
- eventListener: VideoRendererEventListener,
- allowedVideoJoiningTimeMs: Long,
- out: ArrayList<Renderer>
+ return object : DefaultRenderersFactory(context) {
+ override fun buildAudioSink(
+ context: Context,
+ enableFloatOutput: Boolean,
+ enableAudioTrackPlaybackParams: Boolean
+ ): AudioSink {
+ val audioSink = requireNotNull(
+ super.buildAudioSink(context, enableFloatOutput, enableAudioTrackPlaybackParams)
) {
- out.add(object : MediaCodecVideoRenderer(
+ "DefaultRenderersFactory did not provide an AudioSink."
+ }
+ return AudioVideoOffsetAudioSink(
+ delegate = audioSink,
+ offsetUsProvider = { audioVideoOffsetUs.get() }
+ )
+ }
+
+ override fun buildVideoRenderers(
+ context: Context,
+ extensionRendererMode: Int,
+ mediaCodecSelector: MediaCodecSelector,
+ enableDecoderFallback: Boolean,
+ eventHandler: Handler,
+ eventListener: VideoRendererEventListener,
+ allowedVideoJoiningTimeMs: Long,
+ out: ArrayList<Renderer>
+ ) {
+ if (!compatibilityProfile.shouldDisableDecoderReuseWorkaround()) {
+ super.buildVideoRenderers(
context,
+ extensionRendererMode,
mediaCodecSelector,
- allowedVideoJoiningTimeMs,
enableDecoderFallback,
eventHandler,
eventListener,
- 50
- ) {
- override fun canReuseCodec(
- codecInfo: MediaCodecInfo,
- oldFormat: Format,
- newFormat: Format
- ): DecoderReuseEvaluation {
- return DecoderReuseEvaluation(
- codecInfo.name,
- oldFormat,
- newFormat,
- DecoderReuseEvaluation.REUSE_RESULT_NO,
- DecoderReuseEvaluation.DISCARD_REASON_MAX_INPUT_SIZE_EXCEEDED
- )
- }
- })
+ allowedVideoJoiningTimeMs,
+ out
+ )
+ return
}
- }
- } else {
- DefaultRenderersFactory(context)
- }
- return baseFactory.apply {
+ out.add(object : MediaCodecVideoRenderer(
+ context,
+ mediaCodecSelector,
+ allowedVideoJoiningTimeMs,
+ enableDecoderFallback,
+ eventHandler,
+ eventListener,
+ 50
+ ) {
+ override fun canReuseCodec(
+ codecInfo: MediaCodecInfo,
+ oldFormat: Format,
+ newFormat: Format
+ ): DecoderReuseEvaluation {
+ return DecoderReuseEvaluation(
+ codecInfo.name,
+ oldFormat,
+ newFormat,
+ DecoderReuseEvaluation.REUSE_RESULT_NO,
+ DecoderReuseEvaluation.DISCARD_REASON_MAX_INPUT_SIZE_EXCEEDED
+ )
+ }
+ })
+ }
+ }.apply {
setEnableDecoderFallback(true)
+ setMediaCodecSelector(
+ PlaybackCodecSelector(
+ policyProvider = { activeDecoderPolicy },
+ knownBadProvider = { knownBadDecoderNames }
+ )
+ )
setExtensionRendererMode(
when (activeDecoderMode) {
DecoderMode.AUTO, DecoderMode.HARDWARE -> DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON
- DecoderMode.SOFTWARE -> DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER
+ DecoderMode.SOFTWARE, DecoderMode.COMPATIBILITY -> DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER
}
)
}
@@ -742,6 +904,18 @@ class Media3PlayerEngine @Inject constructor(
decoderReuseEvaluation: DecoderReuseEvaluation?
) {
statsCollector.onVideoFormatChanged(format)
+ refreshKnownBadCompatibilityRecords()
+ }
+
+ override fun onVideoDecoderInitialized(
+ eventTime: AnalyticsListener.EventTime,
+ decoderName: String,
+ initializedTimestampMs: Long,
+ initializationDurationMs: Long
+ ) {
+ selectedVideoDecoderName = decoderName
+ _playerStats.value = _playerStats.value.copy(videoDecoderName = decoderName)
+ Log.i(TAG, "video-decoder name=$decoderName policy=$activeDecoderPolicy surface=${_renderSurfaceType.value}")
}
override fun onAudioInputFormatChanged(
@@ -972,6 +1146,128 @@ class Media3PlayerEngine @Inject constructor(
TAG,
"$reason streamType=$currentResolvedStreamType timeoutProfile=$currentTimeoutProfile target=${PlaybackLogSanitizer.sanitizeUrl(lastStreamInfo?.url)}"
)
+ recordCompatibilitySuccess()
+ }
+
+ private fun resolveActiveDecoderPolicy(mode: DecoderMode): ActiveDecoderPolicy = when (mode) {
+ DecoderMode.AUTO -> ActiveDecoderPolicy.AUTO
+ DecoderMode.HARDWARE -> ActiveDecoderPolicy.HARDWARE_PREFERRED
+ DecoderMode.SOFTWARE -> ActiveDecoderPolicy.SOFTWARE_PREFERRED
+ DecoderMode.COMPATIBILITY -> ActiveDecoderPolicy.COMPATIBILITY
+ }
+
+ private fun updateRenderSurfaceForMode() {
+ _renderSurfaceType.value = when (requestedSurfaceMode) {
+ PlayerSurfaceMode.SURFACE_VIEW -> PlayerRenderSurfaceType.SURFACE_VIEW
+ PlayerSurfaceMode.TEXTURE_VIEW -> PlayerRenderSurfaceType.TEXTURE_VIEW
+ PlayerSurfaceMode.AUTO -> if (activeDecoderPolicy == ActiveDecoderPolicy.COMPATIBILITY) {
+ PlayerRenderSurfaceType.TEXTURE_VIEW
+ } else {
+ PlayerRenderSurfaceType.SURFACE_VIEW
+ }
+ }
+ }
+
+ private fun refreshKnownBadCompatibilityRecords() {
+ val video = _videoFormat.value
+ val videoMime = video.codecV ?: _playerStats.value.videoCodec
+ val bucket = resolutionBucket(video.width.takeIf { it > 0 } ?: _playerStats.value.width)
+ scope.launch(Dispatchers.IO) {
+ val records = playbackCompatibilityRepository.getKnownBadRecords(
+ deviceFingerprint = Build.FINGERPRINT.orEmpty(),
+ streamType = currentResolvedStreamType.name,
+ videoMimeType = videoMime.takeIf { it.isNotBlank() } ?: "unknown",
+ resolutionBucket = bucket
+ )
+ val names = PlaybackCodecSelector.knownBadDecoderNames(records)
+ scope.launch { knownBadDecoderNames = names }
+ }
+ }
+
+ private fun handleVideoStall() {
+ val streamInfo = lastStreamInfo ?: return
+ videoStallCount++
+ videoStallRecoveryAttempt++
+ recordCompatibilityFailure("VIDEO_STALL")
+ _playerStats.value = _playerStats.value.copy(videoStallCount = videoStallCount)
+
+ val wasPlaying = exoPlayer?.playWhenReady ?: true
+ val seekPosition = exoPlayer?.currentPosition?.takeIf { it > 0L }
+ Log.w(
+ TAG,
+ "video-stall attempt=$videoStallRecoveryAttempt decoder=$selectedVideoDecoderName policy=$activeDecoderPolicy surface=${_renderSurfaceType.value} target=${PlaybackLogSanitizer.sanitizeUrl(streamInfo.url)}"
+ )
+
+ when (videoStallRecoveryAttempt) {
+ 1 -> {
+ viewBinder.attachPlayer(null)
+ viewBinder.attachPlayer(exoPlayer)
+ prepareInternal(streamInfo, preserveRetryState = true, seekPositionMs = seekPosition, autoPlay = wasPlaying)
+ }
+ 2 -> {
+ activeDecoderPolicy = when (activeDecoderPolicy) {
+ ActiveDecoderPolicy.SOFTWARE_PREFERRED -> ActiveDecoderPolicy.HARDWARE_PREFERRED
+ else -> ActiveDecoderPolicy.SOFTWARE_PREFERRED
+ }
+ recoveryDecoderPolicyOverride = activeDecoderPolicy
+ recreatePlayer()
+ prepareInternal(streamInfo, preserveRetryState = true, seekPositionMs = seekPosition, autoPlay = wasPlaying)
+ }
+ 3 -> {
+ requestedDecoderMode = DecoderMode.COMPATIBILITY
+ activeDecoderPolicy = ActiveDecoderPolicy.COMPATIBILITY
+ recoveryDecoderPolicyOverride = activeDecoderPolicy
+ updateRenderSurfaceForMode()
+ recreatePlayer()
+ prepareInternal(streamInfo, preserveRetryState = true, seekPositionMs = seekPosition, autoPlay = wasPlaying)
+ }
+ else -> {
+ _error.tryEmit(
+ PlayerError.DecoderError(
+ "Video decoder stalled on this device. Try Compatibility Mode, TextureView, or a lower-quality stream."
+ )
+ )
+ }
+ }
+ }
+
+ private fun recordCompatibilityFailure(failureType: String) {
+ val key = currentCompatibilityKey() ?: return
+ scope.launch(Dispatchers.IO) {
+ playbackCompatibilityRepository.recordFailure(key, failureType)
+ }
+ }
+
+ private fun recordCompatibilitySuccess() {
+ val key = currentCompatibilityKey() ?: return
+ scope.launch(Dispatchers.IO) {
+ playbackCompatibilityRepository.recordSuccess(key)
+ }
+ }
+
+ private fun currentCompatibilityKey(): PlaybackCompatibilityKey? {
+ val decoder = selectedVideoDecoderName.takeIf { it.isNotBlank() && it != "Unknown" } ?: return null
+ val video = _videoFormat.value
+ val width = video.width.takeIf { it > 0 } ?: _playerStats.value.width
+ val mime = video.codecV ?: _playerStats.value.videoCodec
+ return PlaybackCompatibilityKey(
+ deviceFingerprint = Build.FINGERPRINT.orEmpty(),
+ deviceModel = Build.MODEL.orEmpty(),
+ androidSdk = Build.VERSION.SDK_INT,
+ streamType = currentResolvedStreamType.name,
+ videoMimeType = mime.takeIf { it.isNotBlank() } ?: "unknown",
+ resolutionBucket = resolutionBucket(width),
+ decoderName = decoder,
+ surfaceType = _renderSurfaceType.value.name
+ )
+ }
+
+ private fun resolutionBucket(width: Int): String = when {
+ width >= 3800 -> "4K"
+ width >= 1900 -> "1080P"
+ width >= 1200 -> "720P"
+ width > 0 -> "SD"
+ else -> "UNKNOWN"
}
private fun handleAudioRendererIssue(error: Exception, source: String) {
diff --git a/player/src/main/java/com/streamvault/player/PlayerEngine.kt b/player/src/main/java/com/streamvault/player/PlayerEngine.kt
index 1aab2bc5..106b3730 100644
--- a/player/src/main/java/com/streamvault/player/PlayerEngine.kt
+++ b/player/src/main/java/com/streamvault/player/PlayerEngine.kt
@@ -3,6 +3,7 @@ package com.streamvault.player
import android.content.Context
import android.view.View
import com.streamvault.domain.model.DecoderMode
+import com.streamvault.domain.model.PlayerSurfaceMode
import com.streamvault.domain.model.DrmScheme
import com.streamvault.domain.model.StreamInfo
import com.streamvault.domain.model.VideoFormat
@@ -18,6 +19,10 @@ import com.streamvault.player.timeshift.TimeshiftConfig
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
+const val AUDIO_VIDEO_OFFSET_MIN_MS = -2_000
+const val AUDIO_VIDEO_OFFSET_MAX_MS = 2_000
+const val AUDIO_VIDEO_OFFSET_STEP_MS = 50
+
const val PLAYER_TRACK_AUTO_ID = "__auto__"
enum class PlayerRenderSurfaceType {
@@ -45,7 +50,9 @@ interface PlayerEngine {
val availableSubtitleTracks: StateFlow<List<PlayerTrack>>
val availableVideoTracks: StateFlow<List<PlayerTrack>>
val playbackSpeed: StateFlow<Float>
+ val audioVideoOffsetMs: StateFlow<Int>
val timeshiftState: StateFlow<LiveTimeshiftState>
+ val renderSurfaceType: StateFlow<PlayerRenderSurfaceType>
/** In-stream metadata title (ICY / HLS). Null when the stream sends nothing. */
val mediaTitle: StateFlow<String?>
@@ -59,10 +66,12 @@ interface PlayerEngine {
fun seekForward(ms: Long = 10_000)
fun seekBackward(ms: Long = 10_000)
fun setDecoderMode(mode: DecoderMode)
+ fun setSurfaceMode(mode: PlayerSurfaceMode)
fun setMediaSessionEnabled(enabled: Boolean)
fun setVolume(volume: Float)
fun setMuted(muted: Boolean)
fun setPlaybackSpeed(speed: Float)
+ fun setAudioVideoOffsetMs(offsetMs: Int)
fun startLiveTimeshift(streamInfo: StreamInfo, channelKey: String, config: TimeshiftConfig)
fun stopLiveTimeshift()
fun seekToLiveEdge()
@@ -74,6 +83,7 @@ interface PlayerEngine {
fun selectAudioTrack(trackId: String)
fun selectVideoTrack(trackId: String)
fun selectSubtitleTrack(trackId: String?) // null to disable subtitles
+ fun addExternalSubtitle(subtitleUri: android.net.Uri, language: String)
fun release()
/** Toggle mute without losing the remembered volume level. */
@@ -130,6 +140,11 @@ enum class PlaybackState {
data class PlayerStats(
val videoCodec: String = "Unknown",
val audioCodec: String = "Unknown",
+ val videoDecoderName: String = "Unknown",
+ val activeDecoderPolicy: String = "AUTO",
+ val renderSurfaceType: String = "SURFACE_VIEW",
+ val videoStallCount: Int = 0,
+ val lastVideoFrameAgoMs: Long = 0,
val videoBitrate: Int = 0,
val droppedFrames: Int = 0,
val width: Int = 0,
diff --git a/player/src/main/java/com/streamvault/player/playback/AudioVideoOffsetAudioSink.kt b/player/src/main/java/com/streamvault/player/playback/AudioVideoOffsetAudioSink.kt
new file mode 100644
index 00000000..c085a2c7
--- /dev/null
+++ b/player/src/main/java/com/streamvault/player/playback/AudioVideoOffsetAudioSink.kt
@@ -0,0 +1,20 @@
+package com.streamvault.player.playback
+
+import androidx.media3.common.util.UnstableApi
+import androidx.media3.exoplayer.audio.AudioSink
+
+@UnstableApi
+internal class AudioVideoOffsetAudioSink(
+ private val delegate: AudioSink,
+ private val offsetUsProvider: () -> Long
+) : AudioSink by delegate {
+ override fun getCurrentPositionUs(sourceEnded: Boolean): Long {
+ val positionUs = delegate.getCurrentPositionUs(sourceEnded)
+ return if (positionUs == AudioSink.CURRENT_POSITION_NOT_SET) {
+ positionUs
+ } else {
+ positionUs + offsetUsProvider()
+ }
+ }
+}
+
diff --git a/player/src/main/java/com/streamvault/player/playback/CodecPreference.kt b/player/src/main/java/com/streamvault/player/playback/CodecPreference.kt
new file mode 100644
index 00000000..794552db
--- /dev/null
+++ b/player/src/main/java/com/streamvault/player/playback/CodecPreference.kt
@@ -0,0 +1,62 @@
+package com.streamvault.player.playback
+
+import androidx.media3.common.util.UnstableApi
+import androidx.media3.exoplayer.mediacodec.MediaCodecInfo
+import androidx.media3.exoplayer.mediacodec.MediaCodecSelector
+import com.streamvault.domain.model.DecoderMode
+import com.streamvault.domain.model.PlaybackCompatibilityRecord
+import java.util.Locale
+
+enum class ActiveDecoderPolicy {
+ AUTO,
+ HARDWARE_PREFERRED,
+ SOFTWARE_PREFERRED,
+ COMPATIBILITY
+}
+
+@UnstableApi
+class PlaybackCodecSelector(
+ private val delegate: MediaCodecSelector = MediaCodecSelector.DEFAULT,
+ private val policyProvider: () -> ActiveDecoderPolicy,
+ private val knownBadProvider: () -> Set<String>
+) : MediaCodecSelector {
+ override fun getDecoderInfos(
+ mimeType: String,
+ requiresSecureDecoder: Boolean,
+ requiresTunnelingDecoder: Boolean
+ ): MutableList<MediaCodecInfo> {
+ val infos = delegate.getDecoderInfos(mimeType, requiresSecureDecoder, requiresTunnelingDecoder)
+ val knownBad = knownBadProvider().map { it.lowercase(Locale.ROOT) }.toSet()
+ val policy = policyProvider()
+ return infos.sortedWith(
+ compareBy<MediaCodecInfo> { info ->
+ if (info.name.lowercase(Locale.ROOT) in knownBad) 1 else 0
+ }.thenBy { info ->
+ when (policy) {
+ ActiveDecoderPolicy.AUTO -> 0
+ ActiveDecoderPolicy.HARDWARE_PREFERRED -> if (isSoftwareCodec(info.name)) 1 else 0
+ ActiveDecoderPolicy.SOFTWARE_PREFERRED,
+ ActiveDecoderPolicy.COMPATIBILITY -> if (isSoftwareCodec(info.name)) 0 else 1
+ }
+ }
+ ).toMutableList()
+ }
+
+ companion object {
+ fun isSoftwareCodec(name: String): Boolean {
+ val normalized = name.lowercase(Locale.ROOT)
+ return normalized.startsWith("omx.google.") ||
+ normalized.startsWith("c2.android.") ||
+ normalized.contains("ffmpeg") ||
+ normalized.contains("avcodec") ||
+ normalized.contains("sw")
+ }
+
+ fun knownBadDecoderNames(records: List<PlaybackCompatibilityRecord>): Set<String> =
+ records.filter(PlaybackCompatibilityRecord::isKnownBad)
+ .map { it.key.decoderName }
+ .filter { it.isNotBlank() }
+ .toSet()
+ }
+}
+
diff --git a/player/src/main/java/com/streamvault/player/playback/DecoderPreferencePolicy.kt b/player/src/main/java/com/streamvault/player/playback/DecoderPreferencePolicy.kt
index 087ac057..96107fcf 100644
--- a/player/src/main/java/com/streamvault/player/playback/DecoderPreferencePolicy.kt
+++ b/player/src/main/java/com/streamvault/player/playback/DecoderPreferencePolicy.kt
@@ -13,13 +13,13 @@ class DefaultDecoderPreferencePolicy : DecoderPreferencePolicy {
override fun preferredMode(requestedMode: DecoderMode, mediaId: String): DecoderMode {
return when (requestedMode) {
- DecoderMode.SOFTWARE -> DecoderMode.SOFTWARE
+ DecoderMode.SOFTWARE, DecoderMode.COMPATIBILITY -> DecoderMode.SOFTWARE
DecoderMode.HARDWARE, DecoderMode.AUTO -> DecoderMode.HARDWARE
}
}
override fun onDecoderInitFailure(requestedMode: DecoderMode, mediaId: String): DecoderMode? {
- if (requestedMode == DecoderMode.SOFTWARE) return null
+ if (requestedMode == DecoderMode.SOFTWARE || requestedMode == DecoderMode.COMPATIBILITY) return null
if (!softwareRetriedMediaIds.add(mediaId)) return null
return DecoderMode.SOFTWARE
}
diff --git a/player/src/main/java/com/streamvault/player/playback/VideoStallDetector.kt b/player/src/main/java/com/streamvault/player/playback/VideoStallDetector.kt
new file mode 100644
index 00000000..3c0bfbfc
--- /dev/null
+++ b/player/src/main/java/com/streamvault/player/playback/VideoStallDetector.kt
@@ -0,0 +1,68 @@
+package com.streamvault.player.playback
+
+import com.streamvault.player.PlaybackState
+
+class VideoStallDetector(
+ private val nowMs: () -> Long = System::currentTimeMillis,
+ private val initialGraceMs: Long = 8_000L,
+ private val stallThresholdMs: Long = 5_000L,
+ private val minPositionAdvanceMs: Long = 1_500L
+) {
+ private var startedAtMs: Long = 0L
+ private var lastFrameAtMs: Long = 0L
+ private var lastPositionMs: Long = 0L
+ private var lastPositionCheckMs: Long = 0L
+ private var stalled = false
+
+ fun reset() {
+ val now = nowMs()
+ startedAtMs = now
+ lastFrameAtMs = 0L
+ lastPositionMs = 0L
+ lastPositionCheckMs = now
+ stalled = false
+ }
+
+ fun onVideoFrameRendered() {
+ lastFrameAtMs = nowMs()
+ stalled = false
+ }
+
+ fun lastVideoFrameAgoMs(): Long {
+ val frameAt = lastFrameAtMs
+ return if (frameAt <= 0L) 0L else (nowMs() - frameAt).coerceAtLeast(0L)
+ }
+
+ fun shouldReportStall(
+ playbackState: PlaybackState,
+ isPlaying: Boolean,
+ currentPositionMs: Long,
+ bufferedDurationMs: Long
+ ): Boolean {
+ val now = nowMs()
+ if (playbackState != PlaybackState.READY || !isPlaying || bufferedDurationMs <= 1_000L) {
+ lastPositionMs = currentPositionMs
+ lastPositionCheckMs = now
+ stalled = false
+ return false
+ }
+ if (now - startedAtMs < initialGraceMs || lastFrameAtMs <= 0L) return false
+
+ val positionAdvanced = currentPositionMs - lastPositionMs >= minPositionAdvanceMs
+ val checkWindowElapsed = now - lastPositionCheckMs >= minPositionAdvanceMs
+ if (checkWindowElapsed) {
+ lastPositionMs = currentPositionMs
+ lastPositionCheckMs = now
+ }
+
+ val frameSilent = now - lastFrameAtMs >= stallThresholdMs
+ val nextStalled = positionAdvanced && frameSilent
+ if (nextStalled && !stalled) {
+ stalled = true
+ return true
+ }
+ if (!frameSilent) stalled = false
+ return false
+ }
+}
+
diff --git a/player/src/test/java/com/streamvault/player/playback/AudioVideoOffsetAudioSinkTest.kt b/player/src/test/java/com/streamvault/player/playback/AudioVideoOffsetAudioSinkTest.kt
new file mode 100644
index 00000000..8a6ca5f4
--- /dev/null
+++ b/player/src/test/java/com/streamvault/player/playback/AudioVideoOffsetAudioSinkTest.kt
@@ -0,0 +1,65 @@
+package com.streamvault.player.playback
+
+import androidx.media3.common.util.UnstableApi
+import androidx.media3.exoplayer.audio.AudioSink
+import com.google.common.truth.Truth.assertThat
+import java.lang.reflect.Proxy
+import org.junit.Test
+
+@UnstableApi
+class AudioVideoOffsetAudioSinkTest {
+
+ @Test
+ fun `positive offset reports clock ahead`() {
+ val sink = AudioVideoOffsetAudioSink(
+ delegate = fakeAudioSink(positionUs = 1_000_000L),
+ offsetUsProvider = { 250_000L }
+ )
+
+ assertThat(sink.getCurrentPositionUs(false)).isEqualTo(1_250_000L)
+ }
+
+ @Test
+ fun `negative offset reports clock behind`() {
+ val sink = AudioVideoOffsetAudioSink(
+ delegate = fakeAudioSink(positionUs = 1_000_000L),
+ offsetUsProvider = { -250_000L }
+ )
+
+ assertThat(sink.getCurrentPositionUs(false)).isEqualTo(750_000L)
+ }
+
+ @Test
+ fun `current position not set is preserved`() {
+ val sink = AudioVideoOffsetAudioSink(
+ delegate = fakeAudioSink(positionUs = AudioSink.CURRENT_POSITION_NOT_SET),
+ offsetUsProvider = { 250_000L }
+ )
+
+ assertThat(sink.getCurrentPositionUs(false)).isEqualTo(AudioSink.CURRENT_POSITION_NOT_SET)
+ }
+
+ private fun fakeAudioSink(positionUs: Long): AudioSink {
+ return Proxy.newProxyInstance(
+ AudioSink::class.java.classLoader,
+ arrayOf(AudioSink::class.java)
+ ) { _, method, _ ->
+ when (method.name) {
+ "getCurrentPositionUs" -> positionUs
+ "toString" -> "FakeAudioSink"
+ else -> defaultValue(method.returnType)
+ }
+ } as AudioSink
+ }
+
+ private fun defaultValue(type: Class<*>): Any? = when (type) {
+ java.lang.Boolean.TYPE -> false
+ java.lang.Integer.TYPE -> 0
+ java.lang.Long.TYPE -> 0L
+ java.lang.Float.TYPE -> 0f
+ java.lang.Double.TYPE -> 0.0
+ java.lang.Void.TYPE -> Unit
+ else -> null
+ }
+}
+
diff --git a/player/src/test/java/com/streamvault/player/playback/PlaybackCodecSelectorTest.kt b/player/src/test/java/com/streamvault/player/playback/PlaybackCodecSelectorTest.kt
new file mode 100644
index 00000000..aa333650
--- /dev/null
+++ b/player/src/test/java/com/streamvault/player/playback/PlaybackCodecSelectorTest.kt
@@ -0,0 +1,58 @@
+package com.streamvault.player.playback
+
+import androidx.media3.common.util.UnstableApi
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+
+@UnstableApi
+class PlaybackCodecSelectorTest {
+
+ @Test
+ fun `software codec names are recognized`() {
+ assertThat(PlaybackCodecSelector.isSoftwareCodec("OMX.google.h264.decoder")).isTrue()
+ assertThat(PlaybackCodecSelector.isSoftwareCodec("c2.android.hevc.decoder")).isTrue()
+ assertThat(PlaybackCodecSelector.isSoftwareCodec("OMX.ffmpeg.avc.decoder")).isTrue()
+ }
+
+ @Test
+ fun `vendor codec names are not software`() {
+ assertThat(PlaybackCodecSelector.isSoftwareCodec("OMX.qcom.video.decoder.avc")).isFalse()
+ assertThat(PlaybackCodecSelector.isSoftwareCodec("c2.mtk.hevc.decoder")).isFalse()
+ assertThat(PlaybackCodecSelector.isSoftwareCodec("OMX.amlogic.avc.decoder.awesome")).isFalse()
+ }
+
+ @Test
+ fun `known bad records extract decoder names`() {
+ val records = listOf(
+ compatibilityRecord("OMX.bad.decoder", failures = 2, successAt = 0, failedAt = 10),
+ compatibilityRecord("OMX.good.decoder", failures = 1, successAt = 0, failedAt = 10),
+ compatibilityRecord("OMX.recovered.decoder", failures = 4, successAt = 20, failedAt = 10)
+ )
+
+ assertThat(PlaybackCodecSelector.knownBadDecoderNames(records))
+ .containsExactly("OMX.bad.decoder")
+ }
+
+ private fun compatibilityRecord(
+ decoderName: String,
+ failures: Int,
+ successAt: Long,
+ failedAt: Long
+ ) = com.streamvault.domain.model.PlaybackCompatibilityRecord(
+ key = com.streamvault.domain.model.PlaybackCompatibilityKey(
+ deviceFingerprint = "device",
+ deviceModel = "model",
+ androidSdk = 35,
+ streamType = "HLS",
+ videoMimeType = "video/avc",
+ resolutionBucket = "1080P",
+ decoderName = decoderName,
+ surfaceType = "SURFACE_VIEW"
+ ),
+ failureType = "VIDEO_STALL",
+ lastFailedAt = failedAt,
+ lastSucceededAt = successAt,
+ failureCount = failures,
+ successCount = if (successAt > 0) 1 else 0
+ )
+}
diff --git a/player/src/test/java/com/streamvault/player/playback/VideoStallDetectorTest.kt b/player/src/test/java/com/streamvault/player/playback/VideoStallDetectorTest.kt
new file mode 100644
index 00000000..8e7573c4
--- /dev/null
+++ b/player/src/test/java/com/streamvault/player/playback/VideoStallDetectorTest.kt
@@ -0,0 +1,88 @@
+package com.streamvault.player.playback
+
+import com.google.common.truth.Truth.assertThat
+import com.streamvault.player.PlaybackState
+import org.junit.Test
+
+class VideoStallDetectorTest {
+ private var nowMs = 0L
+
+ @Test
+ fun `does not report before initial grace`() {
+ val detector = detector()
+ detector.reset()
+ detector.onVideoFrameRendered()
+ nowMs = 3_000L
+
+ assertThat(
+ detector.shouldReportStall(
+ playbackState = PlaybackState.READY,
+ isPlaying = true,
+ currentPositionMs = 3_000L,
+ bufferedDurationMs = 5_000L
+ )
+ ).isFalse()
+ }
+
+ @Test
+ fun `reports once when position advances and frames stop`() {
+ val detector = detector()
+ detector.reset()
+ nowMs = 1_000L
+ detector.onVideoFrameRendered()
+ nowMs = 9_000L
+
+ assertThat(
+ detector.shouldReportStall(
+ playbackState = PlaybackState.READY,
+ isPlaying = true,
+ currentPositionMs = 3_000L,
+ bufferedDurationMs = 5_000L
+ )
+ ).isTrue()
+ assertThat(
+ detector.shouldReportStall(
+ playbackState = PlaybackState.READY,
+ isPlaying = true,
+ currentPositionMs = 5_000L,
+ bufferedDurationMs = 5_000L
+ )
+ ).isFalse()
+ }
+
+ @Test
+ fun `does not report while buffering paused or empty buffered`() {
+ val detector = detector()
+ detector.reset()
+ nowMs = 1_000L
+ detector.onVideoFrameRendered()
+ nowMs = 9_000L
+
+ assertThat(detector.shouldReportStall(PlaybackState.BUFFERING, true, 4_000L, 5_000L)).isFalse()
+ assertThat(detector.shouldReportStall(PlaybackState.READY, false, 4_000L, 5_000L)).isFalse()
+ assertThat(detector.shouldReportStall(PlaybackState.READY, true, 4_000L, 0L)).isFalse()
+ }
+
+ @Test
+ fun `new rendered frame clears stalled state`() {
+ val detector = detector()
+ detector.reset()
+ nowMs = 1_000L
+ detector.onVideoFrameRendered()
+ nowMs = 9_000L
+ assertThat(detector.shouldReportStall(PlaybackState.READY, true, 3_000L, 5_000L)).isTrue()
+
+ nowMs = 9_100L
+ detector.onVideoFrameRendered()
+ nowMs = 15_000L
+ assertThat(detector.shouldReportStall(PlaybackState.READY, true, 6_000L, 5_000L)).isTrue()
+ }
+
+ private fun detector() = VideoStallDetector(
+ nowMs = { nowMs },
+ initialGraceMs = 5_000L,
+ stallThresholdMs = 4_000L,
+ minPositionAdvanceMs = 1_000L
+ )
+}
+