LCD4Linux MPD Date/Track/Disc patch August 08, 2014 04:29PM |
Registered: 13 years ago Posts: 26 |
--- plugin_mpd.c 2011-07-27 02:53:04.000000000 +0000 +++ plugin_mpd.c 2014-08-08 22:09:44.029630371 +0000 @@ -1,5 +1,5 @@ -/* $Id$ - * $URL$ +/* $Id: plugin_mpd.c 1150 2011-07-27 02:53:04Z michael $ + * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/plugin_mpd.c $ * * mpd informations v0.82 * @@ -67,6 +67,12 @@ * changelog v0.83 (26.07.2008): * added: -mpd::cmd* commands * + * + * changelog v0.83b (09.08.2014) - Tsuñulukaï patch: + * added: -mpd::disc - song disc number + * -mpd::track - song track number + * -mpd::date - song year + * */ /* @@ -576,6 +582,45 @@ SetResult(&result, R_STRING, ""); } +static void getTrack(RESULT * result) +{ + const char *value = NULL; + mpd_update(); + if (currentSong != NULL) { + value = mpd_song_get_tag(currentSong, MPD_TAG_TRACK, 0); + } + if (value) + SetResult(&result, R_STRING, charset_from_utf8(value)); + else + SetResult(&result, R_STRING, ""); +} + +static void getDisc(RESULT * result) +{ + const char *value = NULL; + mpd_update(); + if (currentSong != NULL) { + value = mpd_song_get_tag(currentSong, MPD_TAG_DISC, 0); + } + if (value) + SetResult(&result, R_STRING, charset_from_utf8(value)); + else + SetResult(&result, R_STRING, ""); +} + +static void getDate(RESULT * result) +{ + const char *value = NULL; + mpd_update(); + if (currentSong != NULL) { + value = mpd_song_get_tag(currentSong, MPD_TAG_DATE, 0); + } + if (value) + SetResult(&result, R_STRING, charset_from_utf8(value)); + else + SetResult(&result, R_STRING, ""); +} + static void getFilename(RESULT * result) { const char *value = NULL; @@ -881,6 +926,9 @@ AddFunction("mpd::artist", 0, getArtist); AddFunction("mpd::title", 0, getTitle); AddFunction("mpd::album", 0, getAlbum); + AddFunction("mpd::track", 0, getTrack); + AddFunction("mpd::disc", 0, getDisc); + AddFunction("mpd::date", 0, getDate); AddFunction("mpd::file", 0, getFilename); AddFunction("mpd::totalTimeSec", 0, totalTimeSec); AddFunction("mpd::elapsedTimeSec", 0, elapsedTimeSec);