Skip to content

Commit

Permalink
JSON-RPC can now use the image:// wrapped URLs for video and picture art
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Marshall committed May 13, 2012
1 parent d6dd972 commit e75baf2
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 24 deletions.
66 changes: 44 additions & 22 deletions xbmc/interfaces/json-rpc/FileItemHandler.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions xbmc/video/VideoInfoTag.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit e75baf2

Please sign in to comment.