From 04ee234d500ff780952c0989039c203669c9c87e Mon Sep 17 00:00:00 2001 From: Qball Cow Date: Thu, 25 Sep 2008 16:39:49 +0200 Subject: [PATCH] Convert to using gmpc_get_metadata_filename --- configure.ac | 2 +- src/plugin.c | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 3cbd113..c753c4f 100644 --- a/configure.ac +++ b/configure.ac @@ -26,7 +26,7 @@ PKG_CHECK_MODULES([gmpclyricwiki],[ gthread-2.0 gio-2.0 libmpd >= 0.15.98 - gmpc >= 0.15.98 + gmpc >= 0.16.2 ]) AC_SUBST(gmpclyricwiki_LIBS) diff --git a/src/plugin.c b/src/plugin.c index 495ccf7..772d9dc 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -59,16 +59,18 @@ static int lyricwiki_fetch_get_lyric(mpd_Song *song,MetaDataType type, char **pa artist, title); printf("%s\n", uri_path); file = g_file_new_for_uri(uri_path); - - stream = (GInputStream *)g_file_read(file,NULL,NULL); + GError *error = NULL; + stream = (GInputStream *)g_file_read(file,NULL,&error); if(stream) { char buffer[1024]; gssize size; xmlParserCtxtPtr ctxt = xmlCreatePushParserCtxt(NULL, NULL, NULL, 0, NULL); + printf("trying to read stream\n"); while((size = g_input_stream_read(stream, buffer, 1024, NULL, NULL)) > 0) { + printf("read chunk of %i bytes\n", size); xmlParseChunk(ctxt, buffer, (int)size, FALSE); } /* Parse last chunk */ @@ -85,9 +87,7 @@ static int lyricwiki_fetch_get_lyric(mpd_Song *song,MetaDataType type, char **pa if(lyric && strcmp(lyric,"Not found")!= 0) { /* now we want to store it somewhere */ - gchar *filename = g_strdup_printf("%s-%s.txt", artist, title); - gchar *full_path = gmpc_get_covers_path(filename); - g_free(filename); + gchar *full_path = gmpc_get_metadata_filename(META_SONG_TXT, song, NULL); /* don't need fancy writers/loaders, just dump the file. */ if(g_file_set_contents(full_path, lyric, -1, NULL)) { @@ -108,6 +108,12 @@ static int lyricwiki_fetch_get_lyric(mpd_Song *song,MetaDataType type, char **pa g_input_stream_close(stream,NULL, NULL); xmlFreeParserCtxt(ctxt); } + else if (error) + { + printf("Failed to create stream: %s\n", error->message); + g_error_free(error); + error = NULL; + } g_object_unref(file); g_free(uri_path); xmlCleanupParser(); -- 2.11.4.GIT