From 161338752c66c8cc05533dd0039137ff3683792f Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Mon, 2 Dec 2013 22:19:12 +0100 Subject: [PATCH] Support for genre tag in dacp playqueue-edit queuefilter --- src/player.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/player.c b/src/player.c index 6928424a..97ebd962 100644 --- a/src/player.c +++ b/src/player.c @@ -709,7 +709,9 @@ player_queue_make_daap(struct player_source **head, const char *query, const cha int plid; int idx; int ret; - char buf[200]; + int len; + char *s; + char buf[1024]; /* If query doesn't give even a single result give up */ ret = fetch_first_query_match(query, &dbmfi); @@ -729,13 +731,17 @@ player_queue_make_daap(struct player_source **head, const char *query, const cha safe_atou32(dbmfi.id, &id); qp.sort = S_ALBUM; qp.type = Q_ITEMS; - snprintf(buf, sizeof(buf), "f.album_artist = \"%s\"", db_escape_string(dbmfi.album_artist)); + s = db_escape_string(dbmfi.album_artist); + if (!s) + return -1; + snprintf(buf, sizeof(buf), "f.album_artist = '%s'", s); qp.filter = strdup(buf); } else if (queuefilter) { safe_atou32(dbmfi.id, &id); - if ((strlen(queuefilter) > 6) && (strncmp(queuefilter, "album:", 6) == 0)) + len = strlen(queuefilter); + if ((len > 6) && (strncmp(queuefilter, "album:", 6) == 0)) { qp.type = Q_ITEMS; ret = safe_atoi64(strchr(queuefilter, ':') + 1, &albumid); @@ -748,7 +754,7 @@ 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 ((strlen(queuefilter) > 9) && (strncmp(queuefilter, "playlist:", 9) == 0)) + else if ((len > 9) && (strncmp(queuefilter, "playlist:", 9) == 0)) { qp.type = Q_PLITEMS; ret = safe_atoi32(strchr(queuefilter, ':') + 1, &plid); @@ -761,6 +767,15 @@ player_queue_make_daap(struct player_source **head, const char *query, const cha qp.id = plid; qp.filter = strdup("1 = 1"); } + else if ((len > 6) && (strncmp(queuefilter, "genre:", 6) == 0)) + { + qp.type = Q_ITEMS; + s = db_escape_string(queuefilter + 6); + if (!s) + return -1; + snprintf(buf, sizeof(buf), "f.genre = '%s'", s); + qp.filter = strdup(buf); + } else { DPRINTF(E_LOG, L_PLAYER, "Unknown queuefilter: %s\n", queuefilter);