From 4d09cad8181ad61385c7e67b735683ce732b7cf6 Mon Sep 17 00:00:00 2001 From: ksooo <3226626+ksooo@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:16:15 +0200 Subject: [PATCH] Fix playback: Add custom user agent to inputstream.adaptive properties. --- pvr.plutotv/addon.xml.in | 2 +- pvr.plutotv/changelog.txt | 3 +++ src/PlutotvData.cpp | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/pvr.plutotv/addon.xml.in b/pvr.plutotv/addon.xml.in index 8bfd347..4b1ffb6 100644 --- a/pvr.plutotv/addon.xml.in +++ b/pvr.plutotv/addon.xml.in @@ -1,7 +1,7 @@ @ADDON_DEPENDS@ diff --git a/pvr.plutotv/changelog.txt b/pvr.plutotv/changelog.txt index f7ae94d..8cfe6f8 100644 --- a/pvr.plutotv/changelog.txt +++ b/pvr.plutotv/changelog.txt @@ -1,3 +1,6 @@ +v22.1.1 +- Add custom user agent to inputstream.adaptive properties. + v22.1.0 - PVR Add-on API v9.0.0 diff --git a/src/PlutotvData.cpp b/src/PlutotvData.cpp index e3a3ceb..53210c4 100644 --- a/src/PlutotvData.cpp +++ b/src/PlutotvData.cpp @@ -12,7 +12,11 @@ #include "Utils.h" #include "kodi/tools/StringUtils.h" +#include #include +#include +#include +#include namespace { @@ -66,6 +70,32 @@ PVR_ERROR PlutotvData::GetBackendVersion(std::string& version) return PVR_ERROR_NO_ERROR; } +namespace +{ +// http://stackoverflow.com/a/17708801 +const std::string UrlEncode(const std::string& value) +{ + std::ostringstream escaped; + escaped.fill('0'); + escaped << std::hex; + + for (auto c : value) + { + // Keep alphanumeric and other accepted characters intact + if (std::isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') + { + escaped << c; + continue; + } + + // Any other characters are percent-encoded + escaped << '%' << std::setw(2) << int(static_cast(c)); + } + + return escaped.str(); +} +} // unnamed namespace + void PlutotvData::SetStreamProperties(std::vector& properties, const std::string& url, bool realtime) @@ -77,6 +107,13 @@ void PlutotvData::SetStreamProperties(std::vector