Skip to content
This repository
Browse code

Merge pull request #1610 from jmarshallnz/multi_artist_genre_fixups

Use the music separator for artists/album artists/genres
  • Loading branch information...
commit 0358178dca13a322b9281f3285498b814e5bde55 2 parents e331bf6 + 67876f7
jmarshallnz authored October 13, 2012
60  xbmc/music/tags/TagLoaderTagLib.cpp
@@ -223,12 +223,12 @@ bool CTagLoaderTagLib::ParseASF(ASF::Tag *asf, EmbeddedArt *art, CMusicInfoTag&
223 223
   const ASF::AttributeListMap& attributeListMap = asf->attributeListMap();
224 224
   for (ASF::AttributeListMap::ConstIterator it = attributeListMap.begin(); it != attributeListMap.end(); ++it)
225 225
   {
226  
-    if (it->first == "Author")                           tag.SetArtist(GetASFStringList(it->second));
227  
-    else if (it->first == "WM/AlbumArtist")              tag.SetAlbumArtist(GetASFStringList(it->second));
  226
+    if (it->first == "Author")                           SetArtist(tag, GetASFStringList(it->second));
  227
+    else if (it->first == "WM/AlbumArtist")              SetAlbumArtist(tag, GetASFStringList(it->second));
228 228
     else if (it->first == "WM/AlbumTitle")               tag.SetAlbum(it->second.front().toString().to8Bit(true));
229 229
     else if (it->first == "WM/TrackNumber")              tag.SetTrackNumber(it->second.front().toUInt());
230 230
     else if (it->first == "WM/PartOfSet")                tag.SetPartOfSet(it->second.front().toUInt());
231  
-    else if (it->first == "WM/Genre")                    tag.SetGenre(GetASFStringList(it->second));
  231
+    else if (it->first == "WM/Genre")                    SetGenre(tag, GetASFStringList(it->second));
232 232
     else if (it->first == "WM/AlbumArtistSortOrder")     {} // Known unsupported, supress warnings
233 233
     else if (it->first == "WM/ArtistSortOrder")          {} // Known unsupported, supress warnings
234 234
     else if (it->first == "WM/Script")                   {} // Known unsupported, supress warnings
@@ -276,11 +276,11 @@ bool CTagLoaderTagLib::ParseID3v2Tag(ID3v2::Tag *id3v2, EmbeddedArt *art, CMusic
276 276
   const ID3v2::FrameListMap& frameListMap = id3v2->frameListMap();
277 277
   for (ID3v2::FrameListMap::ConstIterator it = frameListMap.begin(); it != frameListMap.end(); ++it)
278 278
   {
279  
-    if      (it->first == "TPE1")   tag.SetArtist(GetID3v2StringList(it->second));
  279
+    if      (it->first == "TPE1")   SetArtist(tag, GetID3v2StringList(it->second));
280 280
     else if (it->first == "TALB")   tag.SetAlbum(it->second.front()->toString().to8Bit(true));
281  
-    else if (it->first == "TPE2")   tag.SetAlbumArtist(GetID3v2StringList(it->second));
  281
+    else if (it->first == "TPE2")   SetAlbumArtist(tag, GetID3v2StringList(it->second));
282 282
     else if (it->first == "TIT2")   tag.SetTitle(it->second.front()->toString().to8Bit(true));
283  
-    else if (it->first == "TCON")   tag.SetGenre(it->second.front()->toString().to8Bit(true));
  283
+    else if (it->first == "TCON")   SetGenre(tag, GetID3v2StringList(it->second));
284 284
     else if (it->first == "TRCK")   tag.SetTrackNumber(strtol(it->second.front()->toString().toCString(true), NULL, 10));
285 285
     else if (it->first == "TPOS")   tag.SetPartOfSet(strtol(it->second.front()->toString().toCString(true), NULL, 10));
286 286
     else if (it->first == "TYER")   tag.SetYear(strtol(it->second.front()->toString().toCString(true), NULL, 10));
@@ -401,14 +401,14 @@ bool CTagLoaderTagLib::ParseAPETag(APE::Tag *ape, EmbeddedArt *art, CMusicInfoTa
401 401
   const APE::ItemListMap itemListMap = ape->itemListMap();
402 402
   for (APE::ItemListMap::ConstIterator it = itemListMap.begin(); it != itemListMap.end(); ++it)
403 403
   {
404  
-    if (it->first == "ARTIST")                         tag.SetArtist(StringListToVectorString(it->second.toStringList()));
405  
-    else if (it->first == "ALBUM ARTIST")              tag.SetAlbumArtist(StringListToVectorString(it->second.toStringList()));
  404
+    if (it->first == "ARTIST")                         SetArtist(tag, StringListToVectorString(it->second.toStringList()));
  405
+    else if (it->first == "ALBUM ARTIST")              SetAlbumArtist(tag, StringListToVectorString(it->second.toStringList()));
406 406
     else if (it->first == "ALBUM")                     tag.SetAlbum(it->second.toString().to8Bit(true));
407 407
     else if (it->first == "TITLE")                     tag.SetTitle(it->second.toString().to8Bit(true));
408 408
     else if (it->first == "TRACKNUMBER")               tag.SetTrackNumber(it->second.toString().toInt());
409 409
     else if (it->first == "DISCNUMBER")                tag.SetPartOfSet(it->second.toString().toInt());
410 410
     else if (it->first == "YEAR")                      tag.SetYear(it->second.toString().toInt());
411  
-    else if (it->first == "GENRE")                     tag.SetGenre(StringListToVectorString(it->second.toStringList()));
  411
+    else if (it->first == "GENRE")                     SetGenre(tag, StringListToVectorString(it->second.toStringList()));
412 412
     else if (it->first == "COMMENT")                   tag.SetComment(it->second.toString().to8Bit(true));
413 413
     else if (it->first == "ENCODEDBY")                 {}
414 414
     else if (it->first == "COMPILATION")               tag.SetCompilation(it->second.toString().toInt() == 1);
@@ -436,16 +436,16 @@ bool CTagLoaderTagLib::ParseXiphComment(Ogg::XiphComment *xiph, EmbeddedArt *art
436 436
   const Ogg::FieldListMap& fieldListMap = xiph->fieldListMap();
437 437
   for (Ogg::FieldListMap::ConstIterator it = fieldListMap.begin(); it != fieldListMap.end(); ++it)
438 438
   {
439  
-    if (it->first == "ARTIST")                         tag.SetArtist(StringListToVectorString(it->second));
440  
-    else if (it->first == "ALBUMARTIST")               tag.SetAlbumArtist(StringListToVectorString(it->second));
441  
-    else if (it->first == "ALBUM ARTIST")              tag.SetAlbumArtist(StringListToVectorString(it->second));
  439
+    if (it->first == "ARTIST")                         SetArtist(tag, StringListToVectorString(it->second));
  440
+    else if (it->first == "ALBUMARTIST")               SetAlbumArtist(tag, StringListToVectorString(it->second));
  441
+    else if (it->first == "ALBUM ARTIST")              SetAlbumArtist(tag, StringListToVectorString(it->second));
442 442
     else if (it->first == "ALBUM")                     tag.SetAlbum(it->second.front().to8Bit(true));
443 443
     else if (it->first == "TITLE")                     tag.SetTitle(it->second.front().to8Bit(true));
444 444
     else if (it->first == "TRACKNUMBER")               tag.SetTrackNumber(it->second.front().toInt());
445 445
     else if (it->first == "DISCNUMBER")                tag.SetPartOfSet(it->second.front().toInt());
446 446
     else if (it->first == "YEAR")                      tag.SetYear(it->second.front().toInt());
447 447
     else if (it->first == "DATE")                      tag.SetYear(it->second.front().toInt());
448  
-    else if (it->first == "GENRE")                     tag.SetGenre(StringListToVectorString(it->second));
  448
+    else if (it->first == "GENRE")                     SetGenre(tag, StringListToVectorString(it->second));
449 449
     else if (it->first == "COMMENT")                   tag.SetComment(it->second.front().to8Bit(true));
450 450
     else if (it->first == "ENCODEDBY")                 {}
451 451
     else if (it->first == "ENSEMBLE")                  {}
@@ -486,10 +486,10 @@ bool CTagLoaderTagLib::ParseMP4Tag(MP4::Tag *mp4, EmbeddedArt *art, CMusicInfoTa
486 486
   for (MP4::ItemListMap::ConstIterator it = itemListMap.begin(); it != itemListMap.end(); ++it)
487 487
   {
488 488
     if (it->first == "\251nam")      tag.SetTitle(it->second.toStringList().front().to8Bit(true));
489  
-    else if (it->first == "\251ART") tag.SetArtist(StringListToVectorString(it->second.toStringList()));
  489
+    else if (it->first == "\251ART") SetArtist(tag, StringListToVectorString(it->second.toStringList()));
490 490
     else if (it->first == "\251alb") tag.SetAlbum(it->second.toStringList().front().to8Bit(true));
491  
-    else if (it->first == "aART")    tag.SetAlbumArtist(StringListToVectorString(it->second.toStringList()));
492  
-    else if (it->first == "\251gen") tag.SetGenre(StringListToVectorString(it->second.toStringList()));
  491
+    else if (it->first == "aART")    SetAlbumArtist(tag, StringListToVectorString(it->second.toStringList()));
  492
+    else if (it->first == "\251gen") SetGenre(tag, StringListToVectorString(it->second.toStringList()));
493 493
     else if (it->first == "\251cmt") tag.SetComment(it->second.toStringList().front().to8Bit(true));
494 494
     else if (it->first == "cpil")    tag.SetCompilation(it->second.toBool());
495 495
     else if (it->first == "trkn")    tag.SetTrackNumber(it->second.toIntPair().first);
@@ -529,12 +529,12 @@ bool CTagLoaderTagLib::ParseGenericTag(Tag *generic, EmbeddedArt *art, CMusicInf
529 529
   PropertyMap properties = generic->properties();
530 530
   for (PropertyMap::ConstIterator it = properties.begin(); it != properties.end(); ++it)
531 531
   {
532  
-    if (it->first == "ARTIST")                         tag.SetArtist(StringListToVectorString(it->second));
  532
+    if (it->first == "ARTIST")                         SetArtist(tag, StringListToVectorString(it->second));
533 533
     else if (it->first == "ALBUM")                     tag.SetAlbum(it->second.front().to8Bit(true));
534 534
     else if (it->first == "TITLE")                     tag.SetTitle(it->second.front().to8Bit(true));
535 535
     else if (it->first == "TRACKNUMBER")               tag.SetTrackNumber(it->second.front().toInt());
536 536
     else if (it->first == "YEAR")                      tag.SetYear(it->second.front().toInt());
537  
-    else if (it->first == "GENRE")                     tag.SetGenre(StringListToVectorString(it->second));
  537
+    else if (it->first == "GENRE")                     SetGenre(tag, StringListToVectorString(it->second));
538 538
     else if (it->first == "COMMENT")                   tag.SetComment(it->second.front().to8Bit(true));
539 539
   }
540 540
 
@@ -580,3 +580,27 @@ const vector<string> CTagLoaderTagLib::GetID3v2StringList(const ID3v2::FrameList
580 580
     return StringListToVectorString(frame->fieldList());
581 581
   return vector<string>();
582 582
 }
  583
+
  584
+void CTagLoaderTagLib::SetArtist(CMusicInfoTag &tag, const vector<string> &values)
  585
+{
  586
+  if (values.size() == 1)
  587
+    tag.SetArtist(values[0]);
  588
+  else
  589
+    tag.SetArtist(values);
  590
+}
  591
+
  592
+void CTagLoaderTagLib::SetAlbumArtist(CMusicInfoTag &tag, const vector<string> &values)
  593
+{
  594
+  if (values.size() == 1)
  595
+    tag.SetAlbumArtist(values[0]);
  596
+  else
  597
+    tag.SetAlbumArtist(values);
  598
+}
  599
+
  600
+void CTagLoaderTagLib::SetGenre(CMusicInfoTag &tag, const vector<string> &values)
  601
+{
  602
+  if (values.size() == 1)
  603
+    tag.SetGenre(values[0]);
  604
+  else
  605
+    tag.SetGenre(values);
  606
+}
3  xbmc/music/tags/TagLoaderTagLib.h
@@ -69,4 +69,7 @@ class CTagLoaderTagLib
69 69
   bool                           ParseMP4Tag(TagLib::MP4::Tag *mp4, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag);
70 70
   bool                           ParseGenericTag(TagLib::Tag *generic, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag);
71 71
   void                           SetFlacArt(TagLib::FLAC::File *flacFile, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag &tag);
  72
+  void                           SetArtist(MUSIC_INFO::CMusicInfoTag &tag, const std::vector<std::string> &values);
  73
+  void                           SetAlbumArtist(MUSIC_INFO::CMusicInfoTag &tag, const std::vector<std::string> &values);
  74
+  void                           SetGenre(MUSIC_INFO::CMusicInfoTag &tag, const std::vector<std::string> &values);
72 75
 };

0 notes on commit 0358178

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