Permalink
Browse files

JSON-RPC can now use the image:// wrapped URLs for video and picture art

  • Loading branch information...
1 parent d6dd972 commit e75baf210940ec8c9fcd715db250507a679c4af2 Jonathan Marshall committed May 12, 2012
Showing with 46 additions and 24 deletions.
  1. +44 −22 xbmc/interfaces/json-rpc/FileItemHandler.cpp
  2. +2 −2 xbmc/video/VideoInfoTag.cpp
@@ -49,6 +49,8 @@ void CFileItemHandler::FillDetails(ISerializable* info, CFileItemPtr item, const
CVariant serialization;
info->Serialize(serialization);
+ bool fetchedArt = false;
+
for (unsigned int i = 0; i < fields.size(); i++)
{
CStdString field = fields[i].asString();
@@ -91,37 +93,57 @@ void CFileItemHandler::FillDetails(ISerializable* info, CFileItemPtr item, const
if (field == "thumbnail")
{
- if (item->HasThumbnail())
- result["thumbnail"] = CTextureCache::Get().CheckAndCacheImage(item->GetThumbnailImage());
- else if (item->HasVideoInfoTag())
- { // TODO: Should the JSON-API return actual image URLs, virtual thumb URLs, or local URLs to the cached image?
- // ATM we return the latter
- CStdString thumbURL = CVideoThumbLoader::GetEmbeddedThumbURL(*item);
- CStdString cachedThumb = CTextureCache::Get().GetCachedImage(thumbURL);
- if (!cachedThumb.IsEmpty())
- result["thumbnail"] = cachedThumb;
+ if (item->HasVideoInfoTag())
+ {
+ if (!item->HasThumbnail() && !fetchedArt && item->GetVideoInfoTag()->m_iDbId > -1)
+ {
+ CVideoThumbLoader loader;
+ loader.FillLibraryArt(item.get());
+ fetchedArt = true;
+ }
+ if (item->HasThumbnail())
+ result["thumbnail"] = CTextureCache::GetWrappedImageURL(item->GetThumbnailImage());
}
else if (item->HasPictureInfoTag())
{
- CStdString thumb = CTextureCache::Get().CheckAndCacheImage(CTextureCache::GetWrappedThumbURL(item->GetPath()));
- if (!thumb.empty())
- result["thumbnail"] = thumb;
+ if (!item->HasThumbnail())
+ item->SetThumbnailImage(CTextureCache::GetWrappedThumbURL(item->GetPath()));
+ if (item->HasThumbnail())
+ result["thumbnail"] = CTextureCache::GetWrappedImageURL(item->GetThumbnailImage());
+ }
+ else
+ { // TODO: music art is not currently wrapped
+ if (item->HasThumbnail())
+ result["thumbnail"] = item->GetThumbnailImage();
}
-
if (!result.isMember("thumbnail"))
result["thumbnail"] = "";
+ continue;
}
- if (field == "fanart" && !item->HasPictureInfoTag())
+ if (field == "fanart")
{
- CStdString fanart;
- if (item->HasProperty("fanart_image"))
- fanart = CTextureCache::Get().CheckAndCacheImage(item->GetProperty("fanart_image").asString());
- if (fanart.empty())
- fanart = item->GetCachedFanart();
- if (!fanart.empty())
- result["fanart"] = fanart.c_str();
-
+ if (item->HasVideoInfoTag())
+ {
+ if (!item->HasProperty("fanart_image") && !fetchedArt && item->GetVideoInfoTag()->m_iDbId > -1)
+ {
+ CVideoThumbLoader loader;
+ loader.FillLibraryArt(item.get());
+ fetchedArt = true;
+ }
+ if (item->HasProperty("fanart_image"))
+ result["fanart"] = CTextureCache::GetWrappedImageURL(item->GetProperty("fanart_image").asString());
+ }
+ else if (item->HasMusicInfoTag())
+ { // TODO: music art is not currently wrapped
+ CStdString fanart;
+ if (item->HasProperty("fanart_image"))
+ fanart = item->GetProperty("fanart_image").asString();
+ if (fanart.empty())
+ fanart = item->GetCachedFanart();
+ if (!fanart.empty())
+ result["fanart"] = fanart.c_str();
+ }
continue;
}
@@ -432,8 +432,8 @@ void CVideoInfoTag::Serialize(CVariant& value)
CVariant actor;
actor["name"] = m_cast[i].strName;
actor["role"] = m_cast[i].strRole;
- if (!m_cast[i].thumb.IsEmpty()) // TODO: json-rpc should use real URLs just like everywhere else
- actor["thumbnail"] = CTextureCache::Get().CheckAndCacheImage(m_cast[i].thumb);
+ if (!m_cast[i].thumb.IsEmpty())
+ actor["thumbnail"] = CTextureCache::GetWrappedImageURL(m_cast[i].thumb);
value["cast"].push_back(actor);
}
value["set"] = m_set;

0 comments on commit e75baf2

Please sign in to comment.