add to libmpdclient support for getting list of any tag type
This commit is contained in:
@@ -1340,9 +1340,41 @@ void mpd_sendListCommand(mpd_Connection * connection, int table,
|
|||||||
char st[10];
|
char st[10];
|
||||||
int len;
|
int len;
|
||||||
char *string;
|
char *string;
|
||||||
if(table == MPD_TABLE_ARTIST) strcpy(st,"artist");
|
switch(table) {
|
||||||
else if(table == MPD_TABLE_ALBUM) strcpy(st,"album");
|
case MPD_TABLE_ARTIST:
|
||||||
else {
|
strcpy(st,"artist");
|
||||||
|
break;
|
||||||
|
case MPD_TABLE_ALBUM:
|
||||||
|
strcpy(st,"album");
|
||||||
|
break;
|
||||||
|
case MPD_TABLE_TITLE:
|
||||||
|
strcpy(st,"title");
|
||||||
|
break;
|
||||||
|
case MPD_TABLE_TRACK:
|
||||||
|
strcpy(st,"track");
|
||||||
|
break;
|
||||||
|
case MPD_TABLE_GENRE:
|
||||||
|
strcpy(st,"genre");
|
||||||
|
break;
|
||||||
|
case MPD_TABLE_DATE:
|
||||||
|
strcpy(st,"date");
|
||||||
|
break;
|
||||||
|
case MPD_TABLE_COMPOSER:
|
||||||
|
strcpy(st,"composer");
|
||||||
|
break;
|
||||||
|
case MPD_TABLE_PERFORMER:
|
||||||
|
strcpy(st,"performer");
|
||||||
|
break;
|
||||||
|
case MPD_TABLE_COMMENT:
|
||||||
|
strcpy(st,"comment");
|
||||||
|
break;
|
||||||
|
case MPD_TABLE_DISC:
|
||||||
|
strcpy(st,"disc");
|
||||||
|
break;
|
||||||
|
case MPD_TABLE_FILENAME:
|
||||||
|
strcpy(st,"filename");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
connection->error = 1;
|
connection->error = 1;
|
||||||
strcpy(connection->errorStr,"unknown table for list");
|
strcpy(connection->errorStr,"unknown table for list");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -431,6 +431,13 @@ void mpd_sendLsInfoCommand(mpd_Connection * connection, const char * dir);
|
|||||||
#define MPD_TABLE_ARTIST MPD_TAG_ITEM_ARTIST
|
#define MPD_TABLE_ARTIST MPD_TAG_ITEM_ARTIST
|
||||||
#define MPD_TABLE_ALBUM MPD_TAG_ITEM_ALBUM
|
#define MPD_TABLE_ALBUM MPD_TAG_ITEM_ALBUM
|
||||||
#define MPD_TABLE_TITLE MPD_TAG_ITEM_TITLE
|
#define MPD_TABLE_TITLE MPD_TAG_ITEM_TITLE
|
||||||
|
#define MPD_TABLE_TRACK MPD_TAG_ITEM_TRACK
|
||||||
|
#define MPD_TABLE_GENRE MPD_TAG_ITEM_GENRE
|
||||||
|
#define MPD_TABLE_DATE MPD_TAG_ITEM_DATE
|
||||||
|
#define MPD_TABLE_COMPOSER MPD_TAG_ITEM_COMPOSER
|
||||||
|
#define MPD_TABLE_PERFORMER MPD_TAG_ITEM_PERFORMER
|
||||||
|
#define MPD_TABLE_COMMENT MPD_TAG_ITEM_COMMENT
|
||||||
|
#define MPD_TABLE_DISC MPD_TAG_ITEM_DISC
|
||||||
#define MPD_TABLE_FILENAME MPD_TAG_ITEM_FILENAME
|
#define MPD_TABLE_FILENAME MPD_TAG_ITEM_FILENAME
|
||||||
|
|
||||||
void mpd_sendSearchCommand(mpd_Connection * connection, int table,
|
void mpd_sendSearchCommand(mpd_Connection * connection, int table,
|
||||||
|
|||||||
@@ -628,6 +628,21 @@ void MPDConnection::GetPlaylists(TagList &v) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MPDConnection::GetList(TagList &v, mpd_TagItems type) const
|
||||||
|
{
|
||||||
|
if (isConnected)
|
||||||
|
{
|
||||||
|
mpd_sendListCommand(itsConnection, type, NULL);
|
||||||
|
char *item;
|
||||||
|
while ((item = mpd_getNextTag(itsConnection, type)) != NULL)
|
||||||
|
{
|
||||||
|
v.push_back(item);
|
||||||
|
delete [] item;
|
||||||
|
}
|
||||||
|
mpd_finishCommand(itsConnection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MPDConnection::GetArtists(TagList &v) const
|
void MPDConnection::GetArtists(TagList &v) const
|
||||||
{
|
{
|
||||||
if (isConnected)
|
if (isConnected)
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ class MPDConnection
|
|||||||
void CommitSearch(TagList &) const;
|
void CommitSearch(TagList &) const;
|
||||||
|
|
||||||
void GetPlaylists(TagList &) const;
|
void GetPlaylists(TagList &) const;
|
||||||
|
void GetList(TagList &, mpd_TagItems) const;
|
||||||
void GetArtists(TagList &) const;
|
void GetArtists(TagList &) const;
|
||||||
void GetAlbums(string, TagList &) const;
|
void GetAlbums(string, TagList &) const;
|
||||||
void GetDirectory(const string &, ItemList &) const;
|
void GetDirectory(const string &, ItemList &) const;
|
||||||
|
|||||||
@@ -436,16 +436,7 @@ int main(int argc, char *argv[])
|
|||||||
TagList list;
|
TagList list;
|
||||||
mLibAlbums->Clear(0);
|
mLibAlbums->Clear(0);
|
||||||
mLibSongs->Clear(0);
|
mLibSongs->Clear(0);
|
||||||
if (Config.media_lib_primary_tag == MPD_TAG_ITEM_ARTIST)
|
Mpd->GetList(list, Config.media_lib_primary_tag);
|
||||||
Mpd->GetArtists(list);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Mpd->StartSearch(0);
|
|
||||||
Mpd->AddSearch(Config.media_lib_primary_tag, "");
|
|
||||||
Mpd->StartFieldSearch(Config.media_lib_primary_tag);
|
|
||||||
Mpd->CommitSearch(list);
|
|
||||||
sort(list.begin(), list.end());
|
|
||||||
}
|
|
||||||
sort(list.begin(), list.end(), CaseInsensitiveSorting());
|
sort(list.begin(), list.end(), CaseInsensitiveSorting());
|
||||||
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user