Skip to content

Commit

Permalink
Support the duration specifier for live URLs, useful for plugins and …
Browse files Browse the repository at this point in the history
…debugging
  • Loading branch information
phunkyfish committed Feb 11, 2024
1 parent 5f2c826 commit 0267d5f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/iptvsimple/CatchupController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ std::string FormatDateTime(time_t timeStart, time_t duration, const std::string
return formattedUrl;
}

std::string FormatDateTimeNowOnly(const std::string &urlFormatString, int timezoneShiftSecs, int programmeStartTime)
std::string FormatDateTimeNowOnly(const std::string &urlFormatString, int timezoneShiftSecs, int programmeStartTime, int duration)
{
std::string formattedUrl = urlFormatString;
const time_t timeNow = std::time(0) - timezoneShiftSecs;
Expand All @@ -429,6 +429,8 @@ std::string FormatDateTimeNowOnly(const std::string &urlFormatString, int timezo
FormatTime('H', &dateTimeStart, formattedUrl);
FormatTime('M', &dateTimeStart, formattedUrl);
FormatTime('S', &dateTimeStart, formattedUrl);

FormatUtc("{duration}", duration, formattedUrl);
}

Logger::Log(LEVEL_DEBUG, "%s - \"%s\"", __FUNCTION__, WebUtils::RedactUrl(formattedUrl).c_str());
Expand Down Expand Up @@ -465,7 +467,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(), timezoneShiftSecs, startTime);
startTimeUrl = FormatDateTimeNowOnly(channel.GetStreamURL(), timezoneShiftSecs, startTime, duration);

static const std::regex CATCHUP_ID_REGEX("\\{catchup-id\\}");
if (!programmeCatchupId.empty())
Expand Down Expand Up @@ -515,7 +517,7 @@ std::string CatchupController::GetCatchupUrl(const Channel& channel) const
std::string CatchupController::ProcessStreamUrl(const Channel& channel) const
{
//We only process current time timestamps specifiers in this case
std::string processedUrl = FormatDateTimeNowOnly(channel.GetStreamURL(), m_epg.GetEPGTimezoneShiftSecs(channel) + channel.GetCatchupCorrectionSecs(), m_programmeStartTime);
std::string processedUrl = FormatDateTimeNowOnly(channel.GetStreamURL(), m_epg.GetEPGTimezoneShiftSecs(channel) + channel.GetCatchupCorrectionSecs(), m_programmeStartTime, m_programmeEndTime - m_programmeStartTime);

static const std::regex CATCHUP_ID_REGEX("\\{catchup-id\\}");
if (!m_programmeCatchupId.empty())
Expand Down

0 comments on commit 0267d5f

Please sign in to comment.