diff --git a/data/src/main/java/com/m3u/data/database/M3UDatabase.kt b/data/src/main/java/com/m3u/data/database/M3UDatabase.kt index 1bafb634..3b191c64 100644 --- a/data/src/main/java/com/m3u/data/database/M3UDatabase.kt +++ b/data/src/main/java/com/m3u/data/database/M3UDatabase.kt @@ -17,7 +17,7 @@ import com.m3u.data.database.model.Stream @Database( entities = [Stream::class, Playlist::class, Episode::class, Programme::class, ColorScheme::class], - version = 16, + version = 17, exportSchema = true, autoMigrations = [ AutoMigration( @@ -42,7 +42,8 @@ import com.m3u.data.database.model.Stream from = 14, to = 16, spec = DatabaseMigrations.AutoMigrate14To16::class - ) + ), + AutoMigration(from = 16, to = 17), ] ) @TypeConverters(Converters::class) diff --git a/data/src/main/java/com/m3u/data/database/model/Programme.kt b/data/src/main/java/com/m3u/data/database/model/Programme.kt index a25ea17e..846030d3 100644 --- a/data/src/main/java/com/m3u/data/database/model/Programme.kt +++ b/data/src/main/java/com/m3u/data/database/model/Programme.kt @@ -29,6 +29,12 @@ data class Programme( val title: String, @ColumnInfo(name = "description") val description: String, + @ColumnInfo(name = "new", defaultValue = "0") + val isNew: Boolean, + @ColumnInfo(name = "live", defaultValue = "0") + val isLive: Boolean, + @ColumnInfo(name = "previous_start", defaultValue = "NULL") + val previouslyShownStart: String? = null, @ColumnInfo(name = "icon") val icon: String? = null, @ColumnInfo(name = "categories") diff --git a/data/src/main/java/com/m3u/data/parser/epg/EpgData.kt b/data/src/main/java/com/m3u/data/parser/epg/EpgData.kt index f2f4f3bb..cdbee493 100644 --- a/data/src/main/java/com/m3u/data/parser/epg/EpgData.kt +++ b/data/src/main/java/com/m3u/data/parser/epg/EpgData.kt @@ -30,6 +30,9 @@ data class EpgProgramme( val title: String? = null, val desc: String? = null, val icon: String? = null, + val isNew: Boolean = false, + val isLive: Boolean = false, + val previouslyShownStart: String? = null, val categories: List ) { companion object { @@ -58,6 +61,9 @@ fun EpgProgramme.toProgramme( title = title.orEmpty(), description = desc.orEmpty(), icon = icon, + isNew = isNew, + isLive = isLive, + previouslyShownStart = previouslyShownStart, categories = categories, channelId = channel ) diff --git a/data/src/main/java/com/m3u/data/parser/epg/EpgParserImpl.kt b/data/src/main/java/com/m3u/data/parser/epg/EpgParserImpl.kt index 67dfad87..4a3c8147 100644 --- a/data/src/main/java/com/m3u/data/parser/epg/EpgParserImpl.kt +++ b/data/src/main/java/com/m3u/data/parser/epg/EpgParserImpl.kt @@ -94,6 +94,9 @@ class EpgParserImpl @Inject constructor( var desc: String? = null val categories = mutableListOf() var icon: String? = null + var isNew = false // Initialize isNew flag + var isLive = false + var previouslyShownStart: String? = null // Initialize previouslyShown variable while (next() != XmlPullParser.END_TAG) { if (eventType != XmlPullParser.START_TAG) continue when (name) { @@ -101,6 +104,9 @@ class EpgParserImpl @Inject constructor( "desc" -> desc = readDesc() "category" -> categories += readCategory() "icon" -> icon = readIcon() + "new" -> isNew = readNew() // Update isNewTag flag + "live" -> isLive = readLive() // Update isNewTag flag + "previously-shown" -> previouslyShownStart = readPreviouslyShown() else -> skip() } } @@ -112,7 +118,10 @@ class EpgParserImpl @Inject constructor( title = title, desc = desc, icon = icon, - categories = categories + categories = categories, + isNew = isNew, + isLive = isLive, + previouslyShownStart = previouslyShownStart ) } @@ -170,6 +179,24 @@ class EpgParserImpl @Inject constructor( return category } + private fun XmlPullParser.readNew(): Boolean { + require(XmlPullParser.END_TAG, ns, "new") + return true + } + + private fun XmlPullParser.readLive(): Boolean { + require(XmlPullParser.END_TAG, ns, "live") + return true + } + + private fun XmlPullParser.readPreviouslyShown(): String? { + require(XmlPullParser.START_TAG, ns, "previously-shown") + val start = getAttributeValue(null, "start") + nextTag() + require(XmlPullParser.END_TAG, ns, "previously-shown") + return start + } + private fun XmlPullParser.readText(): String { var result = "" if (next() == XmlPullParser.TEXT) {