Support songartistid (asri) in group requests and queuefilter=artist
- credit misenhower of wp8remote.com
This commit is contained in:
parent
7997377deb
commit
190f91114e
17
src/db.c
17
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)
|
||||
{
|
||||
|
|
2
src/db.h
2
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)
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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
|
||||
|
|
14
src/player.c
14
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;
|
||||
|
|
Loading…
Reference in New Issue