Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

parse id3v1 tags of mp3 files

  • Loading branch information...
commit a320786e46efc30b1885b085c4337e3deba141f3 1 parent 7a6cb7f
Jonathan Marshall authored
View
17 xbmc/music/tags/TagLoaderTagLib.cpp
@@ -169,6 +169,7 @@ bool CTagLoaderTagLib::Load(const string& strFileName, CMusicInfoTag& tag, Embed
APE::Tag *ape = NULL;
ASF::Tag *asf = NULL;
MP4::Tag *mp4 = NULL;
+ ID3v1::Tag *id3v1 = NULL;
ID3v2::Tag *id3v2 = NULL;
Ogg::XiphComment *xiph = NULL;
Tag *generic = NULL;
@@ -186,6 +187,7 @@ bool CTagLoaderTagLib::Load(const string& strFileName, CMusicInfoTag& tag, Embed
mp4 = mp4File->tag();
else if (mpegFile)
{
+ id3v1 = mpegFile->ID3v1Tag(false);
id3v2 = mpegFile->ID3v2Tag(false);
ape = mpegFile->APETag(false);
}
@@ -205,6 +207,8 @@ bool CTagLoaderTagLib::Load(const string& strFileName, CMusicInfoTag& tag, Embed
if (asf)
ParseASF(asf, art, tag);
+ if (id3v1)
+ ParseID3v1Tag(id3v1, art, tag);
if (id3v2)
ParseID3v2Tag(id3v2, art, tag);
if (generic)
@@ -302,6 +306,19 @@ char POPMtoXBMC(int popm)
return '5';
}
+bool CTagLoaderTagLib::ParseID3v1Tag(ID3v1::Tag *id3v1, EmbeddedArt *art, CMusicInfoTag& tag)
+{
@arnova Collaborator
arnova added a note

Afaik: ID3v1 can't have embedded art. It isn't used in this function anyway...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if (!id3v1) return false;
+ tag.SetTitle(id3v1->title().to8Bit(true));
+ tag.SetArtist(id3v1->artist().to8Bit(true));
+ tag.SetAlbum(id3v1->album().to8Bit(true));
+ tag.SetComment(id3v1->comment().to8Bit(true));
+ tag.SetGenre(id3v1->genre().to8Bit(true));
@arnova Collaborator
arnova added a note

I believe this is wrong: ID3v1 genre is a single byte value and should use a lookup table to get the genre string.

@jmarshallnz Owner

Read the taglib sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ tag.SetYear(id3v1->year());
+ tag.SetTrackNumber(id3v1->track());
+ return true;
+}
+
bool CTagLoaderTagLib::ParseID3v2Tag(ID3v2::Tag *id3v2, EmbeddedArt *art, CMusicInfoTag& tag)
{
// tag.SetURL(strFile);
View
1  xbmc/music/tags/TagLoaderTagLib.h
@@ -64,6 +64,7 @@ class CTagLoaderTagLib
bool ParseAPETag(TagLib::APE::Tag *ape, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag);
bool ParseASF(TagLib::ASF::Tag *asf, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag);
+ bool ParseID3v1Tag(TagLib::ID3v1::Tag *id3v1, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag);
bool ParseID3v2Tag(TagLib::ID3v2::Tag *id3v2, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag);
bool ParseXiphComment(TagLib::Ogg::XiphComment *id3v2, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag);
bool ParseMP4Tag(TagLib::MP4::Tag *mp4, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag);
Please sign in to comment.
Something went wrong with that request. Please try again.