From 1bef6a5bea7ae9e3acb1f33d25faeda43f81b5e6 Mon Sep 17 00:00:00 2001 From: phunkyfish Date: Tue, 2 Mar 2021 18:13:11 +0000 Subject: [PATCH 1/3] Support sub channel numbers --- src/iptvsimple/PlaylistLoader.cpp | 13 ++++++++++++- src/iptvsimple/data/Channel.cpp | 3 +++ src/iptvsimple/data/Channel.h | 12 ++++++++---- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/iptvsimple/PlaylistLoader.cpp b/src/iptvsimple/PlaylistLoader.cpp index e098110b8..cdc44b2f6 100644 --- a/src/iptvsimple/PlaylistLoader.cpp +++ b/src/iptvsimple/PlaylistLoader.cpp @@ -228,7 +228,18 @@ std::string PlaylistLoader::ParseIntoChannel(const std::string& line, Channel& c } if (!strChnlNo.empty() && !Settings::GetInstance().NumberChannelsByM3uOrderOnly()) - channel.SetChannelNumber(std::atoi(strChnlNo.c_str())); + { + size_t found = strChnlNo.find('.'); + if (found != std::string::npos) + { + channel.SetChannelNumber(std::atoi(strChnlNo.substr(0, found).c_str())); + channel.SetSubChannelNumber(std::atoi(strChnlNo.substr(found + 1).c_str())); + } + else + { + channel.SetChannelNumber(std::atoi(strChnlNo.c_str())); + } + } double tvgShiftDecimal = std::atof(strTvgShift.c_str()); diff --git a/src/iptvsimple/data/Channel.cpp b/src/iptvsimple/data/Channel.cpp index 701ba75aa..f977d0d3a 100644 --- a/src/iptvsimple/data/Channel.cpp +++ b/src/iptvsimple/data/Channel.cpp @@ -53,6 +53,7 @@ void Channel::UpdateTo(Channel& left) const left.m_uniqueId = m_uniqueId; left.m_radio = m_radio; left.m_channelNumber = m_channelNumber; + left.m_subChannelNumber = m_subChannelNumber; left.m_encryptionSystem = m_encryptionSystem; left.m_tvgShift = m_tvgShift; left.m_channelName = m_channelName; @@ -78,6 +79,7 @@ void Channel::UpdateTo(kodi::addon::PVRChannel& left) const left.SetUniqueId(m_uniqueId); left.SetIsRadio(m_radio); left.SetChannelNumber(m_channelNumber); + left.SetSubChannelNumber(m_subChannelNumber); left.SetChannelName(m_channelName); left.SetEncryptionSystem(m_encryptionSystem); left.SetIconPath(m_iconPath); @@ -90,6 +92,7 @@ void Channel::Reset() m_uniqueId = 0; m_radio = false; m_channelNumber = 0; + m_subChannelNumber = 0; m_encryptionSystem = 0; m_tvgShift = 0; m_channelName.clear(); diff --git a/src/iptvsimple/data/Channel.h b/src/iptvsimple/data/Channel.h index 62d1a1d69..9d7e9702b 100644 --- a/src/iptvsimple/data/Channel.h +++ b/src/iptvsimple/data/Channel.h @@ -41,10 +41,10 @@ namespace iptvsimple Channel() = default; Channel(const Channel &c) : m_radio(c.IsRadio()), m_uniqueId(c.GetUniqueId()), - m_channelNumber(c.GetChannelNumber()), m_encryptionSystem(c.GetEncryptionSystem()), - m_tvgShift(c.GetTvgShift()), m_channelName(c.GetChannelName()), m_iconPath(c.GetIconPath()), - m_streamURL(c.GetStreamURL()), m_hasCatchup(c.HasCatchup()), m_catchupMode(c.GetCatchupMode()), - m_catchupDays(c.GetCatchupDays()), m_catchupSource(c.GetCatchupSource()), + m_channelNumber(c.GetChannelNumber()), m_subChannelNumber(c.GetSubChannelNumber()), + m_encryptionSystem(c.GetEncryptionSystem()), m_tvgShift(c.GetTvgShift()), m_channelName(c.GetChannelName()), + m_iconPath(c.GetIconPath()), m_streamURL(c.GetStreamURL()), m_hasCatchup(c.HasCatchup()), + m_catchupMode(c.GetCatchupMode()), m_catchupDays(c.GetCatchupDays()), m_catchupSource(c.GetCatchupSource()), m_isCatchupTSStream(c.IsCatchupTSStream()), m_catchupSupportsTimeshifting(c.CatchupSupportsTimeshifting()), m_catchupSourceTerminates(c.CatchupSourceTerminates()), m_catchupGranularitySeconds(c.GetCatchupGranularitySeconds()), m_catchupCorrectionSecs(c.GetCatchupCorrectionSecs()), m_tvgId(c.GetTvgId()), m_tvgName(c.GetTvgName()), @@ -60,6 +60,9 @@ namespace iptvsimple int GetChannelNumber() const { return m_channelNumber; } void SetChannelNumber(int value) { m_channelNumber = value; } + int GetSubChannelNumber() const { return m_subChannelNumber; } + void SetSubChannelNumber(int value) { m_subChannelNumber = value; } + int GetEncryptionSystem() const { return m_encryptionSystem; } void SetEncryptionSystem(int value) { m_encryptionSystem = value; } @@ -142,6 +145,7 @@ namespace iptvsimple bool m_radio = false; int m_uniqueId = 0; int m_channelNumber = 0; + int m_subChannelNumber = 0; int m_encryptionSystem = 0; int m_tvgShift = 0; std::string m_channelName = ""; From 001aea483c38eea7d2d8cb6573c4cdefcd2cdb82 Mon Sep 17 00:00:00 2001 From: phunkyfish Date: Sun, 7 Mar 2021 13:21:28 +0000 Subject: [PATCH 2/3] Allow setting scope for channels using catchup mode setting to enable overriding --- README.md | 7 +++-- .../resource.language.en_gb/strings.po | 31 ++++++++++++++++--- pvr.iptvsimple/resources/settings.xml | 15 +++++++++ src/iptvsimple/Settings.cpp | 3 ++ src/iptvsimple/Settings.h | 10 ++++++ src/iptvsimple/data/Channel.cpp | 31 +++++++++++++++---- 6 files changed, 85 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 6a47ba694..e516c0342 100644 --- a/README.md +++ b/README.md @@ -198,14 +198,17 @@ Addon settings for catchup: * **Enable catchup**: Should be enabled if there are channels supporting catchup in your M3U list. * **Query format string**: A format string (provider dependent) allowing timestamp information to be appended to a URL to denote when to catchup from. E.g. `&cutv={Y}-{m}-{d}T{H}:{M}:{S}`, which allows year, month, day, hour minute and second to be inserted to give: `&cutv=2019-11-26T22:00:32`. If the M3U entry using has a catchup mode of `default` or `append` and a `catchup-source` tag is provided in the M3U entry this setting will be ignored. * **Catchup window**: The number of days into the past in which it is possible to catchup on a show. Can be overidden in an M3U entry using a 'catchup-days' tag. -* **All channels support catchup**: If enabled it is assumed that all channels support catchup. If there are no catchup specific tags in the M3U entries then the stream URL will be used as the source, and the URL format and catchup days will come from the addon settings. If this option is disabled then a M3U entry must have at least a `catchup="true"` or `catchup="default"` tag to enable catchup. -* **All channels support catchup using mode**: If enabled it is assumed that all channels support catchup using the selected mode if they do not have catchup tags. In this case the 'Query format string' and 'Catchup window' number of days will come from the addon settings if needed. If this option is disabled then an M3U entry must have at least a `catchup=` tag to enable catchup. The options for how to build the catch URL are: +* **Channels support catchup using mode**: If enabled it is assumed that channels support catchup using the selected catchup mode while also obeying the override mode. If required the 'Query format string' and 'Catchup window' number of days will come from the addon settings. If this option is disabled then an M3U entry must have at least a `catchup=` tag to enable catchup. The options for how to build the catch URL are: - `Disabled` - Do not assume all channel support catchup. - `Default` - Use catchup source as the full catchup URL, if there is no catchup source use Append mode. - `Append` - Append the catchup source to the channel URL, if there is no catchup source append the `Query format string` instead. - `Shift (SIPTV)` - Append the standard SIPTV catchup string to the channel URL. - `Flussonic` - Build a flussonic URL from the channel URL. - `Xtream codes` - Build an Xtream codes URL from the channel URL. +* **Override catchup for channels**: Set the scope for overriding the catchup mode. Options are: + - `without catchup mode` - Only include channels with no catchup mode set (except legacy SIP `timeshift` catchup mode). + - `with catchup mode` - Only include channels with catchup mode set (ignore those without a catchup mode). + - `with and without catchup mode (all channels)` - Include all channels ignoring any catchup mode from the M3U. * **Play from EPG in Live TV mode (using timeshift)**: When disabled any catchup show from the past will be played like a video (bounded by start and end times). If enabled, it will instead act like a live stream with timeshift, also allowing the ability to skip back and forward programmes. Note that the only effect this option has on streams that do not support timeshifting is whether or not to apply the before/after buffer. * **Buffer before programme start**: The amount of buffer to give before the playback start point of an EPG entry that will be watched as a video. * **Buffer after programme end**: The amount of buffer to give after the playback end point of an EPG entry that will be watched as a video. diff --git a/pvr.iptvsimple/resources/language/resource.language.en_gb/strings.po b/pvr.iptvsimple/resources/language/resource.language.en_gb/strings.po index 1aecb74a0..566dcd572 100644 --- a/pvr.iptvsimple/resources/language/resource.language.en_gb/strings.po +++ b/pvr.iptvsimple/resources/language/resource.language.en_gb/strings.po @@ -414,7 +414,7 @@ msgstr "" #. label: Catchup - allChannelsCatchupMode msgctxt "#30104" -msgid "All channels support catchup using mode" +msgid "Channels support catchup using mode" msgstr "" #. label-group: Catchup - Watch From EPG @@ -472,7 +472,25 @@ msgctxt "#30115" msgid "Xtream codes" msgstr "" -#empty strings from id 30116 to 30119 +#. label: Catchup - catchupOverrideMode +msgctxt "#30116" +msgid "Include channels" +msgstr "" + +#. label-option: Catchup - catchupOverrideMode +msgctxt "#30117" +msgid "without catchup mode" +msgstr "" + +#. label-option: Catchup - catchupOverrideMode +msgctxt "#30118" +msgid "with catchup mode" +msgstr "" + +#. label-option: Catchup - catchupOverrideMode +msgctxt "#30119" +msgid "with and without catchup mode (all channels)" +msgstr "" #. label-category: timeshift #. label-group: Timeshift - Timeshift @@ -830,7 +848,7 @@ msgstr "" #. help: Catchup - allChannelsCatchupMode msgctxt "#30704" -msgid "If enabled it is assumed that all channels support catchup using the selected mode if they do not have catchup tags. In this case the 'Query format string' and 'Catchup window' number of days will come from the addon settings if needed. If this option is disabled then an M3U entry must have at least a 'catchup=' tag to enable catchup. The options for how to build the catch URL are: [B]Disabled[/B] - Do not assume all channel support catchup; [B]Default[/B] - Use catchup source as the full catchup URL, if there is no catchup source use Append mode; [B]Append[/B] - Append the catchup source to the channel URL, if there is no catchup source using the 'Query format string'; [B]Shift (SIPTV)[/B] - Append the standard SIPTV catchup string to the channel URL; [B]Flussonic[/B] - Build a flussonic URL from the channel URL; [B]Xtream codes[/B] - Build an Xtream codes URL from the channel URL." +msgid "If enabled it is assumed that channels support catchup using the selected catchup mode while also obeying the override mode. If required the 'Query format string' and 'Catchup window' number of days will come from the addon settings. If this option is disabled then an M3U entry must have at least a 'catchup=' tag to enable catchup. The options for how to build the catch URL are: [B]Disabled[/B] - Do not assume all channel support catchup; [B]Default[/B] - Use catchup source as the full catchup URL, if there is no catchup source use Append mode; [B]Append[/B] - Append the catchup source to the channel URL, if there is no catchup source using the 'Query format string'; [B]Shift (SIPTV)[/B] - Append the standard SIPTV catchup string to the channel URL; [B]Flussonic[/B] - Build a flussonic URL from the channel URL; [B]Xtream codes[/B] - Build an Xtream codes URL from the channel URL." msgstr "" #. help: Catchup - catchupPlayEpgAsLive @@ -853,7 +871,12 @@ msgctxt "#30708" msgid "When selected from the EPG the current live programme cannot be watched as catchup until finished." msgstr "" -#empty strings from id 30709 to 307199 +#. help: Catchup - catchupOverrideMode +msgctxt "#30709" +msgid "Set the scope for overriding the catchup mode. Options are: [B]without catchup mode[/B] - Only include channels with no catchup mode set (except legacy SIP [I]timeshift[/I] catchup mode); [B]with catchup mode[/B] - Only include channels with catchup mode set (ignore those without a catchup mode); [B]with and without catchup mode (all channels)[/B] - Include all channels ignoring any catchup mode from the M3U." +msgstr "" + +#empty strings from id 30710 to 307019 #. help info - Timeshift diff --git a/pvr.iptvsimple/resources/settings.xml b/pvr.iptvsimple/resources/settings.xml index ffbb58452..bc8a7ab29 100644 --- a/pvr.iptvsimple/resources/settings.xml +++ b/pvr.iptvsimple/resources/settings.xml @@ -636,6 +636,21 @@ + + 0 + false + + + + + + + + + 0 + + + diff --git a/src/iptvsimple/Settings.cpp b/src/iptvsimple/Settings.cpp index 6635728c6..0ead9d82e 100644 --- a/src/iptvsimple/Settings.cpp +++ b/src/iptvsimple/Settings.cpp @@ -124,6 +124,7 @@ void Settings::ReadFromAddon(const std::string& userPath, const std::string& cli m_catchupQueryFormat = kodi::GetSettingString("catchupQueryFormat"); m_catchupDays = kodi::GetSettingInt("catchupDays", 5); m_allChannelsCatchupMode = kodi::GetSettingEnum("allChannelsCatchupMode", CatchupMode::DISABLED); + m_catchupOverrideMode = kodi::GetSettingEnum("catchupOverrideMode", CatchupOverrideMode::WITHOUT_TAGS); m_catchupPlayEpgAsLive = kodi::GetSettingBoolean("catchupPlayEpgAsLive", false); m_catchupWatchEpgBeginBufferMins = kodi::GetSettingInt("catchupWatchEpgBeginBufferMins", 5); m_catchupWatchEpgEndBufferMins = kodi::GetSettingInt("catchupWatchEpgEndBufferMins", 15); @@ -263,6 +264,8 @@ ADDON_STATUS Settings::SetValue(const std::string& settingName, const kodi::CSet return SetSetting(settingName, settingValue, m_catchupDays, ADDON_STATUS_OK, ADDON_STATUS_OK); else if (settingName == "allChannelsCatchupMode") return SetEnumSetting(settingName, settingValue, m_allChannelsCatchupMode, ADDON_STATUS_OK, ADDON_STATUS_OK); + else if (settingName == "catchupOverrideMode") + return SetEnumSetting(settingName, settingValue, m_catchupOverrideMode, ADDON_STATUS_OK, ADDON_STATUS_OK); else if (settingName == "catchupPlayEpgAsLive") return SetSetting(settingName, settingValue, m_catchupPlayEpgAsLive, ADDON_STATUS_OK, ADDON_STATUS_OK); else if (settingName == "catchupWatchEpgBeginBufferMins") diff --git a/src/iptvsimple/Settings.h b/src/iptvsimple/Settings.h index f9b4594f4..c13f89474 100644 --- a/src/iptvsimple/Settings.h +++ b/src/iptvsimple/Settings.h @@ -61,6 +61,14 @@ namespace iptvsimple PREFER_XMLTV }; + enum class CatchupOverrideMode + : int // same type as addon settings + { + WITHOUT_TAGS = 0, + WITH_TAGS, + ALL_CHANNELS + }; + class Settings { public: @@ -133,6 +141,7 @@ namespace iptvsimple int GetCatchupDays() const { return m_catchupDays; } time_t GetCatchupDaysInSeconds() const { return static_cast(m_catchupDays) * 24 * 60 * 60; } const CatchupMode& GetAllChannelsCatchupMode() const { return m_allChannelsCatchupMode; } + const CatchupOverrideMode& GetCatchupOverrideMode() const { return m_catchupOverrideMode; } bool CatchupPlayEpgAsLive() const { return m_catchupPlayEpgAsLive; } int GetCatchupWatchEpgBeginBufferMins() const { return m_catchupWatchEpgBeginBufferMins; } time_t GetCatchupWatchEpgBeginBufferSecs() const { return static_cast(m_catchupWatchEpgBeginBufferMins) * 60; } @@ -282,6 +291,7 @@ namespace iptvsimple std::string m_catchupQueryFormat; int m_catchupDays = 3; CatchupMode m_allChannelsCatchupMode = CatchupMode::DISABLED; + CatchupOverrideMode m_catchupOverrideMode = CatchupOverrideMode::WITHOUT_TAGS; bool m_catchupPlayEpgAsLive = false; int m_catchupWatchEpgBeginBufferMins = 5; int m_catchupWatchEpgEndBufferMins = 15; diff --git a/src/iptvsimple/data/Channel.cpp b/src/iptvsimple/data/Channel.cpp index f977d0d3a..26b7de9aa 100644 --- a/src/iptvsimple/data/Channel.cpp +++ b/src/iptvsimple/data/Channel.cpp @@ -303,13 +303,32 @@ void Channel::ConfigureCatchupMode() protocolOptions = m_streamURL.substr(found, m_streamURL.length()); } - if (Settings::GetInstance().GetAllChannelsCatchupMode() != CatchupMode::DISABLED && - (m_catchupMode == CatchupMode::DISABLED || m_catchupMode == CatchupMode::TIMESHIFT)) + if (Settings::GetInstance().GetAllChannelsCatchupMode() != CatchupMode::DISABLED) { - // As CatchupMode::TIMESHIFT is obsolete and some providers use it - // incorrectly we allow this setting to override it - m_catchupMode = Settings::GetInstance().GetAllChannelsCatchupMode(); - m_hasCatchup = true; + bool overrideCatchupMode = false; + + if (Settings::GetInstance().GetCatchupOverrideMode() == CatchupOverrideMode::WITHOUT_TAGS && + (m_catchupMode == CatchupMode::DISABLED || m_catchupMode == CatchupMode::TIMESHIFT)) + { + // As CatchupMode::TIMESHIFT is obsolete and some providers use it + // incorrectly we allow this setting to override it + overrideCatchupMode = true; + } + else if (Settings::GetInstance().GetCatchupOverrideMode() == CatchupOverrideMode::WITH_TAGS && + m_catchupMode != CatchupMode::DISABLED) + { + overrideCatchupMode = true; + } + else if (Settings::GetInstance().GetCatchupOverrideMode() == CatchupOverrideMode::ALL_CHANNELS) + { + overrideCatchupMode = true; + } + + if (overrideCatchupMode) + { + m_catchupMode = Settings::GetInstance().GetAllChannelsCatchupMode(); + m_hasCatchup = true; + } } switch (m_catchupMode) From 715d2447c1670ae108472885e1c6da7cd8cd42e0 Mon Sep 17 00:00:00 2001 From: phunkyfish Date: Tue, 2 Mar 2021 18:14:37 +0000 Subject: [PATCH 3/3] changelog and version - v7.5.0 --- pvr.iptvsimple/addon.xml.in | 6 +++++- pvr.iptvsimple/changelog.txt | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pvr.iptvsimple/addon.xml.in b/pvr.iptvsimple/addon.xml.in index 9f93f8470..5319ad136 100644 --- a/pvr.iptvsimple/addon.xml.in +++ b/pvr.iptvsimple/addon.xml.in @@ -1,7 +1,7 @@ @ADDON_DEPENDS@ @@ -169,6 +169,10 @@ icon.png +v7.5.0 +- Added: Support sub channel numbers +- Added: Allow setting scope for channels using catchup mode setting to enable overriding + v7.4.3 - Fixed: Add support for format specifiers use for detecting terminating catchup and granularity - Update: Make inputstream add-ons a required dependency diff --git a/pvr.iptvsimple/changelog.txt b/pvr.iptvsimple/changelog.txt index d52023f2e..c9afde965 100644 --- a/pvr.iptvsimple/changelog.txt +++ b/pvr.iptvsimple/changelog.txt @@ -1,3 +1,7 @@ +v7.5.0 +- Added: Support sub channel numbers +- Added: Allow setting scope for channels using catchup mode setting to enable overriding + v7.4.3 - Fixed: Add support for format specifiers use for detecting terminating catchup and granularity - Update: Make inputstream add-ons a required dependency