diff --git a/src/db.c b/src/db.c index abcca76a..6163b1ae 100644 --- a/src/db.c +++ b/src/db.c @@ -1539,6 +1539,10 @@ db_query_start(struct query_params *qp) ret = db_build_query_browse(qp, "disc", "disc", &query); break; + case Q_BROWSE_TRACKS: + ret = db_build_query_browse(qp, "track", "track", &query); + break; + case Q_COUNT_ITEMS: ret = db_build_query_count_items(qp, &query); break; diff --git a/src/db.h b/src/db.h index d5f6ef6e..aa87b84e 100644 --- a/src/db.h +++ b/src/db.h @@ -42,6 +42,7 @@ enum query_type { Q_BROWSE_YEARS = Q_F_BROWSE | (1 << 11), Q_COUNT_ITEMS = (1 << 12), Q_BROWSE_DISCS = Q_F_BROWSE | (1 << 13), + Q_BROWSE_TRACKS = Q_F_BROWSE | (1 << 14), }; #define ARTWORK_UNKNOWN 0 diff --git a/src/mpd.c b/src/mpd.c index 30cafdb2..945bd461 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -1991,6 +1991,14 @@ mpd_get_query_params_find(int argc, char **argv, struct query_params *qp) else c1 = sqlite3_mprintf("(f.disc = %d)", num); } + else if (0 == strcasecmp(argv[i], "track")) + { + ret = safe_atou32(argv[i + 1], &num); + if (ret < 0) + DPRINTF(E_WARN, L_MPD, "Track parameter '%s' is not an integer and will be ignored\n", argv[i + 1]); + else + c1 = sqlite3_mprintf("(f.track = %d)", num); + } else if (i == 0 && argc == 1) { // Special case: a single token is allowed if listing albums for an artist @@ -2226,6 +2234,12 @@ mpd_command_list(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) qp.sort = S_NONE; type = "Disc: "; } + else if (0 == strcasecmp(argv[1], "track")) + { + qp.type = Q_BROWSE_TRACKS; + qp.sort = S_NONE; + type = "Track: "; + } else { DPRINTF(E_WARN, L_MPD, "Unsupported type argument for command 'list': %s\n", argv[1]); @@ -2450,6 +2464,14 @@ mpd_get_query_params_search(int argc, char **argv, struct query_params *qp) else c1 = sqlite3_mprintf("(f.disc = %d)", num); } + else if (0 == strcasecmp(argv[i], "track")) + { + ret = safe_atou32(argv[i + 1], &num); + if (ret < 0) + DPRINTF(E_WARN, L_MPD, "Track parameter '%s' is not an integer and will be ignored\n", argv[i + 1]); + else + c1 = sqlite3_mprintf("(f.track = %d)", num); + } else { DPRINTF(E_WARN, L_MPD, "Parameter '%s' is not supported by forked-daapd and will be ignored\n", argv[i]);