commit f73613f6c56516c7a3f36cc4e23b1861e563ff7d
parent ec19af89f4a0e6851bdb3623e5c6e046af7be80a
Author: sin <sin@2f30.org>
Date: Mon, 26 Sep 2016 16:26:53 +0100
Display song filename if the file doesn't have any tags
Diffstat:
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/spoon.c b/spoon.c
@@ -46,7 +46,7 @@ mpdread(char *buf, size_t len)
{
static struct mpd_connection *conn;
struct mpd_song *song;
- const char *artist, *title;
+ const char *artist, *title, *name;
int ret = 0;
if (conn == NULL) {
@@ -69,8 +69,13 @@ mpdread(char *buf, size_t len)
} else if (title != NULL) {
strlcpy(buf, title, len);
} else {
- ret = -1;
- goto out;
+ name = mpd_song_get_uri(song);
+ if (name == NULL) {
+ mpd_song_free(song);
+ ret = -1;
+ goto out;
+ }
+ strlcpy(buf, name, len);
}
mpd_song_free(song);
if (!mpd_response_finish(conn)) {