sound-juicer r2282 - in trunk: . libjuicer



Author: hadess
Date: Wed Sep  3 23:27:06 2008
New Revision: 2282
URL: http://svn.gnome.org/viewvc/sound-juicer?rev=2282&view=rev

Log:
2008-09-04  Bastien Nocera  <hadess hadess net>

	* libjuicer/sj-metadata-musicbrainz.c (mb_list_albums):
	* libjuicer/sj-metadata-musicbrainz3.c (make_album_from_release):
	* libjuicer/sj-metadata.c (sj_metadata_helper_scan_date):
	* libjuicer/sj-metadata.h: Move the date parsing to a common place



Modified:
   trunk/ChangeLog
   trunk/libjuicer/sj-metadata-musicbrainz.c
   trunk/libjuicer/sj-metadata-musicbrainz3.c
   trunk/libjuicer/sj-metadata.c
   trunk/libjuicer/sj-metadata.h

Modified: trunk/libjuicer/sj-metadata-musicbrainz.c
==============================================================================
--- trunk/libjuicer/sj-metadata-musicbrainz.c	(original)
+++ trunk/libjuicer/sj-metadata-musicbrainz.c	Wed Sep  3 23:27:06 2008
@@ -23,7 +23,6 @@
 #endif /* HAVE_CONFIG_H */
 
 #include <string.h>
-#include <stdio.h>
 #include <glib-object.h>
 #include <glib/gi18n.h>
 #include <glib/gerror.h>
@@ -387,11 +386,7 @@
       if (num_releases > 0) {
         mb_Select1(priv->mb, MBS_SelectReleaseDate, 1);
         if (mb_GetResultData(priv->mb, MBE_ReleaseGetDate, data, sizeof (data))) {
-          int matched, year=1, month=1, day=1;
-          matched = sscanf(data, "%u-%u-%u", &year, &month, &day);
-          if (matched >= 1) {
-            album->release_date = g_date_new_dmy ((day == 0) ? 1 : day, (month == 0) ? 1 : month, year);
-          }
+          album->release_date = sj_metadata_helper_scan_date (data);
         }
         mb_Select(priv->mb, MBS_Back);
       }

Modified: trunk/libjuicer/sj-metadata-musicbrainz3.c
==============================================================================
--- trunk/libjuicer/sj-metadata-musicbrainz3.c	(original)
+++ trunk/libjuicer/sj-metadata-musicbrainz3.c	Wed Sep  3 23:27:06 2008
@@ -125,13 +125,10 @@
   if (mb_release_get_num_release_events (release) >= 1) {
     MbReleaseEvent event;
     char *date = NULL;
-    int matched, year=1, month=1, day=1;
 
     event = mb_release_get_release_event (release, 0);
     GET (date, mb_release_event_get_date, event);
-    matched = sscanf(date, "%u-%u-%u", &year, &month, &day);
-    if (matched >= 1)
-      album->release_date = g_date_new_dmy ((day == 0) ? 1 : day, (month == 0) ? 1 : month, year);
+    album->release_date = sj_metadata_helper_scan_date (date);
     g_free (date);
   }
 

Modified: trunk/libjuicer/sj-metadata.c
==============================================================================
--- trunk/libjuicer/sj-metadata.c	(original)
+++ trunk/libjuicer/sj-metadata.c	Wed Sep  3 23:27:06 2008
@@ -20,6 +20,7 @@
 
 #include <glib-object.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include "sj-metadata.h"
 #include "sj-metadata-marshal.h"
 
@@ -136,3 +137,15 @@
   return new_title;
 }
 
+GDate *
+sj_metadata_helper_scan_date (const char *date)
+{
+  int matched, year=1, month=1, day=1;
+  matched = sscanf(date, "%u-%u-%u", &year, &month, &day);
+  if (matched >= 1) {
+    return g_date_new_dmy ((day == 0) ? 1 : day, (month == 0) ? 1 : month, year);
+  }
+
+  return NULL;
+}
+

Modified: trunk/libjuicer/sj-metadata.h
==============================================================================
--- trunk/libjuicer/sj-metadata.h	(original)
+++ trunk/libjuicer/sj-metadata.h	Wed Sep  3 23:27:06 2008
@@ -51,6 +51,7 @@
 GList * sj_metadata_list_albums (SjMetadata *metadata, char **url, GError **error);
 
 char * sj_metadata_helper_scan_disc_number (const char *album_title, int *disc_number);
+GDate * sj_metadata_helper_scan_date (const char *date);
 
 G_END_DECLS
 



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