Code

screen_lyrics: don't use strfsong() to obtain tags
authorMax Kellermann <max@duempel.org>
Thu, 1 Oct 2009 17:40:39 +0000 (19:40 +0200)
committerMax Kellermann <max@duempel.org>
Thu, 1 Oct 2009 17:40:39 +0000 (19:40 +0200)
Use mpd_song_get_tag().  This guarantees that the tags are encoded in
UTF-8.

src/screen_lyrics.c

index 62d5b13c6d64c9ddda8a3c1958885c9604cd5904..054ac6281df2c5dbaa5fca794d77bbdb4a27aab8 100644 (file)
@@ -24,7 +24,6 @@
 #include "mpdclient.h"
 #include "command.h"
 #include "screen.h"
-#include "strfsong.h"
 #include "lyrics.h"
 #include "screen_text.h"
 
@@ -162,20 +161,19 @@ screen_lyrics_callback(const GString *result, G_GNUC_UNUSED void *data)
 static void
 screen_lyrics_load(const struct mpd_song *song)
 {
-       char buffer[MAX_SONGNAME_LENGTH];
+       const char *artist, *title;
 
        assert(song != NULL);
 
        screen_lyrics_abort();
        screen_text_clear(&text);
 
-       current.song = mpd_song_dup(song);
-
-       strfsong(buffer, sizeof(buffer), "%artist%", song);
-       current.artist = g_strdup(buffer);
+       artist = mpd_song_get_tag(song, MPD_TAG_ARTIST, 0);
+       title = mpd_song_get_tag(song, MPD_TAG_TITLE, 0);
 
-       strfsong(buffer, sizeof(buffer), "%title%", song);
-       current.title = g_strdup(buffer);
+       current.song = mpd_song_dup(song);
+       current.artist = g_strdup(artist);
+       current.title = g_strdup(title);
 
        current.loader = lyrics_load(current.artist, current.title,
                                     screen_lyrics_callback, NULL);