Skip to content

Commit

Permalink
Support the Y, m, d, H, M, S specficiers for live URLs, useful for pl…
Browse files Browse the repository at this point in the history
…ugins and debugging
  • Loading branch information
phunkyfish committed Feb 1, 2024
1 parent a063bdd commit 8f7a609
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,12 @@ The format specifiers are substitution based and work as follows:
- `${timestamp}`: Same as `{lutc}`.
- `{utcend}`: The start time of the programme in UTC format + `{duration}`.
- `${end}`: Same as `{utcend}`.
- `{Y}`: The 4-digit year (YYYY) of the start date\time.
- `{m}`: The month (01-12) of the start date\time.
- `{d}`: The day (01-31) of the start date\time.
- `{H}`: The hour (00-23) of the start date\time.
- `{M}`: The minute (00-59) of the start date\time.
- `{S}`: The second (00-59) of the start date\time.
- `{Y}`: The 4-digit year (YYYY) of the start date\time. If used a live stream URL, the current live time will be used instead of the start time.
- `{m}`: The month (01-12) of the start date\time. If used a live stream URL, the current live time will be used instead of the start time.
- `{d}`: The day (01-31) of the start date\time. If used a live stream URL, the current live time will be used instead of the start time.
- `{H}`: The hour (00-23) of the start date\time. If used a live stream URL, the current live time will be used instead of the start time.
- `{M}`: The minute (00-59) of the start date\time. If used a live stream URL, the current live time will be used instead of the start time.
- `{S}`: The second (00-59) of the start date\time. If used a live stream URL, the current live time will be used instead of the start time.
- `{duration}`: The programme duration + any start and end buffer (if set).
- `${duration}`: Same as `{duration}`.
- `{duration:X}`: The programme duration (as above) divided by X seconds. Allows conversion to minutes and other time units. The minimum divider is 1, it must be an integer (not 1.5 or 2.25 etc.) and it must be a positive value. E.g. If you have a duration of 7200 seconds and you need 2 hours (2 hours is 7200 seconds), it means your divider is 3600: `{duration:3600}`. If you need minutes for the same duration you could use: `{duration:60}` which would result in a value of 120.
Expand Down
10 changes: 10 additions & 0 deletions src/iptvsimple/CatchupController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,16 @@ std::string FormatDateTimeNowOnly(const std::string &urlFormatString, int timezo
FormatTime("now", &dateTimeNow, formattedUrl, true);
FormatTime("timestamp", &dateTimeNow, formattedUrl, true);

// We use the curernt time here instead of the start time as
// there is no start time when we playing live!
// This is useful for plugins where finding the start time can be tricky
FormatTime('Y', &dateTimeNow, formattedUrl);
FormatTime('m', &dateTimeNow, formattedUrl);
FormatTime('d', &dateTimeNow, formattedUrl);
FormatTime('H', &dateTimeNow, formattedUrl);
FormatTime('M', &dateTimeNow, formattedUrl);
FormatTime('S', &dateTimeNow, formattedUrl);

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

return formattedUrl;
Expand Down

0 comments on commit 8f7a609

Please sign in to comment.