本文整理汇总了C++中CStdString类的典型用法代码示例。如果您正苦于以下问题:C++ CStdString类的具体用法?C++ CStdString怎么用?C++ CStdString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CStdString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetType
CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlElement* pControlNode, bool insideContainer)
{
// get the control type
CStdString strType = GetType(pControlNode);
CGUIControl::GUICONTROLTYPES type = TranslateControlType(strType);
int id = 0;
float posX = 0, posY = 0;
float width = 0, height = 0;
float minWidth = 0;
int left = 0, right = 0, up = 0, down = 0, next = 0, prev = 0;
vector<CGUIActionDescriptor> leftActions, rightActions, upActions, downActions, nextActions, prevActions;
int pageControl = 0;
CGUIInfoColor colorDiffuse(0xFFFFFFFF);
int defaultControl = 0;
bool defaultAlways = false;
CStdString strTmp;
int singleInfo = 0;
CStdString strLabel;
int iUrlSet=0;
int iToggleSelect;
float spinWidth = 16;
float spinHeight = 16;
float spinPosX = 0, spinPosY = 0;
float checkWidth = 0, checkHeight = 0;
CStdString strSubType;
int iType = SPIN_CONTROL_TYPE_TEXT;
int iMin = 0;
int iMax = 100;
int iInterval = 1;
float fMin = 0.0f;
float fMax = 1.0f;
float fInterval = 0.1f;
bool bReverse = true;
bool bReveal = false;
CTextureInfo textureBackground, textureLeft, textureRight, textureMid, textureOverlay;
CTextureInfo textureNib, textureNibFocus, textureBar, textureBarFocus;
CTextureInfo textureLeftFocus, textureRightFocus;
CTextureInfo textureUp, textureDown;
CTextureInfo textureUpFocus, textureDownFocus;
CTextureInfo texture, borderTexture;
CGUIInfoLabel textureFile;
CTextureInfo textureCheckMark, textureCheckMarkNF;
CTextureInfo textureFocus, textureNoFocus;
CTextureInfo textureAltFocus, textureAltNoFocus;
CTextureInfo textureRadioOn, textureRadioOff;
CTextureInfo imageNoFocus, imageFocus;
CGUIInfoLabel texturePath;
CRect borderSize;
float sliderWidth = 150, sliderHeight = 16;
CPoint offset;
bool bHasPath = false;
vector<CGUIActionDescriptor> clickActions;
vector<CGUIActionDescriptor> altclickActions;
vector<CGUIActionDescriptor> focusActions;
vector<CGUIActionDescriptor> unfocusActions;
vector<CGUIActionDescriptor> textChangeActions;
CStdString strTitle = "";
CStdString strRSSTags = "";
int iNumSlots = 7;
float buttonGap = 5;
int iDefaultSlot = 2;
int iMovementRange = 0;
bool bHorizontal = false;
int iAlpha = 0;
bool bWrapAround = true;
bool bSmoothScrolling = true;
CAspectRatio aspect;
#ifdef PRE_SKIN_VERSION_9_10_COMPATIBILITY
if (insideContainer) // default for inside containers is keep
aspect.ratio = CAspectRatio::AR_KEEP;
#endif
int iVisibleCondition = 0;
CGUIInfoBool allowHiddenFocus(false);
int enableCondition = 0;
vector<CAnimation> animations;
bool bScrollLabel = false;
bool bPulse = true;
unsigned int timePerImage = 0;
unsigned int fadeTime = 0;
unsigned int timeToPauseAtEnd = 0;
bool randomized = false;
bool loop = true;
bool wrapMultiLine = false;
ORIENTATION orientation = VERTICAL;
bool showOnePage = true;
bool scrollOut = true;
int preloadItems = 0;
CLabelInfo labelInfo;
CLabelInfo spinInfo;
//.........这里部分代码省略.........
示例2: lock
bool CSMBDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
// We accept smb://[[[domain;]user[:[email protected]]]server[/share[/path[/file]]]]
/* samba isn't thread safe with old interface, always lock */
CSingleLock lock(smb);
smb.Init();
/* we need an url to do proper escaping */
CURL url(strPath);
//Separate roots for the authentication and the containing items to allow browsing to work correctly
CStdString strRoot = strPath;
CStdString strAuth;
lock.Leave(); // OpenDir is locked
int fd = OpenDir(url, strAuth);
if (fd < 0)
return false;
if (!CUtil::HasSlashAtEnd(strRoot)) strRoot += "/";
if (!CUtil::HasSlashAtEnd(strAuth)) strAuth += "/";
CStdString strFile;
// need to keep the samba lock for as short as possible.
// so we first cache all directory entries and then go over them again asking for stat
// "stat" is locked each time. that way the lock is freed between stat requests
vector<CachedDirEntry> vecEntries;
struct smbc_dirent* dirEnt;
lock.Enter();
while ((dirEnt = smbc_readdir(fd)))
{
CachedDirEntry aDir;
aDir.type = dirEnt->smbc_type;
aDir.name = dirEnt->name;
vecEntries.push_back(aDir);
}
smbc_closedir(fd);
lock.Leave();
for (size_t i=0; i<vecEntries.size(); i++)
{
CachedDirEntry aDir = vecEntries[i];
// We use UTF-8 internally, as does SMB
strFile = aDir.name;
if (!strFile.Equals(".") && !strFile.Equals("..")
&& aDir.type != SMBC_PRINTER_SHARE && aDir.type != SMBC_IPC_SHARE)
{
__int64 iSize = 0;
bool bIsDir = true;
__int64 lTimeDate = 0;
bool hidden = false;
if(strFile.Right(1).Equals("$") && aDir.type == SMBC_FILE_SHARE )
continue;
// only stat files that can give proper responses
if ( aDir.type == SMBC_FILE ||
aDir.type == SMBC_DIR )
{
// set this here to if the stat should fail
bIsDir = (aDir.type == SMBC_DIR);
#ifndef _LINUX
struct __stat64 info = {0};
#else
struct stat info = {0};
#endif
if (m_extFileInfo && g_advancedSettings.m_sambastatfiles)
{
// make sure we use the authenticated path wich contains any default username
CStdString strFullName = strAuth + smb.URLEncode(strFile);
lock.Enter();
if( smbc_stat(strFullName.c_str(), &info) == 0 )
{
#ifndef _LINUX
if ((info.st_mode & S_IXOTH))
hidden = true;
#else
char value[20];
// We poll for extended attributes which symbolizes bits but split up into a string. Where 0x02 is hidden and 0x12 is hidden directory.
// According to the libsmbclient.h it's supposed to return 0 if ok, or the length of the string. It seems always to return the length wich is 4
if (smbc_getxattr(strFullName, "system.dos_attr.mode", value, sizeof(value)) > 0)
{
long longvalue = strtol(value, NULL, 16);
if (longvalue & SMBC_DOS_MODE_HIDDEN)
hidden = true;
}
else
CLog::Log(LOGERROR, "Getting extended attributes for the share: '%s'\nunix_err:'%x' error: '%s'", strFullName.c_str(), errno, strerror(errno));
#endif
//.........这里部分代码省略.........
示例3: PrepareSQL
bool CAddonDatabase::IsAddonBlacklisted(const CStdString& addonID,
const CStdString& version)
{
CStdString where = PrepareSQL("addonID='%s' and version='%s'",addonID.c_str(),version.c_str());
return !GetSingleValue("blacklist","addonID",where).IsEmpty();
}
示例4: strtok
//-------------------------------------------------------------------------------------------------------------------
void Xcddb::parseData(const char *buffer)
{
//writeLog("parseData Start");
std::map<CStdString, CStdString> keywords;
std::list<CStdString> keywordsOrder; // remember order of keywords as it appears in data received from CDDB
// Collect all the keywords and put them in map.
// Multiple occurrences of the same keyword indicate that
// the data contained on those lines should be concatenated
char *line;
const char trenner[3] = {'\n', '\r', '\0'};
strtok((char*)buffer, trenner); // skip first line
while ((line = strtok(0, trenner)))
{
// Lines that begin with # are comments, should be ignored
if (line[0] != '#')
{
char *s = strstr(line, "=");
if (s != NULL)
{
CStdString strKeyword(line, s - line);
strKeyword.TrimRight(" ");
CStdString strValue(s+1);
strValue.Replace("\\n", "\n");
strValue.Replace("\\t", "\t");
strValue.Replace("\\\\", "\\");
g_charsetConverter.unknownToUTF8(strValue);
std::map<CStdString, CStdString>::const_iterator it = keywords.find(strKeyword);
if (it != keywords.end())
strValue = it->second + strValue; // keyword occured before, concatenate
else
keywordsOrder.push_back(strKeyword);
keywords[strKeyword] = strValue;
}
}
}
// parse keywords
for (std::list<CStdString>::const_iterator it = keywordsOrder.begin(); it != keywordsOrder.end(); ++it)
{
CStdString strKeyword = *it;
CStdString strValue = keywords[strKeyword];
if (strKeyword == "DTITLE")
{
// DTITLE may contain artist and disc title, separated with " / ",
// for example: DTITLE=Modern Talking / Album: Victory (The 11th Album)
bool found = false;
for (int i = 0; i < strValue.GetLength() - 2; i++)
{
if (strValue[i] == ' ' && strValue[i + 1] == '/' && strValue[i + 2] == ' ')
{
m_strDisk_artist = TrimToUTF8(strValue.Left(i));
m_strDisk_title = TrimToUTF8(strValue.Mid(i+3));
found = true;
break;
}
}
if (!found)
m_strDisk_title = TrimToUTF8(strValue);
}
else if (strKeyword == "DYEAR")
m_strYear = TrimToUTF8(strValue);
else if (strKeyword== "DGENRE")
m_strGenre = TrimToUTF8(strValue);
else if (strKeyword.Left(6) == "TTITLE")
addTitle(strKeyword + "=" + strValue);
else if (strKeyword == "EXTD")
{
CStdString strExtd(strValue);
if (m_strYear.IsEmpty())
{
// Extract Year from extended info
// as a fallback
int iPos = strExtd.Find("YEAR:");
if (iPos > -1) // You never know if you really get UTF-8 strings from cddb
g_charsetConverter.unknownToUTF8(strExtd.Mid(iPos + 6, 4), m_strYear);
}
if (m_strGenre.IsEmpty())
{
// Extract ID3 Genre
// as a fallback
int iPos = strExtd.Find("ID3G:");
if (iPos > -1)
{
CStdString strGenre = strExtd.Mid(iPos + 5, 4);
strGenre.TrimLeft(' ');
if (StringUtils::IsNaturalNumber(strGenre))
{
CID3Tag tag;
m_strGenre=tag.ParseMP3Genre(strGenre);
}
//.........这里部分代码省略.........
示例5: ParseItemMRSS
static void ParseItemMRSS(CFileItem* item, SResources& resources, TiXmlElement* item_child, const CStdString& name, const CStdString& xmlns, const CStdString& path)
{
CVideoInfoTag* vtag = item->GetVideoInfoTag();
CStdString text = item_child->GetText();
if(name == "content")
{
SResource res;
res.tag = "media:content";
res.mime = item_child->Attribute("type");
res.path = item_child->Attribute("url");
if(item_child->Attribute("width"))
res.width = atoi(item_child->Attribute("width"));
if(item_child->Attribute("height"))
res.height = atoi(item_child->Attribute("height"));
if(item_child->Attribute("bitrate"))
res.bitrate = atoi(item_child->Attribute("bitrate"));
if(item_child->Attribute("duration"))
res.duration = atoi(item_child->Attribute("duration"));
if(item_child->Attribute("fileSize"))
res.size = _atoi64(item_child->Attribute("fileSize"));
resources.push_back(res);
ParseItem(item, resources, item_child, path);
}
else if(name == "group")
{
ParseItem(item, resources, item_child, path);
}
else if(name == "thumbnail")
{
if(item_child->GetText() && IsPathToThumbnail(item_child->GetText()))
item->SetThumbnailImage(item_child->GetText());
else
{
const char * url = item_child->Attribute("url");
if(url && IsPathToThumbnail(url))
item->SetThumbnailImage(url);
}
}
else if (name == "title")
{
if(text.IsEmpty())
return;
if(text.length() > item->m_strTitle.length())
item->m_strTitle = text;
}
else if(name == "description")
{
if(text.IsEmpty())
return;
CStdString description = text;
if(CStdString(item_child->Attribute("type")) == "html")
HTML::CHTMLUtil::RemoveTags(description);
item->SetProperty("description", description);
}
else if(name == "category")
{
if(text.IsEmpty())
return;
CStdString scheme = item_child->Attribute("scheme");
/* okey this is silly, boxee what did you think?? */
if (scheme == "urn:boxee:genre")
vtag->m_genre = StringUtils::Split(text, g_advancedSettings.m_videoItemSeparator);
else if(scheme == "urn:boxee:title-type")
{
if (text == "tv")
item->SetProperty("boxee:istvshow", true);
else if(text == "movie")
item->SetProperty("boxee:ismovie", true);
}
else if(scheme == "urn:boxee:episode")
vtag->m_iEpisode = atoi(text.c_str());
else if(scheme == "urn:boxee:season")
vtag->m_iSeason = atoi(text.c_str());
else if(scheme == "urn:boxee:show-title")
vtag->m_strShowTitle = text.c_str();
else if(scheme == "urn:boxee:view-count")
vtag->m_playCount = atoi(text.c_str());
else if(scheme == "urn:boxee:source")
item->SetProperty("boxee:provider_source", text);
else
vtag->m_genre = StringUtils::Split(text, g_advancedSettings.m_videoItemSeparator);
}
else if(name == "rating")
{
CStdString scheme = item_child->Attribute("scheme");
if(scheme == "urn:user")
vtag->m_fRating = (float)atof(text.c_str());
else
vtag->m_strMPAARating = text;
}
else if(name == "credit")
{
CStdString role = item_child->Attribute("role");
if (role == "director")
//.........这里部分代码省略.........
示例6: switch
bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
{
CFileItemPtr item;
if (itemNumber >= 0 && itemNumber < m_vecItems->Size())
item = m_vecItems->Get(itemNumber);
switch (button)
{
case CONTEXT_BUTTON_INFO:
{
if (!item->IsVideoDb())
return CGUIWindowMusicBase::OnContextButton(itemNumber,button);
// music videos - artists
if (item->GetPath().Left(14).Equals("videodb://3/4/"))
{
long idArtist = m_musicdatabase.GetArtistByName(item->GetLabel());
if (idArtist == -1)
return false;
CStdString path;
path.Format("musicdb://2/%ld/", idArtist);
CArtist artist;
m_musicdatabase.GetArtistInfo(idArtist,artist,false);
*item = CFileItem(artist);
item->SetPath(path);
CGUIWindowMusicBase::OnContextButton(itemNumber,button);
Update(m_vecItems->GetPath());
m_viewControl.SetSelectedItem(itemNumber);
return true;
}
// music videos - albums
if (item->GetPath().Left(14).Equals("videodb://3/5/"))
{
long idAlbum = m_musicdatabase.GetAlbumByName(item->GetLabel());
if (idAlbum == -1)
return false;
CStdString path;
path.Format("musicdb://3/%ld/", idAlbum);
CAlbum album;
m_musicdatabase.GetAlbumInfo(idAlbum,album,NULL);
*item = CFileItem(path,album);
item->SetPath(path);
CGUIWindowMusicBase::OnContextButton(itemNumber,button);
Update(m_vecItems->GetPath());
m_viewControl.SetSelectedItem(itemNumber);
return true;
}
if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strTitle.IsEmpty())
{
CGUIWindowVideoNav* pWindow = (CGUIWindowVideoNav*)g_windowManager.GetWindow(WINDOW_VIDEO_NAV);
if (pWindow)
{
ADDON::ScraperPtr info;
pWindow->OnInfo(item.get(),info);
Update(m_vecItems->GetPath());
}
}
return true;
}
case CONTEXT_BUTTON_INFO_ALL:
OnInfoAll(itemNumber);
return true;
case CONTEXT_BUTTON_UPDATE_LIBRARY:
{
g_application.StartMusicScan("");
return true;
}
case CONTEXT_BUTTON_SET_DEFAULT:
g_settings.m_defaultMusicLibSource = GetQuickpathName(item->GetPath());
g_settings.Save();
return true;
case CONTEXT_BUTTON_CLEAR_DEFAULT:
g_settings.m_defaultMusicLibSource.Empty();
g_settings.Save();
return true;
case CONTEXT_BUTTON_GO_TO_ARTIST:
{
CStdString strPath;
CVideoDatabase database;
database.Open();
strPath.Format("videodb://3/4/%ld/",database.GetMatchingMusicVideo(StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator)));
g_windowManager.ActivateWindow(WINDOW_VIDEO_NAV,strPath);
return true;
}
case CONTEXT_BUTTON_PLAY_OTHER:
{
CVideoDatabase database;
database.Open();
CVideoInfoTag details;
database.GetMusicVideoInfo("",details,database.GetMatchingMusicVideo(StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator),item->GetMusicInfoTag()->GetAlbum(),item->GetMusicInfoTag()->GetTitle()));
g_application.getApplicationMessenger().PlayFile(CFileItem(details));
return true;
//.........这里部分代码省略.........
示例7: GetStartFolder
CStdString CGUIWindowMusicNav::GetStartFolder(const CStdString &dir)
{
if (dir.Equals("Genres"))
return "musicdb://1/";
else if (dir.Equals("Artists"))
return "musicdb://2/";
else if (dir.Equals("Albums"))
return "musicdb://3/";
else if (dir.Equals("Singles"))
return "musicdb://10/";
else if (dir.Equals("Songs"))
return "musicdb://4/";
else if (dir.Equals("Top100"))
return "musicdb://5/";
else if (dir.Equals("Top100Songs"))
return "musicdb://5/1/";
else if (dir.Equals("Top100Albums"))
return "musicdb://5/2/";
else if (dir.Equals("RecentlyAddedAlbums"))
return "musicdb://6/";
else if (dir.Equals("RecentlyPlayedAlbums"))
return "musicdb://7/";
else if (dir.Equals("Compilations"))
return "musicdb://8/";
else if (dir.Equals("Years"))
return "musicdb://9/";
return CGUIWindowMusicBase::GetStartFolder(dir);
}
示例8: GetDirectory
bool CGUIWindowMusicNav::GetDirectory(const CStdString &strDirectory, CFileItemList &items)
{
if (m_bDisplayEmptyDatabaseMessage)
return true;
if (strDirectory.IsEmpty())
AddSearchFolder();
if (m_thumbLoader.IsLoading())
m_thumbLoader.StopThread();
bool bResult = CGUIWindowMusicBase::GetDirectory(strDirectory, items);
if (bResult)
{
if (items.IsPlayList())
OnRetrieveMusicInfo(items);
if (!items.IsMusicDb())
{
items.SetCachedMusicThumbs();
m_thumbLoader.Load(*m_vecItems);
}
}
// update our content in the info manager
if (strDirectory.Left(10).Equals("videodb://"))
{
CVideoDatabaseDirectory dir;
VIDEODATABASEDIRECTORY::NODE_TYPE node = dir.GetDirectoryChildType(strDirectory);
if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_TITLE_MUSICVIDEOS)
items.SetContent("musicvideos");
}
else if (strDirectory.Left(10).Equals("musicdb://"))
{
CMusicDatabaseDirectory dir;
NODE_TYPE node = dir.GetDirectoryChildType(strDirectory);
if (node == NODE_TYPE_ALBUM ||
node == NODE_TYPE_ALBUM_RECENTLY_ADDED ||
node == NODE_TYPE_ALBUM_RECENTLY_PLAYED ||
node == NODE_TYPE_ALBUM_TOP100 ||
node == NODE_TYPE_ALBUM_COMPILATIONS ||
node == NODE_TYPE_YEAR_ALBUM)
items.SetContent("albums");
else if (node == NODE_TYPE_ARTIST)
items.SetContent("artists");
else if (node == NODE_TYPE_SONG ||
node == NODE_TYPE_SONG_TOP100 ||
node == NODE_TYPE_SINGLES)
items.SetContent("songs");
else if (node == NODE_TYPE_GENRE)
items.SetContent("genres");
else if (node == NODE_TYPE_YEAR)
items.SetContent("years");
}
else if (strDirectory.Equals("special://musicplaylists"))
items.SetContent("playlists");
else if (strDirectory.Equals("plugin://music/"))
items.SetContent("plugins");
else if (items.IsPlayList())
items.SetContent("songs");
return bResult;
}
示例9: GetQuickpathName
CStdString CGUIWindowMusicNav::GetQuickpathName(const CStdString& strPath) const
{
if (strPath.Equals("musicdb://1/"))
return "Genres";
else if (strPath.Equals("musicdb://2/"))
return "Artists";
else if (strPath.Equals("musicdb://3/"))
return "Albums";
else if (strPath.Equals("musicdb://4/"))
return "Songs";
else if (strPath.Equals("musicdb://5/"))
return "Top100";
else if (strPath.Equals("musicdb://5/2/"))
return "Top100Songs";
else if (strPath.Equals("musicdb://5/1/"))
return "Top100Albums";
else if (strPath.Equals("musicdb://6/"))
return "RecentlyAddedAlbums";
else if (strPath.Equals("musicdb://7/"))
return "RecentlyPlayedAlbums";
else if (strPath.Equals("musicdb://8/"))
return "Compilations";
else if (strPath.Equals("musicdb://9/"))
return "Years";
else if (strPath.Equals("musicdb://10/"))
return "Singles";
else if (strPath.Equals("special://musicplaylists/"))
return "Playlists";
else
{
CLog::Log(LOGERROR, " CGUIWindowMusicNav::GetQuickpathName: Unknown parameter (%s)", strPath.c_str());
return strPath;
}
}
示例10: 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_pObserver)
{
m_pObserver->OnStateChanged(DOWNLOADING_ALBUM_INFO);
m_pObserver->OnDirectoryChanged(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)
{
pDlg = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
pDlg->SetHeading(g_localizeStrings.Get(181).c_str());
//.........这里部分代码省略.........
示例11: ParseItem
static void ParseItem(CFileItem* item, TiXmlElement* root, const CStdString& path)
{
SResources resources;
ParseItem(item, resources, root, path);
const char* prio[] = { "media:content", "voddler:trailer", "rss:enclosure", "svtplay:broadcasts", "svtplay:xmllink", "rss:link", "rss:guid", NULL };
CStdString mime;
if (FindMime(resources, "video/"))
mime = "video/";
else if(FindMime(resources, "audio/"))
mime = "audio/";
else if(FindMime(resources, "application/rss"))
mime = "application/rss";
else if(FindMime(resources, "image/"))
mime = "image/";
int maxrate = g_guiSettings.GetInt("network.bandwidth");
if(maxrate == 0)
maxrate = INT_MAX;
SResources::iterator best = resources.end();
for(const char** type = prio; *type && best == resources.end(); type++)
{
for(SResources::iterator it = resources.begin(); it != resources.end(); it++)
{
if(it->mime.Left(mime.length()) != mime)
continue;
if(it->tag == *type)
{
if(best == resources.end())
{
best = it;
continue;
}
if(it->bitrate == best->bitrate)
{
if(it->width*it->height > best->width*best->height)
best = it;
continue;
}
if(it->bitrate > maxrate)
{
if(it->bitrate < best->bitrate)
best = it;
continue;
}
if(it->bitrate > best->bitrate)
{
best = it;
continue;
}
}
}
}
if(best != resources.end())
{
item->SetMimeType(best->mime);
item->SetPath(best->path);
item->m_dwSize = best->size;
if(best->duration)
item->SetProperty("duration", StringUtils::SecondsToTimeString(best->duration));
/* handling of mimetypes fo directories are sub optimal at best */
if(best->mime == "application/rss+xml" && item->GetPath().Left(7).Equals("http://"))
item->SetPath("rss://" + item->GetPath().Mid(7));
if(item->GetPath().Left(6).Equals("rss://"))
item->m_bIsFolder = true;
else
item->m_bIsFolder = false;
}
if(!item->m_strTitle.IsEmpty())
item->SetLabel(item->m_strTitle);
if(item->HasVideoInfoTag())
{
CVideoInfoTag* vtag = item->GetVideoInfoTag();
if(item->HasProperty("duration") && vtag->m_strRuntime.IsEmpty())
vtag->m_strRuntime = item->GetProperty("duration").asString();
if(item->HasProperty("description") && vtag->m_strPlot.IsEmpty())
vtag->m_strPlot = item->GetProperty("description").asString();
if(vtag->m_strPlotOutline.IsEmpty() && !vtag->m_strPlot.IsEmpty())
{
int pos = vtag->m_strPlot.Find('\n');
if(pos >= 0)
vtag->m_strPlotOutline = vtag->m_strPlot.Left(pos);
else
vtag->m_strPlotOutline = vtag->m_strPlot;
}
//.........这里部分代码省略.........
示例12: RemoveFolder
void TempFolderHelper::RemoveFolder(CStdString sFolder)
{
if(!CGeneral::RemoveDir(sFolder.c_str()))
ThrowException(_T("Failed to delete temporary managed folder"), -1);
}
示例13: GetDirectory
bool CMultiPathDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
CLog::Log(LOGDEBUG,"CMultiPathDirectory::GetDirectory(%s)", strPath.c_str());
vector<CStdString> vecPaths;
if (!GetPaths(strPath, vecPaths))
return false;
XbmcThreads::EndTime progressTime(3000); // 3 seconds before showing progress bar
CGUIDialogProgress* dlgProgress = NULL;
unsigned int iFailures = 0;
for (unsigned int i = 0; i < vecPaths.size(); ++i)
{
// show the progress dialog if we have passed our time limit
if (progressTime.IsTimePast() && !dlgProgress)
{
dlgProgress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
if (dlgProgress)
{
dlgProgress->SetHeading(15310);
dlgProgress->SetLine(0, 15311);
dlgProgress->SetLine(1, "");
dlgProgress->SetLine(2, "");
dlgProgress->StartModal();
dlgProgress->ShowProgressBar(true);
dlgProgress->SetProgressMax((int)vecPaths.size()*2);
dlgProgress->Progress();
}
}
if (dlgProgress)
{
CURL url(vecPaths[i]);
dlgProgress->SetLine(1, url.GetWithoutUserDetails());
dlgProgress->SetProgressAdvance();
dlgProgress->Progress();
}
CFileItemList tempItems;
CLog::Log(LOGDEBUG,"Getting Directory (%s)", vecPaths[i].c_str());
if (CDirectory::GetDirectory(vecPaths[i], tempItems, m_strFileMask, m_useFileDirectories, m_allowPrompting, m_cacheDirectory, m_extFileInfo))
items.Append(tempItems);
else
{
CLog::Log(LOGERROR,"Error Getting Directory (%s)", vecPaths[i].c_str());
iFailures++;
}
if (dlgProgress)
{
dlgProgress->SetProgressAdvance();
dlgProgress->Progress();
}
}
if (dlgProgress)
dlgProgress->Close();
if (iFailures == vecPaths.size())
return false;
// merge like-named folders into a sub multipath:// style url
MergeItems(items);
return true;
}
示例14: GetCacheFile
CStdString Xcddb::GetCacheFile(unsigned int disc_id) const
{
CStdString strFileName;
strFileName.Format("%x.cddb", disc_id);
return URIUtils::AddFileToFolder(cCacheDir, strFileName);
}
示例15: docHandle
void CMusicInfoScraper::FindAlbuminfo()
{
CStdString strAlbum=m_strAlbum;
CStdString strHTML;
m_vecAlbums.erase(m_vecAlbums.begin(), m_vecAlbums.end());
CScraperParser parser;
if (!parser.Load(_P("q:\\system\\scrapers\\music\\"+m_info.strPath)))
return;
if (!m_info.settings.GetPluginRoot() || m_info.settings.GetSettings().IsEmpty())
{
m_info.settings.LoadSettingsXML(_P("q:\\system\\scrapers\\music\\"+m_info.strPath));
m_info.settings.SaveFromDefault();
}
parser.m_param[0] = strAlbum;
parser.m_param[1] = m_strArtist;
CUtil::URLEncode(parser.m_param[0]);
CUtil::URLEncode(parser.m_param[1]);
CScraperUrl scrURL;
scrURL.ParseString(parser.Parse("CreateAlbumSearchUrl"));
if (!CScraperUrl::Get(scrURL.m_url[0], strHTML, m_http) || strHTML.size() == 0)
{
CLog::Log(LOGERROR, "%s: Unable to retrieve web site",__FUNCTION__);
return;
}
parser.m_param[0] = strHTML;
CStdString strXML = parser.Parse("GetAlbumSearchResults",&m_info.settings);
if (strXML.IsEmpty())
{
CLog::Log(LOGERROR, "%s: Unable to parse web site",__FUNCTION__);
return;
}
if (strXML.Find("encoding=\"utf-8\"") < 0)
g_charsetConverter.stringCharsetToUtf8(strXML);
// ok, now parse the xml file
TiXmlDocument doc;
doc.Parse(strXML.c_str(),0,TIXML_ENCODING_UTF8);
if (!doc.RootElement())
{
CLog::Log(LOGERROR, "%s: Unable to parse xml",__FUNCTION__);
return;
}
TiXmlHandle docHandle( &doc );
TiXmlElement* album = docHandle.FirstChild( "results" ).FirstChild( "entity" ).Element();
if (!album)
return;
while (album)
{
TiXmlNode* title = album->FirstChild("title");
TiXmlElement* link = album->FirstChildElement("url");
TiXmlNode* artist = album->FirstChild("artist");
TiXmlNode* year = album->FirstChild("year");
if (title && title->FirstChild())
{
CStdString strTitle = title->FirstChild()->Value();
CStdString strArtist;
CStdString strAlbumName;
if (artist && artist->FirstChild())
{
strArtist = artist->FirstChild()->Value();
strAlbumName.Format("%s - %s",strArtist.c_str(),strTitle.c_str());
}
else
strAlbumName = strTitle;
if (year && year->FirstChild())
strAlbumName.Format("%s (%s)",strAlbumName.c_str(),year->FirstChild()->Value());
CScraperUrl url;
if (!link)
url.ParseString(scrURL.m_xml);
while (link && link->FirstChild())
{
url.ParseElement(link);
link = link->NextSiblingElement("url");
}
CMusicAlbumInfo newAlbum(strTitle, strArtist, strAlbumName, url);
m_vecAlbums.push_back(newAlbum);
}
album = album->NextSiblingElement();
}
if (m_vecAlbums.size()>0)
m_bSuccessfull=true;
return;
}