Permalink
Browse files

[thumbloader] set fanart for albums/songs in the music thumbloader

  • Loading branch information...
1 parent 0ce8c15 commit 24a5ea069f3dea482bcc3264bafe045ec4bb6b25 Jonathan Marshall committed May 15, 2012
View
21 xbmc/ThumbLoader.cpp
@@ -538,6 +538,23 @@ bool CMusicThumbLoader::LoadItem(CFileItem* pItem)
return true; // no fallback
}
+ if (!pItem->HasProperty("fanart_image"))
+ {
+ if (pItem->HasMusicInfoTag() && !pItem->GetMusicInfoTag()->GetArtist().empty())
+ {
+ std::string artist = pItem->GetMusicInfoTag()->GetArtist()[0];
+ m_database->Open();
+ int idArtist = m_database->GetArtistByName(artist);
+ if (idArtist >= 0)
+ {
+ string fanart = m_database->GetArtForItem(idArtist, "artist", "fanart");
+ if (!fanart.empty())
+ pItem->SetProperty("fanart_image", fanart);
+ }
+ m_database->Close();
+ }
+ }
+
if (!pItem->HasThumbnail())
pItem->SetUserMusicThumb();
return true;
@@ -573,6 +590,10 @@ bool CMusicThumbLoader::FillLibraryArt(CFileItem &item)
else // nothing found - set an empty thumb so that next time around we don't hit here again
m_database->SetArtForItem(tag.GetDatabaseId(), tag.GetType(), "thumb", "");
}
+ if (tag.GetType() == "song" || tag.GetType() == "album")
+ { // fanart from the artist
+ item.SetProperty("fanart_image", m_database->GetArtistArtForItem(tag.GetDatabaseId(), tag.GetType(), "fanart"));
+ }
m_database->Close();
}
return !item.GetArt().empty();
View
4 xbmc/music/MusicDatabase.cpp
@@ -5084,10 +5084,6 @@ void CMusicDatabase::SetPropertiesForFileItem(CFileItem& item)
if (GetAlbumInfo(idAlbum,album,NULL))
SetPropertiesFromAlbum(item,album);
}
-
- CStdString strFanart = item.GetCachedFanart();
- if (XFILE::CFile::Exists(strFanart))
- item.SetProperty("fanart_image",strFanart);
}
void CMusicDatabase::AnnounceRemove(std::string content, int id)
View
5 xbmc/music/tags/MusicInfoTag.cpp
@@ -127,6 +127,11 @@ const std::vector<std::string>& CMusicInfoTag::GetArtist() const
return m_artist;
}
+int CMusicInfoTag::GetArtistId() const
+{
+ return m_iArtistId;
+}
+
const CStdString& CMusicInfoTag::GetAlbum() const
{
return m_strAlbum;
View
1 xbmc/music/tags/MusicInfoTag.h
@@ -44,6 +44,7 @@ class CMusicInfoTag : public IArchivable, public ISerializable, public ISortable
const CStdString& GetTitle() const;
const CStdString& GetURL() const;
const std::vector<std::string>& GetArtist() const;
+ int GetArtistId() const;
const CStdString& GetAlbum() const;
const std::vector<std::string>& GetAlbumArtist() const;
const std::vector<std::string> GetGenre() const;
View
32 xbmc/music/windows/GUIWindowMusicBase.cpp
@@ -692,7 +692,6 @@ void CGUIWindowMusicBase::AddItemToPlayList(const CFileItemPtr &pItem, CFileItem
GetDirectory(pItem->GetPath(), items);
//OnRetrieveMusicInfo(items);
FormatAndSort(items);
- SetupFanart(items);
for (int i = 0; i < items.Size(); ++i)
AddItemToPlayList(items[i], queuedItems);
}
@@ -1349,37 +1348,6 @@ void CGUIWindowMusicBase::OnPrepareFileItems(CFileItemList &items)
items.SetCachedMusicThumbs();
}
-void CGUIWindowMusicBase::SetupFanart(CFileItemList& items)
-{
- // set fanart
- map<CStdString, CStdString> artists;
- for (int i = 0; i < items.Size(); i++)
- {
- CFileItemPtr item = items[i];
- CStdString strArtist;
- if (item->HasProperty("fanart_image"))
- continue;
- if (item->HasMusicInfoTag())
- strArtist = StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator);
- if (item->HasVideoInfoTag())
- strArtist = StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator);
- if (strArtist.IsEmpty())
- continue;
- map<CStdString, CStdString>::iterator artist = artists.find(strArtist);
- if (artist == artists.end())
- {
- CStdString strFanart = item->GetCachedFanart();
- if (XFILE::CFile::Exists(strFanart))
- item->SetProperty("fanart_image",strFanart);
- else
- strFanart = "";
- artists.insert(make_pair(strArtist, strFanart));
- }
- else
- item->SetProperty("fanart_image",artist->second);
- }
-}
-
CStdString CGUIWindowMusicBase::GetStartFolder(const CStdString &dir)
{
if (dir.Equals("Plugins") || dir.Equals("Addons"))
View
1 xbmc/music/windows/GUIWindowMusicBase.h
@@ -49,7 +49,6 @@ class CGUIWindowMusicBase : public CGUIMediaWindow
virtual bool OnBack(int actionID);
void OnInfo(CFileItem *pItem, bool bShowInfo = false);
- static void SetupFanart(CFileItemList& items);
protected:
/*!
View
3 xbmc/music/windows/GUIWindowMusicPlaylistEditor.cpp
@@ -170,9 +170,6 @@ void CGUIWindowMusicPlaylistEditor::OnPrepareFileItems(CFileItemList &items)
{
RetrieveMusicInfo();
- // set fanart
- SetupFanart(items);
-
items.SetCachedMusicThumbs();
}

0 comments on commit 24a5ea0

Please sign in to comment.