mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-29 08:33:23 -05:00
[mpd] support "file" argument in list command
This commit is contained in:
parent
4299de5ac7
commit
2a04740ca2
5
src/db.c
5
src/db.c
@ -287,6 +287,7 @@ static const char *sort_clause[] =
|
|||||||
"ORDER BY f.composer_sort ASC",
|
"ORDER BY f.composer_sort ASC",
|
||||||
"ORDER BY f.disc ASC",
|
"ORDER BY f.disc ASC",
|
||||||
"ORDER BY f.track ASC",
|
"ORDER BY f.track ASC",
|
||||||
|
"ORDER BY f.virtual_path ASC",
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *db_path;
|
static char *db_path;
|
||||||
@ -1529,6 +1530,10 @@ db_query_start(struct query_params *qp)
|
|||||||
ret = db_build_query_browse(qp, "track", "track", &query);
|
ret = db_build_query_browse(qp, "track", "track", &query);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Q_BROWSE_VPATH:
|
||||||
|
ret = db_build_query_browse(qp, "virtual_path", "virtual_path", &query);
|
||||||
|
break;
|
||||||
|
|
||||||
case Q_COUNT_ITEMS:
|
case Q_COUNT_ITEMS:
|
||||||
ret = db_build_query_count_items(qp, &query);
|
ret = db_build_query_count_items(qp, &query);
|
||||||
break;
|
break;
|
||||||
|
32
src/db.h
32
src/db.h
@ -27,26 +27,28 @@ enum sort_type {
|
|||||||
S_COMPOSER,
|
S_COMPOSER,
|
||||||
S_DISC,
|
S_DISC,
|
||||||
S_TRACK,
|
S_TRACK,
|
||||||
|
S_VPATH,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define Q_F_BROWSE (1 << 15)
|
#define Q_F_BROWSE (1 << 15)
|
||||||
|
|
||||||
enum query_type {
|
enum query_type {
|
||||||
Q_ITEMS = (1 << 0),
|
Q_ITEMS = 1,
|
||||||
Q_PL = (1 << 1),
|
Q_PL = 2,
|
||||||
Q_PLITEMS = (1 << 2),
|
Q_PLITEMS = 3,
|
||||||
Q_BROWSE_ARTISTS = Q_F_BROWSE | (1 << 3),
|
Q_BROWSE_ARTISTS = Q_F_BROWSE | 4,
|
||||||
Q_BROWSE_ALBUMS = Q_F_BROWSE | (1 << 4),
|
Q_BROWSE_ALBUMS = Q_F_BROWSE | 5,
|
||||||
Q_BROWSE_GENRES = Q_F_BROWSE | (1 << 5),
|
Q_BROWSE_GENRES = Q_F_BROWSE | 6,
|
||||||
Q_BROWSE_COMPOSERS = Q_F_BROWSE | (1 << 6),
|
Q_BROWSE_COMPOSERS = Q_F_BROWSE | 7,
|
||||||
Q_GROUP_ALBUMS = (1 << 7),
|
Q_GROUP_ALBUMS = 8,
|
||||||
Q_GROUP_ARTISTS = (1 << 8),
|
Q_GROUP_ARTISTS = 9,
|
||||||
Q_GROUP_ITEMS = (1 << 9),
|
Q_GROUP_ITEMS = 10,
|
||||||
Q_GROUP_DIRS = Q_F_BROWSE | (1 << 10),
|
Q_GROUP_DIRS = Q_F_BROWSE | 11,
|
||||||
Q_BROWSE_YEARS = Q_F_BROWSE | (1 << 11),
|
Q_BROWSE_YEARS = Q_F_BROWSE | 12,
|
||||||
Q_COUNT_ITEMS = (1 << 12),
|
Q_COUNT_ITEMS = 13,
|
||||||
Q_BROWSE_DISCS = Q_F_BROWSE | (1 << 13),
|
Q_BROWSE_DISCS = Q_F_BROWSE | 14,
|
||||||
Q_BROWSE_TRACKS = Q_F_BROWSE | (1 << 14),
|
Q_BROWSE_TRACKS = Q_F_BROWSE | 15,
|
||||||
|
Q_BROWSE_VPATH = Q_F_BROWSE | 16,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ARTWORK_UNKNOWN 0
|
#define ARTWORK_UNKNOWN 0
|
||||||
|
20
src/mpd.c
20
src/mpd.c
@ -2431,6 +2431,12 @@ mpd_command_list(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
|
|||||||
qp.sort = S_TRACK;
|
qp.sort = S_TRACK;
|
||||||
type = "Track: ";
|
type = "Track: ";
|
||||||
}
|
}
|
||||||
|
else if (0 == strcasecmp(argv[1], "file"))
|
||||||
|
{
|
||||||
|
qp.type = Q_BROWSE_VPATH;
|
||||||
|
qp.sort = S_VPATH;
|
||||||
|
type = "file: ";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DPRINTF(E_WARN, L_MPD, "Unsupported type argument for command 'list': %s\n", argv[1]);
|
DPRINTF(E_WARN, L_MPD, "Unsupported type argument for command 'list': %s\n", argv[1]);
|
||||||
@ -2456,6 +2462,19 @@ mpd_command_list(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (qp.type & Q_F_BROWSE)
|
if (qp.type & Q_F_BROWSE)
|
||||||
|
{
|
||||||
|
if (qp.type == Q_BROWSE_VPATH)
|
||||||
|
{
|
||||||
|
while (((ret = db_query_fetch_string_sort(&qp, &browse_item, &sort_item)) == 0) && (browse_item))
|
||||||
|
{
|
||||||
|
// Remove the first "/" from the virtual_path
|
||||||
|
evbuffer_add_printf(evbuf,
|
||||||
|
"%s%s\n",
|
||||||
|
type,
|
||||||
|
(browse_item + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
while (((ret = db_query_fetch_string_sort(&qp, &browse_item, &sort_item)) == 0) && (browse_item))
|
while (((ret = db_query_fetch_string_sort(&qp, &browse_item, &sort_item)) == 0) && (browse_item))
|
||||||
{
|
{
|
||||||
@ -2465,6 +2484,7 @@ mpd_command_list(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
|
|||||||
browse_item);
|
browse_item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while ((ret = db_query_fetch_group(&qp, &dbgri)) == 0)
|
while ((ret = db_query_fetch_group(&qp, &dbgri)) == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user