Skip to content

Commit

Permalink
FIX: speedup thumb loading
Browse files Browse the repository at this point in the history
  • Loading branch information
koying authored and popcornmix committed Apr 3, 2020
1 parent 791eb12 commit ce865a9
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions xbmc/video/VideoThumbLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "filesystem/DirectoryCache.h"
#include "filesystem/StackDirectory.h"
#include "guilib/GUIComponent.h"
#include "filesystem/File.h"
#include "filesystem/CurlFile.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/StereoscopicsManager.h"
#include "music/MusicDatabase.h"
Expand Down Expand Up @@ -432,10 +434,28 @@ bool CVideoThumbLoader::LoadItemLookup(CFileItem* pItem)
// We can only extract flags/thumbs for file-like items
if (!pItem->m_bIsFolder && pItem->IsVideo())
{
// An auto-generated thumb may have been cached on a different device - check we have it here
std::string url = pItem->GetArt("thumb");
if (StringUtils::StartsWith(url, "image://video@") && !CTextureCache::GetInstance().HasCachedImage(url))
pItem->SetArt("thumb", "");
if (!CTextureCache::GetInstance().HasCachedImage(url))
{
// An auto-generated thumb may have been cached on a different device - check we have it here
if (StringUtils::StartsWith(url, "image://video@"))
pItem->SetArt("thumb", "");

// Check invalid redirections
else if (URIUtils::IsInternetStream(url))
{
std::string mimetype;
bool valid = XFILE::CCurlFile::GetMimeType(CURL(url), mimetype);
if (valid && !StringUtils::StartsWith(mimetype, "image/"))
valid = false;
if (!valid)
pItem->SetArt("thumb", "");
}

// Check if thumb source still exists
else if (!XFILE::CFile::Exists(url))
pItem->SetArt("thumb", "");
}

const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings();
if (!pItem->HasArt("thumb"))
Expand Down

0 comments on commit ce865a9

Please sign in to comment.