]> git.sesse.net Git - vlc/commitdiff
Added support for oldstyle id3 genres.
authorSigmund Augdal Helberg <sigmunau@videolan.org>
Thu, 13 Mar 2003 22:35:51 +0000 (22:35 +0000)
committerSigmund Augdal Helberg <sigmunau@videolan.org>
Thu, 13 Mar 2003 22:35:51 +0000 (22:35 +0000)
modules/demux/util/id3genres.h [new file with mode: 0644]
modules/demux/util/id3tag.c

diff --git a/modules/demux/util/id3genres.h b/modules/demux/util/id3genres.h
new file mode 100644 (file)
index 0000000..dd455a4
--- /dev/null
@@ -0,0 +1,88 @@
+/* id3genres.h: list of genres for id3 genre tags, found at
+ * http://www.id3.org/id3v2.4.0-frames.txt
+ */
+
+#define NUM_GENRES 80
+
+static char *ppsz_genres[] = {
+    N_("Blues"),
+    N_("Classic Rock"),
+    N_("Country"),
+    N_("Dance"),
+    N_("Disco"),
+    N_("Funk"),
+    N_("Grunge"),
+    N_("Hip-Hop"),
+    N_("Jazz"),
+    N_("Metal"),
+    N_("New Age"),
+    N_("Oldies"),
+    N_("Other"),
+    N_("Pop"),
+    N_("R&B"),
+    N_("Rap"),
+    N_("Reggae"),
+    N_("Rock"),
+    N_("Techno"),
+    N_("Industrial"),
+    N_("Alternative"),
+    N_("Ska"),
+    N_("Death Metal"),
+    N_("Pranks"),
+    N_("Soundtrack"),
+    N_("Euro-Techno"),
+    N_("Ambient"),
+    N_("Trip-Hop"),
+    N_("Vocal"),
+    N_("Jazz+Funk"),
+    N_("Fusion"),
+    N_("Trance"),
+    N_("Classical"),
+    N_("Instrumental"),
+    N_("Acid"),
+    N_("House"),
+    N_("Game"),
+    N_("Sound Clip"),
+    N_("Gospel"),
+    N_("Noise"),
+    N_("AlternRock"),
+    N_("Bass"),
+    N_("Soul"),
+    N_("Punk"),
+    N_("Space"),
+    N_("Meditative"),
+    N_("Instrumental Pop"),
+    N_("Instrumental Rock"),
+    N_("Ethnic"),
+    N_("Gothic"),
+    N_("Darkwave"),
+    N_("Techno-Industrial"),
+    N_("Electronic"),
+    N_("Pop-Folk"),
+    N_("Eurodance"),
+    N_("Dream"),
+    N_("Southern Rock"),
+    N_("Comedy"),
+    N_("Cult"),
+    N_("Gangsta"),
+    N_("Top 40"),
+    N_("Christian Rap"),
+    N_("Pop/Funk"),
+    N_("Jungle"),
+    N_("Native American"),
+    N_("Cabaret"),
+    N_("New Wave"),
+    N_("Psychadelic"),
+    N_("Rave"),
+    N_("Showtunes"),
+    N_("Trailer"),
+    N_("Lo-Fi"),
+    N_("Tribal"),
+    N_("Acid Punk"),
+    N_("Acid Jazz"),
+    N_("Polka"),
+    N_("Retro"),
+    N_("Musical"),
+    N_("Rock & Roll"),
+    N_("Hard Rock")
+};
index ea1dad7abb2d847cf5f54d12080245c04afdb6b6..db94256b7aeb7562dcc0b133dc3e32117e74e458 100644 (file)
@@ -2,7 +2,7 @@
  * id3tag.c: id3 tag parser/skipper based on libid3tag
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: id3tag.c,v 1.4 2003/02/22 14:11:38 sigmunau Exp $
+ * $Id: id3tag.c,v 1.5 2003/03/13 22:35:51 sigmunau Exp $
  *
  * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
  * 
@@ -33,6 +33,7 @@
 #include <sys/types.h>
 
 #include <id3tag.h>
+#include "id3genres.h"
 
 /*****************************************************************************
  * Local prototypes
@@ -72,8 +73,25 @@ static void ParseID3Tag( input_thread_t *p_input, u8 *p_data, int i_size )
         i_strings = id3_field_getnstrings( &p_frame->fields[1] );
         while ( i_strings > 0 )
         {
-            psz_temp = id3_ucs4_latin1duplicate( id3_field_getstrings ( &p_frame->fields[1], --i_strings ) );
-            input_AddInfo( p_category, (char *)p_frame->description, psz_temp );
+            psz_temp = id3_ucs4_latin1duplicate( id3_field_getstrings( &p_frame->fields[1], --i_strings ) );
+            if ( !strcmp(p_frame->id, ID3_FRAME_GENRE ) )
+            {
+                int i_genre;
+                char *psz_endptr;
+                i_genre = strtol( psz_temp, &psz_endptr, 10 );
+                if( psz_temp != psz_endptr && i_genre >= 0 && i_genre < NUM_GENRES )
+                {
+                    input_AddInfo( p_category, (char *)p_frame->description, ppsz_genres[atoi(psz_temp)]);
+                }
+                else
+                {
+                    input_AddInfo( p_category, (char *)p_frame->description, psz_temp );
+                }
+            }
+            else
+            {
+                input_AddInfo( p_category, (char *)p_frame->description, psz_temp );
+            }
             free( psz_temp ); 
         }
         i++;