move GetCached*Thumb() logic from CFileItem/CUtil to CThumbnailCache
authormontellese <montellese@xbmc.org>
Mon, 20 Jun 2011 13:06:36 +0000 (15:06 +0200)
committermontellese <montellese@xbmc.org>
Mon, 20 Jun 2011 13:06:36 +0000 (15:06 +0200)
17 files changed:
xbmc/FileItem.cpp
xbmc/ThumbnailCache.cpp
xbmc/ThumbnailCache.h
xbmc/Util.cpp
xbmc/Util.h
xbmc/dialogs/GUIDialogContextMenu.cpp
xbmc/interfaces/http-api/XBMChttp.cpp
xbmc/interfaces/json-rpc/AudioLibrary.cpp
xbmc/music/dialogs/GUIDialogMusicInfo.cpp
xbmc/music/dialogs/GUIDialogSongInfo.cpp
xbmc/music/infoscanner/MusicInfoScanner.cpp
xbmc/music/tags/FlacTag.cpp
xbmc/music/tags/Id3Tag.cpp
xbmc/music/tags/MusicInfoTagLoaderMP4.cpp
xbmc/music/tags/MusicInfoTagLoaderWMA.cpp
xbmc/music/windows/GUIWindowMusicBase.cpp
xbmc/video/VideoDatabase.cpp

index 19053eb..d7526f8 100644 (file)
@@ -55,6 +55,7 @@
 #include "utils/log.h"
 #include "utils/Variant.h"
 #include "music/karaoke/karaokelyricsfactory.h"
+#include "ThumbnailCache.h"
 
 using namespace std;
 using namespace XFILE;
@@ -954,21 +955,17 @@ void CFileItem::FillInDefaultIcon()
 
 CStdString CFileItem::GetCachedArtistThumb() const
 {
-  return GetCachedThumb("artist"+GetLabel(),g_settings.GetMusicArtistThumbFolder());
+  return CThumbnailCache::GetArtistThumb(*this);
 }
 
 CStdString CFileItem::GetCachedSeasonThumb() const
 {
-  CStdString seasonPath;
-  if (HasVideoInfoTag())
-    seasonPath = GetVideoInfoTag()->m_strPath;
-
-  return GetCachedThumb("season"+seasonPath+GetLabel(),g_settings.GetVideoThumbFolder(),true);
+  return CThumbnailCache::GetSeasonThumb(*this);
 }
 
 CStdString CFileItem::GetCachedActorThumb() const
 {
-  return GetCachedThumb("actor"+GetLabel(),g_settings.GetVideoThumbFolder(),true);
+  return CThumbnailCache::GetActorThumb(*this);
 }
 
 void CFileItem::SetCachedArtistThumb()
@@ -2410,7 +2407,7 @@ CStdString CFileItem::GetPreviouslyCachedMusicThumb() const
   if (!strAlbum.IsEmpty() && !strArtist.IsEmpty())
   {
     // try permanent album thumb using "album name + artist name"
-    CStdString thumb(CUtil::GetCachedAlbumThumb(strAlbum, strArtist));
+    CStdString thumb(CThumbnailCache::GetAlbumThumb(strAlbum, strArtist));
     if (CFile::Exists(thumb))
       return thumb;
   }
@@ -2419,7 +2416,7 @@ CStdString CFileItem::GetPreviouslyCachedMusicThumb() const
   if (!m_bIsFolder)
   {
     // look for locally cached tbn
-    CStdString thumb(CUtil::GetCachedMusicThumb(m_strPath));
+    CStdString thumb(CThumbnailCache::GetMusicThumb(m_strPath));
     if (CFile::Exists(thumb))
       return thumb;
   }
@@ -2433,7 +2430,7 @@ CStdString CFileItem::GetPreviouslyCachedMusicThumb() const
   // music thumbs are cached without slash at end
   URIUtils::RemoveSlashAtEnd(strPath);
 
-  CStdString thumb(CUtil::GetCachedMusicThumb(strPath));
+  CStdString thumb(CThumbnailCache::GetMusicThumb(strPath));
   if (CFile::Exists(thumb))
     return thumb;
 
@@ -2493,7 +2490,7 @@ void CFileItem::SetUserMusicThumb(bool alwaysCheckRemote /* = false */)
   CStdString thumb(GetUserMusicThumb(alwaysCheckRemote));
   if (!thumb.IsEmpty())
   {
-    CStdString cachedThumb(CUtil::GetCachedMusicThumb(m_strPath));
+    CStdString cachedThumb(CThumbnailCache::GetMusicThumb(m_strPath));
     CPicture::CreateThumbnail(thumb, cachedThumb);
   }
 
@@ -2502,24 +2499,12 @@ void CFileItem::SetUserMusicThumb(bool alwaysCheckRemote /* = false */)
 
 CStdString CFileItem::GetCachedVideoThumb() const
 {
-  if (IsStack())
-    return GetCachedThumb(CStackDirectory::GetFirstStackedFile(m_strPath),g_settings.GetVideoThumbFolder(),true);
-  else if (IsVideoDb() && HasVideoInfoTag())
-  {
-    if (m_bIsFolder && !GetVideoInfoTag()->m_strPath.IsEmpty())
-      return GetCachedThumb(GetVideoInfoTag()->m_strPath, g_settings.GetVideoThumbFolder(), true);
-    else if (!GetVideoInfoTag()->m_strFileNameAndPath.IsEmpty())
-      return GetCachedThumb(GetVideoInfoTag()->m_strFileNameAndPath, g_settings.GetVideoThumbFolder(), true);
-  }
-  return GetCachedThumb(m_strPath,g_settings.GetVideoThumbFolder(),true);
+  return CThumbnailCache::GetVideoThumb(*this);
 }
 
 CStdString CFileItem::GetCachedEpisodeThumb() const
 {
-  // get the locally cached thumb
-  CStdString strCRC;
-  strCRC.Format("%sepisode%i",GetVideoInfoTag()->m_strFileNameAndPath.c_str(),GetVideoInfoTag()->m_iEpisode);
-  return GetCachedThumb(strCRC,g_settings.GetVideoThumbFolder(),true);
+  return CThumbnailCache::GetEpisodeThumb(*this);
 }
 
 void CFileItem::SetCachedVideoThumb()
@@ -2816,47 +2801,12 @@ CStdString CFileItem::GetLocalFanart() const
 
 CStdString CFileItem::GetCachedFanart() const
 {
-  // get the locally cached thumb
-  if (IsVideoDb())
-  {
-    if (!HasVideoInfoTag())
-      return "";
-    if (!GetVideoInfoTag()->m_strArtist.IsEmpty())
-      return GetCachedThumb(GetVideoInfoTag()->m_strArtist,g_settings.GetMusicFanartFolder());
-    if (!m_bIsFolder && !GetVideoInfoTag()->m_strShowTitle.IsEmpty())
-    {
-      CVideoDatabase database;
-      database.Open();
-      int iShowId = database.GetTvShowId(GetVideoInfoTag()->m_strPath);
-      CStdString showPath;
-      database.GetFilePathById(iShowId,showPath,VIDEODB_CONTENT_TVSHOWS);
-      return GetCachedThumb(showPath,g_settings.GetVideoFanartFolder());
-    }
-    return GetCachedThumb(m_bIsFolder ? GetVideoInfoTag()->m_strPath : GetVideoInfoTag()->m_strFileNameAndPath,g_settings.GetVideoFanartFolder());
-  }
-  if (HasMusicInfoTag())
-    return GetCachedThumb(GetMusicInfoTag()->GetArtist(),g_settings.GetMusicFanartFolder());
-
-  return GetCachedThumb(m_strPath,g_settings.GetVideoFanartFolder());
+  return CThumbnailCache::GetFanart(*this);
 }
 
 CStdString CFileItem::GetCachedThumb(const CStdString &path, const CStdString &path2, bool split)
 {
-  // get the locally cached thumb
-  Crc32 crc;
-  crc.ComputeFromLowerCase(path);
-
-  CStdString thumb;
-  if (split)
-  {
-    CStdString hex;
-    hex.Format("%08x", (__int32)crc);
-    thumb.Format("%c\\%08x.tbn", hex[0], (unsigned __int32)crc);
-  }
-  else
-    thumb.Format("%08x.tbn", (unsigned __int32)crc);
-
-  return URIUtils::AddFileToFolder(path2, thumb);
+  return CThumbnailCache::GetThumb(path, path2, split);
 }
 
 /*void CFileItem::SetThumb()
index 39d13c6..9c3dd2d 100644 (file)
 #include "filesystem/File.h"
 #include "threads/SingleLock.h"
 
+#include "FileItem.h"
+#include "video/VideoInfoTag.h"
+#include "video/VideoDatabase.h"
+#include "music/tags/MusicInfoTag.h"
+#include "music/Album.h"
+#include "music/Artist.h"
+#include "settings/Settings.h"
+#include "URIUtils.h"
+#include "Crc32.h"
+#include "filesystem/StackDirectory.h"
+
 using namespace std;
 using namespace XFILE;
+using namespace MUSIC_INFO;
 
 CThumbnailCache* CThumbnailCache::m_pCacheInstance = NULL;
 
@@ -97,3 +109,157 @@ void CThumbnailCache::Add(const CStdString& strFileName, bool bExists)
   else
     m_Cache.insert(pair<CStdString, bool>(strFileName, bExists));
 }
+
+CStdString CThumbnailCache::GetAlbumThumb(const CFileItem &item)
+{
+  return GetAlbumThumb(item.GetMusicInfoTag());
+}
+
+CStdString CThumbnailCache::GetAlbumThumb(const CMusicInfoTag *musicInfo)
+{
+  if (!musicInfo)
+    return CStdString();
+
+  return GetAlbumThumb(musicInfo->GetAlbum(), !musicInfo->GetArtist().empty() ? musicInfo->GetArtist() : musicInfo->GetAlbumArtist());
+}
+
+CStdString CThumbnailCache::GetAlbumThumb(const CAlbum &album)
+{
+  return GetAlbumThumb(album.strAlbum, album.strArtist);
+}
+
+CStdString CThumbnailCache::GetAlbumThumb(const CStdString& album, const CStdString& artist)
+{
+  if (album.IsEmpty())
+    return GetMusicThumb("unknown" + artist);
+  if (artist.IsEmpty())
+    return GetMusicThumb(album + "unknown");
+  return GetMusicThumb(album + artist);
+}
+
+CStdString CThumbnailCache::GetArtistThumb(const CFileItem &item)
+{
+  return GetArtistThumb(item.GetLabel());
+}
+
+CStdString CThumbnailCache::GetArtistThumb(const CArtist &artist)
+{
+  return GetArtistThumb(artist.strArtist);
+}
+
+CStdString CThumbnailCache::GetArtistThumb(const CStdString &label)
+{
+  return GetThumb("artist" + label, g_settings.GetMusicArtistThumbFolder());
+}
+
+CStdString CThumbnailCache::GetActorThumb(const CFileItem &item)
+{
+  return GetActorThumb(item.GetLabel());
+}
+
+CStdString CThumbnailCache::GetActorThumb(const CStdString &label)
+{
+  return GetThumb("actor" + label, g_settings.GetVideoThumbFolder(), true);
+}
+
+CStdString CThumbnailCache::GetSeasonThumb(const CFileItem &item)
+{
+  return GetSeasonThumb(item.GetLabel(), item.GetVideoInfoTag());
+}
+
+CStdString CThumbnailCache::GetSeasonThumb(const CStdString &label, const CVideoInfoTag *videoInfo /* = NULL */)
+{
+  CStdString seasonPath;
+  if (videoInfo)
+    seasonPath = videoInfo->m_strPath;
+
+  return GetThumb("season" + seasonPath + label, g_settings.GetVideoThumbFolder(), true);
+}
+
+CStdString CThumbnailCache::GetEpisodeThumb(const CFileItem &item)
+{
+  if (!item.HasVideoInfoTag())
+    return CStdString();
+
+  return GetEpisodeThumb(item.GetVideoInfoTag());
+}
+
+CStdString CThumbnailCache::GetEpisodeThumb(const CVideoInfoTag* videoInfo)
+{
+  // get the locally cached thumb
+  CStdString strCRC;
+  strCRC.Format("%sepisode%i", videoInfo->m_strFileNameAndPath.c_str(), videoInfo->m_iEpisode);
+  return GetThumb(strCRC, g_settings.GetVideoThumbFolder(), true);
+}
+
+CStdString CThumbnailCache::GetVideoThumb(const CFileItem &item)
+{
+  if (item.IsStack())
+    return GetThumb(CStackDirectory::GetFirstStackedFile(item.m_strPath), g_settings.GetVideoThumbFolder(), true);
+  else if (item.IsVideoDb() && item.HasVideoInfoTag())
+  {
+    if (item.m_bIsFolder && !item.GetVideoInfoTag()->m_strPath.IsEmpty())
+      return GetThumb(item.GetVideoInfoTag()->m_strPath, g_settings.GetVideoThumbFolder(), true);
+    else if (!item.GetVideoInfoTag()->m_strFileNameAndPath.IsEmpty())
+      return GetThumb(item.GetVideoInfoTag()->m_strFileNameAndPath, g_settings.GetVideoThumbFolder(), true);
+  }
+  return GetThumb(item.m_strPath, g_settings.GetVideoThumbFolder(), true);
+}
+
+CStdString CThumbnailCache::GetFanart(const CFileItem &item)
+{
+  // get the locally cached thumb
+  if (item.IsVideoDb())
+  {
+    if (!item.HasVideoInfoTag())
+      return "";
+    if (!item.GetVideoInfoTag()->m_strArtist.IsEmpty())
+      return GetThumb(item.GetVideoInfoTag()->m_strArtist,g_settings.GetMusicFanartFolder());
+    if (!item.m_bIsFolder && !item.GetVideoInfoTag()->m_strShowTitle.IsEmpty())
+    {
+      CVideoDatabase database;
+      database.Open();
+      int iShowId = database.GetTvShowId(item.GetVideoInfoTag()->m_strPath);
+      CStdString showPath;
+      database.GetFilePathById(iShowId,showPath,VIDEODB_CONTENT_TVSHOWS);
+      return GetThumb(showPath,g_settings.GetVideoFanartFolder());
+    }
+    return GetThumb(item.m_bIsFolder ? item.GetVideoInfoTag()->m_strPath : item.GetVideoInfoTag()->m_strFileNameAndPath,g_settings.GetVideoFanartFolder());
+  }
+  if (item.HasMusicInfoTag())
+    return GetThumb(item.GetMusicInfoTag()->GetArtist(),g_settings.GetMusicFanartFolder());
+
+  return GetThumb(item.m_strPath,g_settings.GetVideoFanartFolder());
+}
+
+CStdString CThumbnailCache::GetThumb(const CStdString &path, const CStdString &path2, bool split /* = false */)
+{
+  // get the locally cached thumb
+  Crc32 crc;
+  crc.ComputeFromLowerCase(path);
+
+  CStdString thumb;
+  if (split)
+  {
+    CStdString hex;
+    hex.Format("%08x", (__int32)crc);
+    thumb.Format("%c\\%08x.tbn", hex[0], (unsigned __int32)crc);
+  }
+  else
+    thumb.Format("%08x.tbn", (unsigned __int32)crc);
+
+  return URIUtils::AddFileToFolder(path2, thumb);
+}
+
+CStdString CThumbnailCache::GetMusicThumb(const CStdString& path)
+{
+  Crc32 crc;
+  CStdString noSlashPath(path);
+  URIUtils::RemoveSlashAtEnd(noSlashPath);
+  crc.ComputeFromLowerCase(noSlashPath);
+  CStdString hex;
+  hex.Format("%08x", (unsigned __int32) crc);
+  CStdString thumb;
+  thumb.Format("%c/%s.tbn", hex[0], hex.c_str());
+  return URIUtils::AddFileToFolder(g_settings.GetMusicThumbFolder(), thumb);
+}
index d93eec5..2435a75 100644 (file)
 #include <map>
 
 class CCriticalSection;
+class CVideoInfoTag;
+namespace MUSIC_INFO 
+{
+  class CMusicInfoTag;
+}
+class CAlbum;
+class CArtist;
+class CFileItem;
 
 class CThumbnailCache
 {
@@ -38,6 +46,24 @@ public:
   void Add(const CStdString& strFileName, bool bExists);
   void Clear();
   bool IsCached(const CStdString& strFileName);
+
+  static CStdString GetMusicThumb(const CStdString &path);
+  static CStdString GetAlbumThumb(const CFileItem &item);
+  static CStdString GetAlbumThumb(const MUSIC_INFO::CMusicInfoTag *musicInfo);
+  static CStdString GetAlbumThumb(const CAlbum &album);
+  static CStdString GetAlbumThumb(const CStdString &album, const CStdString &artist);
+  static CStdString GetArtistThumb(const CArtist &artist);
+  static CStdString GetArtistThumb(const CFileItem &item);
+  static CStdString GetArtistThumb(const CStdString &label);
+  static CStdString GetActorThumb(const CFileItem &item);
+  static CStdString GetActorThumb(const CStdString &label);
+  static CStdString GetSeasonThumb(const CFileItem &item);
+  static CStdString GetSeasonThumb(const CStdString &label, const CVideoInfoTag *videoInfo = NULL);
+  static CStdString GetEpisodeThumb(const CFileItem &item);
+  static CStdString GetEpisodeThumb(const CVideoInfoTag *videoInfo);
+  static CStdString GetVideoThumb(const CFileItem &item);
+  static CStdString GetFanart(const CFileItem &item);
+  static CStdString GetThumb(const CStdString &path, const CStdString &path2, bool split = false);
 protected:
 
   static CThumbnailCache* m_pCacheInstance;
index 6ce7517..99f6700 100644 (file)
@@ -1892,28 +1892,6 @@ bool CUtil::SupportsFileOperations(const CStdString& strPath)
   return false;
 }
 
-CStdString CUtil::GetCachedAlbumThumb(const CStdString& album, const CStdString& artist)
-{
-  if (album.IsEmpty())
-    return GetCachedMusicThumb("unknown"+artist);
-  if (artist.IsEmpty())
-    return GetCachedMusicThumb(album+"unknown");
-  return GetCachedMusicThumb(album+artist);
-}
-
-CStdString CUtil::GetCachedMusicThumb(const CStdString& path)
-{
-  Crc32 crc;
-  CStdString noSlashPath(path);
-  URIUtils::RemoveSlashAtEnd(noSlashPath);
-  crc.ComputeFromLowerCase(noSlashPath);
-  CStdString hex;
-  hex.Format("%08x", (unsigned __int32) crc);
-  CStdString thumb;
-  thumb.Format("%c/%s.tbn", hex[0], hex.c_str());
-  return URIUtils::AddFileToFolder(g_settings.GetMusicThumbFolder(), thumb);
-}
-
 CStdString CUtil::GetDefaultFolderThumb(const CStdString &folderThumb)
 {
   if (g_TextureManager.HasTexture(folderThumb))
index dc3809c..56271bd 100644 (file)
@@ -135,9 +135,6 @@ public:
   static double AlbumRelevance(const CStdString& strAlbumTemp1, const CStdString& strAlbum1, const CStdString& strArtistTemp1, const CStdString& strArtist1);
   static bool MakeShortenPath(CStdString StrInput, CStdString& StrOutput, int iTextMaxLength);
   static bool SupportsFileOperations(const CStdString& strPath);
-
-  static CStdString GetCachedMusicThumb(const CStdString &path);
-  static CStdString GetCachedAlbumThumb(const CStdString &album, const CStdString &artist);
   static CStdString GetDefaultFolderThumb(const CStdString &folderThumb);
 
 #ifdef UNIT_TESTING
index 404bf9a..e6796f5 100644 (file)
@@ -43,6 +43,7 @@
 #include "guilib/LocalizeStrings.h"
 #include "TextureCache.h"
 #include "video/windows/GUIWindowVideoBase.h"
+#include "ThumbnailCache.h"
 
 #ifdef _WIN32
 #include "WIN32Util.h"
@@ -465,7 +466,7 @@ bool CGUIDialogContextMenu::OnContextButton(const CStdString &type, const CFileI
         {
           cachedThumb = item->m_strPath;
           URIUtils::RemoveSlashAtEnd(cachedThumb);
-          cachedThumb = CUtil::GetCachedMusicThumb(cachedThumb);
+          cachedThumb = CThumbnailCache::GetMusicThumb(cachedThumb);
         }
         else if (type == "video")
           cachedThumb = item->GetCachedVideoThumb();
index ed58816..998c6a2 100644 (file)
@@ -51,6 +51,7 @@
 #include "utils/URIUtils.h"
 #include "utils/log.h"
 #include "TextureCache.h"
+#include "ThumbnailCache.h"
 
 #ifdef _WIN32
 extern "C" FILE *fopen_utf8(const char *_Filename, const char *_Mode);
@@ -1815,7 +1816,7 @@ int CXbmcHttp::xbmcGetThumbFilename(int numParas, CStdString paras[])
 
   if (numParas>1)
   {
-    thumbFilename = CUtil::GetCachedAlbumThumb(paras[0], paras[1]);
+    thumbFilename = CThumbnailCache::GetAlbumThumb(paras[0], paras[1]);
     return SetResponse(openTag+thumbFilename ) ;
   }
   else
index 5acd29a..2f44f66 100644 (file)
@@ -76,8 +76,7 @@ JSON_STATUS CAudioLibrary::GetArtistDetails(const CStdString &method, ITransport
   m_artistItem->GetMusicInfoTag()->SetArtist(m_artistItem->GetLabel());
   m_artistItem->GetMusicInfoTag()->SetDatabaseId(artistID);
   CMusicDatabase::SetPropertiesFromArtist(*m_artistItem, artist);
-  if (CFile::Exists(m_artistItem->GetCachedArtistThumb()))
-    m_artistItem->SetThumbnailImage(m_artistItem->GetCachedArtistThumb());
+  m_artistItem->SetCachedArtistThumb();
   HandleFileItem("artistid", false, "artistdetails", m_artistItem, parameterObject, parameterObject["fields"], result, false);
 
   musicdatabase.Close();
index 617b8d1..c9be2b6 100644 (file)
@@ -41,6 +41,7 @@
 #include "utils/log.h"
 #include "utils/URIUtils.h"
 #include "TextureCache.h"
+#include "ThumbnailCache.h"
 
 using namespace std;
 using namespace XFILE;
@@ -318,7 +319,7 @@ void CGUIDialogMusicInfo::RefreshThumb()
     if (m_bArtistInfo)
       thumbImage = m_albumItem->GetCachedArtistThumb();
     else
-      thumbImage = CUtil::GetCachedAlbumThumb(m_album.strAlbum, m_album.strArtist);
+      thumbImage = CThumbnailCache::GetAlbumThumb(m_album);
 
     if (!CFile::Exists(thumbImage))
     {
@@ -442,7 +443,7 @@ void CGUIDialogMusicInfo::OnGetThumb()
   if (m_bArtistInfo)
     cachedThumb = m_albumItem->GetCachedArtistThumb();
   else
-    cachedThumb = CUtil::GetCachedAlbumThumb(m_album.strAlbum, m_album.strArtist);
+    cachedThumb = CThumbnailCache::GetAlbumThumb(m_album);
 
   CTextureCache::Get().ClearCachedImage(cachedThumb, true);
   if (result.Left(14) == "thumb://Remote")
@@ -480,7 +481,7 @@ void CGUIDialogMusicInfo::OnGetFanart()
 {
   CFileItemList items;
 
-  CStdString cachedThumb(CFileItem::GetCachedThumb(m_artist.strArtist,g_settings.GetMusicFanartFolder()));
+  CStdString cachedThumb(CThumbnailCache::GetThumb(m_artist.strArtist,g_settings.GetMusicFanartFolder()));
   if (CFile::Exists(cachedThumb))
   {
     CFileItemPtr itemCurrent(new CFileItem("fanart://Current",false));
index 51e3034..bd7a947 100644 (file)
@@ -39,6 +39,7 @@
 #include "guilib/LocalizeStrings.h"
 #include "TextureCache.h"
 #include "music/Album.h"
+#include "ThumbnailCache.h"
 
 using namespace XFILE;
 
@@ -284,7 +285,7 @@ void CGUIDialogSongInfo::OnGetThumb()
   // delete the thumbnail if that's what the user wants, else overwrite with the
   // new thumbnail
 
-  CStdString cachedThumb(CUtil::GetCachedAlbumThumb(m_song->GetMusicInfoTag()->GetAlbum(), m_song->GetMusicInfoTag()->GetArtist()));
+  CStdString cachedThumb(CThumbnailCache::GetAlbumThumb(m_song->GetMusicInfoTag()));
 
   CTextureCache::Get().ClearCachedImage(cachedThumb, true);
   if (result == "thumb://None")
index aa89943..6e84690 100644 (file)
@@ -47,6 +47,7 @@
 #include "utils/TimeUtils.h"
 #include "utils/log.h"
 #include "utils/URIUtils.h"
+#include "ThumbnailCache.h"
 
 #include <algorithm>
 
@@ -712,13 +713,13 @@ void CMusicInfoScanner::UpdateFolderThumb(const VECSONGS &songs, const CStdStrin
   CStdString album, artist;
   if (!HasSingleAlbum(songs, album, artist)) return;
   // Was the album art of this album read during scan?
-  CStdString albumCoverArt(CUtil::GetCachedAlbumThumb(album, artist));
+  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(CUtil::GetCachedMusicThumb(folderPath1));
+    CStdString folderCoverArt(CThumbnailCache::GetMusicThumb(folderPath1));
     // copy as directory thumb as well
     if (CFile::Cache(albumCoverArt, folderCoverArt))
       CUtil::ThumbCacheAdd(folderCoverArt, true);
@@ -1018,7 +1019,7 @@ void CMusicInfoScanner::GetAlbumArtwork(long id, const CAlbum &album)
     CStdString thumb;
     if (!m_musicDatabase.GetAlbumThumb(id, thumb) || thumb.IsEmpty() || !XFILE::CFile::Exists(thumb))
     {
-      thumb = CUtil::GetCachedAlbumThumb(album.strAlbum,album.strArtist);
+      thumb = CThumbnailCache::GetAlbumThumb(album);
       CScraperUrl::DownloadThumbnail(thumb,album.thumbURL.m_url[0]);
       m_musicDatabase.SaveAlbumThumb(id, thumb);
     }
index e326931..dc9bf59 100644 (file)
@@ -26,6 +26,7 @@
 #include "filesystem/File.h"
 #include "utils/log.h"
 #include "utils/EndianSwap.h"
+#include "ThumbnailCache.h"
 
 
 #define BYTES_TO_CHECK_FOR_BAD_TAGS 16384
@@ -113,9 +114,9 @@ bool CFlacTag::Read(const CStdString& strFile)
 
   CStdString strCoverArt;
   if (!m_musicInfoTag.GetAlbum().IsEmpty() && (!m_musicInfoTag.GetAlbumArtist().IsEmpty() || !m_musicInfoTag.GetArtist().IsEmpty()))
-    strCoverArt = CUtil::GetCachedAlbumThumb(m_musicInfoTag.GetAlbum(), m_musicInfoTag.GetAlbumArtist().IsEmpty() ? m_musicInfoTag.GetArtist() : m_musicInfoTag.GetAlbumArtist());
+    strCoverArt = CThumbnailCache::GetAlbumThumb(&m_musicInfoTag);
   else
-    strCoverArt = CUtil::GetCachedMusicThumb(m_musicInfoTag.GetURL());
+    strCoverArt = CThumbnailCache::GetMusicThumb(m_musicInfoTag.GetURL());
 
   if (cover && !CUtil::ThumbExists(strCoverArt))
   {
index 9523a66..6a49bcd 100644 (file)
@@ -27,6 +27,7 @@
 #include "guilib/LocalizeStrings.h"
 #include "utils/CharsetConverter.h"
 #include "utils/log.h"
+#include "ThumbnailCache.h"
 
 #include <set>
 
@@ -167,9 +168,9 @@ bool CID3Tag::Parse()
   // other non-tagged files don't get this album image
   CStdString strCoverArt;
   if (!tag.GetAlbum().IsEmpty() && (!tag.GetAlbumArtist().IsEmpty() || !tag.GetArtist().IsEmpty()))
-    strCoverArt = CUtil::GetCachedAlbumThumb(tag.GetAlbum(), tag.GetAlbumArtist().IsEmpty() ? tag.GetArtist() : tag.GetAlbumArtist());
+    strCoverArt = CThumbnailCache::GetAlbumThumb(&tag);
   else
-    strCoverArt = CUtil::GetCachedMusicThumb(tag.GetURL());
+    strCoverArt = CThumbnailCache::GetMusicThumb(tag.GetURL());
   if (bFound && !CUtil::ThumbExists(strCoverArt))
   {
     CStdString strExtension=GetPictureMimeType(pictype);
index c0086d9..9116505 100644 (file)
@@ -27,6 +27,7 @@
 #include "guilib/LocalizeStrings.h"
 #include "utils/AutoPtrHandle.h"
 #include "utils/log.h"
+#include "ThumbnailCache.h"
 
 using namespace XFILE;
 using namespace AUTOPTR;
@@ -396,9 +397,9 @@ bool CMusicInfoTagLoaderMP4::Load(const CStdString& strFileName, CMusicInfoTag&
       // other non-tagged files don't get this album image
       CStdString strCoverArt;
       if (!tag.GetAlbum().IsEmpty() && (!tag.GetAlbumArtist().IsEmpty() || !tag.GetArtist().IsEmpty()))
-        strCoverArt = CUtil::GetCachedAlbumThumb(tag.GetAlbum(), tag.GetAlbumArtist().IsEmpty() ? tag.GetArtist() : tag.GetAlbumArtist());
+        strCoverArt = CThumbnailCache::GetAlbumThumb(&tag);
       else
-        strCoverArt = CUtil::GetCachedMusicThumb(tag.GetURL());
+        strCoverArt = CThumbnailCache::GetMusicThumb(tag.GetURL());
       if (!CUtil::ThumbExists(strCoverArt))
       {
         if (CPicture::CreateThumbnailFromMemory( m_thumbData, m_thumbSize, "", strCoverArt ) )
index 06f9a45..ced5d2d 100644 (file)
@@ -28,6 +28,7 @@
 #include "utils/AutoPtrHandle.h"
 #include "utils/CharsetConverter.h"
 #include "utils/log.h"
+#include "ThumbnailCache.h"
 
 using namespace AUTOPTR;
 using namespace XFILE;
@@ -516,9 +517,9 @@ void CMusicInfoTagLoaderWMA::SetTagValueBinary(const CStdString& strFrameName, c
       // other non-tagged files don't get this album image
       CStdString strCoverArt;
       if (!tag.GetAlbum().IsEmpty() && (!tag.GetAlbumArtist().IsEmpty() || !tag.GetArtist().IsEmpty()))
-        strCoverArt = CUtil::GetCachedAlbumThumb(tag.GetAlbum(), tag.GetAlbumArtist().IsEmpty() ? tag.GetArtist() : tag.GetAlbumArtist());
+        strCoverArt = CThumbnailCache::GetAlbumThumb(&tag);
       else
-        strCoverArt = CUtil::GetCachedMusicThumb(tag.GetURL());
+        strCoverArt = CThumbnailCache::GetMusicThumb(tag.GetURL());
       if (!CUtil::ThumbExists(strCoverArt))
       {
         int nPos = strExtension.Find('/');
index a5aea32..388f757 100644 (file)
@@ -60,6 +60,7 @@
 #include "utils/TimeUtils.h"
 #include "utils/log.h"
 #include "utils/URIUtils.h"
+#include "ThumbnailCache.h"
 
 using namespace std;
 using namespace XFILE;
@@ -1201,7 +1202,7 @@ void CGUIWindowMusicBase::UpdateThumb(const CAlbum &album, const CStdString &pat
     saveDirThumb = false;
   }
 
-  CStdString albumThumb(CUtil::GetCachedAlbumThumb(album.strAlbum, album.strArtist));
+  CStdString albumThumb(CThumbnailCache::GetAlbumThumb(album));
 
   // Update the thumb in the music database (songs + albums)
   CStdString albumPath(path);
@@ -1249,7 +1250,7 @@ void CGUIWindowMusicBase::UpdateThumb(const CAlbum &album, const CStdString &pat
     CStdString album, artist;
     if (CMusicInfoScanner::HasSingleAlbum(songs, album, artist))
     { // can cache as the folder thumb
-      CStdString folderThumb(CUtil::GetCachedMusicThumb(albumPath));
+      CStdString folderThumb(CThumbnailCache::GetMusicThumb(albumPath));
       CFile::Cache(albumThumb, folderThumb);
     }
   }
index c3024b3..4ad5fb9 100644 (file)
@@ -49,6 +49,7 @@
 #include "addons/AddonInstaller.h"
 #include "interfaces/AnnouncementManager.h"
 #include "dbwrappers/dataset.h"
+#include "ThumbnailCache.h"
 
 using namespace std;
 using namespace dbiplus;
@@ -4097,7 +4098,7 @@ bool CVideoDatabase::GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileI
           if (!items.Contains(pItem->m_strPath))
           {
             pItem->GetVideoInfoTag()->m_strArtist = m_pDS->fv(2).get_asString();
-            CStdString strThumb = CUtil::GetCachedAlbumThumb(pItem->GetLabel(),pItem->GetVideoInfoTag()->m_strArtist);
+            CStdString strThumb = CThumbnailCache::GetAlbumThumb(*pItem);
             if (CFile::Exists(strThumb))
               pItem->SetThumbnailImage(strThumb);
             items.Add(pItem);
@@ -4120,7 +4121,7 @@ bool CVideoDatabase::GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileI
           if (!items.Contains(pItem->m_strPath))
           {
             pItem->GetVideoInfoTag()->m_strArtist = m_pDS->fv(2).get_asString();
-            CStdString strThumb = CUtil::GetCachedAlbumThumb(pItem->GetLabel(),m_pDS->fv(2).get_asString());
+            CStdString strThumb = CThumbnailCache::GetAlbumThumb(pItem->GetLabel(), m_pDS->fv(2).get_asString());
             if (CFile::Exists(strThumb))
               pItem->SetThumbnailImage(strThumb);
             items.Add(pItem);