[sound-juicer] Use only the UUID part of MusicBrainz IDs.



commit 48ff7aaae5966de125404cc8e39df4014147c780
Author: Philipp Wolfer <ph wolfer googlemail com>
Date:   Mon Aug 17 23:05:06 2009 +0200

    Use only the UUID part of MusicBrainz IDs.

 configure.in                         |    5 ++++
 libjuicer/sj-metadata-musicbrainz3.c |   36 ++++++++++++++++++++++-----------
 2 files changed, 29 insertions(+), 12 deletions(-)
---
diff --git a/configure.in b/configure.in
index 91e3db9..c72f753 100644
--- a/configure.in
+++ b/configure.in
@@ -106,6 +106,11 @@ LIBS="$LIBS $MUSICBRAINZ_LIBS"
 AC_CHECK_FUNCS(mb_SetProxyCreds)
 LIBS="$oldlibs"
 
+oldlibs=$LIBS
+LIBS="$LIBS $MUSICBRAINZ3_LIBS"
+AC_CHECK_FUNCS(mb_extract_uuid)
+LIBS="$oldlibs"
+
 # Find gio for the metadata extractor
 PKG_CHECK_MODULES(GIO, gio-2.0)
 AC_SUBST(GIO_CFLAGS)
diff --git a/libjuicer/sj-metadata-musicbrainz3.c b/libjuicer/sj-metadata-musicbrainz3.c
index 785b4a2..7dfd7c2 100644
--- a/libjuicer/sj-metadata-musicbrainz3.c
+++ b/libjuicer/sj-metadata-musicbrainz3.c
@@ -44,6 +44,25 @@
 		field = g_strdup (buffer);					\
 }
 
+#if HAVE_MB_EXTRACT_UUID
+#define GET_ID(field, function, obj) {						\
+        function (obj, buffer, sizeof (buffer));				\
+	mb_extract_uuid (buffer, uuid_buffer, sizeof (uuid_buffer));		\
+	if (field)								\
+		g_free (field);							\
+	if (*uuid_buffer == '\0')						\
+		field = NULL;							\
+	else									\
+		field = g_strdup (uuid_buffer);					\
+}
+#else
+#define GET_ID(field, function, obj) {						\
+	if (field)								\
+		g_free (field);							\
+	field = NULL;								\
+}
+#endif /* HAVE_MB_EXTRACT_UUID */
+
 #define GCONF_MUSICBRAINZ_SERVER "/apps/sound-juicer/musicbrainz_server"
 #define GCONF_PROXY_USE_PROXY "/system/http_proxy/use_http_proxy"
 #define GCONF_PROXY_HOST "/system/http_proxy/host"
@@ -90,6 +109,7 @@ make_album_from_release (MbRelease *release)
 {
   AlbumDetails *album;
   char buffer[512];
+  char uuid_buffer[37];
   MbArtist artist;
   char *new_title;
   int i;
@@ -98,15 +118,7 @@ make_album_from_release (MbRelease *release)
 
   album = g_new0 (AlbumDetails, 1);
 
-   /* Some versions of libmusicbrainz3 seem to forget the trailing .html in the URL */
-  GET (album->album_id, mb_release_get_id, release);
-  if (album->album_id && g_str_has_suffix (album->album_id, ".html") == FALSE) {
-    char *tmp;
-    tmp = g_strdup_printf ("%s.html", album->album_id);
-    g_free (album->album_id);
-    album->album_id = tmp;
-  }
-
+  GET_ID (album->album_id, mb_release_get_id, release);
   GET (album->title, mb_release_get_title, release);
   new_title = sj_metadata_helper_scan_disc_number (album->title, &album->disc_number);
   if (new_title) {
@@ -115,7 +127,7 @@ make_album_from_release (MbRelease *release)
   }
 
   artist = mb_release_get_artist (release);
-  GET (album->artist_id, mb_artist_get_id, artist);
+  GET_ID (album->artist_id, mb_artist_get_id, artist);
   GET (album->artist, mb_artist_get_name, artist);
   GET (album->artist_sortname, mb_artist_get_sortname, artist);
 
@@ -168,7 +180,7 @@ make_album_from_release (MbRelease *release)
     track->album = album;
 
     track->number = i + 1;
-    GET (track->track_id, mb_track_get_id, mbt);
+    GET_ID (track->track_id, mb_track_get_id, mbt);
 
     GET (track->title, mb_track_get_title, mbt);
     track->duration = mb_track_get_duration (mbt) / 1000;
@@ -176,7 +188,7 @@ make_album_from_release (MbRelease *release)
     artist = mb_track_get_artist (mbt);
     if (artist == NULL)
       artist = mb_release_get_artist (release);
-    GET (track->artist_id, mb_artist_get_id, artist);
+    GET_ID (track->artist_id, mb_artist_get_id, artist);
     GET (track->artist, mb_artist_get_name, artist);
     GET (track->artist_sortname, mb_artist_get_sortname, artist);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]