From 143970c8bda5603f41c7c3d6d82fd7b14dbc6da1 Mon Sep 17 00:00:00 2001 From: Daniel Scheller Date: Tue, 19 Dec 2023 09:39:06 +0100 Subject: [PATCH] settings: Add setting for the first channel number used Make the first channel number used to populate the channel list configurable as the default of 1 very likely conflicts with other PVR backend channel list when multiple backends are activated. While at it, optimize the loop logic a bit to not logically work with a zero-based start number. Signed-off-by: Daniel Scheller --- .../language/resource.language.en_gb/strings.po | 4 ++++ pvr.plutotv/resources/settings.xml | 8 ++++++++ src/PlutotvData.cpp | 12 +++++++++--- src/PlutotvData.h | 1 + 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/pvr.plutotv/resources/language/resource.language.en_gb/strings.po b/pvr.plutotv/resources/language/resource.language.en_gb/strings.po index 292a51e..33c9be4 100644 --- a/pvr.plutotv/resources/language/resource.language.en_gb/strings.po +++ b/pvr.plutotv/resources/language/resource.language.en_gb/strings.po @@ -30,6 +30,10 @@ msgctxt "#30007" msgid "(Re)install Widevine CDM library" msgstr "" +msgctxt "#30008" +msgid "First channel number" +msgstr "" + msgctxt "#30040" msgid "Debug" msgstr "" diff --git a/pvr.plutotv/resources/settings.xml b/pvr.plutotv/resources/settings.xml index 2d7cc4f..b6a5616 100644 --- a/pvr.plutotv/resources/settings.xml +++ b/pvr.plutotv/resources/settings.xml @@ -3,6 +3,14 @@
+ + 0 + 1 + + false + + + 0 diff --git a/src/PlutotvData.cpp b/src/PlutotvData.cpp index 09cc921..139ba8f 100644 --- a/src/PlutotvData.cpp +++ b/src/PlutotvData.cpp @@ -113,7 +113,8 @@ bool PlutotvData::LoadChannelsData() kodi::Log(ADDON_LOG_DEBUG, "[channels] iterate channels"); kodi::Log(ADDON_LOG_DEBUG, "[channels] size: %i;", channelsDoc["result"].Size()); - int i = 0; + // Use configured start channel number to populate the channel list + int i = GetSettingsStartChannel(); for (const auto& channel : channelsDoc["result"].GetArray()) { /** @@ -153,9 +154,9 @@ bool PlutotvData::LoadChannelsData() }}, */ const std::string plutotvid = channel["_id"].GetString(); - ++i; + PlutotvChannel plutotv_channel; - plutotv_channel.iChannelNumber = i; // position + plutotv_channel.iChannelNumber = i++; // position kodi::Log(ADDON_LOG_DEBUG, "[channel] channelnr(pos): %i;", plutotv_channel.iChannelNumber); plutotv_channel.plutotvID = plutotvid; @@ -262,6 +263,11 @@ std::string PlutotvData::GetSettingsUUID(const std::string& setting) return uuid; } +int PlutotvData::GetSettingsStartChannel() const +{ + return kodi::addon::GetSettingInt("start_channelnum", 1); +} + std::string PlutotvData::GetChannelStreamURL(int uniqueId) { LoadChannelsData(); diff --git a/src/PlutotvData.h b/src/PlutotvData.h index 3bd6d70..be25913 100644 --- a/src/PlutotvData.h +++ b/src/PlutotvData.h @@ -74,6 +74,7 @@ class ATTR_DLL_LOCAL PlutotvData : public kodi::addon::CAddonBase, std::string GetChannelStreamURL(int uniqueId); std::string GetSettingsUUID(const std::string& setting); + int GetSettingsStartChannel() const; void SetStreamProperties(std::vector& properties, const std::string& url, bool realtime);