sound-juicer r1996 - in trunk: . libjuicer src



Author: rburton
Date: Tue Jan 22 20:46:34 2008
New Revision: 1996
URL: http://svn.gnome.org/viewvc/sound-juicer?rev=1996&view=rev

Log:
2008-01-22  Ross Burton  <ross burtonini com>

	* libjuicer/sj-metadata-musicbrainz.c:
	Look for album titles with "(disc X)" in and extract the disc number.

	* src/sj-main.c:
	Update the UI from the disk number if it is set.

	#510439, thanks to Matthew Martin.


Modified:
   trunk/ChangeLog
   trunk/libjuicer/sj-metadata-musicbrainz.c
   trunk/src/sj-main.c

Modified: trunk/libjuicer/sj-metadata-musicbrainz.c
==============================================================================
--- trunk/libjuicer/sj-metadata-musicbrainz.c	(original)
+++ trunk/libjuicer/sj-metadata-musicbrainz.c	Tue Jan 22 20:46:34 2008
@@ -58,6 +58,7 @@
   /* TODO: remove and use an async queue? */
   GList *albums;
   GError *error;
+  GRegex *disc_regex;
 };
 
 #define GET_PRIVATE(o)  \
@@ -330,6 +331,7 @@
   SjMetadataMusicbrainzPrivate *priv;
   GList *albums = NULL;
   GList *al, *tl;
+  GMatchInfo *info;
   char data[256];
   int num_albums, i, j;
   NautilusBurnMediaType type;
@@ -421,6 +423,22 @@
       album->title = g_strdup (_("Unknown Title"));
     }
 
+    if (g_regex_match (priv->disc_regex, album->title, 0, &info)) {
+      int pos = 0;
+      char *s;
+ 
+      g_match_info_fetch_pos (info, 1, &pos, NULL);
+      if (pos) {
+        g_free (album->title);
+        album->title = g_strndup (album->title, pos);
+      }
+      
+      s = g_match_info_fetch (info, 2);
+      album->disc_number = atoi (s);
+      g_free (s);
+    }
+    g_match_info_free (info);
+
     {
       int num_releases;
       num_releases = mb_GetResultInt (priv->mb, MBE_AlbumGetNumReleaseDates);
@@ -633,6 +651,8 @@
   if (g_getenv("MUSICBRAINZ_DEBUG")) {
     mb_SetDebug (self->priv->mb, TRUE);
   }
+
+  self->priv->disc_regex = g_regex_new (".+( \\(disc (\\d+).*)", 0, 0, NULL);
 }
 
 static void
@@ -698,6 +718,7 @@
 
   g_free (priv->http_proxy);
   g_free (priv->cdrom);
+  g_regex_unref (priv->disc_regex);
   mb_Delete (priv->mb);
 
   G_OBJECT_CLASS (sj_metadata_musicbrainz_parent_class)->finalize (object);

Modified: trunk/src/sj-main.c
==============================================================================
--- trunk/src/sj-main.c	(original)
+++ trunk/src/sj-main.c	Tue Jan 22 20:46:34 2008
@@ -522,6 +522,9 @@
     g_signal_handlers_block_by_func (disc_number_entry, on_disc_number_edit_changed, NULL);
     gtk_entry_set_text (GTK_ENTRY (title_entry), album->title);
     gtk_entry_set_text (GTK_ENTRY (artist_entry), album->artist);
+    if (album->disc_number) {
+      gtk_entry_set_text (GTK_ENTRY (disc_number_entry), g_strdup_printf ("%d", album->disc_number));
+    }
     if (g_date_valid (album->release_date)) {
       gtk_entry_set_text (GTK_ENTRY (year_entry), g_strdup_printf ("%d", g_date_get_year (album->release_date)));
     }



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