Skip to content

Commit

Permalink
Merge pull request #1687 from CastagnaIT/common_headers
Browse files Browse the repository at this point in the history
[KodiProps] add common_headers property
  • Loading branch information
CastagnaIT authored Oct 8, 2024
2 parents 4794c89 + 60b581b commit 18b9ca1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion inputstream.adaptive/addon.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
name="adaptive"
extension=""
tags="true"
listitemprops="drm|drm_legacy|license_type|license_key|license_url|license_url_append|license_data|license_flags|server_certificate|manifest_upd_params|manifest_params|manifest_headers|stream_params|stream_headers|original_audio_language|play_timeshift_buffer|pre_init_data|stream_selection_type|chooser_bandwidth_max|chooser_resolution_max|chooser_resolution_secure_max|live_delay|config|manifest_config"
listitemprops="drm|drm_legacy|license_type|license_key|license_url|license_url_append|license_data|license_flags|server_certificate|common_headers|manifest_upd_params|manifest_params|manifest_headers|stream_params|stream_headers|original_audio_language|play_timeshift_buffer|pre_init_data|stream_selection_type|chooser_bandwidth_max|chooser_resolution_max|chooser_resolution_secure_max|live_delay|config|manifest_config"
library_@PLATFORM@="@LIBRARY_FILENAME@"/>
<extension point="xbmc.addon.metadata">
<platform>@PLATFORM@</platform>
Expand Down
7 changes: 7 additions & 0 deletions src/CompKodiProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ constexpr std::string_view PROP_LICENSE_DATA = "inputstream.adaptive.license_dat
constexpr std::string_view PROP_LICENSE_FLAGS = "inputstream.adaptive.license_flags"; //! @todo: to be deprecated
constexpr std::string_view PROP_SERVER_CERT = "inputstream.adaptive.server_certificate"; //! @todo: to be deprecated

constexpr std::string_view PROP_COMMON_HEADERS = "inputstream.adaptive.common_headers";

constexpr std::string_view PROP_MANIFEST_PARAMS = "inputstream.adaptive.manifest_params";
constexpr std::string_view PROP_MANIFEST_HEADERS = "inputstream.adaptive.manifest_headers";
constexpr std::string_view PROP_MANIFEST_UPD_PARAMS = "inputstream.adaptive.manifest_upd_params";
Expand Down Expand Up @@ -143,6 +145,11 @@ void ADP::KODI_PROPS::CCompKodiProps::Init(const std::map<std::string, std::stri
"Kodi v22. Please use the appropriate properties to set the DRM configuration.");
licenseUrl += prop.second;
}
else if (prop.first == PROP_COMMON_HEADERS)
{
LogProp(prop.first, prop.second);
ParseHeaderString(m_commonHeaders, prop.second);
}
else if (prop.first == PROP_MANIFEST_UPD_PARAMS)
{
LogProp(prop.first, prop.second);
Expand Down
4 changes: 4 additions & 0 deletions src/CompKodiProps.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ class ATTR_DLL_LOCAL CCompKodiProps

void Init(const std::map<std::string, std::string>& props);

// \brief HTTP headers used for any HTTP request
const std::map<std::string, std::string>& GetCommonHeaders() const { return m_commonHeaders; }

// \brief HTTP parameters used to download manifest updates
std::string GetManifestUpdParams() const { return m_manifestUpdParams; }
// \brief HTTP parameters used to download manifests
Expand Down Expand Up @@ -175,6 +178,7 @@ class ATTR_DLL_LOCAL CCompKodiProps

std::string m_manifestUpdParams;
std::string m_manifestParams;
std::map<std::string, std::string> m_commonHeaders;
std::map<std::string, std::string> m_manifestHeaders;
std::string m_streamParams;
std::map<std::string, std::string> m_streamHeaders;
Expand Down
2 changes: 2 additions & 0 deletions src/utils/CurlUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ UTILS::CURL::CUrl::CUrl(std::string_view url)
if (!kodiProps.GetConfig().curlSSLVerifyPeer)
m_file.CURLAddOption(ADDON_CURL_OPTION_PROTOCOL, "verifypeer", "false");

AddHeaders(kodiProps.GetCommonHeaders());

// Add session cookies
// NOTE: if kodi property inputstream.adaptive.stream_headers is set with "cookie" header
// the cookies set by the property will replace these
Expand Down

0 comments on commit 18b9ca1

Please sign in to comment.