diff --git a/src/db.c b/src/db.c index c737774c..56f095a0 100644 --- a/src/db.c +++ b/src/db.c @@ -251,6 +251,7 @@ static const ssize_t dbgri_cols_map[] = dbgri_offsetof(itemcount), dbgri_offsetof(groupalbumcount), dbgri_offsetof(songalbumartist), + dbgri_offsetof(songartistid), }; /* This list must be kept in sync with @@ -1075,13 +1076,13 @@ db_build_query_group_albums(struct query_params *qp, char **q) sort = sort_clause[qp->sort]; if (idx && qp->filter) - query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album, f.album_sort, COUNT(f.id), 1, f.album_artist FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND %s GROUP BY f.album, g.name %s %s;", G_ALBUMS, qp->filter, sort, idx); + query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album, f.album_sort, COUNT(f.id), 1, f.album_artist, f.songartistid FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND %s GROUP BY f.album, g.name %s %s;", G_ALBUMS, qp->filter, sort, idx); else if (idx) - query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album, f.album_sort, COUNT(f.id), 1, f.album_artist FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 GROUP BY f.album, g.name %s %s;", G_ALBUMS, sort, idx); + query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album, f.album_sort, COUNT(f.id), 1, f.album_artist, f.songartistid FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 GROUP BY f.album, g.name %s %s;", G_ALBUMS, sort, idx); else if (qp->filter) - query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album, f.album_sort, COUNT(f.id), 1, f.album_artist FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND %s GROUP BY f.album, g.name %s;", G_ALBUMS, qp->filter, sort); + query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album, f.album_sort, COUNT(f.id), 1, f.album_artist, f.songartistid FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND %s GROUP BY f.album, g.name %s;", G_ALBUMS, qp->filter, sort); else - query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album, f.album_sort, COUNT(f.id), 1, f.album_artist FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 GROUP BY f.album, g.name %s;", G_ALBUMS, sort); + query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album, f.album_sort, COUNT(f.id), 1, f.album_artist, f.songartistid FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 GROUP BY f.album, g.name %s;", G_ALBUMS, sort); if (!query) { @@ -1114,13 +1115,13 @@ db_build_query_group_artists(struct query_params *qp, char **q) sort = sort_clause[qp->sort]; if (idx && qp->filter) - query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album_artist, f.album_artist_sort, COUNT(f.id), COUNT(DISTINCT f.songalbumid), f.album_artist FROM files f, groups g WHERE f.songartistid = g.persistentid AND g.type = %d AND f.disabled = 0 AND %s GROUP BY f.album_artist, g.name %s %s;", G_ARTISTS, qp->filter, sort, idx); + query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album_artist, f.album_artist_sort, COUNT(f.id), COUNT(DISTINCT f.songalbumid), f.album_artist, f.songartistid FROM files f, groups g WHERE f.songartistid = g.persistentid AND g.type = %d AND f.disabled = 0 AND %s GROUP BY f.album_artist, g.name %s %s;", G_ARTISTS, qp->filter, sort, idx); else if (idx) - query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album_artist, f.album_artist_sort, COUNT(f.id), COUNT(DISTINCT f.songalbumid), f.album_artist FROM files f, groups g WHERE f.songartistid = g.persistentid AND g.type = %d AND f.disabled = 0 GROUP BY f.album_artist, g.name %s %s;", G_ARTISTS, sort, idx); + query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album_artist, f.album_artist_sort, COUNT(f.id), COUNT(DISTINCT f.songalbumid), f.album_artist, f.songartistid FROM files f, groups g WHERE f.songartistid = g.persistentid AND g.type = %d AND f.disabled = 0 GROUP BY f.album_artist, g.name %s %s;", G_ARTISTS, sort, idx); else if (qp->filter) - query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album_artist, f.album_artist_sort, COUNT(f.id), COUNT(DISTINCT f.songalbumid), f.album_artist FROM files f, groups g WHERE f.songartistid = g.persistentid AND g.type = %d AND f.disabled = 0 AND %s GROUP BY f.album_artist, g.name %s;", G_ARTISTS, qp->filter, sort); + query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album_artist, f.album_artist_sort, COUNT(f.id), COUNT(DISTINCT f.songalbumid), f.album_artist, f.songartistid FROM files f, groups g WHERE f.songartistid = g.persistentid AND g.type = %d AND f.disabled = 0 AND %s GROUP BY f.album_artist, g.name %s;", G_ARTISTS, qp->filter, sort); else - query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album_artist, f.album_artist_sort, COUNT(f.id), COUNT(DISTINCT f.songalbumid), f.album_artist FROM files f, groups g WHERE f.songartistid = g.persistentid AND g.type = %d AND f.disabled = 0 GROUP BY f.album_artist, g.name %s;", G_ARTISTS, sort); + query = sqlite3_mprintf("SELECT g.id, g.persistentid, f.album_artist, f.album_artist_sort, COUNT(f.id), COUNT(DISTINCT f.songalbumid), f.album_artist, f.songartistid FROM files f, groups g WHERE f.songartistid = g.persistentid AND g.type = %d AND f.disabled = 0 GROUP BY f.album_artist, g.name %s;", G_ARTISTS, sort); if (!query) { diff --git a/src/db.h b/src/db.h index 65a981ca..05408075 100644 --- a/src/db.h +++ b/src/db.h @@ -194,6 +194,7 @@ struct group_info { uint32_t itemcount; /* number of items (mimc) */ uint32_t groupalbumcount; /* number of albums (agac) */ char *songalbumartist; /* song album artist (asaa) */ + uint64_t songartistid; /* song artist id (asri) */ }; #define gri_offsetof(field) offsetof(struct group_info, field) @@ -206,6 +207,7 @@ struct db_group_info { char *itemcount; char *groupalbumcount; char *songalbumartist; + char *songartistid; }; #define dbgri_offsetof(field) offsetof(struct db_group_info, field) diff --git a/src/dmap_fields.gperf b/src/dmap_fields.gperf index 0db2e5f4..c3017acd 100644 --- a/src/dmap_fields.gperf +++ b/src/dmap_fields.gperf @@ -66,7 +66,7 @@ static const struct dmap_field_map dfm_dmap_asai = { dbmfi_offsetof(songalbumid) static const struct dmap_field_map dfm_dmap_asaa = { dbmfi_offsetof(album_artist), -1, dbgri_offsetof(songalbumartist) }; static const struct dmap_field_map dfm_dmap_asac = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_asar = { dbmfi_offsetof(artist), -1, -1 }; -static const struct dmap_field_map dfm_dmap_asri = { dbmfi_offsetof(songartistid), -1, -1 }; +static const struct dmap_field_map dfm_dmap_asri = { dbmfi_offsetof(songartistid), -1, dbgri_offsetof(songartistid) }; static const struct dmap_field_map dfm_dmap_asbt = { dbmfi_offsetof(bpm), -1, -1 }; static const struct dmap_field_map dfm_dmap_asbr = { dbmfi_offsetof(bitrate), -1, -1 }; static const struct dmap_field_map dfm_dmap_ascm = { dbmfi_offsetof(comment), -1, -1 }; diff --git a/src/httpd_dacp.c b/src/httpd_dacp.c index f3af0403..c39e8b2e 100644 --- a/src/httpd_dacp.c +++ b/src/httpd_dacp.c @@ -1408,6 +1408,9 @@ dacp_reply_playqueueedit(struct evhttp_request *req, struct evbuffer *evbuf, cha User selected track (album tab): ?command=add&query='dmap.itemid:...'&queuefilter=album:...&sort=album&mode=1&session-id=... -> clear queue, play itemid and the rest of album + User selected track (artist tab): + ?command=add&query='dmap.itemid:...'&queuefilter=artist:...&sort=album&mode=1&session-id=... + -> clear queue, play itemid and the rest of artist tracks User selected track (song tab): ?command=add&query='dmap.itemid:...'&queuefilter=playlist:...&sort=name&mode=1&session-id=... -> clear queue, play itemid and the rest of playlist @@ -1427,7 +1430,7 @@ dacp_reply_playqueueedit(struct evhttp_request *req, struct evbuffer *evbuf, cha ?command=playnow&index=...&session-id=... -> play index - And the quirky query - no sort, and either no queuefilter or queuefilter=album:(null) + And the quirky query from iPad Remote - no sort and no queuefilter User selected track (artist tab): ?command=add&query='dmap.itemid:...'&mode=1&session-id=... -> clear queue, play itemid and the rest of artist tracks diff --git a/src/player.c b/src/player.c index 5e305380..6ae79835 100644 --- a/src/player.c +++ b/src/player.c @@ -724,6 +724,7 @@ player_queue_make_daap(struct player_source **head, const char *query, const cha struct query_params qp; struct player_source *ps; int64_t albumid; + int64_t artistid; int plid; int id; int idx; @@ -769,6 +770,19 @@ player_queue_make_daap(struct player_source **head, const char *query, const cha snprintf(buf, sizeof(buf), "f.songalbumid = %" PRIi64, albumid); qp.filter = strdup(buf); } + else if ((len > 7) && (strncmp(queuefilter, "artist:", 7) == 0)) + { + qp.type = Q_ITEMS; + ret = safe_atoi64(strchr(queuefilter, ':') + 1, &artistid); + if (ret < 0) + { + DPRINTF(E_LOG, L_PLAYER, "Invalid artist id in queuefilter: %s\n", queuefilter); + + return -1; + } + snprintf(buf, sizeof(buf), "f.songartistid = %" PRIi64, artistid); + qp.filter = strdup(buf); + } else if ((len > 9) && (strncmp(queuefilter, "playlist:", 9) == 0)) { qp.type = Q_PLITEMS;