changeset 1431:6b1f888a4c52

Use tuple_new_from_filename in more plugins.
author Tony Vroon <chainsaw@gentoo.org>
date Fri, 10 Aug 2007 14:01:43 +0100
parents bf7d4c236d9f
children e6eab0c725cd
files src/aac/src/libmp4.c src/alac/plugin.c src/sexypsf/plugin.c src/vtx/vtx.c
diffstat 4 files changed, 32 insertions(+), 70 deletions(-) [+]
line wrap: on
line diff
--- a/src/aac/src/libmp4.c	Fri Aug 10 13:49:59 2007 +0100
+++ b/src/aac/src/libmp4.c	Fri Aug 10 14:01:43 2007 +0100
@@ -333,8 +333,7 @@
     mp4ff_callback_t *mp4cb = g_malloc0(sizeof(mp4ff_callback_t));
     VFSFile *mp4fh;
     mp4ff_t *mp4file;
-    Tuple *ti = tuple_new();
-    gchar *scratch;
+    Tuple *ti = tuple_new_from_filename(fn);
     gboolean remote = str_has_prefix_nocase(filename, "http:") ||
 	              str_has_prefix_nocase(filename, "https:");
 
@@ -348,15 +347,6 @@
         tuple_associate_string(ti, "title", vfs_get_metadata(mp4fh, "track-name"));
         tuple_associate_string(ti, "album", vfs_get_metadata(mp4fh, "stream-name"));
 
-        scratch = g_path_get_basename(fn);
-        tuple_associate_string(ti, "file-name", scratch);
-        g_free(scratch);
-
-        scratch = g_path_get_dirname(fn);
-        tuple_associate_string(ti, "file-path", scratch);
-        g_free(scratch);
-
-        tuple_associate_string(ti, "file-ext", extname(fn));
         tuple_associate_string(ti, "codec", "Advanced Audio Coding (AAC)");
         tuple_associate_string(ti, "quality", "lossy");
 
@@ -414,39 +404,41 @@
 
         msDuration = ((float)numSamples * (float)(framesize - 1.0)/(float)samplerate) * 1000;
 
-        mp4ff_meta_get_title(mp4file, scratch);
-        tuple_associate_string(ti, "title", scratch);
-	g_free(scratch);
-
-        mp4ff_meta_get_album(mp4file, scratch);
-        tuple_associate_string(ti, "title", scratch);
-	g_free(scratch);
-
-        mp4ff_meta_get_artist(mp4file, scratch);
-        tuple_associate_string(ti, "artist", scratch);
-	g_free(scratch);
-
-        mp4ff_meta_get_genre(mp4file, scratch);
-        tuple_associate_string(ti, "genre", scratch);
-	g_free(scratch);
-
-        mp4ff_meta_get_date(mp4file, &tmpval);
-
+        mp4ff_meta_get_title(mp4file, &tmpval);
         if (tmpval)
         {
-            input->year = atoi(tmpval);
+            tuple_associate_string(ti, "title", tmpval);
+            free(tmpval);
+        }
+
+        mp4ff_meta_get_album(mp4file, &tmpval);
+        if (tmpval)
+        {
+            tuple_associate_string(ti, "title", tmpval);
             free(tmpval);
         }
 
-        scratch = g_path_get_basename(fn);
-        tuple_associate_string(ti, "file-name", scratch);
-        g_free(scratch);
+        mp4ff_meta_get_artist(mp4file, &tmpval);
+        if (tmpval)
+        {
+            tuple_associate_string(ti, "artist", tmpval);
+            free(tmpval);
+        }
 
-        scratch = g_path_get_dirname(fn);
-        tuple_associate_string(ti, "file-path", scratch);
-        g_free(scratch);
+        mp4ff_meta_get_genre(mp4file, &tmpval);
+        if (tmpval)
+        {
+            tuple_associate_string(ti, "genre", tmpval);
+            free(tmpval);
+        }
 
-        tuple_associate_string(ti, "file-ext", extname(fn));
+        mp4ff_meta_get_date(mp4file, &tmpval);
+        if (tmpval)
+        {
+            tuple_associate_int(ti, "year", atoi(tmpval));
+            free(tmpval);
+        }
+
         tuple_associate_string(ti, "codec", "Advanced Audio Coding (AAC)");
         tuple_associate_string(ti, "quality", "lossy");
 
--- a/src/alac/plugin.c	Fri Aug 10 13:49:59 2007 +0100
+++ b/src/alac/plugin.c	Fri Aug 10 14:01:43 2007 +0100
@@ -119,8 +119,7 @@
 
 Tuple *build_tuple_from_demux(demux_res_t *demux_res, char *path)
 {
-    Tuple *ti = tuple_new();
-    gchar *scratch;
+    Tuple *ti = tuple_new_from_filename(path);
 
     if (demux_res->tuple.art != NULL)
         tuple_associate_string(ti, "artist", demux_res->tuple.art);
@@ -135,15 +134,6 @@
     if (demux_res->tuple.day != NULL)
         tuple_associate_int(ti, "year", atoi(demux_res->tuple.day));
 
-    scratch = g_path_get_basename(path);
-    tuple_associate_string(ti, "file-name", scratch);
-    g_free(scratch);
-
-    scratch = g_path_get_dirname(path);
-    tuple_associate_string(ti, "file-path", scratch);
-    g_free(scratch);
-
-    tuple_associate_string(ti, "file-ext", extname(path));
     tuple_associate_string(ti, "codec", "Apple Lossless (ALAC)");
     tuple_associate_string(ti, "quality", "lossless");
 
--- a/src/sexypsf/plugin.c	Fri Aug 10 13:49:59 2007 +0100
+++ b/src/sexypsf/plugin.c	Fri Aug 10 14:01:43 2007 +0100
@@ -225,9 +225,7 @@
     PSFINFO *tmp = sexypsf_getpsfinfo(fn);
 
     if (tmp->length) {
-        gchar *scratch;
-
-        tuple = tuple_new();
+        tuple = tuple_new_from_filename(fn);
 	tuple_associate_int(tuple, "length", tmp->length);
 	tuple_associate_string(tuple, "artist", tmp->artist);
 	tuple_associate_string(tuple, "album", tmp->game);
@@ -241,14 +239,6 @@
         tuple_associate_string(tuple, "dumper", tmp->psfby);
         tuple_associate_string(tuple, "comment", tmp->comment);
 
-        scratch = g_path_get_basename(fn);
-        tuple_associate_string(tuple, "file-name", scratch);
-        g_free(scratch);
-
-        scratch = g_path_get_dirname(fn);
-        tuple_associate_string(tuple, "file-path", scratch);
-        g_free(scratch);
-
         sexypsf_freepsfinfo(tmp);
     }
 
--- a/src/vtx/vtx.c	Fri Aug 10 13:49:59 2007 +0100
+++ b/src/vtx/vtx.c	Fri Aug 10 14:01:43 2007 +0100
@@ -95,22 +95,12 @@
 Tuple *
 vtx_get_song_tuple_from_vtx(const gchar *filename, ayemu_vtx_t *in)
 {
-  Tuple *out = tuple_new();
+  Tuple *out = tuple_new_from_filename(filename);
   gchar *string;
-  gchar *scratch;
 
   tuple_associate_string(out, "artist", in->hdr.author);
   tuple_associate_string(out, "title", in->hdr.title);
 
-  scratch = g_path_get_basename(filename);
-  tuple_associate_string(out, "file-name", scratch);
-  g_free(scratch);
- 
-  scratch = g_path_get_dirname(filename);
-  tuple_associate_string(out, "file-path", scratch);
-  g_free(scratch);
-
-  tuple_associate_string(out, "file-ext", strrchr(filename, '.') + 1);
   tuple_associate_int(out, "length", in->hdr.regdata_size / 14 * 1000 / 50);
 
   tuple_associate_string(out, "genre", (in->hdr.chiptype == AYEMU_AY)? "AY chiptunes" : "YM chiptunes");