Skip to content

Commit

Permalink
Kodi Adaptions (#188)
Browse files Browse the repository at this point in the history
* feat: use tvg-name to pair epg programmes if tvg-id is missing.

* refactor: rename originalId to relationId.

* feat: read kodi user-agent option when playing channel.

* fix: solve cr comments.
  • Loading branch information
oxyroid authored Sep 6, 2024
1 parent 829928b commit 55b3790
Show file tree
Hide file tree
Showing 21 changed files with 528 additions and 101 deletions.
353 changes: 353 additions & 0 deletions data/schemas/com.m3u.data.database.M3UDatabase/20.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,353 @@
{
"formatVersion": 1,
"database": {
"version": 20,
"identityHash": "c665404489c7590c01a608ea687840c4",
"entities": [
{
"tableName": "playlists",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`title` TEXT NOT NULL, `url` TEXT NOT NULL, `pinned_groups` TEXT NOT NULL DEFAULT '[]', `hidden_groups` TEXT NOT NULL DEFAULT '[]', `source` TEXT NOT NULL DEFAULT '0', `user_agent` TEXT DEFAULT NULL, `epg_urls` TEXT NOT NULL DEFAULT '[]', `auto_refresh_programmes` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`url`))",
"fields": [
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "url",
"columnName": "url",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "pinnedCategories",
"columnName": "pinned_groups",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "'[]'"
},
{
"fieldPath": "hiddenCategories",
"columnName": "hidden_groups",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "'[]'"
},
{
"fieldPath": "source",
"columnName": "source",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "'0'"
},
{
"fieldPath": "userAgent",
"columnName": "user_agent",
"affinity": "TEXT",
"notNull": false,
"defaultValue": "NULL"
},
{
"fieldPath": "epgUrls",
"columnName": "epg_urls",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "'[]'"
},
{
"fieldPath": "autoRefreshProgrammes",
"columnName": "auto_refresh_programmes",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"url"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "streams",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`url` TEXT NOT NULL, `group` TEXT NOT NULL, `title` TEXT NOT NULL, `cover` TEXT, `playlist_url` TEXT NOT NULL, `license_type` TEXT DEFAULT NULL, `license_key` TEXT DEFAULT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `favourite` INTEGER NOT NULL, `hidden` INTEGER NOT NULL DEFAULT 0, `seen` INTEGER NOT NULL DEFAULT 0, `relation_id` TEXT DEFAULT NULL)",
"fields": [
{
"fieldPath": "url",
"columnName": "url",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "category",
"columnName": "group",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "cover",
"columnName": "cover",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "playlistUrl",
"columnName": "playlist_url",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "licenseType",
"columnName": "license_type",
"affinity": "TEXT",
"notNull": false,
"defaultValue": "NULL"
},
{
"fieldPath": "licenseKey",
"columnName": "license_key",
"affinity": "TEXT",
"notNull": false,
"defaultValue": "NULL"
},
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "favourite",
"columnName": "favourite",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "hidden",
"columnName": "hidden",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "seen",
"columnName": "seen",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "relationId",
"columnName": "relation_id",
"affinity": "TEXT",
"notNull": false,
"defaultValue": "NULL"
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [
{
"name": "index_streams_playlist_url",
"unique": false,
"columnNames": [
"playlist_url"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_streams_playlist_url` ON `${TABLE_NAME}` (`playlist_url`)"
},
{
"name": "index_streams_favourite",
"unique": false,
"columnNames": [
"favourite"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_streams_favourite` ON `${TABLE_NAME}` (`favourite`)"
}
],
"foreignKeys": []
},
{
"tableName": "programmes",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`relation_id` TEXT NOT NULL, `epg_url` TEXT NOT NULL, `start` INTEGER NOT NULL, `end` INTEGER NOT NULL, `title` TEXT NOT NULL, `description` TEXT NOT NULL, `icon` TEXT, `categories` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
"fields": [
{
"fieldPath": "channelId",
"columnName": "relation_id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "epgUrl",
"columnName": "epg_url",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "start",
"columnName": "start",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "end",
"columnName": "end",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "description",
"columnName": "description",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "icon",
"columnName": "icon",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "categories",
"columnName": "categories",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [
{
"name": "index_programmes_epg_url",
"unique": false,
"columnNames": [
"epg_url"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_programmes_epg_url` ON `${TABLE_NAME}` (`epg_url`)"
}
],
"foreignKeys": []
},
{
"tableName": "episodes",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`title` TEXT NOT NULL, `series_id` INTEGER NOT NULL, `season` TEXT NOT NULL, `number` INTEGER NOT NULL, `url` TEXT NOT NULL, `id` INTEGER NOT NULL, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "seriesId",
"columnName": "series_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "season",
"columnName": "season",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "number",
"columnName": "number",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "url",
"columnName": "url",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "color_pack",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`argb` INTEGER NOT NULL, `dark` INTEGER NOT NULL, `name` TEXT NOT NULL, PRIMARY KEY(`argb`, `dark`))",
"fields": [
{
"fieldPath": "argb",
"columnName": "argb",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "isDark",
"columnName": "dark",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"argb",
"dark"
]
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"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, 'c665404489c7590c01a608ea687840c4')"
]
}
}
20 changes: 20 additions & 0 deletions data/src/main/java/com/m3u/data/database/DatabaseMigrations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,24 @@ internal object DatabaseMigrations {
DeleteColumn(tableName = "programmes", columnName = "previous_start")
)
class AutoMigrate18To19: AutoMigrationSpec

@RenameColumn.Entries(
RenameColumn(
tableName = "streams",
fromColumnName = "channel_id",
toColumnName = "relation_id"
),
RenameColumn(
tableName = "programmes",
fromColumnName = "channel_id",
toColumnName = "relation_id"
),
RenameColumn(
tableName = "streams",
fromColumnName = "playlistUrl",
toColumnName = "playlist_url"
)
)
class AutoMigrate19To20: AutoMigrationSpec

}
Loading

0 comments on commit 55b3790

Please sign in to comment.