bool CVideoThumbLoader::LoadItem(CFileItem* pItem) { if (pItem->m_bIsShareOrDrive) return true; CStdString cachedThumb(pItem->GetCachedVideoThumb()); if (!pItem->HasThumbnail()) { pItem->SetUserVideoThumb(); if (!CFile::Exists(cachedThumb)) { CStdString strPath, strFileName; CUtil::Split(cachedThumb, strPath, strFileName); // create unique thumb for auto generated thumbs cachedThumb = strPath + "auto-" + strFileName; if (pItem->IsVideo() && !pItem->IsInternetStream() && !pItem->IsPlayList() && !CFile::Exists(cachedThumb)) { if (pItem->IsStack()) { CStackDirectory stack; CVideoThumbLoader::ExtractThumb(stack.GetFirstStackedFile(pItem->m_strPath), cachedThumb); } else { CVideoThumbLoader::ExtractThumb(pItem->m_strPath, cachedThumb); } } if (CFile::Exists(cachedThumb)) { pItem->SetProperty("HasAutoThumb", "1"); pItem->SetProperty("AutoThumbImage", cachedThumb); pItem->SetThumbnailImage(cachedThumb); } } } else { // look for remote thumbs CStdString thumb(pItem->GetThumbnailImage()); if (!CURL::IsFileOnly(thumb) && !CUtil::IsHD(thumb)) { if(CFile::Exists(cachedThumb)) pItem->SetThumbnailImage(cachedThumb); else { CPicture pic; if(pic.DoCreateThumbnail(thumb, cachedThumb)) pItem->SetThumbnailImage(cachedThumb); else pItem->SetThumbnailImage(""); } } } if (!pItem->HasProperty("fanart_image")) { pItem->CacheFanart(); if (pItem->GetQuickFanart().size() > 0) { if (CFile::Exists(pItem->GetCachedProgramFanart())) pItem->SetProperty("fanart_image",pItem->GetCachedProgramFanart()); } else { if (CFile::Exists(pItem->GetCachedFanart())) pItem->SetProperty("fanart_image",pItem->GetCachedFanart()); } } return true; }
bool CVideoThumbLoader::LoadItem(CFileItem* pItem, bool bCanBlock) { if (pItem->m_bIsShareOrDrive) return false; bool retVal = false; if (pItem->IsVideoDb() && pItem->HasVideoInfoTag() && !pItem->HasThumbnail()) { if (pItem->m_bIsFolder && pItem->GetVideoInfoTag()->m_iSeason > -1) return false; CFileItem item(*pItem->GetVideoInfoTag()); bool bResult = LoadItem(&item, bCanBlock); if (bResult) { pItem->SetProperty("HasAutoThumb",item.GetProperty("HasAutoThumb")); pItem->SetProperty("AutoThumbImage",item.GetProperty("AutoThumbImage")); pItem->SetProperty("fanart_image",item.GetProperty("fanart_image")); pItem->SetThumbnailImage(item.GetThumbnailImage()); pItem->GetVideoInfoTag()->m_streamDetails = item.GetVideoInfoTag()->m_streamDetails; } return bResult; } CStdString cachedThumb(pItem->GetCachedVideoThumb()); CLog::Log(LOGDEBUG, "CVideoThumbLoader::LoadItem, strItemPath = %s, cachedThumb = %s (thumb)", pItem->m_strPath.c_str(), cachedThumb.c_str()); if (!pItem->HasThumbnail()) { if (CFile::Exists(cachedThumb)) { CLog::Log(LOGDEBUG, "CVideoThumbLoader::LoadItem, EXISTS, strItemPath = %s, cachedThumb = %s (thumb)", pItem->m_strPath.c_str(), cachedThumb.c_str()); pItem->SetCachedVideoThumb(); } else if (pItem->m_bIsFolder) pItem->SetUserVideoThumb(); else { CStdString strPath, strFileName; CUtil::Split(cachedThumb, strPath, strFileName); // create unique thumb for auto generated thumbs cachedThumb = strPath + "auto-" + strFileName; if (pItem->IsVideo() && !pItem->IsInternetStream() && !pItem->IsPlayList() && !CFile::Exists(cachedThumb) && !pItem->m_bIsFolder) { if (!bCanBlock) { // we should not retreive remote (e.g. SMB) thumbs if requested not to block return false; } CStreamDetails details; if (pItem->IsStack()) { CStackDirectory stack; CVideoThumbLoader::ExtractThumb(stack.GetFirstStackedFile(pItem->m_strPath), cachedThumb, &details); } else { CVideoThumbLoader::ExtractThumb(pItem->m_strPath, cachedThumb, &details); } if (details.HasItems() && m_pStreamDetailsObs) m_pStreamDetailsObs->OnStreamDetails(details, pItem->m_strPath, -1); } if (CFile::Exists(cachedThumb)) { pItem->SetProperty("HasAutoThumb", "1"); pItem->SetProperty("AutoThumbImage", cachedThumb); pItem->SetThumbnailImage(cachedThumb); retVal = true; } else pItem->SetThumbnailImage(""); } } else { // look for remote thumbs CStdString thumb(pItem->GetThumbnailImage()); if (!CURI::IsFileOnly(thumb) && !CUtil::IsHD(thumb)) { if (pItem->GetProperty("OriginalThumb").IsEmpty()) { //when the item is loaded from the database we don't want to overwrite the original thumb by mistake because the user might have his own thumb //related to http://jira.boxee.tv/browse/BOXEE-8488 pItem->SetProperty("OriginalThumb", thumb); } if(CFile::Exists(cachedThumb)) { pItem->SetThumbnailImage(cachedThumb); retVal = true; } else { if (!bCanBlock) { // we should not retreive remote thumbs if requested not to block return false; } if(CPicture::CreateThumbnail(thumb, cachedThumb)) pItem->SetThumbnailImage(cachedThumb); else pItem->SetThumbnailImage(""); } } else { if (!CFile::Exists(cachedThumb)) { // Thumb can not be found. Going to create the thumb by fetching the original thumb and save it in cache if (!bCanBlock) { if (pItem->GetProperty("OriginalThumb").IsEmpty()) { pItem->SetProperty("OriginalThumb", thumb); } return false; } CStdString originalThumb = pItem->GetProperty("OriginalThumb"); if (!pItem->GetThumbnailImage().IsEmpty() && (CUtil::IsHD(pItem->GetThumbnailImage()) || CUtil::IsSmb(pItem->GetThumbnailImage()) || CUtil::IsUPnP(pItem->GetThumbnailImage())) && CFile::Exists(pItem->GetThumbnailImage())) { //if the user has the thumb locally, use it originalThumb = pItem->GetThumbnailImage(); } CStdString newCachedThumb = pItem->GetCachedPictureThumb(); if(CPicture::CreateThumbnail(originalThumb, newCachedThumb,true )) { pItem->SetThumbnailImage(newCachedThumb); } else { pItem->SetThumbnailImage(""); } } } } if (!pItem->HasProperty("fanart_image") && bCanBlock) { pItem->CacheFanart(); if (CFile::Exists(pItem->GetCachedFanart())) { pItem->SetProperty("fanart_image",pItem->GetCachedFanart()); retVal = true; } } if (!pItem->m_bIsFolder && !pItem->IsInternetStream() && pItem->HasVideoInfoTag() && g_guiSettings.GetBool("myvideos.extractflags") && !pItem->GetVideoInfoTag()->HasStreamDetails()) { if (CDVDFileInfo::GetFileStreamDetails(pItem) && m_pStreamDetailsObs) { CVideoInfoTag *info = pItem->GetVideoInfoTag(); m_pStreamDetailsObs->OnStreamDetails(info->m_streamDetails, "", info->m_iFileId); pItem->SetInvalid(); retVal = true; } } // if (pItem->IsVideo() && !pItem->IsInternetStream()) // CDVDPlayer::GetFileMetaData(pItem->m_strPath, pItem); return retVal; }
bool CVideoThumbLoader::LoadItem(CFileItem* pItem) { if (pItem->m_bIsShareOrDrive) return true; if (pItem->IsVideoDb() && pItem->HasVideoInfoTag() && !pItem->HasThumbnail()) { if (pItem->m_bIsFolder && pItem->GetVideoInfoTag()->m_iSeason > -1) return false; CFileItem item(*pItem->GetVideoInfoTag()); bool bResult = LoadItem(&item); if (bResult) { pItem->SetProperty("HasAutoThumb",item.GetProperty("HasAutoThumb")); pItem->SetProperty("AutoThumbImage",item.GetProperty("AutoThumbImage")); pItem->SetProperty("fanart_image",item.GetProperty("fanart_image")); pItem->SetThumbnailImage(item.GetThumbnailImage()); } return bResult; } CStdString cachedThumb(pItem->GetCachedVideoThumb()); if (!pItem->HasThumbnail()) { pItem->SetUserVideoThumb(); if (!CFile::Exists(cachedThumb)) { CStdString strPath, strFileName; CUtil::Split(cachedThumb, strPath, strFileName); // create unique thumb for auto generated thumbs cachedThumb = strPath + "auto-" + strFileName; if (pItem->IsVideo() && !pItem->IsInternetStream() && !pItem->IsPlayList() && !CFile::Exists(cachedThumb)) { if (pItem->IsStack()) { CStackDirectory stack; CVideoThumbLoader::ExtractThumb(stack.GetFirstStackedFile(pItem->m_strPath), cachedThumb); } else { CVideoThumbLoader::ExtractThumb(pItem->m_strPath, cachedThumb); } } if (CFile::Exists(cachedThumb)) { pItem->SetProperty("HasAutoThumb", "1"); pItem->SetProperty("AutoThumbImage", cachedThumb); pItem->SetThumbnailImage(cachedThumb); } } } else LoadRemoteThumb(pItem); if (!pItem->HasProperty("fanart_image")) { pItem->CacheFanart(); if (CFile::Exists(pItem->GetCachedFanart())) pItem->SetProperty("fanart_image",pItem->GetCachedFanart()); } // if (pItem->IsVideo() && !pItem->IsInternetStream()) // CDVDPlayer::GetFileMetaData(pItem->m_strPath, pItem); return true; }