本文整理汇总了C++中addon::ScraperPtr::ClearCache方法的典型用法代码示例。如果您正苦于以下问题:C++ ScraperPtr::ClearCache方法的具体用法?C++ ScraperPtr::ClearCache怎么用?C++ ScraperPtr::ClearCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类addon::ScraperPtr
的用法示例。
在下文中一共展示了ScraperPtr::ClearCache方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Work
bool CVideoLibraryRefreshingJob::Work(CVideoDatabase &db)
{
if (m_item == nullptr)
return false;
// determine the scraper for the item's path
VIDEO::SScanSettings scanSettings;
ADDON::ScraperPtr scraper = db.GetScraperForPath(m_item->GetPath(), scanSettings);
if (scraper == nullptr)
return false;
// copy the scraper in case we need it again
ADDON::ScraperPtr originalScraper(scraper);
// get the item's correct title
std::string itemTitle = m_searchTitle;
if (itemTitle.empty())
itemTitle = m_item->GetMovieName(scanSettings.parent_name);
CScraperUrl scraperUrl;
VIDEO::CVideoInfoScanner scanner;
bool needsRefresh = m_forceRefresh;
bool hasDetails = false;
bool ignoreNfo = m_ignoreNfo;
// run this in a loop in case we need to refresh again
bool failure = false;
do
{
if (!ignoreNfo)
{
// check if there's an NFO for the item
CNfoFile::NFOResult nfoResult = scanner.CheckForNFOFile(m_item.get(), scanSettings.parent_name_root, scraper, scraperUrl);
// if there's no NFO remember it in case we have to refresh again
if (nfoResult == CNfoFile::ERROR_NFO)
ignoreNfo = true;
else if (nfoResult != CNfoFile::NO_NFO)
hasDetails = true;
// if we are performing a forced refresh ask the user to choose between using a valid NFO and a valid scraper
if (needsRefresh && IsModal() && !scraper->IsNoop() &&
(nfoResult == CNfoFile::URL_NFO || nfoResult == CNfoFile::COMBINED_NFO || nfoResult == CNfoFile::FULL_NFO))
{
int heading = 20159;
if (scraper->Content() == CONTENT_MOVIES)
heading = 13346;
else if (scraper->Content() == CONTENT_TVSHOWS)
heading = m_item->m_bIsFolder ? 20351 : 20352;
else if (scraper->Content() == CONTENT_MUSICVIDEOS)
heading = 20393;
if (CGUIDialogYesNo::ShowAndGetInput(heading, 20446))
{
hasDetails = false;
ignoreNfo = true;
scraperUrl.Clear();
scraper = originalScraper;
}
}
}
// no need to re-fetch the episode guide for episodes
if (scraper->Content() == CONTENT_TVSHOWS && !m_item->m_bIsFolder)
hasDetails = true;
// if we don't have an url or need to refresh anyway do the web search
if (!hasDetails && (needsRefresh || scraperUrl.m_url.empty()))
{
SetTitle(StringUtils::Format(g_localizeStrings.Get(197).c_str(), scraper->Name().c_str()));
SetText(itemTitle);
SetProgress(0);
// clear any cached data from the scraper
scraper->ClearCache();
// create the info downloader for the scraper
CVideoInfoDownloader infoDownloader(scraper);
// try to find a matching item
MOVIELIST itemResultList;
int result = infoDownloader.FindMovie(itemTitle, itemResultList, GetProgressDialog());
// close the progress dialog
MarkFinished();
if (result > 0)
{
// there are multiple matches for the item
if (!itemResultList.empty())
{
// choose the first match
if (!IsModal())
scraperUrl = itemResultList.at(0);
else
{
// ask the user what to do
CGUIDialogSelect* selectDialog = static_cast<CGUIDialogSelect*>(g_windowManager.GetWindow(WINDOW_DIALOG_SELECT));
selectDialog->Reset();
selectDialog->SetHeading(scraper->Content() == CONTENT_TVSHOWS ? 20356 : 196);
for (const auto& itemResult : itemResultList)
//.........这里部分代码省略.........
示例2: DownloadAlbumInfo
bool CMusicInfoScanner::DownloadAlbumInfo(const CStdString& strPath, const CStdString& strArtist, const CStdString& strAlbum, bool& bCanceled, CMusicAlbumInfo& albumInfo, CGUIDialogProgress* pDialog)
{
CAlbum album;
VECSONGS songs;
XFILE::MUSICDATABASEDIRECTORY::CQueryParams params;
XFILE::MUSICDATABASEDIRECTORY::CDirectoryNode::GetDatabaseInfo(strPath, params);
bCanceled = false;
m_musicDatabase.Open();
if (m_musicDatabase.HasAlbumInfo(params.GetAlbumId()) && m_musicDatabase.GetAlbumInfo(params.GetAlbumId(),album,&songs))
return true;
// find album info
ADDON::ScraperPtr info;
if (!m_musicDatabase.GetScraperForPath(strPath, info, ADDON::ADDON_SCRAPER_ALBUMS) || !info)
{
m_musicDatabase.Close();
return false;
}
if (m_handle)
{
m_handle->SetTitle(StringUtils::Format(g_localizeStrings.Get(20321), info->Name().c_str()));
m_handle->SetText(strArtist+" - "+strAlbum);
}
// clear our scraper cache
info->ClearCache();
CMusicInfoScraper scraper(info);
// handle nfo files
CStdString strAlbumPath, strNfo;
m_musicDatabase.GetAlbumPath(params.GetAlbumId(),strAlbumPath);
URIUtils::AddFileToFolder(strAlbumPath,"album.nfo",strNfo);
CNfoFile::NFOResult result=CNfoFile::NO_NFO;
CNfoFile nfoReader;
if (XFILE::CFile::Exists(strNfo))
{
CLog::Log(LOGDEBUG,"Found matching nfo file: %s", strNfo.c_str());
result = nfoReader.Create(strNfo, info, -1, strPath);
if (result == CNfoFile::FULL_NFO)
{
CLog::Log(LOGDEBUG, "%s Got details from nfo", __FUNCTION__);
CAlbum album;
nfoReader.GetDetails(album);
m_musicDatabase.SetAlbumInfo(params.GetAlbumId(), album, album.songs);
GetAlbumArtwork(params.GetAlbumId(), album);
m_musicDatabase.Close();
return true;
}
else if (result == CNfoFile::URL_NFO || result == CNfoFile::COMBINED_NFO)
{
CScraperUrl scrUrl(nfoReader.ScraperUrl());
CMusicAlbumInfo album("nfo",scrUrl);
info = nfoReader.GetScraperInfo();
CLog::Log(LOGDEBUG,"-- nfo-scraper: %s",info->Name().c_str());
CLog::Log(LOGDEBUG,"-- nfo url: %s", scrUrl.m_url[0].m_url.c_str());
scraper.SetScraperInfo(info);
scraper.GetAlbums().push_back(album);
}
else
CLog::Log(LOGERROR,"Unable to find an url in nfo file: %s", strNfo.c_str());
}
if (!scraper.CheckValidOrFallback(g_guiSettings.GetString("musiclibrary.albumsscraper")))
{ // the current scraper is invalid, as is the default - bail
CLog::Log(LOGERROR, "%s - current and default scrapers are invalid. Pick another one", __FUNCTION__);
return false;
}
if (!scraper.GetAlbumCount())
{
scraper.FindAlbumInfo(strAlbum, strArtist);
while (!scraper.Completed())
{
if (m_bStop)
{
scraper.Cancel();
bCanceled = true;
}
Sleep(1);
}
}
CGUIDialogSelect *pDlg=NULL;
int iSelectedAlbum=0;
if (result == CNfoFile::NO_NFO)
{
iSelectedAlbum = -1; // set negative so that we can detect a failure
if (scraper.Succeeded() && scraper.GetAlbumCount() >= 1)
{
int bestMatch = -1;
double bestRelevance = 0;
double minRelevance = THRESHOLD;
if (scraper.GetAlbumCount() > 1) // score the matches
{
//show dialog with all albums found
if (pDialog)
{
//.........这里部分代码省略.........
示例3: DownloadArtistInfo
INFO_RET CMusicInfoScanner::DownloadArtistInfo(const CArtist& artist, const ADDON::ScraperPtr& info, MUSIC_GRABBER::CMusicArtistInfo& artistInfo, CGUIDialogProgress* pDialog)
{
if (m_handle)
{
m_handle->SetTitle(StringUtils::Format(g_localizeStrings.Get(20320).c_str(), info->Name().c_str()));
m_handle->SetText(artist.strArtist);
}
// clear our scraper cache
info->ClearCache();
CMusicInfoScraper scraper(info);
bool bMusicBrainz = false;
if (!artist.strMusicBrainzArtistID.empty())
{
CScraperUrl musicBrainzURL;
if (ResolveMusicBrainz(artist.strMusicBrainzArtistID, info, musicBrainzURL))
{
CMusicArtistInfo artistNfo("nfo", musicBrainzURL);
scraper.GetArtists().clear();
scraper.GetArtists().push_back(artistNfo);
bMusicBrainz = true;
}
}
// handle nfo files
std::string path = artist.strPath;
if (path.empty())
m_musicDatabase.GetArtistPath(artist.idArtist, path);
std::string strNfo = URIUtils::AddFileToFolder(path, "artist.nfo");
CNfoFile::NFOResult result=CNfoFile::NO_NFO;
CNfoFile nfoReader;
if (XFILE::CFile::Exists(strNfo))
{
CLog::Log(LOGDEBUG,"Found matching nfo file: %s", strNfo.c_str());
result = nfoReader.Create(strNfo, info);
if (result == CNfoFile::FULL_NFO)
{
CLog::Log(LOGDEBUG, "%s Got details from nfo", __FUNCTION__);
nfoReader.GetDetails(artistInfo.GetArtist());
return INFO_ADDED;
}
else if (result == CNfoFile::URL_NFO || result == CNfoFile::COMBINED_NFO)
{
CScraperUrl scrUrl(nfoReader.ScraperUrl());
CMusicArtistInfo artistNfo("nfo",scrUrl);
ADDON::ScraperPtr nfoReaderScraper = nfoReader.GetScraperInfo();
CLog::Log(LOGDEBUG,"-- nfo-scraper: %s",nfoReaderScraper->Name().c_str());
CLog::Log(LOGDEBUG,"-- nfo url: %s", scrUrl.m_url[0].m_url.c_str());
scraper.SetScraperInfo(nfoReaderScraper);
scraper.GetArtists().push_back(artistNfo);
}
else
CLog::Log(LOGERROR,"Unable to find an url in nfo file: %s", strNfo.c_str());
}
if (!scraper.GetArtistCount())
{
scraper.FindArtistInfo(artist.strArtist);
while (!scraper.Completed())
{
if (m_bStop)
{
scraper.Cancel();
return INFO_CANCELLED;
}
Sleep(1);
}
}
int iSelectedArtist = 0;
if (result == CNfoFile::NO_NFO && !bMusicBrainz)
{
if (scraper.GetArtistCount() >= 1)
{
// now load the first match
if (pDialog && scraper.GetArtistCount() > 1)
{
// if we found more then 1 album, let user choose one
CGUIDialogSelect *pDlg = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (pDlg)
{
pDlg->SetHeading(g_localizeStrings.Get(21890));
pDlg->Reset();
pDlg->EnableButton(true, 413); // manual
for (int i = 0; i < scraper.GetArtistCount(); ++i)
{
// set the label to artist
CFileItem item(scraper.GetArtist(i).GetArtist());
std::string strTemp=scraper.GetArtist(i).GetArtist().strArtist;
if (!scraper.GetArtist(i).GetArtist().strBorn.empty())
strTemp += " ("+scraper.GetArtist(i).GetArtist().strBorn+")";
if (!scraper.GetArtist(i).GetArtist().genre.empty())
{
std::string genres = StringUtils::Join(scraper.GetArtist(i).GetArtist().genre, g_advancedSettings.m_musicItemSeparator);
if (!genres.empty())
strTemp = StringUtils::Format("[%s] %s", genres.c_str(), strTemp.c_str());
//.........这里部分代码省略.........
示例4: DownloadArtistInfo
bool CMusicInfoScanner::DownloadArtistInfo(const CStdString& strPath, const CStdString& strArtist, bool& bCanceled, CGUIDialogProgress* pDialog)
{
XFILE::MUSICDATABASEDIRECTORY::CQueryParams params;
XFILE::MUSICDATABASEDIRECTORY::CDirectoryNode::GetDatabaseInfo(strPath, params);
bCanceled = false;
CArtist artist;
m_musicDatabase.Open();
if (m_musicDatabase.GetArtistInfo(params.GetArtistId(),artist)) // already got the info
return true;
// find artist info
ADDON::ScraperPtr info;
if (!m_musicDatabase.GetScraperForPath(strPath, info, ADDON::ADDON_SCRAPER_ARTISTS) || !info)
{
m_musicDatabase.Close();
return false;
}
if (m_handle)
{
m_handle->SetTitle(StringUtils::Format(g_localizeStrings.Get(20320), info->Name().c_str()));
m_handle->SetText(strArtist);
}
// clear our scraper cache
info->ClearCache();
CMusicInfoScraper scraper(info);
// handle nfo files
CStdString strArtistPath, strNfo;
m_musicDatabase.GetArtistPath(params.GetArtistId(),strArtistPath);
URIUtils::AddFileToFolder(strArtistPath,"artist.nfo",strNfo);
CNfoFile::NFOResult result=CNfoFile::NO_NFO;
CNfoFile nfoReader;
if (XFILE::CFile::Exists(strNfo))
{
CLog::Log(LOGDEBUG,"Found matching nfo file: %s", strNfo.c_str());
result = nfoReader.Create(strNfo, info);
if (result == CNfoFile::FULL_NFO)
{
CLog::Log(LOGDEBUG, "%s Got details from nfo", __FUNCTION__);
CArtist artist;
nfoReader.GetDetails(artist);
m_musicDatabase.SetArtistInfo(params.GetArtistId(), artist);
map<string, string> artwork = GetArtistArtwork(params.GetArtistId(), &artist);
m_musicDatabase.SetArtForItem(params.GetArtistId(), "artist", artwork);
m_musicDatabase.Close();
return true;
}
else if (result == CNfoFile::URL_NFO || result == CNfoFile::COMBINED_NFO)
{
CScraperUrl scrUrl(nfoReader.ScraperUrl());
CMusicArtistInfo artist("nfo",scrUrl);
info = nfoReader.GetScraperInfo();
CLog::Log(LOGDEBUG,"-- nfo-scraper: %s",info->Name().c_str());
CLog::Log(LOGDEBUG,"-- nfo url: %s", scrUrl.m_url[0].m_url.c_str());
scraper.SetScraperInfo(info);
scraper.GetArtists().push_back(artist);
}
else
CLog::Log(LOGERROR,"Unable to find an url in nfo file: %s", strNfo.c_str());
}
if (!scraper.GetArtistCount())
{
scraper.FindArtistInfo(strArtist);
while (!scraper.Completed())
{
if (m_bStop)
{
scraper.Cancel();
bCanceled = true;
}
Sleep(1);
}
}
int iSelectedArtist = 0;
if (result == CNfoFile::NO_NFO)
{
if (scraper.Succeeded() && scraper.GetArtistCount() >= 1)
{
// now load the first match
if (pDialog && scraper.GetArtistCount() > 1)
{
// if we found more then 1 album, let user choose one
CGUIDialogSelect *pDlg = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (pDlg)
{
pDlg->SetHeading(g_localizeStrings.Get(21890));
pDlg->Reset();
pDlg->EnableButton(true, 413); // manual
for (int i = 0; i < scraper.GetArtistCount(); ++i)
{
// set the label to artist
CFileItem item(scraper.GetArtist(i).GetArtist());
CStdString strTemp=scraper.GetArtist(i).GetArtist().strArtist;
if (!scraper.GetArtist(i).GetArtist().strBorn.IsEmpty())
//.........这里部分代码省略.........
示例5: DownloadAlbumInfo
INFO_RET CMusicInfoScanner::DownloadAlbumInfo(const CAlbum& album, const ADDON::ScraperPtr& info, CMusicAlbumInfo& albumInfo, CGUIDialogProgress* pDialog)
{
if (m_handle)
{
m_handle->SetTitle(StringUtils::Format(g_localizeStrings.Get(20321).c_str(), info->Name().c_str()));
m_handle->SetText(StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator) + " - " + album.strAlbum);
}
// clear our scraper cache
info->ClearCache();
CMusicInfoScraper scraper(info);
bool bMusicBrainz = false;
if (!album.strMusicBrainzAlbumID.empty())
{
CScraperUrl musicBrainzURL;
if (ResolveMusicBrainz(album.strMusicBrainzAlbumID, info, musicBrainzURL))
{
CMusicAlbumInfo albumNfo("nfo", musicBrainzURL);
scraper.GetAlbums().clear();
scraper.GetAlbums().push_back(albumNfo);
bMusicBrainz = true;
}
}
// handle nfo files
std::string path = album.strPath;
if (path.empty())
m_musicDatabase.GetAlbumPath(album.idAlbum, path);
std::string strNfo = URIUtils::AddFileToFolder(path, "album.nfo");
CNfoFile::NFOResult result = CNfoFile::NO_NFO;
CNfoFile nfoReader;
if (XFILE::CFile::Exists(strNfo))
{
CLog::Log(LOGDEBUG,"Found matching nfo file: %s", strNfo.c_str());
result = nfoReader.Create(strNfo, info);
if (result == CNfoFile::FULL_NFO)
{
CLog::Log(LOGDEBUG, "%s Got details from nfo", __FUNCTION__);
nfoReader.GetDetails(albumInfo.GetAlbum());
return INFO_ADDED;
}
else if (result == CNfoFile::URL_NFO || result == CNfoFile::COMBINED_NFO)
{
CScraperUrl scrUrl(nfoReader.ScraperUrl());
CMusicAlbumInfo albumNfo("nfo",scrUrl);
ADDON::ScraperPtr nfoReaderScraper = nfoReader.GetScraperInfo();
CLog::Log(LOGDEBUG,"-- nfo-scraper: %s", nfoReaderScraper->Name().c_str());
CLog::Log(LOGDEBUG,"-- nfo url: %s", scrUrl.m_url[0].m_url.c_str());
scraper.SetScraperInfo(nfoReaderScraper);
scraper.GetAlbums().clear();
scraper.GetAlbums().push_back(albumNfo);
}
else
CLog::Log(LOGERROR,"Unable to find an url in nfo file: %s", strNfo.c_str());
}
if (!scraper.CheckValidOrFallback(CSettings::Get().GetString("musiclibrary.albumsscraper")))
{ // the current scraper is invalid, as is the default - bail
CLog::Log(LOGERROR, "%s - current and default scrapers are invalid. Pick another one", __FUNCTION__);
return INFO_ERROR;
}
if (!scraper.GetAlbumCount())
{
scraper.FindAlbumInfo(album.strAlbum, StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator));
while (!scraper.Completed())
{
if (m_bStop)
{
scraper.Cancel();
return INFO_CANCELLED;
}
Sleep(1);
}
}
CGUIDialogSelect *pDlg = NULL;
int iSelectedAlbum=0;
if (result == CNfoFile::NO_NFO && !bMusicBrainz)
{
iSelectedAlbum = -1; // set negative so that we can detect a failure
if (scraper.Succeeded() && scraper.GetAlbumCount() >= 1)
{
double bestRelevance = 0;
double minRelevance = THRESHOLD;
if (scraper.GetAlbumCount() > 1) // score the matches
{
//show dialog with all albums found
if (pDialog)
{
pDlg = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
pDlg->SetHeading(g_localizeStrings.Get(181).c_str());
pDlg->Reset();
pDlg->EnableButton(true, 413); // manual
}
for (int i = 0; i < scraper.GetAlbumCount(); ++i)
//.........这里部分代码省略.........