Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[imageloader] adds ability to cache embedded music art

  • Loading branch information...
commit fd9df6a586ab79b14f733ac66b25a6bb65f804e2 1 parent 06e1d96
authored June 24, 2012
18  xbmc/TextureCacheJob.cpp
@@ -33,6 +33,8 @@
33 33
 #include "utils/StringUtils.h"
34 34
 #include "URL.h"
35 35
 #include "FileItem.h"
  36
+#include "ThumbLoader.h"
  37
+#include "music/tags/MusicInfoTag.h"
36 38
 
37 39
 CTextureCacheJob::CTextureCacheJob(const CStdString &url, const CStdString &oldHash)
38 40
 {
@@ -78,7 +80,7 @@ bool CTextureCacheJob::CacheTexture(CBaseTexture **out_texture)
78 80
   unsigned int width, height;
79 81
   CStdString image = DecodeImageURL(m_url, width, height, additional_info);
80 82
 
81  
-  m_details.updateable = UpdateableURL(image);
  83
+  m_details.updateable = additional_info != "music" && UpdateableURL(image);
82 84
 
83 85
   // generate the hash
84 86
   m_details.hash = GetImageHash(image);
@@ -130,7 +132,12 @@ CStdString CTextureCacheJob::DecodeImageURL(const CStdString &url, unsigned int
130 132
     CURL thumbURL(url);
131 133
 
132 134
     if (!thumbURL.GetUserName().IsEmpty())
133  
-      return ""; // we don't re-cache special images (eg picturefolder/video embedded thumbs)
  135
+    {
  136
+      if (thumbURL.GetUserName() == "music")
  137
+        additional_info = "music";
  138
+      else
  139
+        return ""; // we don't re-cache special images (eg picturefolder/video embedded thumbs)
  140
+    }
134 141
 
135 142
     image = thumbURL.GetHostName();
136 143
     CURL::Decode(image);
@@ -169,6 +176,13 @@ CStdString CTextureCacheJob::DecodeImageURL(const CStdString &url, unsigned int
169 176
 
170 177
 CBaseTexture *CTextureCacheJob::LoadImage(const CStdString &image, unsigned int width, unsigned int height, const std::string &additional_info)
171 178
 {
  179
+  if (additional_info == "music")
  180
+  { // special case for embedded music images
  181
+    MUSIC_INFO::EmbeddedArt art;
  182
+    if (CMusicThumbLoader::GetEmbeddedThumb(image, art))
  183
+      return CBaseTexture::LoadFromFileInMemory(&art.data[0], art.size, art.mime, width, height);
  184
+  }
  185
+
172 186
   // Validate file URL to see if it is an image
173 187
   CFileItem file(image, false);
174 188
   if (!(file.IsPicture() && !(file.IsZIP() || file.IsRAR() || file.IsCBR() || file.IsCBZ() ))
11  xbmc/ThumbLoader.cpp
@@ -38,6 +38,7 @@
38 38
 #include "cores/dvdplayer/DVDFileInfo.h"
39 39
 #include "video/VideoInfoScanner.h"
40 40
 #include "music/tags/MusicInfoTag.h"
  41
+#include "music/tags/MusicInfoTagLoaderFactory.h"
41 42
 #include "music/infoscanner/MusicInfoScanner.h"
42 43
 #include "music/Artist.h"
43 44
 
@@ -598,3 +599,13 @@ bool CMusicThumbLoader::FillLibraryArt(CFileItem &item)
598 599
   }
599 600
   return !item.GetArt().empty();
600 601
 }
  602
+
  603
+bool CMusicThumbLoader::GetEmbeddedThumb(const std::string &path, EmbeddedArt &art)
  604
+{
  605
+  auto_ptr<IMusicInfoTagLoader> pLoader (CMusicInfoTagLoaderFactory::CreateLoader(path));
  606
+  CMusicInfoTag tag;
  607
+  if (NULL != pLoader.get())
  608
+    pLoader->Load(path, tag, &art);
  609
+
  610
+  return !art.empty();
  611
+}
7  xbmc/ThumbLoader.h
@@ -156,6 +156,11 @@ class CProgramThumbLoader : public CThumbLoader
156 156
   static CStdString GetLocalThumb(const CFileItem &item);
157 157
 };
158 158
 
  159
+namespace MUSIC_INFO
  160
+{
  161
+  class EmbeddedArt;
  162
+};
  163
+
159 164
 class CMusicThumbLoader : public CThumbLoader
160 165
 {
161 166
 public:
@@ -169,6 +174,8 @@ class CMusicThumbLoader : public CThumbLoader
169 174
    */
170 175
   bool FillLibraryArt(CFileItem &item);
171 176
 
  177
+  static bool GetEmbeddedThumb(const std::string &path, MUSIC_INFO::EmbeddedArt &art);
  178
+
172 179
 protected:
173 180
   virtual void OnLoaderStart();
174 181
   virtual void OnLoaderFinish();

0 notes on commit fd9df6a

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