1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-17 10:35:10 +00:00

MPD: add mpd_albumartist (sf.net #3532376)

Adds mpd_albumartist support as an object since mpd_artist lists all participating artists of the
current song and not the main album artist.

patch by Sébastien Lavoie-Courchesne
This commit is contained in:
Pavel Labath 2012-10-07 11:46:31 +02:00
parent ef2855080e
commit 5177c8d282
6 changed files with 27 additions and 0 deletions

View File

@ -2471,6 +2471,15 @@
compile compile
<para /></listitem> <para /></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>
<command>
<option>mpd_albumartist</option>
</command>
</term>
<listitem>Artist of the album of the current MPD song.
<para /></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term> <term>
<command> <command>

View File

@ -1421,6 +1421,9 @@ struct text_object *construct_text_object(char *s, const char *arg,
END OBJ(mpd_artist, 0) END OBJ(mpd_artist, 0)
mpd_set_maxlen(mpd_artist); mpd_set_maxlen(mpd_artist);
obj->callbacks.print = &print_mpd_artist; obj->callbacks.print = &print_mpd_artist;
END OBJ(mpd_albumartist, 0)
mpd_set_maxlen(mpd_albumartist);
obj->callbacks.print = &print_mpd_albumartist;
END OBJ(mpd_title, 0) END OBJ(mpd_title, 0)
mpd_set_maxlen(mpd_title); mpd_set_maxlen(mpd_title);
obj->callbacks.print = &print_mpd_title; obj->callbacks.print = &print_mpd_title;

View File

@ -986,6 +986,7 @@ static void mpd_initSong(mpd_Song *song)
{ {
song->file = NULL; song->file = NULL;
song->artist = NULL; song->artist = NULL;
song->albumartist = NULL;
song->album = NULL; song->album = NULL;
song->track = NULL; song->track = NULL;
song->title = NULL; song->title = NULL;
@ -1007,6 +1008,7 @@ static void mpd_finishSong(mpd_Song *song)
{ {
free_and_zero(song->file); free_and_zero(song->file);
free_and_zero(song->artist); free_and_zero(song->artist);
free_and_zero(song->albumartist);
free_and_zero(song->album); free_and_zero(song->album);
free_and_zero(song->title); free_and_zero(song->title);
free_and_zero(song->track); free_and_zero(song->track);
@ -1043,6 +1045,9 @@ mpd_Song *mpd_songDup(mpd_Song *song)
if (song->artist) { if (song->artist) {
ret->artist = strndup(song->artist, text_buffer_size.get(*state)); ret->artist = strndup(song->artist, text_buffer_size.get(*state));
} }
if (song->albumartist) {
ret->artist = strndup(song->albumartist, text_buffer_size.get(*state));
}
if (song->album) { if (song->album) {
ret->album = strndup(song->album, text_buffer_size.get(*state)); ret->album = strndup(song->album, text_buffer_size.get(*state));
} }
@ -1251,6 +1256,9 @@ mpd_InfoEntity *mpd_getNextInfoEntity(mpd_Connection *connection)
if (!entity->info.song->artist if (!entity->info.song->artist
&& strcmp(re->name, "Artist") == 0) { && strcmp(re->name, "Artist") == 0) {
entity->info.song->artist = strndup(re->value, text_buffer_size.get(*state)); entity->info.song->artist = strndup(re->value, text_buffer_size.get(*state));
} else if (!entity->info.song->albumartist
&& strcmp(re->name, "AlbumArtist") == 0) {
entity->info.song->albumartist = strndup(re->value, text_buffer_size.get(*state));
} else if (!entity->info.song->album } else if (!entity->info.song->album
&& strcmp(re->name, "Album") == 0) { && strcmp(re->name, "Album") == 0) {
entity->info.song->album = strndup(re->value, text_buffer_size.get(*state)); entity->info.song->album = strndup(re->value, text_buffer_size.get(*state));

View File

@ -1,4 +1,5 @@
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
* vim: ts=4 sw=4 noet ai cindent syntax=c
* *
* libmpdclient * libmpdclient
* (c)2003-2006 by Warren Dukes (warren.dukes@gmail.com) * (c)2003-2006 by Warren Dukes (warren.dukes@gmail.com)
@ -74,6 +75,7 @@
typedef enum mpd_TagItems { typedef enum mpd_TagItems {
MPD_TAG_ITEM_ARTIST, MPD_TAG_ITEM_ARTIST,
MPD_TAG_ITEM_ALBUMARTIST,
MPD_TAG_ITEM_ALBUM, MPD_TAG_ITEM_ALBUM,
MPD_TAG_ITEM_TITLE, MPD_TAG_ITEM_TITLE,
MPD_TAG_ITEM_TRACK, MPD_TAG_ITEM_TRACK,
@ -241,6 +243,8 @@ typedef struct _mpd_Song {
char *file; char *file;
/* artist, maybe NULL if there is no tag */ /* artist, maybe NULL if there is no tag */
char *artist; char *artist;
/* albumartist, maybe NULL if there is no tag */
char *albumartist;
/* title, maybe NULL if there is no tag */ /* title, maybe NULL if there is no tag */
char *title; char *title;
/* album, maybe NULL if there is no tag */ /* album, maybe NULL if there is no tag */

View File

@ -122,6 +122,7 @@ namespace {
struct mpd_result { struct mpd_result {
std::string title; std::string title;
std::string artist; std::string artist;
std::string albumartist;
std::string album; std::string album;
std::string date; std::string date;
std::string status; std::string status;
@ -398,6 +399,7 @@ void print_mpd_##name(struct text_object *obj, char *p, int p_max_size) \
MPD_PRINT_GENERATOR(title, "%s", .c_str()) MPD_PRINT_GENERATOR(title, "%s", .c_str())
MPD_PRINT_GENERATOR(artist, "%s", .c_str()) MPD_PRINT_GENERATOR(artist, "%s", .c_str())
MPD_PRINT_GENERATOR(albumartist, "%s", .c_str())
MPD_PRINT_GENERATOR(album, "%s", .c_str()) MPD_PRINT_GENERATOR(album, "%s", .c_str())
MPD_PRINT_GENERATOR(date, "%s", .c_str()) MPD_PRINT_GENERATOR(date, "%s", .c_str())
MPD_PRINT_GENERATOR(random, "%s", .c_str()) MPD_PRINT_GENERATOR(random, "%s", .c_str())

View File

@ -34,6 +34,7 @@ double mpd_barval(struct text_object *);
void print_mpd_smart(struct text_object *, char *, int); void print_mpd_smart(struct text_object *, char *, int);
void print_mpd_title(struct text_object *, char *, int); void print_mpd_title(struct text_object *, char *, int);
void print_mpd_artist(struct text_object *, char *, int); void print_mpd_artist(struct text_object *, char *, int);
void print_mpd_albumartist(struct text_object *, char *, int);
void print_mpd_album(struct text_object *, char *, int); void print_mpd_album(struct text_object *, char *, int);
void print_mpd_date(struct text_object *, char *, int); void print_mpd_date(struct text_object *, char *, int);
void print_mpd_random(struct text_object *, char *, int); void print_mpd_random(struct text_object *, char *, int);