Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow catchup correction (timezone shift) when live URLs have catchup placeholders #509

Merged
merged 3 commits into from May 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -124,7 +124,7 @@ General settings required for the addon to function.
* **Custom Radio Groups file**: The file used to load the custom Radio groups (groups). The default file is `customRadioGroups-example.xml`. Details on how to customise can be found in the next section of the README.

### EPG
Settings related to the EPG.
Settings related to the EPG. Note that Kodi will only load the EPG data when it needs to. The add-on will force a load of the EPG data regardless of whether or not Kodi requests it if either catchup is enabled or XMLTV logos are required.

For settings related to genres please see the next section.

Expand Down
6 changes: 5 additions & 1 deletion pvr.iptvsimple/addon.xml.in
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.iptvsimple"
version="7.6.1"
version="7.6.2"
name="PVR IPTV Simple Client"
provider-name="nightik and Ross Nicholson">
<requires>@ADDON_DEPENDS@
Expand Down Expand Up @@ -169,6 +169,10 @@
<icon>icon.png</icon>
</assets>
<news>
v7.6.2
- Fixed: Allow catchup correction (timezone shift) when live URLs have catchup placeholders
- Fixed: Always load EPG data if we prefer XMLTV logos or catchup is enabled

v7.6.1
- Fixed: Allow ignoring M3U logos when using local logo path

Expand Down
4 changes: 4 additions & 0 deletions pvr.iptvsimple/changelog.txt
@@ -1,3 +1,7 @@
v7.6.2
- Fixed: Allow catchup correction (timezone shift) when live URLs have catchup placeholders
- Fixed: Always load EPG data if we prefer XMLTV logos or catchup is enabled

v7.6.1
- Fixed: Allow ignoring M3U logos when using local logo path

Expand Down
Expand Up @@ -692,7 +692,7 @@ msgstr ""

#. help-category: EPG Settings
msgctxt "#30620"
msgid "Settings related to the EPG."
msgid "Settings related to the EPG. Note that Kodi will only load the EPG data when it needs to. The add-on will force a load of the EPG data regardless of whether or not Kodi requests it if either catchup is enabled or XMLTV logos are required."
msgstr ""

#. help: EPG Settings - epgPathType
Expand Down
2 changes: 1 addition & 1 deletion src/PVRIptvData.cpp
Expand Up @@ -191,7 +191,7 @@ PVR_ERROR PVRIptvData::GetChannelStreamProperties(const kodi::addon::PVRChannel&
if (!catchupUrl.empty())
streamURL = catchupUrl;
else
streamURL = m_catchupController.ProcessStreamUrl(streamURL);
streamURL = m_catchupController.ProcessStreamUrl(m_currentChannel);

StreamUtils::SetAllStreamProperties(properties, m_currentChannel, streamURL, catchupUrl.empty(), catchupProperties);

Expand Down
14 changes: 7 additions & 7 deletions src/iptvsimple/CatchupController.cpp
Expand Up @@ -378,10 +378,10 @@ std::string FormatDateTime(time_t timeStart, time_t duration, const std::string
return formattedUrl;
}

std::string FormatDateTimeNowOnly(const std::string &urlFormatString)
std::string FormatDateTimeNowOnly(const std::string &urlFormatString, int timezoneShiftSecs)
{
std::string formattedUrl = urlFormatString;
const time_t timeNow = std::time(0);
const time_t timeNow = std::time(0) - timezoneShiftSecs;
std::tm dateTimeNow = SafeLocaltime(timeNow);

FormatUtc("{lutc}", timeNow, formattedUrl);
Expand Down Expand Up @@ -425,7 +425,7 @@ std::string BuildEpgTagUrl(time_t startTime, time_t duration, const Channel& cha
if ((startTime > 0 && offset < (timeNow - 5)) || (channel.IgnoreCatchupDays() && !programmeCatchupId.empty()))
startTimeUrl = FormatDateTime(offset - timezoneShiftSecs, duration, channel.GetCatchupSource());
else
startTimeUrl = FormatDateTimeNowOnly(channel.GetStreamURL());
startTimeUrl = FormatDateTimeNowOnly(channel.GetStreamURL(), timezoneShiftSecs);

static const std::regex CATCHUP_ID_REGEX("\\{catchup-id\\}");
if (!programmeCatchupId.empty())
Expand Down Expand Up @@ -472,10 +472,10 @@ std::string CatchupController::GetCatchupUrl(const Channel& channel) const
return "";
}

std::string CatchupController::ProcessStreamUrl(const std::string& streamUrl) const
std::string CatchupController::ProcessStreamUrl(const Channel& channel) const
{
//We only process current time timestamps specifiers in this case
return FormatDateTimeNowOnly(streamUrl);
//We only process current time timestamps specifiers in this case
return FormatDateTimeNowOnly(channel.GetStreamURL(), m_epg.GetEPGTimezoneShiftSecs(channel) + channel.GetCatchupCorrectionSecs());
}

std::string CatchupController::GetStreamTestUrl(const Channel& channel, bool fromEpg) const
Expand All @@ -484,7 +484,7 @@ std::string CatchupController::GetStreamTestUrl(const Channel& channel, bool fro
// Test URL from 2 hours ago for 1 hour duration.
return BuildEpgTagUrl(std::time(nullptr) - (2 * 60 * 60), 60 * 60, channel, 0, m_programmeCatchupId, m_epg.GetEPGTimezoneShiftSecs(channel) + channel.GetCatchupCorrectionSecs());
else
return ProcessStreamUrl(channel.GetStreamURL());
return ProcessStreamUrl(channel);
}

std::string CatchupController::GetStreamKey(const Channel& channel, bool fromEpg) const
Expand Down
2 changes: 1 addition & 1 deletion src/iptvsimple/CatchupController.h
Expand Up @@ -34,7 +34,7 @@ namespace iptvsimple

std::string GetCatchupUrlFormatString(const data::Channel& channel) const;
std::string GetCatchupUrl(const data::Channel& channel) const;
std::string ProcessStreamUrl(const std::string& streamUrl) const;
std::string ProcessStreamUrl(const data::Channel& channel) const;

bool ControlsLiveStream() const { return m_controlsLiveStream; }
void ResetCatchupState() { m_resetCatchupState = true; }
Expand Down
8 changes: 4 additions & 4 deletions src/iptvsimple/Epg.cpp
Expand Up @@ -46,11 +46,11 @@ bool Epg::Init(int epgMaxPastDays, int epgMaxFutureDays)
SetEPGMaxPastDays(epgMaxPastDays);
SetEPGMaxFutureDays(epgMaxFutureDays);

if (Settings::GetInstance().IsCatchupEnabled())
if (Settings::GetInstance().AlwaysLoadEPGData())
{
// For catchup we need a local store of the EPG data. Kodi may not load the
// data on each startup so we need to make sure it's loaded whether or not
// kodi considers it necessary.
// Kodi may not load the data on each startup so we need to make sure it's loaded whether
// or not kodi considers it necessary when either 1) we need the EPG logos or 2) for
// catchup we need a local store of the EPG data
time_t now = std::time(nullptr);
LoadEPG(now - m_epgMaxPastDaysSeconds, now + m_epgMaxFutureDaysSeconds);
}
Expand Down
1 change: 1 addition & 0 deletions src/iptvsimple/Settings.h
Expand Up @@ -117,6 +117,7 @@ namespace iptvsimple
float GetEpgTimeshiftHours() const { return m_epgTimeShiftHours; }
int GetEpgTimeshiftSecs() const { return static_cast<int>(m_epgTimeShiftHours * 60 * 60); }
bool GetTsOverride() const { return m_tsOverride; }
bool AlwaysLoadEPGData() const { return m_epgLogosMode == EpgLogosMode::PREFER_XMLTV || IsCatchupEnabled(); }

const std::string& GetGenresLocation() const { return m_genresPathType == PathType::REMOTE_PATH ? m_genresUrl : m_genresPath; }
bool UseEpgGenreTextWhenMapping() const { return m_useEpgGenreTextWhenMapping; }
Expand Down