本文整理汇总了C++中CFileCurl::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileCurl::Get方法的具体用法?C++ CFileCurl::Get怎么用?C++ CFileCurl::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileCurl
的用法示例。
在下文中一共展示了CFileCurl::Get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RadioHandShake
bool CLastFmManager::RadioHandShake()
{
if (!m_RadioSession.IsEmpty()) return true; //already signed in
if (dlgProgress)
{
dlgProgress->SetLine(2, 15251);//Connecting to Last.fm..
dlgProgress->Progress();
}
m_RadioSession = "";
CFileCurl http;
CStdString html;
CStdString strPassword = g_guiSettings.GetString("scrobbler.lastfmpass");
CStdString strUserName = g_guiSettings.GetString("scrobbler.lastfmusername");
if (strUserName.IsEmpty() || strPassword.IsEmpty())
{
CLog::Log(LOGERROR, "Last.fm stream selected but no username or password set.");
return false;
}
CStdString passwordmd5(strPassword);
passwordmd5.ToLower();
CStdString url;
CURL::Encode(strUserName);
url.Format("http://ws.audioscrobbler.com/radio/handshake.php?version=%s&platform=%s&username=%s&passwordmd5=%s&debug=%i&partner=%s", XBMC_LASTFM_VERSION, XBMC_LASTFM_ID, strUserName, passwordmd5, 0, "");
if (!http.Get(url, html))
{
CLog::Log(LOGERROR, "Connect to Last.fm radio failed.");
return false;
}
//CLog::Log(LOGDEBUG, "Handshake: %s", html.c_str());
Parameter("session", html, m_RadioSession);
Parameter("base_url", html, m_RadioBaseUrl);
Parameter("base_path", html, m_RadioBasePath);
Parameter("subscriber", html, m_RadioSubscriber);
Parameter("banned", html, m_RadioBanned);
if (m_RadioSession.CompareNoCase("failed") == 0)
{
CLog::Log(LOGERROR, "Last.fm return failed response, possible bad username or password?");
m_RadioSession = "";
}
return !m_RadioSession.IsEmpty();
}
示例2: open
bool MythXml::open(CStdString hostname, int port, CStdString user, CStdString pass, int pin, long timeout) {
hostname_ = hostname;
port_ = port;
timeout_ = timeout;
pin_ = pin;
CStdString strUrl;
strUrl.Format("http://%s:%i/Myth/GetConnectionInfo?Pin=%i", hostname.c_str(), port, pin);
CStdString strXML;
CFileCurl http;
http.SetTimeout(timeout);
if(!http.Get(strUrl, strXML)) {
CLog::Log(LOGDEBUG, "MythXml - Could not open connection to mythtv backend.");
http.Cancel();
return false;
}
http.Cancel();
return true;
}
示例3: RequestRadioTracks
bool CLastFmManager::RequestRadioTracks()
{
unsigned int start = CTimeUtils::GetTimeMS();
CStdString url;
CStdString html;
url.Format("http://" + m_RadioBaseUrl + m_RadioBasePath + "/xspf.php?sk=%s&discovery=0&desktop=", m_RadioSession);
{
CFileCurl http;
if (!http.Get(url, html))
{
m_RadioSession.empty();
CLog::Log(LOGERROR, "LastFmManager: Connect to Last.fm to request tracks failed.");
return false;
}
}
//CLog::Log(LOGDEBUG, "RequestRadioTracks: %s", html.c_str());
//parse playlist
TiXmlDocument xmlDoc;
xmlDoc.Parse(html);
if (xmlDoc.Error())
{
m_RadioSession.empty();
CLog::Log(LOGERROR, "LastFmManager: Unable to parse tracklist Error: %s", xmlDoc.ErrorDesc());
return false;
}
TiXmlElement* pRootElement = xmlDoc.RootElement();
if (!pRootElement )
{
CLog::Log(LOGWARNING, "LastFmManager: No more tracks received");
m_RadioSession.empty();
return false;
}
TiXmlElement* pBodyElement = pRootElement->FirstChildElement("trackList");
if (!pBodyElement )
{
CLog::Log(LOGWARNING, "LastFmManager: No more tracks received, no tracklist");
m_RadioSession.empty();
return false;
}
TiXmlElement* pTrackElement = pBodyElement->FirstChildElement("track");
if (!pTrackElement)
{
CLog::Log(LOGWARNING, "LastFmManager: No more tracks received, empty tracklist");
m_RadioSession.empty();
return false;
}
while (pTrackElement)
{
CFileItemPtr newItem(new CFileItem);
TiXmlElement* pElement = pTrackElement->FirstChildElement("location");
if (pElement)
{
TiXmlNode* child = pElement->FirstChild();
if (child)
{
CStdString url = child->Value();
url.Replace("http:", "lastfm:");
newItem->m_strPath = url;
}
}
pElement = pTrackElement->FirstChildElement("title");
if (pElement)
{
TiXmlNode* child = pElement->FirstChild();
if (child)
{
newItem->SetLabel(child->Value());
newItem->GetMusicInfoTag()->SetTitle(child->Value());
}
}
pElement = pTrackElement->FirstChildElement("creator");
if (pElement)
{
TiXmlNode* child = pElement->FirstChild();
if (child)
{
newItem->GetMusicInfoTag()->SetArtist(child->Value());
}
}
pElement = pTrackElement->FirstChildElement("album");
if (pElement)
{
TiXmlNode* child = pElement->FirstChild();
if (child)
{
newItem->GetMusicInfoTag()->SetAlbum(child->Value());
}
}
pElement = pTrackElement->FirstChildElement("duration");
if (pElement)
{
TiXmlNode* child = pElement->FirstChild();
//.........这里部分代码省略.........
示例4: ChangeStation
bool CLastFmManager::ChangeStation(const CURL& stationUrl)
{
unsigned int start = CTimeUtils::GetTimeMS();
InitProgressDialog(stationUrl.Get());
StopRadio(false);
if (!RadioHandShake())
{
CloseProgressDialog();
CGUIDialogOK::ShowAndGetInput(15200, 15206, 0, 0);
return false;
}
UpdateProgressDialog(15252); // Selecting station...
CFileCurl http;
CStdString url;
CStdString html;
url.Format("http://" + m_RadioBaseUrl + m_RadioBasePath + "/adjust.php?session=%s&url=%s&debug=%i", m_RadioSession, stationUrl.Get().c_str(), 0);
if (!http.Get(url, html))
{
CLog::Log(LOGERROR, "Connect to Last.fm to change station failed.");
CloseProgressDialog();
return false;
}
//CLog::Log(LOGDEBUG, "ChangeStation: %s", html.c_str());
CStdString strErrorCode;
Parameter("error", html, strErrorCode);
if (strErrorCode != "")
{
CLog::Log(LOGERROR, "Last.fm returned an error (%s) response for change station request.", strErrorCode.c_str());
CloseProgressDialog();
return false;
}
UpdateProgressDialog(261); //Waiting for start....
g_playlistPlayer.ClearPlaylist(PLAYLIST_MUSIC);
RequestRadioTracks();
CacheTrackThumb(XBMC_LASTFM_MINTRACKS);
AddToPlaylist(XBMC_LASTFM_MINTRACKS);
Create(); //start thread
m_hWorkerEvent.Set(); //kickstart the thread
CSingleLock lock(m_lockPlaylist);
CPlayList& playlist = g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC);
if ((int)playlist.size())
{
g_application.m_strPlayListFile = stationUrl.Get(); //needed to highlight the playing item
g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_MUSIC);
g_playlistPlayer.Play(0);
CLog::Log(LOGDEBUG, "%s: Done (time: %i ms)", __FUNCTION__, (int)(CTimeUtils::GetTimeMS() - start));
CloseProgressDialog();
return true;
}
CloseProgressDialog();
return false;
}
示例5: Process
void CRssReader::Process()
{
while (GetQueueSize())
{
CSingleLock lock(*this);
int iFeed = m_vecQueue.front();
m_vecQueue.erase(m_vecQueue.begin());
m_strFeed[iFeed] = "";
m_strColors[iFeed] = "";
CFileCurl http;
http.SetUserAgent(g_settings.m_userAgent);
http.SetTimeout(2);
CStdString strXML;
CStdString strUrl = m_vecUrls[iFeed];
lock.Leave();
int nRetries = 3;
CURL url(strUrl);
// we wait for the network to come up
if ((url.GetProtocol() == "http" || url.GetProtocol() == "https") && !g_application.getNetwork().IsAvailable(true))
strXML = "<rss><item><title>"+g_localizeStrings.Get(15301)+"</title></item></rss>";
else
{
unsigned int starttime = CTimeUtils::GetTimeMS();
while ( (!m_bStop) && (nRetries > 0) )
{
unsigned int currenttimer = CTimeUtils::GetTimeMS() - starttime;
if (currenttimer > 15000)
{
CLog::Log(LOGERROR,"Timeout whilst retrieving %s", strUrl.c_str());
http.Cancel();
break;
}
nRetries--;
if (url.GetProtocol() != "http" && url.GetProtocol() != "https")
{
CFile file;
if (file.Open(strUrl))
{
char *yo = new char[(int)file.GetLength()+1];
file.Read(yo,file.GetLength());
yo[file.GetLength()] = '\0';
strXML = yo;
delete[] yo;
break;
}
}
else
if (http.Get(strUrl, strXML))
{
CLog::Log(LOGDEBUG, "Got rss feed: %s", strUrl.c_str());
break;
}
}
http.Cancel();
}
if ((!strXML.IsEmpty()) && m_pObserver)
{
// erase any <content:encoded> tags (also unsupported by tinyxml)
int iStart = strXML.Find("<content:encoded>");
int iEnd = 0;
while (iStart > 0)
{
// get <content:encoded> end position
iEnd = strXML.Find("</content:encoded>", iStart) + 18;
// erase the section
strXML = strXML.erase(iStart, iEnd - iStart);
iStart = strXML.Find("<content:encoded>");
}
if (Parse((LPSTR)strXML.c_str(),iFeed))
{
CLog::Log(LOGDEBUG, "Parsed rss feed: %s", strUrl.c_str());
}
}
}
UpdateObserver();
}