diff options
author | Philipp Kerling <pkerling@casix.org> | 2018-03-17 13:02:08 +0100 |
---|---|---|
committer | Philipp Kerling <pkerling@casix.org> | 2018-04-05 11:39:32 +0200 |
commit | c71a87acb117ce6b14d234fad3042fc1d97bdabd (patch) | |
tree | a0f8f87e3f358983a7ec42d37bedc246bf2f1c1b | |
parent | cda38421f402732f33036163f29ab8319ffe222e (diff) |
[addons] Allow specifying separate URL for add-on art
Needed so we do not overload the mirror redirector with SSL requests
(when datadir is set to an HTTPS URL)
-rw-r--r-- | addons/repository.xbmc.org/addon.xml | 1 | ||||
-rw-r--r-- | xbmc/addons/AddonManager.cpp | 34 | ||||
-rw-r--r-- | xbmc/addons/AddonManager.h | 4 | ||||
-rw-r--r-- | xbmc/addons/Repository.cpp | 5 | ||||
-rw-r--r-- | xbmc/addons/Repository.h | 1 |
5 files changed, 29 insertions, 16 deletions
diff --git a/addons/repository.xbmc.org/addon.xml b/addons/repository.xbmc.org/addon.xml index 127b5fc0da..ca909cbb3f 100644 --- a/addons/repository.xbmc.org/addon.xml +++ b/addons/repository.xbmc.org/addon.xml @@ -10,6 +10,7 @@ <info>http://mirrors.kodi.tv/addons/leia/addons.xml.gz</info> <checksum>http://mirrors.kodi.tv/addons/leia/addons.xml.gz.md5</checksum> <datadir>https://mirrors.kodi.tv/addons/leia</datadir> + <artdir>http://mirrors.kodi.tv/addons/leia</artdir> <hashes>true</hashes> </extension> <extension point="xbmc.addon.metadata"> diff --git a/xbmc/addons/AddonManager.cpp b/xbmc/addons/AddonManager.cpp index 796a9239df..60734eb999 100644 --- a/xbmc/addons/AddonManager.cpp +++ b/xbmc/addons/AddonManager.cpp @@ -74,7 +74,7 @@ AddonPtr CAddonMgr::Factory(const cp_plugin_info_t* plugin, TYPE type) return nullptr; } -bool CAddonMgr::Factory(const cp_plugin_info_t* plugin, TYPE type, CAddonBuilder& builder, bool ignoreExtensions/* = false*/) +bool CAddonMgr::Factory(const cp_plugin_info_t* plugin, TYPE type, CAddonBuilder& builder, bool ignoreExtensions/* = false*/, std::string assetBasePath) { if (!plugin || !plugin->identifier) return false; @@ -101,11 +101,17 @@ bool CAddonMgr::Factory(const cp_plugin_info_t* plugin, TYPE type, CAddonBuilder } } - FillCpluffMetadata(plugin, builder); + if (assetBasePath.empty() && plugin->plugin_path) + { + // Default for add-on information not loaded from repository + assetBasePath = plugin->plugin_path; + } + + FillCpluffMetadata(plugin, builder, assetBasePath); return true; } -void CAddonMgr::FillCpluffMetadata(const cp_plugin_info_t* plugin, CAddonBuilder& builder) +void CAddonMgr::FillCpluffMetadata(const cp_plugin_info_t* plugin, CAddonBuilder& builder, std::string const& assetBasePath) { builder.SetId(plugin->identifier); @@ -142,15 +148,15 @@ void CAddonMgr::FillCpluffMetadata(const cp_plugin_info_t* plugin, CAddonBuilder if (!metadata) metadata = CServiceBroker::GetAddonMgr().GetExtension(plugin, "kodi.addon.metadata"); - if (plugin->plugin_path && strcmp(plugin->plugin_path, "") != 0) + if (!assetBasePath.empty()) { //backwards compatibility std::string icon = metadata && CServiceBroker::GetAddonMgr().GetExtValue(metadata->configuration, "noicon") == "true" ? "" : "icon.png"; std::string fanart = metadata && CServiceBroker::GetAddonMgr().GetExtValue(metadata->configuration, "nofanart") == "true" ? "" : "fanart.jpg"; if (!icon.empty()) - builder.SetIcon(URIUtils::AddFileToFolder(plugin->plugin_path, icon)); + builder.SetIcon(URIUtils::AddFileToFolder(assetBasePath, icon)); if (!fanart.empty()) - builder.SetArt("fanart", URIUtils::AddFileToFolder(plugin->plugin_path, fanart)); + builder.SetArt("fanart", URIUtils::AddFileToFolder(assetBasePath, fanart)); } if (metadata) @@ -172,7 +178,7 @@ void CAddonMgr::FillCpluffMetadata(const cp_plugin_info_t* plugin, CAddonBuilder builder.SetBroken(CServiceBroker::GetAddonMgr().GetExtValue(metadata->configuration, "broken")); - if (plugin->plugin_path && strcmp(plugin->plugin_path, "") != 0) + if (!assetBasePath.empty()) { auto assets = CServiceBroker::GetAddonMgr().GetExtElement(metadata->configuration, "assets"); if (assets) @@ -181,7 +187,7 @@ void CAddonMgr::FillCpluffMetadata(const cp_plugin_info_t* plugin, CAddonBuilder builder.SetArt("fanart", ""); std::string icon = CServiceBroker::GetAddonMgr().GetExtValue(assets, "icon"); if (!icon.empty()) - icon = URIUtils::AddFileToFolder(plugin->plugin_path, icon); + icon = URIUtils::AddFileToFolder(assetBasePath, icon); builder.SetIcon(icon); std::map<std::string, std::string> art; @@ -191,7 +197,7 @@ void CAddonMgr::FillCpluffMetadata(const cp_plugin_info_t* plugin, CAddonBuilder auto value = CServiceBroker::GetAddonMgr().GetExtValue(assets, type.c_str()); if (!value.empty()) { - value = URIUtils::AddFileToFolder(plugin->plugin_path, value); + value = URIUtils::AddFileToFolder(assetBasePath, value); builder.SetArt(type, value); } } @@ -203,7 +209,7 @@ void CAddonMgr::FillCpluffMetadata(const cp_plugin_info_t* plugin, CAddonBuilder for (const auto& elem : elements) { if (elem->value && strcmp(elem->value, "") != 0) - screenshots.emplace_back(URIUtils::AddFileToFolder(plugin->plugin_path, elem->value)); + screenshots.emplace_back(URIUtils::AddFileToFolder(assetBasePath, elem->value)); } } builder.SetScreenshots(std::move(screenshots)); @@ -1175,15 +1181,15 @@ bool CAddonMgr::AddonsFromRepoXML(const CRepository::DirInfo& repo, const std::s if (info) { CAddonBuilder builder; - auto basePath = URIUtils::AddFileToFolder(repo.datadir, std::string(info->identifier)); + auto basePath = URIUtils::AddFileToFolder(repo.datadir, info->identifier); info->plugin_path = static_cast<char*>(malloc(basePath.length() + 1)); strncpy(info->plugin_path, basePath.c_str(), basePath.length()); info->plugin_path[basePath.length()] = '\0'; - if (Factory(info, ADDON_UNKNOWN, builder)) + if (Factory(info, ADDON_UNKNOWN, builder, false, URIUtils::AddFileToFolder(repo.artdir, info->identifier))) { - builder.SetPath(URIUtils::AddFileToFolder(repo.datadir, StringUtils::Format("%s/%s-%s.zip", - info->identifier, info->identifier, builder.GetVersion().asString().c_str()))); + builder.SetPath(URIUtils::AddFileToFolder(repo.datadir, info->identifier, + StringUtils::Format("{}-{}.zip", info->identifier, builder.GetVersion().asString()))); auto addon = builder.Build(); if (addon) addons.push_back(std::move(addon)); diff --git a/xbmc/addons/AddonManager.h b/xbmc/addons/AddonManager.h index a581f0ee87..d092f194e3 100644 --- a/xbmc/addons/AddonManager.h +++ b/xbmc/addons/AddonManager.h @@ -287,8 +287,8 @@ namespace ADDON std::vector<DependencyInfo> GetDepsRecursive(const std::string& id); static AddonPtr Factory(const cp_plugin_info_t* plugin, TYPE type); - static bool Factory(const cp_plugin_info_t* plugin, TYPE type, CAddonBuilder& builder, bool ignoreExtensions = false); - static void FillCpluffMetadata(const cp_plugin_info_t* plugin, CAddonBuilder& builder); + static bool Factory(const cp_plugin_info_t* plugin, TYPE type, CAddonBuilder& builder, bool ignoreExtensions = false, std::string assetBasePath = ""); + static void FillCpluffMetadata(const cp_plugin_info_t* plugin, CAddonBuilder& builder, std::string const& assetBasePath); private: CAddonMgr& operator=(CAddonMgr const&) = delete; diff --git a/xbmc/addons/Repository.cpp b/xbmc/addons/Repository.cpp index 7e5a6005f8..82e1b8b688 100644 --- a/xbmc/addons/Repository.cpp +++ b/xbmc/addons/Repository.cpp @@ -119,6 +119,11 @@ CRepository::DirInfo CRepository::ParseDirConfiguration(cp_cfg_element_t* config dir.checksum = mgr.GetExtValue(configuration, "checksum"); dir.info = mgr.GetExtValue(configuration, "info"); dir.datadir = mgr.GetExtValue(configuration, "datadir"); + dir.artdir = mgr.GetExtValue(configuration, "artdir"); + if (dir.artdir.empty()) + { + dir.artdir = dir.datadir; + } dir.hashes = mgr.GetExtValue(configuration, "hashes") == "true"; dir.version = AddonVersion{mgr.GetExtValue(configuration, "@minversion")}; return dir; diff --git a/xbmc/addons/Repository.h b/xbmc/addons/Repository.h index e082c8d46a..825ecfa112 100644 --- a/xbmc/addons/Repository.h +++ b/xbmc/addons/Repository.h @@ -41,6 +41,7 @@ namespace ADDON std::string info; std::string checksum; std::string datadir; + std::string artdir; bool hashes; }; |