本文整理汇总了C++中SResources类的典型用法代码示例。如果您正苦于以下问题:C++ SResources类的具体用法?C++ SResources怎么用?C++ SResources使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SResources类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindMime
static bool FindMime(SResources resources, std::string mime)
{
for(SResources::iterator it = resources.begin(); it != resources.end(); it++)
{
if(StringUtils::StartsWithNoCase(it->mime, mime))
return true;
}
return false;
}
示例2: FindMime
static bool FindMime(SResources resources, CStdString mime)
{
for(SResources::iterator it = resources.begin(); it != resources.end(); it++)
{
if(it->mime.Left(mime.length()).Equals(mime))
return true;
}
return false;
}
示例3: ParseItemRSS
static void ParseItemRSS(CFileItem* item, SResources& resources, TiXmlElement* item_child, const CStdString& name, const CStdString& xmlns, const CStdString& path)
{
CStdString text = item_child->GetText();
if (name == "title")
{
if(text.length() > item->m_strTitle.length())
item->m_strTitle = text;
}
else if (name == "pubDate")
{
CDateTime pubDate(ParseDate(text));
item->m_dateTime = pubDate;
}
else if (name == "link")
{
SResource res;
res.tag = "rss:link";
res.path = text;
resources.push_back(res);
}
else if(name == "enclosure")
{
const char * url = item_child->Attribute("url");
const char * type = item_child->Attribute("type");
const char * len = item_child->Attribute("length");
SResource res;
res.tag = "rss:enclosure";
if(url)
res.path = url;
if(type)
res.mime = type;
if(len)
res.size = _atoi64(len);
resources.push_back(res);
}
else if(name == "description")
{
CStdString description = text;
HTML::CHTMLUtil::RemoveTags(description);
item->SetProperty("description", description);
}
else if(name == "guid")
{
if(IsPathToMedia(text))
{
SResource res;
res.tag = "rss:guid";
res.path = text;
resources.push_back(res);
}
}
}
示例4: ParseItemVoddler
static void ParseItemVoddler(CFileItem* item, SResources& resources, TiXmlElement* element, const std::string& name, const std::string& xmlns, const std::string& path)
{
CVideoInfoTag* vtag = item->GetVideoInfoTag();
std::string text = GetValue(element);
if(name == "trailer")
{
vtag->m_strTrailer = text;
SResource res;
res.tag = "voddler:trailer";
res.mime = XMLUtils::GetAttribute(element, "type");
res.path = text;
resources.push_back(res);
}
else if(name == "year")
vtag->m_iYear = atoi(text.c_str());
else if(name == "rating")
vtag->m_fRating = (float)atof(text.c_str());
else if(name == "tagline")
vtag->m_strTagLine = text;
else if(name == "posterwall")
{
const char* url = element->Attribute("url");
if(url)
item->SetArt("fanart", url);
else if(IsPathToThumbnail(text))
item->SetArt("fanart", text);
}
}
示例5: ParseItemVoddler
static void ParseItemVoddler(CFileItem* item, SResources& resources, TiXmlElement* element, const CStdString& name, const CStdString& xmlns)
{
CVideoInfoTag* vtag = item->GetVideoInfoTag();
CStdString text = element->GetText();
if(name == "trailer")
{
vtag->m_strTrailer = text;
SResource res;
res.tag = "voddler:trailer";
res.mime = element->Attribute("type");
res.path = text;
resources.push_back(res);
}
else if(name == "year")
vtag->m_iYear = atoi(text);
else if(name == "rating")
vtag->m_fRating = (float)atof(text);
else if(name == "tagline")
vtag->m_strTagLine = text;
else if(name == "posterwall")
{
const char* url = element->Attribute("url");
if(url)
item->SetProperty("fanart_image", url);
else if(IsPathToThumbnail(text))
item->SetProperty("fanart_image", text);
}
}
示例6: ParseItemSVT
static void ParseItemSVT(CFileItem* item, SResources& resources, TiXmlElement* element, const CStdString& name, const CStdString& xmlns)
{
CStdString text = element->GetText();
if (name == "xmllink")
{
SResource res;
res.tag = "svtplay:xmllink";
res.path = text;
res.mime = "application/rss+xml";
resources.push_back(res);
}
}
示例7: ParseItemSVT
static void ParseItemSVT(CFileItem* item, SResources& resources, TiXmlElement* element, const std::string& name, const std::string& xmlns, const std::string& path)
{
std::string text = GetValue(element);
if (name == "xmllink")
{
SResource res;
res.tag = "svtplay:xmllink";
res.path = text;
res.mime = "application/rss+xml";
resources.push_back(res);
}
else if (name == "broadcasts")
{
CURL url(path);
if(StringUtils::StartsWith(url.GetFileName(), "v1/"))
{
SResource res;
res.tag = "svtplay:broadcasts";
res.path = url.GetWithoutFilename() + "v1/video/list/" + text;
res.mime = "application/rss+xml";
resources.push_back(res);
}
}
}
示例8: ParseItemSVT
static void ParseItemSVT(CFileItem* item, SResources& resources, TiXmlElement* element, const CStdString& name, const CStdString& xmlns, const CStdString& path)
{
CStdString text = element->GetText();
if (name == "xmllink")
{
SResource res;
res.tag = "svtplay:xmllink";
res.path = text;
res.mime = "application/rss+xml";
resources.push_back(res);
}
else if (name == "broadcasts")
{
CURL url(path);
if(url.GetFileName().Left(3) == "v1/")
{
SResource res;
res.tag = "svtplay:broadcasts";
res.path = url.GetWithoutFilename() + "v1/video/list/" + text;
res.mime = "application/rss+xml";
resources.push_back(res);
}
}
}
示例9: ParseItem
static void ParseItem(CFileItem* item, TiXmlElement* root, const std::string& 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 };
std::string 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 = CSettings::Get().GetInt(CSettings::SETTING_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(!StringUtils::StartsWith(it->mime, 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" && StringUtils::StartsWithNoCase(item->GetPath(), "http://"))
item->SetPath("rss://" + item->GetPath().substr(7));
if(StringUtils::StartsWithNoCase(item->GetPath(), "rss://"))
item->m_bIsFolder = true;
else
item->m_bIsFolder = false;
}
if(!item->m_strTitle.empty())
item->SetLabel(item->m_strTitle);
if(item->HasVideoInfoTag())
{
CVideoInfoTag* vtag = item->GetVideoInfoTag();
if(item->HasProperty("duration") && !vtag->GetDuration())
vtag->m_duration = StringUtils::TimeStringToSeconds(item->GetProperty("duration").asString());
if(item->HasProperty("description") && vtag->m_strPlot.empty())
vtag->m_strPlot = item->GetProperty("description").asString();
if(vtag->m_strPlotOutline.empty() && !vtag->m_strPlot.empty())
{
size_t pos = vtag->m_strPlot.find('\n');
if(pos != std::string::npos)
vtag->m_strPlotOutline = vtag->m_strPlot.substr(0, pos);
else
vtag->m_strPlotOutline = vtag->m_strPlot;
}
//.........这里部分代码省略.........
示例10: ParseItemMRSS
static void ParseItemMRSS(CFileItem* item, SResources& resources, TiXmlElement* item_child, const std::string& name, const std::string& xmlns, const std::string& path)
{
CVideoInfoTag* vtag = item->GetVideoInfoTag();
std::string text = GetValue(item_child);
if(name == "content")
{
SResource res;
res.tag = "media:content";
res.mime = XMLUtils::GetAttribute(item_child, "type");
res.path = XMLUtils::GetAttribute(item_child, "url");
item_child->Attribute("width", &res.width);
item_child->Attribute("height", &res.height);
item_child->Attribute("bitrate", &res.bitrate);
item_child->Attribute("duration", &res.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->NoChildren() && IsPathToThumbnail(item_child->FirstChild()->ValueStr()))
item->SetArt("thumb", item_child->FirstChild()->ValueStr());
else
{
const char * url = item_child->Attribute("url");
if(url && IsPathToThumbnail(url))
item->SetArt("thumb", url);
}
}
else if (name == "title")
{
if(text.empty())
return;
if(text.length() > item->m_strTitle.length())
item->m_strTitle = text;
}
else if(name == "description")
{
if(text.empty())
return;
std::string description = text;
if(XMLUtils::GetAttribute(item_child, "type") == "html")
HTML::CHTMLUtil::RemoveTags(description);
item->SetProperty("description", description);
}
else if(name == "category")
{
if(text.empty())
return;
std::string scheme = XMLUtils::GetAttribute(item_child, "scheme");
/* okey this is silly, boxee what did you think?? */
if (scheme == "urn:boxee:genre")
vtag->m_genre.push_back(text);
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")
{
std::string scheme = XMLUtils::GetAttribute(item_child, "scheme");
if(scheme == "urn:user")
vtag->m_fRating = (float)atof(text.c_str());
else
vtag->m_strMPAARating = text;
}
else if(name == "credit")
{
std::string role = XMLUtils::GetAttribute(item_child, "role");
if (role == "director")
vtag->m_director.push_back(text);
else if(role == "author"
|| role == "writer")
vtag->m_writingCredits.push_back(text);
//.........这里部分代码省略.........
示例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->GetDuration())
vtag->m_duration = StringUtils::TimeStringToSeconds(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: ParseItem
static void ParseItem(CFileItem* item, TiXmlElement* root)
{
SResources resources;
ParseItem(item, resources, root);
const char* prio[] = { "media:content", "voddler:trailer", "rss:enclosure", "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/";
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;
else if(it->width && it->height || best->width && best->height)
{
if(it->width*it->height > best->width*best->height)
best = it;
}
else if(it->bitrate > best->bitrate)
best = it;
}
}
}
if(best != resources.end())
{
item->SetMimeType(best->mime);
item->m_strPath = 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->m_strPath.Left(7).Equals("http://"))
item->m_strPath.replace(0, 7, "rss://");
if(item->m_strPath.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();
// clean up ", " added during build
vtag->m_strDirector.Delete(0, 2);
vtag->m_strWritingCredits.Delete(0, 2);
if(item->HasProperty("duration") && vtag->m_strRuntime.IsEmpty())
vtag->m_strRuntime = item->GetProperty("duration");
if(item->HasProperty("description") && vtag->m_strPlot.IsEmpty())
vtag->m_strPlot = item->GetProperty("description");
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;
}
if(!vtag->m_strRuntime.IsEmpty())
item->SetLabel2(vtag->m_strRuntime);
}
}
示例13: ParseItemMRSS
static void ParseItemMRSS(CFileItem* item, SResources& resources, TiXmlElement* item_child, const CStdString& name, const CStdString& xmlns)
{
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);
}
else if(name == "group")
{
ParseItem(item, resources, item_child);
}
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_strGenre = text;
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_strGenre = text;
}
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")
//.........这里部分代码省略.........