[db] Make Apple Music on Catalina work - part 2 (fix for issue #834)

Extends the playlist table with media_kind to handle playlist queries like
this from Apple Music:

/databases/71/containers?session-id=12345678&revision-number=4&delta=0&query=('dmap.itemname:Library%20name','com.apple.itunes.extended-media-kind:1','com.apple.itunes.extended-media-kind:32','com.apple.itunes.extended-media-kind:128','com.apple.itunes.extended-media-kind:65537')&meta=dmap.itemid,dmap.itemname,dmap.persistentid,dmap.parentcontainerid,com.apple.itunes.is-podcast-playlist,com.apple.itunes.special-playlist,com.apple.itunes.smart-playlist,dmap.haschildcontainers,com.apple.itunes.saved-genius,dmap.objectextradata
This commit is contained in:
ejurgensen 2019-11-01 15:44:53 -07:00
parent a69e79e5ec
commit 40c7522baa
3 changed files with 25 additions and 2 deletions

View File

@ -114,7 +114,8 @@
" parent_id INTEGER DEFAULT 0," \
" directory_id INTEGER DEFAULT 0," \
" query_order VARCHAR(1024)," \
" query_limit INTEGER DEFAULT -1" \
" query_limit INTEGER DEFAULT -1," \
" media_kind INTEGER DEFAULT 1" \
");"
#define T_PLITEMS \

View File

@ -26,7 +26,7 @@
* is a major upgrade. In other words minor version upgrades permit downgrading
* forked-daapd after the database was upgraded. */
#define SCHEMA_VERSION_MAJOR 21
#define SCHEMA_VERSION_MINOR 01
#define SCHEMA_VERSION_MINOR 02
int
db_init_indices(sqlite3 *hdl);

View File

@ -1020,6 +1020,22 @@ static const struct db_upgrade_query db_upgrade_v2101_queries[] =
{ U_v2101_SCVER_MINOR, "set schema_version_minor to 01" },
};
// This column added because Apple Music makes a DAAP request for playlists
// that has a query condition on extended-media-kind. We set the default value
// to 1 to signify music.
#define U_v2102_ALTER_PLAYLISTS_ADD_MEDIA_KIND \
"ALTER TABLE playlists ADD COLUMN media_kind INTEGER DEFAULT 1;"
#define U_v2102_SCVER_MINOR \
"UPDATE admin SET value = '02' WHERE key = 'schema_version_minor';"
static const struct db_upgrade_query db_upgrade_v2102_queries[] =
{
{ U_v2102_ALTER_PLAYLISTS_ADD_MEDIA_KIND, "alter table playlists add column media_kind" },
{ U_v2102_SCVER_MINOR, "set schema_version_minor to 02" },
};
int
db_upgrade(sqlite3 *hdl, int db_ver)
@ -1175,6 +1191,12 @@ db_upgrade(sqlite3 *hdl, int db_ver)
if (ret < 0)
return -1;
/* FALLTHROUGH */
case 2101:
ret = db_generic_upgrade(hdl, db_upgrade_v2102_queries, ARRAY_SIZE(db_upgrade_v2102_queries));
if (ret < 0)
return -1;
break;
default: