Xiph: support TRACKNUMBER=xx/xx in vorbis comments
authorJean-Baptiste Kempf <jb@videolan.org>
Thu, 8 Aug 2013 10:07:37 +0000 (12:07 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Thu, 8 Aug 2013 10:07:55 +0000 (12:07 +0200)
Yeah, yeah, such a clever idea, thx...
Let' not use TRACKTOTAL or TOTALTRACKS or TOTALTRACK or TRACKSTOTAL,
because you know, there is not enough options...
Oh, and let's not make ANY of the above official in the spec, because
then, people could follow the spec...
https://www.xiph.org/vorbis/doc/v-comment.html

Next time, please use mkv...

modules/demux/xiph_metadata.c

index 75bf95b..f4f324d 100644 (file)
@@ -155,7 +155,6 @@ void vorbis_ParseComment( vlc_meta_t **pp_meta,
     /* */
     bool hasTitle        = false;
     bool hasAlbum        = false;
-    bool hasTrackNumber  = false;
     bool hasTrackTotal   = false;
     bool hasArtist       = false;
     bool hasCopyright    = false;
@@ -198,7 +197,22 @@ void vorbis_ParseComment( vlc_meta_t **pp_meta,
     }
         IF_EXTRACT("TITLE=", Title )
         else IF_EXTRACT("ALBUM=", Album )
-        else IF_EXTRACT("TRACKNUMBER=", TrackNumber )
+        else if( !strncasecmp(psz_comment, "TRACKNUMBER=", strlen("TRACKNUMBER=" ) ) )
+        {
+            /* Yeah yeah, such a clever idea, let's put xx/xx inside TRACKNUMBER
+             * Oh, and let's not use TRACKTOTAL or TOTALTRACKS... */
+            short unsigned u_track, u_total;
+            if( sscanf( &psz_comment[strlen("TRACKNUMBER=")], "%hu/%hu", &u_track, &u_total ) == 2 )
+            {
+                char str[6];
+                snprintf(str, 6, "%d", u_track);
+                vlc_meta_Set( p_meta, vlc_meta_TrackNumber, str );
+                snprintf(str, 6, "%d", u_total);
+                vlc_meta_Set( p_meta, vlc_meta_TrackTotal, str );
+            }
+            else
+                vlc_meta_Set( p_meta, vlc_meta_TrackNumber, &psz_comment[strlen("TRACKNUMBER=")] );
+        }
         else if( !strncasecmp(psz_comment, "TRACKTOTAL=", strlen("TRACKTOTAL=")))
             vlc_meta_Set( p_meta, vlc_meta_TrackTotal, &psz_comment[strlen("TRACKTOTAL=")] );
         else if( !strncasecmp(psz_comment, "TOTALTRACKS=", strlen("TOTALTRACKS=")))