本文整理汇总了C++中CNfoFile类的典型用法代码示例。如果您正苦于以下问题:C++ CNfoFile类的具体用法?C++ CNfoFile怎么用?C++ CNfoFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CNfoFile类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ScrapeFilename
bool CIMDB::ScrapeFilename(const CStdString& strFileName, CVideoInfoTag& details)
{
m_parser.m_param[0] = strFileName;
CUtil::RemoveExtension(m_parser.m_param[0]);
m_parser.m_param[0].Replace("_"," ");
CStdString strResult = m_parser.Parse("FileNameScrape",&m_info.settings);
TiXmlDocument doc;
doc.Parse(strResult.c_str());
if (doc.RootElement())
{
CNfoFile file;
if (file.GetDetails(details,strResult.c_str()))
return true;
}
return false;
}
示例2: scraper
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: scraper
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());
//.........这里部分代码省略.........