Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 24a5ea069f3dea482bcc3264bafe045ec4bb6b25 1 parent 0ce8c15
Jonathan Marshall authored
21 xbmc/ThumbLoader.cpp
@@ -538,6 +538,23 @@ bool CMusicThumbLoader::LoadItem(CFileItem* pItem)
538 538 return true; // no fallback
539 539 }
540 540
  541 + if (!pItem->HasProperty("fanart_image"))
  542 + {
  543 + if (pItem->HasMusicInfoTag() && !pItem->GetMusicInfoTag()->GetArtist().empty())
  544 + {
  545 + std::string artist = pItem->GetMusicInfoTag()->GetArtist()[0];
  546 + m_database->Open();
  547 + int idArtist = m_database->GetArtistByName(artist);
  548 + if (idArtist >= 0)
  549 + {
  550 + string fanart = m_database->GetArtForItem(idArtist, "artist", "fanart");
  551 + if (!fanart.empty())
  552 + pItem->SetProperty("fanart_image", fanart);
  553 + }
  554 + m_database->Close();
  555 + }
  556 + }
  557 +
541 558 if (!pItem->HasThumbnail())
542 559 pItem->SetUserMusicThumb();
543 560 return true;
@@ -573,6 +590,10 @@ bool CMusicThumbLoader::FillLibraryArt(CFileItem &item)
573 590 else // nothing found - set an empty thumb so that next time around we don't hit here again
574 591 m_database->SetArtForItem(tag.GetDatabaseId(), tag.GetType(), "thumb", "");
575 592 }
  593 + if (tag.GetType() == "song" || tag.GetType() == "album")
  594 + { // fanart from the artist
  595 + item.SetProperty("fanart_image", m_database->GetArtistArtForItem(tag.GetDatabaseId(), tag.GetType(), "fanart"));
  596 + }
576 597 m_database->Close();
577 598 }
578 599 return !item.GetArt().empty();
4 xbmc/music/MusicDatabase.cpp
@@ -5084,10 +5084,6 @@ void CMusicDatabase::SetPropertiesForFileItem(CFileItem& item)
5084 5084 if (GetAlbumInfo(idAlbum,album,NULL))
5085 5085 SetPropertiesFromAlbum(item,album);
5086 5086 }
5087   -
5088   - CStdString strFanart = item.GetCachedFanart();
5089   - if (XFILE::CFile::Exists(strFanart))
5090   - item.SetProperty("fanart_image",strFanart);
5091 5087 }
5092 5088
5093 5089 void CMusicDatabase::AnnounceRemove(std::string content, int id)
5 xbmc/music/tags/MusicInfoTag.cpp
@@ -127,6 +127,11 @@ const std::vector<std::string>& CMusicInfoTag::GetArtist() const
127 127 return m_artist;
128 128 }
129 129
  130 +int CMusicInfoTag::GetArtistId() const
  131 +{
  132 + return m_iArtistId;
  133 +}
  134 +
130 135 const CStdString& CMusicInfoTag::GetAlbum() const
131 136 {
132 137 return m_strAlbum;
1  xbmc/music/tags/MusicInfoTag.h
@@ -44,6 +44,7 @@ class CMusicInfoTag : public IArchivable, public ISerializable, public ISortable
44 44 const CStdString& GetTitle() const;
45 45 const CStdString& GetURL() const;
46 46 const std::vector<std::string>& GetArtist() const;
  47 + int GetArtistId() const;
47 48 const CStdString& GetAlbum() const;
48 49 const std::vector<std::string>& GetAlbumArtist() const;
49 50 const std::vector<std::string> GetGenre() const;
32 xbmc/music/windows/GUIWindowMusicBase.cpp
@@ -692,7 +692,6 @@ void CGUIWindowMusicBase::AddItemToPlayList(const CFileItemPtr &pItem, CFileItem
692 692 GetDirectory(pItem->GetPath(), items);
693 693 //OnRetrieveMusicInfo(items);
694 694 FormatAndSort(items);
695   - SetupFanart(items);
696 695 for (int i = 0; i < items.Size(); ++i)
697 696 AddItemToPlayList(items[i], queuedItems);
698 697 }
@@ -1349,37 +1348,6 @@ void CGUIWindowMusicBase::OnPrepareFileItems(CFileItemList &items)
1349 1348 items.SetCachedMusicThumbs();
1350 1349 }
1351 1350
1352   -void CGUIWindowMusicBase::SetupFanart(CFileItemList& items)
1353   -{
1354   - // set fanart
1355   - map<CStdString, CStdString> artists;
1356   - for (int i = 0; i < items.Size(); i++)
1357   - {
1358   - CFileItemPtr item = items[i];
1359   - CStdString strArtist;
1360   - if (item->HasProperty("fanart_image"))
1361   - continue;
1362   - if (item->HasMusicInfoTag())
1363   - strArtist = StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator);
1364   - if (item->HasVideoInfoTag())
1365   - strArtist = StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator);
1366   - if (strArtist.IsEmpty())
1367   - continue;
1368   - map<CStdString, CStdString>::iterator artist = artists.find(strArtist);
1369   - if (artist == artists.end())
1370   - {
1371   - CStdString strFanart = item->GetCachedFanart();
1372   - if (XFILE::CFile::Exists(strFanart))
1373   - item->SetProperty("fanart_image",strFanart);
1374   - else
1375   - strFanart = "";
1376   - artists.insert(make_pair(strArtist, strFanart));
1377   - }
1378   - else
1379   - item->SetProperty("fanart_image",artist->second);
1380   - }
1381   -}
1382   -
1383 1351 CStdString CGUIWindowMusicBase::GetStartFolder(const CStdString &dir)
1384 1352 {
1385 1353 if (dir.Equals("Plugins") || dir.Equals("Addons"))
1  xbmc/music/windows/GUIWindowMusicBase.h
@@ -49,7 +49,6 @@ class CGUIWindowMusicBase : public CGUIMediaWindow
49 49 virtual bool OnBack(int actionID);
50 50
51 51 void OnInfo(CFileItem *pItem, bool bShowInfo = false);
52   - static void SetupFanart(CFileItemList& items);
53 52
54 53 protected:
55 54 /*!
3  xbmc/music/windows/GUIWindowMusicPlaylistEditor.cpp
@@ -170,9 +170,6 @@ void CGUIWindowMusicPlaylistEditor::OnPrepareFileItems(CFileItemList &items)
170 170 {
171 171 RetrieveMusicInfo();
172 172
173   - // set fanart
174   - SetupFanart(items);
175   -
176 173 items.SetCachedMusicThumbs();
177 174 }
178 175

0 comments on commit 24a5ea0

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