Skip to content

Commit

Permalink
Allow HTTP PROXY to be set via KODIPROP's
Browse files Browse the repository at this point in the history
  • Loading branch information
phunkyfish committed Oct 21, 2024
1 parent b131c99 commit 4f9d60c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ http://127.0.0.1:3002/mystream.m3u8
- `timezone_shift`: The value in seconds to shift the catchup times by for your timezone. Valid values range from -43200 to 50400 (from -12 hours to +14 hours).
- `default_programme_duration`: If the programme duration is unknown use this default value in seconds instead. If this value is not provided 4 hours (14,400 secs) will be used will be used.
- `programme_catchup_id`: For providers that require a programme specifc id the following value can be used in the url format string.
- `http_proxy_host`: Host to use for http proxy. Note that the general add-on setting will be ignored if this used. All proxy properties must be set.
- `http_proxy_port`: Port to use for http proxy. Note that the general add-on setting will be ignored if this used. All proxy properties must be set.
- `http_proxy_user`: User to use for http proxy. Note that the general add-on setting will be ignored if this used. All proxy properties must be set.
- `http_proxy_password`: Password to use for http proxy. Note that the general add-on setting will be ignored if this used. All proxy properties must be set.

**Notes:**
- Setting `playback_as_live` to `true` only makes sense when the catchup start and end times are set to the size of the catchup windows (e.g. 3 days). If the catchup start and end times are set to the programme times then `playback_as_live` will have little effect.
Expand Down
2 changes: 1 addition & 1 deletion inputstream.ffmpegdirect/addon.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
name="ffmpegdirect"
extension=""
tags="true"
listitemprops="program_number|stream_mode|open_mode|manifest_type|default_url|is_realtime_stream|playback_as_live|programme_start_time|programme_end_time|catchup_url_format_string|catchup_url_near_live_format_string|catchup_buffer_start_time|catchup_buffer_end_time|catchup_buffer_offset|catchup_terminates|catchup_granularity|timezone_shift|default_programme_duration|programme_catchup_id"
listitemprops="program_number|stream_mode|open_mode|manifest_type|default_url|is_realtime_stream|playback_as_live|programme_start_time|programme_end_time|catchup_url_format_string|catchup_url_near_live_format_string|catchup_buffer_start_time|catchup_buffer_end_time|catchup_buffer_offset|catchup_terminates|catchup_granularity|timezone_shift|default_programme_duration|programme_catchup_id|http_proxy_host|http_proxy_port|http_proxy_user|http_proxy_password"
library_@PLATFORM@="@LIBRARY_FILENAME@" />
<extension point="xbmc.service" library="resources/lib/runner.py"/>
<extension point="xbmc.addon.metadata">
Expand Down
25 changes: 22 additions & 3 deletions src/StreamManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ bool InputStreamFFmpegDirect::Open(const kodi::addon::InputstreamProperty& props
{
Log(LOGLEVEL_INFO, "inputstream.ffmpegdirect: OpenStream() - Num Props: %d", props.GetPropertiesAmount());

HttpProxy httpProxy;

for (const auto& prop : props.GetProperties())
{
if (StringUtils::StartsWith(prop.second, "http://") || StringUtils::StartsWith(prop.second, "https://"))
Expand Down Expand Up @@ -154,6 +156,25 @@ bool InputStreamFFmpegDirect::Open(const kodi::addon::InputstreamProperty& props
{
m_properties.m_programmeCatchupId = prop.second;
}
else if (HTTP_PROXY_HOST == prop.first)
{
httpProxy.SetProxyHost(prop.second);
kodi::Log(ADDON_LOG_INFO, "HttpProxy host set vis KODIPROP: '%s'", httpProxy.GetProxyHost().c_str());
}
else if (HTTP_PROXY_PORT == prop.first)
{
httpProxy.SetProxyPort(std::atoi(prop.second.c_str()));
kodi::Log(ADDON_LOG_INFO, "HttpProxy port set as KODIPROP: %d", static_cast<int>(httpProxy.GetProxyPort()));
}
else if (HTTP_PROXY_USER == prop.first)
{
httpProxy.SetProxyUser(prop.second);
kodi::Log(ADDON_LOG_INFO, "HttpProxy user set as KODIPROP: '%s'", httpProxy.GetProxyUser().c_str());
}
else if (HTTP_PROXY_PASSWORD == prop.first)
{
httpProxy.SetProxyPassword(prop.second);
}
}

m_streamUrl = props.GetURL();
Expand Down Expand Up @@ -190,10 +211,8 @@ bool InputStreamFFmpegDirect::Open(const kodi::addon::InputstreamProperty& props
m_properties.m_openMode = OpenMode::CURL;
}

HttpProxy httpProxy;

bool useHttpProxy = kodi::addon::GetSettingBoolean("useHttpProxy");
if (useHttpProxy)
if (useHttpProxy && !httpProxy.GetProxyHost().empty()) // If a proxy host as not been set as a KODIPROP
{
httpProxy.SetProxyHost(kodi::addon::GetSettingString("httpProxyHost"));
kodi::Log(ADDON_LOG_INFO, "HttpProxy host set: '%s'", httpProxy.GetProxyHost().c_str());
Expand Down
4 changes: 4 additions & 0 deletions src/StreamManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ static const std::string CATCHUP_GRANULARITY = "inputstream.ffmpegdirect.catchup
static const std::string TIMEZONE_SHIFT = "inputstream.ffmpegdirect.timezone_shift";
static const std::string DEFAULT_PROGRAMME_DURATION = "inputstream.ffmpegdirect.default_programme_duration";
static const std::string PROGRAMME_CATCHUP_ID = "inputstream.ffmpegdirect.programme_catchup_id";
static const std::string HTTP_PROXY_HOST = "inputstream.ffmpegdirect.http_proxy_host";
static const std::string HTTP_PROXY_PORT = "inputstream.ffmpegdirect.http_proxy_port";
static const std::string HTTP_PROXY_USER = "inputstream.ffmpegdirect.http_proxy_user";
static const std::string HTTP_PROXY_PASSWORD = "inputstream.ffmpegdirect.http_proxy_password";

class ATTR_DLL_LOCAL InputStreamFFmpegDirect
: public kodi::addon::CInstanceInputStream, ffmpegdirect::IManageDemuxPacket
Expand Down

0 comments on commit 4f9d60c

Please sign in to comment.