CStdString CTextureCacheJob::DecodeImageURL(const CStdString &url, unsigned int &width, unsigned int &height, std::string &additional_info) { // unwrap the URL as required CStdString image(url); additional_info.clear(); width = height = 0; if (url.compare(0, 8, "image://") == 0) { // format is image://[type@]<url_encoded_path>?options CURL thumbURL(url); if (!thumbURL.GetUserName().IsEmpty()) { if (thumbURL.GetUserName() == "music") additional_info = "music"; else return ""; // we don't re-cache special images (eg picturefolder/video embedded thumbs) } image = thumbURL.GetHostName(); CURL::Decode(image); CStdString optionString = thumbURL.GetOptions().Mid(1); optionString.TrimRight('/'); // in case XBMC adds a slash std::vector<CStdString> options; StringUtils::SplitString(optionString, "&", options); for (std::vector<CStdString>::iterator i = options.begin(); i != options.end(); i++) { CStdString option, value; int pos = i->Find('='); if (pos != -1) { option = i->Left(pos); value = i->Mid(pos + 1); } else { option = *i; value = ""; } if (option == "size" && value == "thumb") { width = height = g_advancedSettings.GetThumbSize(); } else if (option == "flipped") { additional_info = "flipped"; } } } return image; }
CStdString CTextureCacheJob::DecodeImageURL(const CStdString &url, unsigned int &width, unsigned int &height, std::string &additional_info) { // unwrap the URL as required CStdString image(url); additional_info.clear(); width = height = 0; if (StringUtils::StartsWith(url, "image://")) { // format is image://[type@]<url_encoded_path>?options CURL thumbURL(url); if (!CTextureCache::CanCacheImageURL(thumbURL)) return ""; if (thumbURL.GetUserName() == "music") additional_info = "music"; image = thumbURL.GetHostName(); CStdString optionString = thumbURL.GetOptions().substr(1); StringUtils::TrimRight(optionString, "/"); // In case XBMC adds a slash. std::vector<CStdString> options; StringUtils::SplitString(optionString, "&", options); for (std::vector<CStdString>::iterator i = options.begin(); i != options.end(); i++) { CStdString option, value; size_t pos = i->find('='); if (pos != std::string::npos) { option = i->substr(0, pos); value = i->substr(pos + 1); } else { option = *i; value = ""; } if (option == "size" && value == "thumb") { width = height = g_advancedSettings.GetThumbSize(); } else if (option == "flipped") { additional_info = "flipped"; } } } return image; }
std::string CTextureCacheJob::DecodeImageURL(const std::string &url, unsigned int &width, unsigned int &height, CPictureScalingAlgorithm::Algorithm& scalingAlgorithm, std::string &additional_info) { // unwrap the URL as required std::string image(url); additional_info.clear(); width = height = 0; scalingAlgorithm = CPictureScalingAlgorithm::NoAlgorithm; if (StringUtils::StartsWith(url, "image://")) { // format is image://[type@]<url_encoded_path>?options CURL thumbURL(url); if (!CTextureCache::CanCacheImageURL(thumbURL)) return ""; if (thumbURL.GetUserName() == "music") additional_info = "music"; image = thumbURL.GetHostName(); if (thumbURL.HasOption("flipped")) additional_info = "flipped"; if (thumbURL.GetOption("size") == "thumb") width = height = g_advancedSettings.m_imageRes; else { if (thumbURL.HasOption("width") && StringUtils::IsInteger(thumbURL.GetOption("width"))) width = strtol(thumbURL.GetOption("width").c_str(), NULL, 0); if (thumbURL.HasOption("height") && StringUtils::IsInteger(thumbURL.GetOption("height"))) height = strtol(thumbURL.GetOption("height").c_str(), NULL, 0); } if (thumbURL.HasOption("scaling_algorithm")) scalingAlgorithm = CPictureScalingAlgorithm::FromString(thumbURL.GetOption("scaling_algorithm")); } return image; }