Commit c8407ec6 authored by Wieland Hoffmann's avatar Wieland Hoffmann Committed by Jean-Baptiste Kempf

meta_engine/taglib: Write MusicBrainz Track IDs

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 922c1bc9
...@@ -793,7 +793,7 @@ static void WriteMetaToAPE( APE::Tag* tag, input_item_t* p_item ) ...@@ -793,7 +793,7 @@ static void WriteMetaToAPE( APE::Tag* tag, input_item_t* p_item )
WRITE( Copyright, "COPYRIGHT" ); WRITE( Copyright, "COPYRIGHT" );
WRITE( Language, "LANGUAGE" ); WRITE( Language, "LANGUAGE" );
WRITE( Publisher, "PUBLISHER" ); WRITE( Publisher, "PUBLISHER" );
WRITE( TrackID, "MUSICBRAINZ_TRACKID" );
#undef WRITE #undef WRITE
} }
...@@ -825,35 +825,41 @@ static void WriteMetaToId3v2( ID3v2::Tag* tag, input_item_t* p_item ) ...@@ -825,35 +825,41 @@ static void WriteMetaToId3v2( ID3v2::Tag* tag, input_item_t* p_item )
WRITE( Publisher, "TPUB" ); WRITE( Publisher, "TPUB" );
#undef WRITE #undef WRITE
/* Track Total as Custom Field */ /* Known TXXX frames */
psz_meta = input_item_GetTrackTotal( p_item );
if ( psz_meta )
{
ID3v2::FrameList list = tag->frameListMap()["TXXX"]; ID3v2::FrameList list = tag->frameListMap()["TXXX"];
ID3v2::UserTextIdentificationFrame *p_txxx;
for( ID3v2::FrameList::Iterator iter = list.begin(); iter != list.end(); iter++ ) #define WRITETXXX( metaName, txxName )\
{ psz_meta = input_item_Get##metaName( p_item ); \
p_txxx = dynamic_cast<ID3v2::UserTextIdentificationFrame*>(*iter); if ( psz_meta ) \
if( !p_txxx ) { \
continue; ID3v2::UserTextIdentificationFrame *p_txxx; \
if( !strcmp( p_txxx->description().toCString( true ), "TRACKTOTAL" ) ) for( ID3v2::FrameList::Iterator iter = list.begin(); iter != list.end(); iter++ )\
{ { \
p_txxx->setText( psz_meta ); p_txxx = dynamic_cast<ID3v2::UserTextIdentificationFrame*>(*iter); \
FREENULL( psz_meta ); if( !p_txxx ) \
break; continue; \
} if( !strcmp( p_txxx->description().toCString( true ), txxName ) ) \
} { \
if( psz_meta ) /* not found in existing custom fields */ p_txxx->setText( psz_meta ); \
{ FREENULL( psz_meta ); \
ByteVector p_byte( "TXXX", 4 ); break; \
p_txxx = new ID3v2::UserTextIdentificationFrame( p_byte ); } \
p_txxx->setDescription( "TRACKTOTAL" ); } \
p_txxx->setText( psz_meta ); if( psz_meta ) /* not found in existing custom fields */ \
free( psz_meta ); { \
tag->addFrame( p_txxx ); ByteVector p_byte( "TXXX", 4 ); \
} p_txxx = new ID3v2::UserTextIdentificationFrame( p_byte ); \
p_txxx->setDescription( txxName ); \
p_txxx->setText( psz_meta ); \
free( psz_meta ); \
tag->addFrame( p_txxx ); \
} \
} }
WRITETXXX( TrackTotal, "TRACKTOTAL" );
#undef WRITETXXX
/* Write album art */ /* Write album art */
char *psz_url = input_item_GetArtworkURL( p_item ); char *psz_url = input_item_GetArtworkURL( p_item );
if( psz_url == NULL ) if( psz_url == NULL )
...@@ -952,7 +958,7 @@ static void WriteMetaToXiph( Ogg::XiphComment* tag, input_item_t* p_item ) ...@@ -952,7 +958,7 @@ static void WriteMetaToXiph( Ogg::XiphComment* tag, input_item_t* p_item )
WRITE( EncodedBy, "ENCODER" ); WRITE( EncodedBy, "ENCODER" );
WRITE( Rating, "RATING" ); WRITE( Rating, "RATING" );
WRITE( Language, "LANGUAGE" ); WRITE( Language, "LANGUAGE" );
WRITE( TrackID, "MUSICBRAINZ_TRACKID" );
#undef WRITE #undef WRITE
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment