[vlc-commits] Xiph: support TRACKNUMBER=xx/xx in vorbis comments

Jean-Baptiste Kempf git at videolan.org
Thu Aug 8 12:17:36 CEST 2013


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Thu Aug  8 12:07:37 2013 +0200| [6283a220d45b768f569903fd16e966d50aa66187] | committer: Jean-Baptiste Kempf

Xiph: support TRACKNUMBER=xx/xx in vorbis comments

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...

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6283a220d45b768f569903fd16e966d50aa66187
---

 modules/demux/xiph_metadata.c |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/modules/demux/xiph_metadata.c b/modules/demux/xiph_metadata.c
index 75bf95b..f4f324d 100644
--- a/modules/demux/xiph_metadata.c
+++ b/modules/demux/xiph_metadata.c
@@ -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=")))



More information about the vlc-commits mailing list