aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorksooo <3226626+ksooo@users.noreply.github.com>2024-10-04 12:06:08 +0200
committerksooo <3226626+ksooo@users.noreply.github.com>2024-10-11 21:31:31 +0200
commit58db23532ede2a5987091682eb0234045ff87b1d (patch)
tree9349de623765ee8861d96c7adefbf5288ae741dd
parenta5c3649c69b009a9334435b1b08af981e402d39b (diff)
[PVR] CPVRGUIActionsTimers::AddTimer: Fix support for EPG gap tags.
-rw-r--r--xbmc/pvr/guilib/PVRGUIActionsTimers.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/xbmc/pvr/guilib/PVRGUIActionsTimers.cpp b/xbmc/pvr/guilib/PVRGUIActionsTimers.cpp
index 582a3174f1..a247d46ec5 100644
--- a/xbmc/pvr/guilib/PVRGUIActionsTimers.cpp
+++ b/xbmc/pvr/guilib/PVRGUIActionsTimers.cpp
@@ -207,11 +207,17 @@ bool CPVRGUIActionsTimers::AddTimer(const CFileItem& item,
ParentalCheckResult::SUCCESS)
return false;
+ CDateTime gapStart;
+ int gapDuration{CPVRTimerInfoTag::DEFAULT_PVRRECORD_INSTANTRECORDTIME};
std::shared_ptr<CPVREpgInfoTag> epgTag = CPVRItem(item).GetEpgInfoTag();
if (epgTag)
{
if (epgTag->IsGapTag())
- epgTag.reset(); // for gap tags, we can only create instant timers
+ {
+ gapStart = epgTag->StartAsUTC();
+ gapDuration = (epgTag->EndAsUTC() - gapStart).GetSecondsTotal();
+ epgTag.reset(); // for gap tags, we can only create instant or time-based timers
+ }
}
else if (bCreateRule)
{
@@ -232,9 +238,28 @@ bool CPVRGUIActionsTimers::AddTimer(const CFileItem& item,
return false;
}
- std::shared_ptr<CPVRTimerInfoTag> newTimer(
- epgTag ? CPVRTimerInfoTag::CreateFromEpg(epgTag, bCreateRule)
- : CPVRTimerInfoTag::CreateInstantTimerTag(channel));
+ std::shared_ptr<CPVRTimerInfoTag> newTimer;
+ if (epgTag)
+ {
+ newTimer = CPVRTimerInfoTag::CreateFromEpg(epgTag, bCreateRule);
+ }
+ else if (gapStart.IsValid() &&
+ gapDuration != CPVRTimerInfoTag::DEFAULT_PVRRECORD_INSTANTRECORDTIME)
+ {
+ if (gapStart <= CDateTime::GetUTCDateTime())
+ gapStart = CDateTime{time_t{0}}; // special PVR addon API value for an instant recording
+
+ // prevent super long recordings for channels without any epg data
+ gapDuration = std::min(
+ m_settings.GetIntValue(CSettings::SETTING_PVRRECORD_INSTANTRECORDTIME) * 60, gapDuration);
+
+ newTimer = CPVRTimerInfoTag::CreateTimerTag(channel, gapStart, gapDuration);
+ }
+ else
+ {
+ newTimer = CPVRTimerInfoTag::CreateInstantTimerTag(channel);
+ }
+
if (!newTimer)
{
if (bCreateRule && bFallbackToOneShotTimer)