bool CInputStreamAddon::Supports(BinaryAddonBasePtr& addonBase, const CFileItem &fileitem) { // check if a specific inputstream addon is requested CVariant addon = fileitem.GetProperty("inputstreamaddon"); if (!addon.isNull()) return (addon.asString() == addonBase->ID()); // check protocols std::string protocol = fileitem.GetURL().GetProtocol(); if (!protocol.empty()) { std::string protocols = addonBase->Type(ADDON_INPUTSTREAM)->GetValue("@protocols").asString(); if (!protocols.empty()) { std::vector<std::string> protocolsList = StringUtils::Tokenize(protocols, "|"); for (auto& value : protocolsList) { StringUtils::Trim(value); if (value == protocol) return true; } } } std::string filetype = fileitem.GetURL().GetFileType(); if (!filetype.empty()) { std::string extensions = addonBase->Type(ADDON_INPUTSTREAM)->GetValue("@extension").asString(); if (!extensions.empty()) { std::vector<std::string> extensionsList = StringUtils::Tokenize(extensions, "|"); for (auto& value : extensionsList) { StringUtils::Trim(value); if (value == filetype) return true; } } } return false; }
void CGUIDialogSubtitles::Download(const CFileItem &subtitle) { UpdateStatus(DOWNLOADING); // subtitle URL should be of the form plugin://<addonid>/?param=foo¶m=bar // we just append (if not already present) the action=download parameter. CURL url(subtitle.GetURL()); if (url.GetOption("action").empty()) url.SetOption("action", "download"); AddJob(new CSubtitlesJob(url, subtitle.GetLabel())); }
bool CInputStream::Supports(const CFileItem &fileitem) { { CSingleLock lock(m_parentSection); auto it = m_configMap.find(ID()); if (it == m_configMap.end()) return false; if (!it->second.m_ready) return false; } // check if a specific inputstream addon is requested CVariant addon = fileitem.GetProperty("inputstreamaddon"); if (!addon.isNull()) { if (addon.asString() != ID()) return false; else return true; } // check protocols std::string protocol = fileitem.GetURL().GetProtocol(); if (!protocol.empty()) { if (std::find(m_protocolsList.begin(), m_protocolsList.end(), protocol) != m_protocolsList.end()) return true; } // check paths CSingleLock lock(m_parentSection); auto it = m_configMap.find(ID()); if (it == m_configMap.end()) return false; bool match = false; for (auto &path : it->second.m_pathList) { if (path.empty()) continue; CRegExp r(true, CRegExp::asciiOnly, path.c_str()); if (r.RegFind(fileitem.GetPath().c_str()) == 0 && r.GetFindLen() > 5) { match = true; break; } } return match; }