Browse files

[infoscanner] remove old album categorisation and thumb updating func…

…tions from the infoscanner
  • Loading branch information...
1 parent a29d994 commit 58a38d8d9a4910c0d5a5fb8e29a2ab09270f6c15 Jonathan Marshall committed Jun 30, 2012
Showing with 0 additions and 143 deletions.
  1. +0 −140 xbmc/music/infoscanner/MusicInfoScanner.cpp
  2. +0 −3 xbmc/music/infoscanner/MusicInfoScanner.h
View
140 xbmc/music/infoscanner/MusicInfoScanner.cpp
@@ -48,7 +48,6 @@
#include "utils/TimeUtils.h"
#include "utils/log.h"
#include "utils/URIUtils.h"
-#include "ThumbnailCache.h"
#include "TextureCache.h"
#include "ThumbLoader.h"
#include "interfaces/AnnouncementManager.h"
@@ -790,145 +789,6 @@ void CMusicInfoScanner::FindArtForAlbums(VECALBUMS &albums, const CStdString &pa
}
}
-void CMusicInfoScanner::CheckForVariousArtists(VECSONGS &songsToCheck)
-{
- // first, find all the album names for these songs
- map<CStdString, vector<CSong *> > albumsToAdd;
- map<CStdString, vector<CSong *> >::iterator it;
- for (unsigned int i = 0; i < songsToCheck.size(); ++i)
- {
- CSong &song = songsToCheck[i];
- if (!song.albumArtist.empty()) // albumartist specified, so assume the user knows what they're doing
- continue;
- it = albumsToAdd.find(song.strAlbum);
- if (it == albumsToAdd.end())
- {
- vector<CSong *> songs;
- songs.push_back(&song);
- albumsToAdd.insert(make_pair(song.strAlbum, songs));
- }
- else
- it->second.push_back(&song);
- }
- // as an additional check for those that have multiple albums in the same folder, ignore albums
- // that have overlapping track numbers
- for (it = albumsToAdd.begin(); it != albumsToAdd.end();)
- {
- vector<CSong *> &songs = it->second;
- bool overlappingTrackNumbers(false);
- if (songs.size() > 1)
- {
- sort(songs.begin(), songs.end(), SortSongsByTrack);
- for (unsigned int i = 0; i < songs.size() - 1; i++)
- {
- CSong *song = songs[i];
- CSong *song2 = songs[i+1];
- if (song->iTrack == song2->iTrack)
- {
- overlappingTrackNumbers = true;
- break;
- }
- }
- }
- if (overlappingTrackNumbers)
- { // remove this album
- albumsToAdd.erase(it++);
- }
- else
- it++;
- }
-
- // ok, now run through these albums, and check whether they qualify as a "various artist" album
- // an album is considered a various artists album if the songs' primary artist differs
- // it qualifies as a "single artist with featured artists" album if the primary artist is the same, but secondary artists differ
- for (it = albumsToAdd.begin(); it != albumsToAdd.end(); it++)
- {
- const CStdString &album = it->first;
- vector<CSong *> &songs = it->second;
- if (!album.IsEmpty() && songs.size() > 1)
- {
- bool variousArtists(false);
- bool singleArtistWithFeaturedArtists(false);
- for (unsigned int i = 0; i < songs.size() - 1; i++)
- {
- CSong *song1 = songs[i];
- CSong *song2 = songs[i+1];
- CStdString primaryArtist1 = song1->artist[0]; primaryArtist1.TrimRight();
- CStdString primaryArtist2 = song2->artist[0]; primaryArtist2.TrimRight();
- if (primaryArtist1 != primaryArtist2)
- { // primary artist differs -> a various artists album
- variousArtists = true;
- break;
- }
- else if (StringUtils::Join(song1->artist, g_advancedSettings.m_musicItemSeparator) != StringUtils::Join(song2->artist, g_advancedSettings.m_musicItemSeparator))
- { // have more than one artist, the first artist(s) agree, but the full artist name doesn't
- // so this is likely a single-artist compilation (ie with other artists featured on some tracks) album
- singleArtistWithFeaturedArtists = true;
- }
- }
- if (variousArtists)
- { // have a various artists album - update all songs to be the various artist
- for (unsigned int i = 0; i < songs.size(); i++)
- {
- CSong *song = songs[i];
- song->albumArtist.clear();
- song->albumArtist.push_back(g_localizeStrings.Get(340)); // Various Artists
- }
- }
- else if (singleArtistWithFeaturedArtists)
- { // have an album where all the first artists agree - make this the album artist
- CStdString albumArtist(songs[0]->artist[0]);
- for (unsigned int i = 0; i < songs.size(); i++)
- {
- CSong *song = songs[i];
- song->albumArtist = StringUtils::Split(albumArtist, g_advancedSettings.m_musicItemSeparator); // first artist of all tracks
- }
- }
- }
- }
-}
-
-bool CMusicInfoScanner::HasSingleAlbum(const VECSONGS &songs, CStdString &album, CStdString &artist)
-{
- // check how many unique albums are in this path, and if there's only one, and it has a thumb
- // then cache the thumb as the folder thumb
- for (unsigned int i = 0; i < songs.size(); i++)
- {
- const CSong &song = songs[i];
- // don't bother with empty album tags - they're treated as singles, and there's no way to determine
- // whether more than one track in the folder is supposed to mean they belong to an "album"
- if (song.strAlbum.IsEmpty())
- return false;
-
- CStdString albumArtist = StringUtils::Join(song.albumArtist.empty() ? song.artist : song.albumArtist, g_advancedSettings.m_musicItemSeparator);
-
- if (!album.IsEmpty() && (album != song.strAlbum || artist != albumArtist))
- return false; // have more than one album
-
- album = song.strAlbum;
- artist = albumArtist;
- }
- return !album.IsEmpty();
-}
-
-void CMusicInfoScanner::UpdateFolderThumb(const VECSONGS &songs, const CStdString &folderPath)
-{
- CStdString album, artist;
- if (!HasSingleAlbum(songs, album, artist)) return;
- // Was the album art of this album read during scan?
- CStdString albumCoverArt(CThumbnailCache::GetAlbumThumb(album, artist));
- if (CUtil::ThumbExists(albumCoverArt))
- {
- CStdString folderPath1(folderPath);
- // Folder art is cached without the slash at end
- URIUtils::RemoveSlashAtEnd(folderPath1);
- CStdString folderCoverArt(CThumbnailCache::GetMusicThumb(folderPath1));
- // copy as directory thumb as well
- if (CFile::Cache(albumCoverArt, folderCoverArt))
- CUtil::ThumbCacheAdd(folderCoverArt, true);
- }
-}
-
// This function is run by another thread
void CMusicInfoScanner::Run()
{
View
3 xbmc/music/infoscanner/MusicInfoScanner.h
@@ -93,8 +93,6 @@ class CMusicInfoScanner : CThread, public IRunnable
\param path [in] path containing albums.
*/
static void FindArtForAlbums(VECALBUMS &albums, const CStdString &path);
- static void CheckForVariousArtists(VECSONGS &songs);
- static bool HasSingleAlbum(const VECSONGS &songs, CStdString &album, CStdString &artist);
bool DownloadAlbumInfo(const CStdString& strPath, const CStdString& strArtist, const CStdString& strAlbum, bool& bCanceled, MUSIC_GRABBER::CMusicAlbumInfo& album, CGUIDialogProgress* pDialog=NULL);
bool DownloadArtistInfo(const CStdString& strPath, const CStdString& strArtist, bool& bCanceled, CGUIDialogProgress* pDialog=NULL);
@@ -103,7 +101,6 @@ class CMusicInfoScanner : CThread, public IRunnable
protected:
virtual void Process();
int RetrieveMusicInfo(CFileItemList& items, const CStdString& strDirectory);
- void UpdateFolderThumb(const VECSONGS &songs, const CStdString &folderPath);
int GetPathHash(const CFileItemList &items, CStdString &hash);
void GetAlbumArtwork(long id, const CAlbum &artist);

0 comments on commit 58a38d8

Please sign in to comment.