Skip to content

Commit

Permalink
Support the all specifier for live URLs, useful for plugins and debug…
Browse files Browse the repository at this point in the history
…ging
  • Loading branch information
phunkyfish committed Feb 13, 2024
1 parent f674680 commit 43c350d
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 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, int duration)
std::string FormatDateTimeNowOnly(const std::string &urlFormatString, int timezoneShiftSecs, int timeStart, int duration)
{
std::string formattedUrl = urlFormatString;
const time_t timeNow = std::time(0) - timezoneShiftSecs;
Expand All @@ -418,19 +418,44 @@ std::string FormatDateTimeNowOnly(const std::string &urlFormatString, int timezo
FormatTime("now", &dateTimeNow, formattedUrl, true);
FormatTime("timestamp", &dateTimeNow, formattedUrl, true);

// If we have the start time for a programme also process those spcifiers
if (programmeStartTime > 0)
// If we have the start time for a programme also process those specifiers
// These can be useful for plugins that don't call ffmpegdirect and instead
// play EPG as live for catchup="vod"
if (timeStart > 0)
{
std::tm dateTimeStart = SafeLocaltime(programmeStartTime);
std::tm dateTimeStart = SafeLocaltime(timeStart);

const time_t timeEnd = timeStart + duration;
std::tm dateTimeEnd = SafeLocaltime(timeEnd);

FormatTime('Y', &dateTimeStart, formattedUrl);
FormatTime('m', &dateTimeStart, formattedUrl);
FormatTime('d', &dateTimeStart, formattedUrl);
FormatTime('H', &dateTimeStart, formattedUrl);
FormatTime('M', &dateTimeStart, formattedUrl);
FormatTime('S', &dateTimeStart, formattedUrl);

FormatUtc("{utc}", timeStart, formattedUrl);
FormatUtc("${start}", timeStart, formattedUrl);
FormatUtc("{utcend}", timeStart + duration, formattedUrl);
FormatUtc("${end}", timeStart + duration, formattedUrl);
FormatUtc("{lutc}", timeNow, formattedUrl);
FormatUtc("${now}", timeNow, formattedUrl);
FormatUtc("${timestamp}", timeNow, formattedUrl);
FormatUtc("${duration}", duration, formattedUrl);
FormatUtc("{duration}", duration, formattedUrl);
FormatUnits("duration", duration, formattedUrl);
FormatUtc("${offset}", timeNow - timeStart, formattedUrl);
FormatUnits("offset", timeNow - timeStart, formattedUrl);

FormatTime("utc", &dateTimeStart, formattedUrl, false);
FormatTime("start", &dateTimeStart, formattedUrl, true);

FormatTime("utcend", &dateTimeEnd, formattedUrl, false);
FormatTime("end", &dateTimeEnd, formattedUrl, true);

FormatTime("lutc", &dateTimeNow, formattedUrl, false);
FormatTime("now", &dateTimeNow, formattedUrl, true);
FormatTime("timestamp", &dateTimeNow, formattedUrl, true);
}

Logger::Log(LEVEL_DEBUG, "%s - \"%s\"", __FUNCTION__, WebUtils::RedactUrl(formattedUrl).c_str());
Expand Down

0 comments on commit 43c350d

Please sign in to comment.