Skip to content

Commit

Permalink
Merge pull request #334 from Be4stElectrjc/Matrix
Browse files Browse the repository at this point in the history
User-Agent choice - Matrix
  • Loading branch information
phunkyfish authored Feb 26, 2020
2 parents e57a009 + 214bf15 commit 7e80cbc
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Advanced settings such as multicast relays.
* **Relay port**: The port of the multicast relay (`udpxy`) on the local network.
* **Use FFMpeg http reconnect options if possible**: Note this can only apply to http/https streams that are processed by libavformat (e.g. M3u8/HLS). Using libavformat can be specified in an M3U file by setting the property `inputstreamclass` as `inputstream.ffmpeg`. I.e. adding the line: `#KODIPROP:inputstreamclass=inputstream.ffmpeg`. If this opton is not enabled it can still be enabled per stream/channel by adding a kodi property, i.e.: `#KODIPROP:http-reconnect=true`.
* **Use inputstream.adaptive for m3u8 (HLS) streams**: Use inputstream.adaptive instead of ffmpeg's libavformat for m3u8 (HLS) streams.
* **User-Agent**: Select which User-Agent to use if there is not one supplied as a property or as part of the channel stream URL.

## Appendix

Expand Down Expand Up @@ -387,4 +388,4 @@ or
**Copy the addon to the Kodi addon directory on Mac**

1. `rm -rf "$HOME/Library/Application Support/Kodi/addons/pvr.iptvsimple"`
2. `cp -rf $HOME/xbmc-addon/addons/pvr.iptvsimple "$HOME/Library/Application Support/Kodi/addons"`
2. `cp -rf $HOME/xbmc-addon/addons/pvr.iptvsimple "$HOME/Library/Application Support/Kodi/addons"`
6 changes: 5 additions & 1 deletion pvr.iptvsimple/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.iptvsimple"
version="4.9.0"
version="4.10.0"
name="PVR IPTV Simple Client"
provider-name="nightik">
<requires>@ADDON_DEPENDS@</requires>
Expand Down Expand Up @@ -159,6 +159,10 @@
<disclaimer lang="zh_TW">這是測試中的軟體!原創作者無法針對以下情況負責:包括播放失敗,不正確的電子節目表,多餘的時數,或任何不可預期的不良影響。</disclaimer>
<platform>@PLATFORM@</platform>
<news>

v4.10.0
- Added: User-Agent support from advanced addon setting

v4.9.0
- Added: Catchup support (a.k.a Archive)
- Added: Missing check for HLS stream type
Expand Down
3 changes: 3 additions & 0 deletions pvr.iptvsimple/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v4.10.0
- Added: User-Agent support from advanced addon setting

v4.9.0
- Added: Catchup support (a.k.a Archive)
- Added: Missing check for HLS stream type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,12 @@ msgctxt "#30067"
msgid "Use FFMpeg http reconnect options if possible"
msgstr ""

#empty strings from id 30068 to 30099
#. label: Advanced - userAgent
msgctxt "#30068"
msgid "User-Agent"
msgstr ""

#empty strings from id 30069 to 30099

#. label-category: catchup
#. label-group: Catchup - Catchup
Expand Down Expand Up @@ -501,7 +506,12 @@ msgctxt "#30685"
msgid "Note this can only apply to http/https streams that are processed by libavformat (e.g. M3u8/HLS). Using libavformat can be specified in an M3U file by setting the property `inputstreamclass` as `inputstream.ffmpeg` for kodi's internal implementation or `inputstream.ffmpegdirect` for addon version. I.e. adding the line: `#KODIPROP:inputstreamclass=inputstream.ffmpeg`. If this option is not enabled it can still be enabled per stream/channel by adding a kodi property, i.e.: `#KODIPROP:http-reconnect=true`."
msgstr ""

#empty strings from id 30686 to 30699
#. help: Advanced - userAgent
msgctxt "#30686"
msgid "Use this User-Agent if there is not one supplied as a property or as part of the channel stream URL."
msgstr ""

#empty strings from id 30687 to 30699

#. help info - Catchup

Expand Down Expand Up @@ -548,4 +558,4 @@ msgstr ""
#. help: Catchup - catchupOnlyOnFinishedProgrammes
msgctxt "#30708"
msgid "When selected from the EPG the current live programme cannot be watched as catchup until finished."
msgstr ""
msgstr ""
7 changes: 7 additions & 0 deletions pvr.iptvsimple/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,13 @@
<default>false</default>
<control type="toggle" />
</setting>
<setting id="userAgent" type="string" label="30068" help="30686">
<level>3</level>
<constraints>
<allowempty>true</allowempty>
</constraints>
<control type="edit" format="string" />
</setting>
</group>
</category>

Expand Down
6 changes: 5 additions & 1 deletion src/iptvsimple/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void Settings::ReadFromAddon(const std::string& userPath, const std::string clie
if (XBMC->GetSetting("m3uUrl", &buffer))
m_m3uUrl = buffer;
if (!XBMC->GetSetting("m3uCache", &m_cacheM3U))
m_cacheM3U = true;
m_cacheM3U = true;
if (!XBMC->GetSetting("startNum", &m_startChannelNumber))
m_startChannelNumber = 1;
if (!XBMC->GetSetting("numberByOrder", &m_numberChannelsByM3uOrderOnly))
Expand Down Expand Up @@ -122,6 +122,8 @@ void Settings::ReadFromAddon(const std::string& userPath, const std::string clie
m_useFFmpegReconnect = false;
if (!XBMC->GetSetting("useInputstreamAdaptiveforHls", &m_useInputstreamAdaptiveforHls))
m_useInputstreamAdaptiveforHls = false;
if (XBMC->GetSetting("userAgent", &buffer))
m_userAgent = buffer;
}

ADDON_STATUS Settings::SetValue(const std::string& settingName, const void* settingValue)
Expand Down Expand Up @@ -219,6 +221,8 @@ ADDON_STATUS Settings::SetValue(const std::string& settingName, const void* sett
return SetSetting<bool, ADDON_STATUS>(settingName, settingValue, m_useFFmpegReconnect, ADDON_STATUS_OK, ADDON_STATUS_OK);
if (settingName == "useInputstreamAdaptiveforHls")
return SetSetting<bool, ADDON_STATUS>(settingName, settingValue, m_useInputstreamAdaptiveforHls, ADDON_STATUS_OK, ADDON_STATUS_OK);
if (settingName == "userAgent")
return SetStringSetting<ADDON_STATUS>(settingName, settingValue, m_userAgent, ADDON_STATUS_OK, ADDON_STATUS_OK);

return ADDON_STATUS_OK;
}
2 changes: 2 additions & 0 deletions src/iptvsimple/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ namespace iptvsimple
int GetUdpxyPort() const { return m_udpxyPort; }
bool UseFFmpegReconnect() const { return m_useFFmpegReconnect; }
bool UseInputstreamAdaptiveforHls() const { return m_useInputstreamAdaptiveforHls; }
const std::string& GetUserAgent() const { return m_userAgent; }

const std::string& GetTvgUrl() const { return m_tvgUrl; }
void SetTvgUrl(const std::string& tvgUrl) { m_tvgUrl = tvgUrl; }
Expand Down Expand Up @@ -216,6 +217,7 @@ namespace iptvsimple
int m_udpxyPort = DEFAULT_UDPXY_MULTICAST_RELAY_PORT;
bool m_useFFmpegReconnect = true;
bool m_useInputstreamAdaptiveforHls = false;
std::string m_userAgent;

std::string m_tvgUrl;
};
Expand Down
3 changes: 3 additions & 0 deletions src/iptvsimple/data/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ void Channel::SetStreamURL(const std::string& url)

if (StringUtils::StartsWith(url, HTTP_PREFIX) || StringUtils::StartsWith(url, HTTPS_PREFIX))
{
if (!Settings::GetInstance().GetUserAgent().empty() && GetProperty("http-user-agent").empty())
AddProperty("http-user-agent", Settings::GetInstance().GetUserAgent());

TryToAddPropertyAsHeader("http-user-agent", "user-agent");
TryToAddPropertyAsHeader("http-referrer", "referer"); // spelling differences are correct
}
Expand Down

0 comments on commit 7e80cbc

Please sign in to comment.