[vlc-commits] Taglib: use an extradata to store MB releases
Jean-Baptiste Kempf
git at videolan.org
Thu Feb 6 21:47:39 CET 2014
vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Thu Feb 6 19:44:15 2014 +0100| [45d50c431a1109c89ac2cd56b639d0be7d2389e5] | committer: Jean-Baptiste Kempf
Taglib: use an extradata to store MB releases
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=45d50c431a1109c89ac2cd56b639d0be7d2389e5
---
include/vlc_meta.h | 1 +
modules/meta_engine/taglib.cpp | 39 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/include/vlc_meta.h b/include/vlc_meta.h
index 5dc8b19..bd7b319 100644
--- a/include/vlc_meta.h
+++ b/include/vlc_meta.h
@@ -160,5 +160,6 @@ VLC_API int input_item_WriteMeta(vlc_object_t *, input_item_t *);
#define VLC_META_SHOW_NAME vlc_meta_TypeToLocalizedString( vlc_meta_ShowName )
#define VLC_META_ACTORS vlc_meta_TypeToLocalizedString( vlc_meta_Actors )
+#define VLC_META_EXTRA_MB_ALBUMID "MB_ALBUMID"
#endif
diff --git a/modules/meta_engine/taglib.cpp b/modules/meta_engine/taglib.cpp
index f64c5db..c6e78de 100644
--- a/modules/meta_engine/taglib.cpp
+++ b/modules/meta_engine/taglib.cpp
@@ -167,7 +167,11 @@ static void ReadMetaFromAPE( APE::Tag* tag, demux_meta_t* p_demux_meta, vlc_meta
#define SET( keyName, metaName ) \
item = tag->itemListMap()[keyName]; \
- if( !item.isEmpty() ) vlc_meta_Set##metaName( p_meta, item.toString().toCString( true ) ); \
+ if( !item.isEmpty() ) vlc_meta_Set##metaName( p_meta, item.toString().toCString( true ) );
+
+#define SET_EXTRA( keyName, metaName ) \
+ item = tag->itemListMap()[keyName]; \
+ if( !item.isEmpty() ) vlc_meta_AddExtra( p_meta, metaName, item.toString().toCString( true ) );
SET( "ALBUM", Album );
SET( "ARTIST", Artist );
@@ -179,7 +183,10 @@ static void ReadMetaFromAPE( APE::Tag* tag, demux_meta_t* p_demux_meta, vlc_meta
SET( "PUBLISHER", Publisher );
SET( "MUSICBRAINZ_TRACKID", TrackID );
+ SET_EXTRA( "MUSICBRAINZ_ALBUMID", VLC_META_EXTRA_MB_ALBUMID );
+
#undef SET
+#undef SET_EXTRA
/* */
item = tag->itemListMap()["TRACK"];
@@ -207,9 +214,18 @@ static void ReadMetaFromASF( ASF::Tag* tag, demux_meta_t* p_demux_meta, vlc_meta
vlc_meta_Set##metaName( p_meta, list.front().toString().toCString( true ) ); \
}
+#define SET_EXTRA( keyName, metaName ) \
+ if( tag->attributeListMap().contains(keyName) ) \
+ { \
+ list = tag->attributeListMap()[keyName]; \
+ vlc_meta_AddExtra( p_meta, metaName, list.front().toString().toCString( true ) ); \
+ }
+
SET("MusicBrainz/Track Id", TrackID );
+ SET_EXTRA("MusicBrainz/Album Id", VLC_META_EXTRA_MB_ALBUMID );
#undef SET
+#undef SET_EXTRA
#ifdef TAGLIB_HAVE_ASFPICTURE_H
// List the pictures
@@ -299,6 +315,11 @@ static void ReadMetaFromId3v2( ID3v2::Tag* tag, demux_meta_t* p_demux_meta, vlc_
vlc_meta_Set( p_meta, vlc_meta_TrackTotal, p_txxx->fieldList().back().toCString( true ) );
continue;
}
+ if( !strcmp( p_txxx->description().toCString( true ), "MusicBrainz Album Id" ) )
+ {
+ vlc_meta_AddExtra( p_meta, VLC_META_EXTRA_MB_ALBUMID, p_txxx->fieldList().back().toCString( true ) );
+ continue;
+ }
vlc_meta_AddExtra( p_meta, p_txxx->description().toCString( true ),
p_txxx->fieldList().back().toCString( true ) );
}
@@ -449,6 +470,11 @@ static void ReadMetaFromXiph( Ogg::XiphComment* tag, demux_meta_t* p_demux_meta,
if( !list.isEmpty() ) \
vlc_meta_Set##metaName( p_meta, (*list.begin()).toCString( true ) );
+#define SET_EXTRA( keyName, metaName ) \
+ list = tag->fieldListMap()[keyName]; \
+ if( !list.isEmpty() ) \
+ vlc_meta_AddExtra( p_meta, keyName, (*list.begin()).toCString( true ) );
+
SET( "COPYRIGHT", Copyright );
SET( "ORGANIZATION", Publisher );
SET( "DATE", Date );
@@ -456,7 +482,10 @@ static void ReadMetaFromXiph( Ogg::XiphComment* tag, demux_meta_t* p_demux_meta,
SET( "RATING", Rating );
SET( "LANGUAGE", Language );
SET( "MUSICBRAINZ_TRACKID", TrackID );
+
+ SET_EXTRA( "MUSICBRAINZ_ALBUMID", VLC_META_EXTRA_MB_ALBUMID );
#undef SET
+#undef SET_EXTRA
list = tag->fieldListMap()["TRACKNUMBER"];
if( !list.isEmpty() )
@@ -560,10 +589,18 @@ static void ReadMetaFromMP4( MP4::Tag* tag, demux_meta_t *p_demux_meta, vlc_meta
list = tag->itemListMap()[keyName]; \
vlc_meta_Set##metaName( p_meta, list.toStringList().front().toCString( true ) ); \
}
+#define SET_EXTRA( keyName, metaName ) \
+ if( tag->itemListMap().contains(keyName) ) \
+ { \
+ list = tag->itemListMap()[keyName]; \
+ vlc_meta_AddExtra( p_meta, metaName, list.toStringList().front().toCString( true ) ); \
+ }
SET("----:com.apple.iTunes:MusicBrainz Track Id", TrackID );
+ SET_EXTRA("----:com.apple.iTunes:MusicBrainz Album Id", VLC_META_EXTRA_MB_ALBUMID );
#undef SET
+#undef SET_EXTRA
if( tag->itemListMap().contains("covr") )
{
More information about the vlc-commits
mailing list