[httpd_daap] Honour sort param "artist" for album groups (fixes issue #358)

This commit is contained in:
ejurgensen 2017-03-05 09:45:34 +01:00
parent 9f2f5566d2
commit 6c94cdd635

View File

@ -666,15 +666,10 @@ get_query_params(struct evkeyvalq *query, int *sort_headers, struct query_params
{ {
*sort_headers = 0; *sort_headers = 0;
param = evhttp_find_header(query, "include-sort-headers"); param = evhttp_find_header(query, "include-sort-headers");
if (param) if (param && (strcmp(param, "1") == 0))
{ {
if (strcmp(param, "1") == 0) *sort_headers = 1;
{ DPRINTF(E_SPAM, L_DAAP, "Sort headers requested\n");
*sort_headers = 1;
DPRINTF(E_DBG, L_DAAP, "Sort headers requested\n");
}
else
DPRINTF(E_DBG, L_DAAP, "Unknown include-sort-headers param: %s\n", param);
} }
} }
@ -1661,7 +1656,8 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
memset(&qp, 0, sizeof(struct query_params)); memset(&qp, 0, sizeof(struct query_params));
get_query_params(query, NULL, &qp); get_query_params(query, NULL, &qp);
qp.type = Q_PL; qp.type = Q_PL;
qp.sort = S_PLAYLIST; if (qp.sort == S_NONE)
qp.sort = S_PLAYLIST;
ret = db_query_start(&qp); ret = db_query_start(&qp);
if (ret < 0) if (ret < 0)
@ -1876,15 +1872,22 @@ daap_reply_groups(struct evhttp_request *req, struct evbuffer *evbuf, char **uri
param = evhttp_find_header(query, "group-type"); param = evhttp_find_header(query, "group-type");
if (strcmp(param, "artists") == 0) if (strcmp(param, "artists") == 0)
{ {
// Request from Remote may have the form:
// groups?meta=dmap.xxx,dma...&type=music&group-type=artists&sort=album&include-sort-headers=1&query=('...')&session-id=...
// Note: Since grouping by artist and sorting by album is crazy we override
tag = "agar"; tag = "agar";
qp.type = Q_GROUP_ARTISTS; qp.type = Q_GROUP_ARTISTS;
qp.sort = S_ARTIST; qp.sort = S_ARTIST;
} }
else else
{ {
// Request from Remote may have the form:
// groups?meta=dmap.xxx,dma...&type=music&group-type=albums&sort=artist&include-sort-headers=0&query=('...'))&session-id=...
// Sort may also be 'album'
tag = "agal"; tag = "agal";
qp.type = Q_GROUP_ALBUMS; qp.type = Q_GROUP_ALBUMS;
qp.sort = S_ALBUM; if (qp.sort == S_NONE)
qp.sort = S_ALBUM;
} }
ret = evbuffer_expand(evbuf, 61); ret = evbuffer_expand(evbuf, 61);