Skip to content
This repository
Browse code

parse id3v1 tags of mp3 files

  • Loading branch information...
commit a320786e46efc30b1885b085c4337e3deba141f3 1 parent 7a6cb7f
authored January 03, 2013
17  xbmc/music/tags/TagLoaderTagLib.cpp
@@ -169,6 +169,7 @@ bool CTagLoaderTagLib::Load(const string& strFileName, CMusicInfoTag& tag, Embed
169 169
   APE::Tag *ape = NULL;
170 170
   ASF::Tag *asf = NULL;
171 171
   MP4::Tag *mp4 = NULL;
  172
+  ID3v1::Tag *id3v1 = NULL;
172 173
   ID3v2::Tag *id3v2 = NULL;
173 174
   Ogg::XiphComment *xiph = NULL;
174 175
   Tag *generic = NULL;
@@ -186,6 +187,7 @@ bool CTagLoaderTagLib::Load(const string& strFileName, CMusicInfoTag& tag, Embed
186 187
     mp4 = mp4File->tag();
187 188
   else if (mpegFile)
188 189
   {
  190
+    id3v1 = mpegFile->ID3v1Tag(false);
189 191
     id3v2 = mpegFile->ID3v2Tag(false);
190 192
     ape = mpegFile->APETag(false);
191 193
   }
@@ -205,6 +207,8 @@ bool CTagLoaderTagLib::Load(const string& strFileName, CMusicInfoTag& tag, Embed
205 207
 
206 208
   if (asf)
207 209
     ParseASF(asf, art, tag);
  210
+  if (id3v1)
  211
+    ParseID3v1Tag(id3v1, art, tag);
208 212
   if (id3v2)
209 213
     ParseID3v2Tag(id3v2, art, tag);
210 214
   if (generic)
@@ -302,6 +306,19 @@ char POPMtoXBMC(int popm)
302 306
   return '5';
303 307
 }
304 308
 
  309
+bool CTagLoaderTagLib::ParseID3v1Tag(ID3v1::Tag *id3v1, EmbeddedArt *art, CMusicInfoTag& tag)
  310
+{
  311
+  if (!id3v1) return false;
  312
+  tag.SetTitle(id3v1->title().to8Bit(true));
  313
+  tag.SetArtist(id3v1->artist().to8Bit(true));
  314
+  tag.SetAlbum(id3v1->album().to8Bit(true));
  315
+  tag.SetComment(id3v1->comment().to8Bit(true));
  316
+  tag.SetGenre(id3v1->genre().to8Bit(true));
  317
+  tag.SetYear(id3v1->year());
  318
+  tag.SetTrackNumber(id3v1->track());
  319
+  return true;
  320
+}
  321
+
305 322
 bool CTagLoaderTagLib::ParseID3v2Tag(ID3v2::Tag *id3v2, EmbeddedArt *art, CMusicInfoTag& tag)
306 323
 {
307 324
   //  tag.SetURL(strFile);
1  xbmc/music/tags/TagLoaderTagLib.h
@@ -64,6 +64,7 @@ class CTagLoaderTagLib
64 64
 
65 65
   bool                           ParseAPETag(TagLib::APE::Tag *ape, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag);
66 66
   bool                           ParseASF(TagLib::ASF::Tag *asf, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag);
  67
+  bool                           ParseID3v1Tag(TagLib::ID3v1::Tag *id3v1, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag);
67 68
   bool                           ParseID3v2Tag(TagLib::ID3v2::Tag *id3v2, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag);
68 69
   bool                           ParseXiphComment(TagLib::Ogg::XiphComment *id3v2, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag);
69 70
   bool                           ParseMP4Tag(TagLib::MP4::Tag *mp4, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag);

0 notes on commit a320786

arnova

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

arnova

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

Please sign in to comment.
Something went wrong with that request. Please try again.