return CThumbnailCache::GetArtistThumb(*this);
}
-CStdString CFileItem::GetCachedSeasonThumb() const
-{
- return CThumbnailCache::GetSeasonThumb(*this);
-}
-
-CStdString CFileItem::GetCachedActorThumb() const
-{
- return CThumbnailCache::GetActorThumb(*this);
-}
-
void CFileItem::SetCachedArtistThumb()
{
CStdString thumb(GetCachedArtistThumb());
SetUserMusicThumb(alwaysCheckRemote);
}
-void CFileItem::SetCachedSeasonThumb()
-{
- CStdString thumb(GetCachedSeasonThumb());
- if (CFile::Exists(thumb))
- {
- // found it, we are finished.
- SetThumbnailImage(thumb);
- }
-}
-
void CFileItem::RemoveExtension()
{
if (m_bIsFolder)
return false;
}
-void CFileItemList::SetCachedVideoThumbs()
-{
- CSingleLock lock(m_lock);
- // TODO: Investigate caching time to see if it speeds things up
- for (unsigned int i = 0; i < m_items.size(); ++i)
- {
- CFileItemPtr pItem = m_items[i];
- pItem->SetCachedVideoThumb();
- }
-}
-
void CFileItemList::SetCachedMusicThumbs()
{
CSingleLock lock(m_lock);
SetCachedMusicThumb();
}
-CStdString CFileItem::GetCachedVideoThumb() const
-{
- return CThumbnailCache::GetVideoThumb(*this);
-}
-
-CStdString CFileItem::GetCachedEpisodeThumb() const
-{
- return CThumbnailCache::GetEpisodeThumb(*this);
-}
-
-void CFileItem::SetCachedVideoThumb()
-{
- if (IsParentFolder()) return;
- if (HasThumbnail()) return;
- CStdString cachedThumb(GetCachedVideoThumb());
- if (HasVideoInfoTag() && !m_bIsFolder &&
- GetVideoInfoTag()->m_iEpisode > -1 &&
- CFile::Exists(GetCachedEpisodeThumb()))
- {
- SetThumbnailImage(GetCachedEpisodeThumb());
- }
- else if (CFile::Exists(cachedThumb))
- SetThumbnailImage(cachedThumb);
-}
-
// Gets the .tbn filename from a file or folder name.
// <filename>.ext -> <filename>.tbn
// <foldername>/ -> <foldername>.tbn
}
#endif
-void CFileItem::SetVideoThumb()
-{
- if (HasThumbnail()) return;
- SetCachedVideoThumb();
- if (!HasThumbnail())
- SetUserVideoThumb();
-}
-
-void CFileItem::SetUserVideoThumb()
-{
- if (m_bIsShareOrDrive) return;
- if (IsParentFolder()) return;
-
- // caches as the local thumb
- CStdString thumb(GetUserVideoThumb());
- if (!thumb.IsEmpty())
- {
- CStdString cachedThumb(GetCachedVideoThumb());
- CPicture::CreateThumbnail(thumb, cachedThumb);
- }
- SetCachedVideoThumb();
-}
-
bool CFileItem::CacheLocalFanart() const
{
// first check for an already cached fanart image
CPictureInfoTag* GetPictureInfoTag();
// Gets the cached thumb filename (no existence checks)
- CStdString GetCachedVideoThumb() const;
- CStdString GetCachedEpisodeThumb() const;
CStdString GetCachedArtistThumb() const;
- CStdString GetCachedSeasonThumb() const;
- CStdString GetCachedActorThumb() const;
/*!
\brief Get the cached fanart path for this item if it exists
\return path to the cached fanart for this item, or empty if none exists
CStdString GetCachedFanart() const;
static CStdString GetCachedThumb(const CStdString &path, const CStdString& strPath2, bool split=false);
- // Sets the video thumb (cached first, else caches user thumb)
- void SetVideoThumb();
/*!
\brief Cache a copy of the local fanart for this item if we don't already have an image cached
\return true if we already have cached fanart or if the caching was successful, false if no image is cached.
CStdString GetLocalFanart() const;
// Sets the cached thumb for the item if it exists
- void SetCachedVideoThumb();
void SetCachedArtistThumb();
void SetCachedMusicThumb();
- void SetCachedSeasonThumb();
// Gets the .tbn file associated with this item
CStdString GetTBNFile() const;
CStdString GetUserMusicThumb(bool alwaysCheckRemote = false) const;
// Caches the user thumb and assigns it to the item
- void SetUserVideoThumb();
void SetUserMusicThumb(bool alwaysCheckRemote = false);
/*! \brief Get the path where we expect local metadata to reside.
void RemoveDiscCache(int windowID = 0) const;
bool AlwaysCache() const;
- void SetCachedVideoThumbs();
void SetCachedMusicThumbs();
void Swap(unsigned int item1, unsigned int item2);
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.GetPath()), 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.GetPath(), g_settings.GetVideoThumbFolder(), true);
-}
-
CStdString CThumbnailCache::GetFanart(const CFileItem &item)
{
// get the locally cached thumb
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:
for (map<int, string>::iterator i = art.begin(); i != art.end(); ++i)
CTextureCache::Get().BackgroundCacheImage(i->second);
}
-
- void CVideoInfoScanner::FetchSeasonThumbs(int idTvShow, const CStdString &folderToCheck, bool download, bool overwrite)
- {
- // ensure our database is open (this can get called via other classes)
- if (!m_database.Open())
- return;
-
- CVideoInfoTag movie;
- m_database.GetTvShowInfo("", movie, idTvShow);
- CStdString showDir(folderToCheck.IsEmpty() ? movie.m_strPath : folderToCheck);
- CFileItemList items;
- CStdString strPath;
- strPath.Format("videodb://2/2/%i/", idTvShow);
- m_database.GetSeasonsNav(strPath, items, -1, -1, -1, -1, idTvShow);
- CFileItemPtr pItem;
- pItem.reset(new CFileItem(g_localizeStrings.Get(20366))); // "All Seasons"
- CStdString path; path.Format("%s/-1/", strPath.c_str());
- pItem->SetPath(path);
- pItem->GetVideoInfoTag()->m_iSeason = -1;
- pItem->GetVideoInfoTag()->m_strPath = movie.m_strPath;
- if (overwrite || !XFILE::CFile::Exists(pItem->GetCachedSeasonThumb()))
- items.Add(pItem);
-
- // used for checking for a season[ ._-](number).tbn
- CFileItemList tbnItems;
- CDirectory::GetDirectory(showDir, tbnItems, ".tbn");
- for (int i=0;i<items.Size();++i)
- {
- if (overwrite || !items[i]->HasThumbnail())
- {
- CStdString strExpression;
- int iSeason = items[i]->GetVideoInfoTag()->m_iSeason;
- if (iSeason == -1)
- strExpression = "season-all.tbn";
- else if (iSeason == 0)
- strExpression = "season-specials.tbn";
- else
- strExpression.Format("season[ ._-]?(0?%i)\\.tbn", items[i]->GetVideoInfoTag()->m_iSeason);
- bool bDownload = download;
- CRegExp reg;
- if (reg.RegComp(strExpression.c_str()))
- {
- for (int j=0;j<tbnItems.Size();++j)
- {
- CStdString strCheck = URIUtils::GetFileName(tbnItems[j]->GetPath());
- strCheck.ToLower();
- if (reg.RegFind(strCheck.c_str()) > -1)
- {
- CPicture::CreateThumbnail(tbnItems[j]->GetPath(), items[i]->GetCachedSeasonThumb());
- bDownload=false;
- break;
- }
- }
- }
- if (bDownload)
- DownloadImage(CScraperUrl::GetThumbURL(movie.m_strPictureURL.GetSeasonThumb(items[i]->GetVideoInfoTag()->m_iSeason)), items[i]->GetCachedSeasonThumb());
- }
- }
- m_database.Close();
- }
void CVideoInfoScanner::FetchActorThumbs(vector<SActorInfo>& actors, const CStdString& strPath)
{
static bool DownloadFailed(CGUIDialogProgress* pDlgProgress);
CNfoFile::NFOResult CheckForNFOFile(CFileItem* pItem, bool bGrabAny, ADDON::ScraperPtr& scraper, CScraperUrl& scrUrl);
- /*! \brief Fetch thumbs for seasons for a given show
- Fetches and caches local season thumbs of the form season##.tbn and season-all.tbn for the current show,
- and downloads online thumbs if they don't exist.
- \param idTvShow database id of the tvshow.
- \param folderToCheck folder to check for local thumbs, if other than the show folder. Defaults to empty.
- \param download whether we should download thumbs that don't exist. Defaults to true.
- \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.