Skip to content

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

feat: increase XMLTV ingestion limits for large full-country guides and improve source assignment handling

David Nashashd2a0949bcd34
diff --git a/data/src/main/java/com/streamvault/data/parser/XmltvIngestionLimits.kt b/data/src/main/java/com/streamvault/data/parser/XmltvIngestionLimits.kt
index 76735a52..fa1aef77 100644
--- a/data/src/main/java/com/streamvault/data/parser/XmltvIngestionLimits.kt
+++ b/data/src/main/java/com/streamvault/data/parser/XmltvIngestionLimits.kt
@@ -7,7 +7,7 @@ data class XmltvIngestionLimits(
val maxRawBytes: Long = NetworkTimeoutConfig.EPG_MAX_RAW_SIZE_BYTES,
val maxDecompressedBytes: Long = NetworkTimeoutConfig.EPG_MAX_SIZE_BYTES,
val maxChannels: Int = 100_000,
- val maxProgrammes: Int = 1_000_000,
+ val maxProgrammes: Int = 2_000_000,
val maxFieldChars: Int = 65_536,
val maxCategoriesPerProgramme: Int = 64,
val maxXmlDepth: Int = 32
diff --git a/data/src/main/java/com/streamvault/data/remote/NetworkTimeoutConfig.kt b/data/src/main/java/com/streamvault/data/remote/NetworkTimeoutConfig.kt
index 2a68dc22..7c1af589 100644
--- a/data/src/main/java/com/streamvault/data/remote/NetworkTimeoutConfig.kt
+++ b/data/src/main/java/com/streamvault/data/remote/NetworkTimeoutConfig.kt
@@ -6,8 +6,11 @@ object NetworkTimeoutConfig {
const val WRITE_TIMEOUT_SECONDS = 30L
// EPG files can be large and served from slow hosts — allow more time per read.
const val EPG_READ_TIMEOUT_SECONDS = 120L
- const val EPG_MAX_RAW_SIZE_BYTES = 64L * 1_048_576 // 64 MB before decompression
- const val EPG_MAX_SIZE_BYTES = 200L * 1_048_576 // 200 MB
+ // Full-country XMLTV guides decompress well past 200 MB (e.g. iptv-epg.org's
+ // epg-us.xml.gz expands to ~500 MB). The parser streams to the database, so a
+ // higher byte ceiling is safe; the programme/channel limits remain the hard guard.
+ const val EPG_MAX_RAW_SIZE_BYTES = 1024L * 1_048_576 // 1 GiB before decompression
+ const val EPG_MAX_SIZE_BYTES = 1024L * 1_048_576 // 1 GiB decompressed XML
const val XTREAM_SEGMENTED_READ_TIMEOUT_SECONDS = 45L
const val XTREAM_SEGMENTED_WRITE_TIMEOUT_SECONDS = 45L
const val XTREAM_SEGMENTED_CALL_TIMEOUT_SECONDS = 50L
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index e87daa73..4b720c8a 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -40,6 +40,8 @@ All notable product changes are recorded in this document.
- Fixed Xtream series showing an empty episode list after re-entering: a hydrated series whose local episodes went missing is now re-fetched, and re-hydration no longer replaces a larger cached episode set with a smaller, partially re-scraped provider response.
- Fixed adaptive M3U metadata being dropped between playlist parsing, import staging, catalog synchronization, and channel or movie playback reconstruction.
- Fixed Xtream Codes and Xtream M3U URL setup crashing on devices with a broken hardware-backed Keystore (such as some budget Android TV boxes): credential encryption now falls back to a software key instead of aborting when the device cannot generate a hardware key.
+- Fixed large full-country XMLTV guides (such as iptv-epg.org's epg-us.xml.gz) failing to import with an "EPG decompressed XML bytes exceeded safety limit" error by raising the raw-download, decompressed-XML, and programme ingestion ceilings, since the parser streams to the database rather than buffering the whole document in memory.
+- Fixed a freshly-added EPG source resolving to no matches after assignment by downloading it once on assignment before re-resolving the provider's guide mappings, so the source has programme data available when it is first used.
### Changed
diff --git a/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsEpgActions.kt b/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsEpgActions.kt
index 7db7c074..f95106b5 100644
--- a/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsEpgActions.kt
+++ b/feature/settings/src/main/java/com/streamvault/feature/settings/presentation/SettingsEpgActions.kt
@@ -193,12 +193,25 @@ class SettingsEpgActions(
val result = epgSourceRepository.assignSourceToProvider(providerId, epgSourceId, nextPriority)
if (result is Result.Error) {
uiState.update { it.copy(userMessage = result.message) }
- } else {
- refreshProviderEpgSummary(providerId)
+ return@launch
+ }
+ // A freshly-added source has no programme data yet, so assigning it would
+ // otherwise resolve to "Matched 0/N". Download it once now (rate-limited)
+ // so the assignment produces real matches, then surface any refresh error.
+ uiState.update { it.copy(refreshingEpgSourceIds = it.refreshingEpgSourceIds + epgSourceId) }
+ val refreshResult = epgSourceRepository.refreshSource(epgSourceId)
+ refreshProviderEpgSummary(providerId)
+ uiState.update {
+ it.copy(
+ refreshingEpgSourceIds = it.refreshingEpgSourceIds - epgSourceId,
+ userMessage = if (refreshResult is Result.Error) refreshResult.message else null
+ )
}
} catch (cancelled: CancellationException) {
+ uiState.update { it.copy(refreshingEpgSourceIds = it.refreshingEpgSourceIds - epgSourceId) }
throw cancelled
} catch (error: Exception) {
+ uiState.update { it.copy(refreshingEpgSourceIds = it.refreshingEpgSourceIds - epgSourceId) }
showUnexpectedError(error, "Failed to assign EPG source")
}
}