Skip to content

Commit

Permalink
Merge pull request #51 from herrnst/startchannel
Browse files Browse the repository at this point in the history
settings: Add setting for the first channel number used
  • Loading branch information
ksooo authored Mar 24, 2024
2 parents 888d89c + 143970c commit 7a694f7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
8 changes: 8 additions & 0 deletions pvr.plutotv/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
<section id="pvr.plutotv">
<category id="credentials" label="30001" help="">
<group id="1" label="">
<setting id="start_channelnum" type="integer" label="30008" help="">
<level>0</level>
<default>1</default>
<constraints>
<allowempty>false</allowempty>
</constraints>
<control type="edit" format="integer" />
</setting>
<setting id="install_widevine" type="string" label="30007"
help="">
<level>0</level>
Expand Down
12 changes: 9 additions & 3 deletions src/PlutotvData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
/**
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/PlutotvData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<kodi::addon::PVRStreamProperty>& properties,
const std::string& url,
bool realtime);
Expand Down

0 comments on commit 7a694f7

Please sign in to comment.