Skip to content
This repository
Browse code

change compilations logic to detect album_artist set to 'Various' or …

…'Various Artists'
  • Loading branch information...
commit 2a1022c9fa0a277783562e535d8008b284af0d26 1 parent 6ebca65
authored January 06, 2013
29  xbmc/music/infoscanner/MusicInfoScanner.cpp
@@ -658,21 +658,23 @@ void CMusicInfoScanner::CategoriseAlbums(VECSONGS &songsToCheck, VECALBUMS &albu
658 658
     sort(songs.begin(), songs.end(), SortSongsByTrack);
659 659
 
660 660
     // map the songs to their primary artists
661  
-    bool compilation = !i->first.empty();
  661
+    bool tracksOverlap = false;
  662
+    bool hasAlbumArtist = false;
  663
+
662 664
     map<string, vector<CSong *> > artists;
663 665
     for (vector<CSong *>::iterator j = songs.begin(); j != songs.end(); ++j)
664 666
     {
665 667
       CSong *song = *j;
666 668
       // test for song overlap
667 669
       if (j != songs.begin() && song->iTrack == (*(j-1))->iTrack)
668  
-        compilation = false;
  670
+        tracksOverlap = true;
669 671
 
670 672
       // get primary artist
671 673
       string primary;
672 674
       if (!song->albumArtist.empty())
673 675
       {
674 676
         primary = song->albumArtist[0];
675  
-        compilation = false;
  677
+        hasAlbumArtist = true;
676 678
       }
677 679
       else if (!song->artist.empty())
678 680
         primary = song->artist[0];
@@ -683,19 +685,30 @@ void CMusicInfoScanner::CategoriseAlbums(VECSONGS &songsToCheck, VECALBUMS &albu
683 685
 
684 686
     /*
685 687
      We have a compilation if
686  
-     1. album name is non-empty
687  
-     2. no tracks overlap
688  
-     3. no album artist is specified
689  
-     4. we have at least two different primary artists
  688
+     1. album name is non-empty AND
  689
+     2. no tracks overlap AND
  690
+     3a. a unique primary artist is specified as "various" or "various artists" OR
  691
+     3b. we have at least two primary artists and no album artist specified.
690 692
      */
  693
+    bool compilation = !i->first.empty() && !tracksOverlap; // 1+2
691 694
     if (artists.size() == 1)
  695
+    {
  696
+      string artist = artists.begin()->first; StringUtils::ToLower(artist);
  697
+      if (!StringUtils::EqualsNoCase(artist, "various") &&
  698
+          !StringUtils::EqualsNoCase(artist, "various artists")) // 3a
  699
+        compilation = false;
  700
+    }
  701
+    else if (hasAlbumArtist) // 3b
692 702
       compilation = false;
  703
+
693 704
     if (compilation)
694 705
     {
  706
+      CLog::Log(LOGDEBUG, "Album '%s' is a compilation as there's no overlapping tracks and %s", i->first.c_str(), hasAlbumArtist ? "the album artist is 'Various'" : "there is more than one unique artist");
695 707
       artists.clear();
696 708
       std::string various = g_localizeStrings.Get(340); // Various Artists
  709
+      vector<string> va; va.push_back(various);
697 710
       for (vector<CSong *>::iterator j = songs.begin(); j != songs.end(); ++j)
698  
-        (*j)->albumArtist.push_back(various);
  711
+        (*j)->albumArtist = va;
699 712
       artists.insert(make_pair(various, songs));
700 713
     }
701 714
 

0 notes on commit 2a1022c

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