Skip to content

Commit

Permalink
Fix finding of local thumbs/fanart for VIDEO_TS/BDMV items in the par…
Browse files Browse the repository at this point in the history
…ent folder
  • Loading branch information
Jonathan Marshall committed Jan 17, 2012
1 parent 919a875 commit ac6a16f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 14 deletions.
45 changes: 31 additions & 14 deletions xbmc/FileItem.cpp
Expand Up @@ -2112,25 +2112,11 @@ void CFileItemList::StackFolders()
if (!dvdPath.IsEmpty())
{
// NOTE: should this be done for the CD# folders too?
/* set the thumbnail based on folder */
item->SetCachedVideoThumb();
if (!item->HasThumbnail())
item->SetUserVideoThumb();

item->m_bIsFolder = false;
item->SetPath(dvdPath);
item->SetLabel2("");
item->SetLabelPreformated(true);
m_sortMethod = SORT_METHOD_NONE; /* sorting is now broken */

/* override the previously set thumb if video_ts.ifo has any */
/* otherwise user can't set icon on the stacked file as that */
/* will allways be set on the video_ts.ifo file */
CStdString thumb(item->GetCachedVideoThumb());
if(CFile::Exists(thumb))
item->SetThumbnailImage(thumb);
else
item->SetUserVideoThumb();
}
}
}
Expand Down Expand Up @@ -2646,6 +2632,15 @@ CStdString CFileItem::GetUserVideoThumb() const
if (CFile::Exists(fileThumb))
return fileThumb;

if (IsOpticalMediaFile())
{ // special case for optical media "folders" - check the parent folder (or parent of parent)
// TODO: A better way to handle this would be to treat stacked folders as folders rather than files.
CFileItem item(GetLocalMetadataPath(), true);
CStdString thumb(item.GetUserVideoThumb());
if (!thumb.IsEmpty())
return thumb;
}

// 2. - check movie.tbn, as long as it's not a folder
if (!m_bIsFolder)
{
Expand Down Expand Up @@ -2886,6 +2881,12 @@ CStdString CFileItem::GetLocalFanart() const

CFileItemList items;
CDirectory::GetDirectory(strDir, items, g_settings.m_pictureExtensions, false, false, DIR_CACHE_ALWAYS, false, true);
if (IsOpticalMediaFile())
{ // grab from the optical media parent folder as well - see GetUserVideoThumb
CFileItemList moreItems;
CDirectory::GetDirectory(GetLocalMetadataPath(), moreItems, g_settings.m_pictureExtensions, false, false, DIR_CACHE_ALWAYS, false, true);
items.Append(moreItems);
}

CStdStringArray fanarts;
StringUtils::SplitString(g_advancedSettings.m_fanartImages, "|", fanarts);
Expand All @@ -2912,6 +2913,22 @@ CStdString CFileItem::GetLocalFanart() const
return "";
}

CStdString CFileItem::GetLocalMetadataPath() const
{
if (m_bIsFolder && !IsFileFolder())
return m_strPath;

CStdString parent(URIUtils::GetParentPath(m_strPath));
CStdString parentFolder(parent);
URIUtils::RemoveSlashAtEnd(parentFolder);
parentFolder = URIUtils::GetFileName(parentFolder);
if (parentFolder == "VIDEO_TS" || parentFolder == "BDMV")
{ // go back up another one
parent = URIUtils::GetParentPath(parent);
}
return parent;
}

CStdString CFileItem::GetCachedFanart() const
{
return CThumbnailCache::GetFanart(*this);
Expand Down
14 changes: 14 additions & 0 deletions xbmc/FileItem.h
Expand Up @@ -258,6 +258,20 @@ class CFileItem :
void SetUserVideoThumb();
void SetUserMusicThumb(bool alwaysCheckRemote = false);

/*! \brief Get the path where we expect local metadata to reside.
For a folder, this is just the existing path (eg tvshow folder)
For a file, this is the parent path, with exceptions made for VIDEO_TS and BDMV files
Three cases are handled:
/foo/bar/movie_name/file_name -> /foo/bar/movie_name/
/foo/bar/movie_name/VIDEO_TS/file_name -> /foo/bar/movie_name/
/foo/bar/movie_name/BDMV/file_name -> /foo/bar/movie_name/
\sa URIUtils::GetParentPath
*/
CStdString GetLocalMetadataPath() const;

// finds a matching local trailer file
CStdString FindTrailer() const;

Expand Down

0 comments on commit ac6a16f

Please sign in to comment.