]> git.sesse.net Git - vlc/commitdiff
taglib: ID3v2: save TrackTotal
authorFrancois Cartegnie <fcvlcdev@free.fr>
Tue, 18 Dec 2012 21:54:37 +0000 (22:54 +0100)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Tue, 18 Dec 2012 21:56:15 +0000 (22:56 +0100)
modules/meta_engine/taglib.cpp

index 2561b4cc234e5f8d7e8f44f41238bd7e60cfe601..49561d185365e443b140cf151156292b0213ddb6 100644 (file)
@@ -715,6 +715,34 @@ static void WriteMetaToId3v2( ID3v2::Tag* tag, input_item_t* p_item )
     WRITE( Publisher, "TPUB" );
 
 #undef WRITE
+    /* Track Total as Custom Field */
+    psz_meta = input_item_GetTrackTotal( p_item );
+    if ( psz_meta )
+    {
+        ID3v2::FrameList list = tag->frameListMap()["TXXX"];
+        ID3v2::UserTextIdentificationFrame *p_txxx;
+        for( ID3v2::FrameList::Iterator iter = list.begin(); iter != list.end(); iter++ )
+        {
+            p_txxx = dynamic_cast<ID3v2::UserTextIdentificationFrame*>(*iter);
+            if( !p_txxx )
+                continue;
+            if( !strcmp( p_txxx->description().toCString( true ), "TRACKTOTAL" ) )
+            {
+                p_txxx->setText( psz_meta );
+                FREENULL( psz_meta );
+                break;
+            }
+        }
+        if( psz_meta ) /* not found in existing custom fields */
+        {
+            ByteVector p_byte( "TXXX", 4 );
+            p_txxx = new ID3v2::UserTextIdentificationFrame( p_byte );
+            p_txxx->setDescription( "TRACKTOTAL" );
+            p_txxx->setText( psz_meta );
+            free( psz_meta );
+            tag->addFrame( p_txxx );
+        }
+    }
 
     /* Write album art */
     char *psz_url = input_item_GetArtworkURL( p_item );