Skip to content
Browse files

recentlyadded: remember the cover and fanart of an album

When retrieving multiple songs of the same album for recently added album
songs, remember the album's cover and fanart and therefore avoid querying
and retrieving the same cover and fanart multiple times.
  • Loading branch information...
1 parent fcb6107 commit ea3ea3675830a12753de689b6e4e344c250da700 @Montellese committed
Showing with 20 additions and 6 deletions.
  1. +20 −6 xbmc/utils/RecentlyAddedJob.cpp
View
26 xbmc/utils/RecentlyAddedJob.cpp
@@ -229,9 +229,12 @@ bool CRecentlyAddedJob::UpdateMusic()
musicdatabase.Open();
if (musicdatabase.GetRecentlyAddedAlbumSongs("musicdb://", musicItems, NUM_ITEMS))
- {
+ {
+ long idAlbum = -1;
+ CStdString strAlbumThumb;
+ CStdString strAlbumFanart;
for (; i < musicItems.Size(); ++i)
- {
+ {
CFileItemPtr item = musicItems.Get(i);
CStdString value;
value.Format("%i", i + 1);
@@ -239,8 +242,19 @@ bool CRecentlyAddedJob::UpdateMusic()
CStdString strRating;
CStdString strAlbum = item->GetMusicInfoTag()->GetAlbum();
CStdString strArtist = StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator);
-
- loader.LoadItem(item.get());
+
+ if (idAlbum != item->GetMusicInfoTag()->GetAlbumId())
+ {
+ strAlbumThumb.clear();
+ strAlbumFanart.clear();
+ idAlbum = item->GetMusicInfoTag()->GetAlbumId();
+
+ if (loader.LoadItem(item.get()))
+ {
+ strAlbumThumb = item->GetThumbnailImage();
+ strAlbumFanart = item->GetProperty("fanart_image").asString();
+ }
+ }
strRating.Format("%c", item->GetMusicInfoTag()->GetRating());
@@ -250,8 +264,8 @@ bool CRecentlyAddedJob::UpdateMusic()
home->SetProperty("LatestSong." + value + ".Album" , strAlbum);
home->SetProperty("LatestSong." + value + ".Rating" , strRating);
home->SetProperty("LatestSong." + value + ".Path" , item->GetMusicInfoTag()->GetURL());
- home->SetProperty("LatestSong." + value + ".Thumb" , item->GetThumbnailImage());
- home->SetProperty("LatestSong." + value + ".Fanart" , item->GetProperty("fanart_image"));
+ home->SetProperty("LatestSong." + value + ".Thumb" , strAlbumThumb);
+ home->SetProperty("LatestSong." + value + ".Fanart" , strAlbumFanart);
}
}
for (; i < NUM_ITEMS; ++i)

0 comments on commit ea3ea36

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