Skip to content

Commit

Permalink
add backward compatibility to fetch thumbs and fanart for items in th…
Browse files Browse the repository at this point in the history
…e video library without art assigned
  • Loading branch information
Jonathan Marshall committed May 8, 2012
1 parent a9fefed commit ae9b05a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 8 deletions.
40 changes: 40 additions & 0 deletions xbmc/ThumbLoader.cpp
Expand Up @@ -36,9 +36,11 @@
#include "video/VideoInfoTag.h"
#include "video/VideoDatabase.h"
#include "cores/dvdplayer/DVDFileInfo.h"
#include "video/VideoInfoScanner.h"

using namespace XFILE;
using namespace std;
using namespace VIDEO;

CThumbLoader::CThumbLoader(int nThreads) :
CBackgroundInfoLoader(nThreads)
Expand Down Expand Up @@ -205,6 +207,44 @@ bool CVideoThumbLoader::LoadItem(CFileItem* pItem)
map<string, string> artwork;
if (db.GetArtForItem(pItem->GetVideoInfoTag()->m_iDbId, pItem->GetVideoInfoTag()->m_type, artwork))
pItem->SetArt(artwork);
else
{
if (pItem->GetVideoInfoTag()->m_type == "movie" ||
pItem->GetVideoInfoTag()->m_type == "episode" ||
pItem->GetVideoInfoTag()->m_type == "tvshow" ||
pItem->GetVideoInfoTag()->m_type == "musicvideo")
{ // no art in the library, so find it locally and add
SScanSettings settings;
ADDON::ScraperPtr info = db.GetScraperForPath(pItem->GetVideoInfoTag()->m_strPath, settings);
if (info)
{
CFileItem item(*pItem);
item.SetPath(pItem->GetVideoInfoTag()->GetPath());
CVideoInfoScanner scanner;
scanner.GetArtwork(&item, info->Content(), settings.parent_name_root, true);
pItem->SetArt(item.GetArt());
}
}
else if (pItem->GetVideoInfoTag()->m_type == "set")
{ // no art for a set -> use the first movie for this set for art
CFileItemList items;
if (db.GetMoviesNav("", items, -1, -1, -1, -1, -1, -1, pItem->GetVideoInfoTag()->m_iDbId) && items.Size() > 0)
{
if (db.GetArtForItem(items[0]->GetVideoInfoTag()->m_iDbId, items[0]->GetVideoInfoTag()->m_type, artwork))
pItem->SetArt(artwork);
}
}
// add to the database for next time around
map<string, string> artwork = pItem->GetArt();
if (!artwork.empty())
{
db.SetArtForItem(pItem->GetVideoInfoTag()->m_iDbId, pItem->GetVideoInfoTag()->m_type, artwork);
for (map<string, string>::iterator i = artwork.begin(); i != artwork.end(); ++i)
CTextureCache::Get().BackgroundCacheImage(i->second);
}
else // nothing found - set an empty thumb so that next time around we don't hit here again
db.SetArtForItem(pItem->GetVideoInfoTag()->m_iDbId, pItem->GetVideoInfoTag()->m_type, "thumb", "");
}
// For episodes and seasons, we want to set fanart for that of the show
if (!pItem->HasProperty("fanart_image") && pItem->GetVideoInfoTag()->m_iIdShow >= 0)
{
Expand Down
17 changes: 9 additions & 8 deletions xbmc/video/VideoInfoScanner.h
Expand Up @@ -126,6 +126,15 @@ namespace VIDEO
\param overwrite whether to overwrite currently cached thumbs. Defaults to false.
*/
void FetchSeasonThumbs(int idTvShow, const CStdString &folderToCheck = "", bool download = true, bool overwrite = false);

/*! \brief Retrieve any artwork associated with an item
\param pItem item to find artwork for.
\param content content type of the item.
\param bApplyToDir whether we should apply any thumbs to a folder. Defaults to false.
\param useLocal whether we should use local thumbs. Defaults to true.
*/
void GetArtwork(CFileItem *pItem, const CONTENT_TYPE &content, bool bApplyToDir=false, bool useLocal=true);

protected:
virtual void Process();
bool DoScan(const CStdString& strDirectory);
Expand Down Expand Up @@ -163,14 +172,6 @@ namespace VIDEO
*/
bool GetDetails(CFileItem *pItem, CScraperUrl &url, const ADDON::ScraperPtr &scraper, CNfoFile *nfoFile=NULL, CGUIDialogProgress* pDialog=NULL);

/*! \brief Retrieve any artwork associated with an item
\param pItem item to find artwork for.
\param content content type of the item.
\param bApplyToDir whether we should apply any thumbs to a folder. Defaults to false.
\param useLocal whether we should use local thumbs. Defaults to true.
*/
void GetArtwork(CFileItem *pItem, const CONTENT_TYPE &content, bool bApplyToDir=false, bool useLocal=true);

/*! \brief Extract episode and season numbers from a processed regexp
\param reg Regular expression object with at least 2 matches
\param episodeInfo Episode information to fill in.
Expand Down

0 comments on commit ae9b05a

Please sign in to comment.