From a5c3649c69b009a9334435b1b08af981e402d39b Mon Sep 17 00:00:00 2001 From: ksooo <3226626+ksooo@users.noreply.github.com> Date: Fri, 4 Oct 2024 12:49:35 +0200 Subject: [PVR] Support to the second duration when creating time-based timers (before it was full minutes only). --- xbmc/pvr/guilib/PVRGUIActionsTimers.cpp | 4 ++-- xbmc/pvr/timers/PVRTimerInfoTag.cpp | 9 +++++---- xbmc/pvr/timers/PVRTimers.cpp | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/xbmc/pvr/guilib/PVRGUIActionsTimers.cpp b/xbmc/pvr/guilib/PVRGUIActionsTimers.cpp index 570249b12a..582a3174f1 100644 --- a/xbmc/pvr/guilib/PVRGUIActionsTimers.cpp +++ b/xbmc/pvr/guilib/PVRGUIActionsTimers.cpp @@ -562,7 +562,7 @@ bool CPVRGUIActionsTimers::SetRecordingOnChannel(const std::shared_ptr newTimer( epgTag ? CPVRTimerInfoTag::CreateFromEpg(epgTag, false) - : CPVRTimerInfoTag::CreateInstantTimerTag(channel, iDuration)); + : CPVRTimerInfoTag::CreateInstantTimerTag(channel, iDuration * 60)); if (newTimer) bReturn = CServiceBroker::GetPVRManager().Timers()->AddTimer(newTimer); @@ -984,7 +984,7 @@ void CPVRGUIActionsTimers::AnnounceReminder(const std::shared_ptrEndAsUTC() - timer->StartAsUTC()).GetSecondsTotal() / 60; + const int iDuration{(timer->EndAsUTC() - timer->StartAsUTC()).GetSecondsTotal()}; newTimer = CPVRTimerInfoTag::CreateTimerTag(timer->Channel(), timer->StartAsUTC(), iDuration); } diff --git a/xbmc/pvr/timers/PVRTimerInfoTag.cpp b/xbmc/pvr/timers/PVRTimerInfoTag.cpp index 6f5ea746ea..9c49d9d850 100644 --- a/xbmc/pvr/timers/PVRTimerInfoTag.cpp +++ b/xbmc/pvr/timers/PVRTimerInfoTag.cpp @@ -791,7 +791,7 @@ std::shared_ptr CPVRTimerInfoTag::CreateFromDate( if (bInstantStart) epgTag = channel->GetEPGNow(); else if (channel->GetEPG()) - epgTag = channel->GetEPG()->GetTagBetween(start, start + CDateTimeSpan(0, 0, iDuration, 0)); + epgTag = channel->GetEPG()->GetTagBetween(start, start + CDateTimeSpan(0, 0, 0, iDuration)); } std::shared_ptr newTimer; @@ -853,16 +853,17 @@ std::shared_ptr CPVRTimerInfoTag::CreateFromDate( if (iDuration == DEFAULT_PVRRECORD_INSTANTRECORDTIME) iDuration = CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt( - CSettings::SETTING_PVRRECORD_INSTANTRECORDTIME); + CSettings::SETTING_PVRRECORD_INSTANTRECORDTIME) * + 60; if (bInstantStart) { - CDateTime endTime = now + CDateTimeSpan(0, 0, iDuration ? iDuration : 120, 0); + const CDateTime endTime{now + CDateTimeSpan(0, 0, 0, iDuration ? iDuration : 2 * 60 * 60)}; newTimer->SetEndFromUTC(endTime); } else { - CDateTime endTime = start + CDateTimeSpan(0, 0, iDuration ? iDuration : 120, 0); + const CDateTime endTime{start + CDateTimeSpan(0, 0, 0, iDuration ? iDuration : 2 * 60 * 60)}; newTimer->SetEndFromUTC(endTime); } diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp index ccf719091a..a6d0ae395d 100644 --- a/xbmc/pvr/timers/PVRTimers.cpp +++ b/xbmc/pvr/timers/PVRTimers.cpp @@ -635,8 +635,8 @@ bool CPVRTimers::UpdateEntries(int iMaxNotificationDelay) { const CDateTimeSpan duration = timer->EndAsUTC() - timer->StartAsUTC(); const std::shared_ptr childTimer = - CPVRTimerInfoTag::CreateReminderFromDate( - nextStart, duration.GetSecondsTotal() / 60, timer); + CPVRTimerInfoTag::CreateReminderFromDate(nextStart, duration.GetSecondsTotal(), + timer); if (childTimer) { bChanged = true; @@ -1062,7 +1062,7 @@ bool CPVRTimers::AddLocalTimer(const std::shared_ptr& tag, boo { const CDateTimeSpan duration = persistedTimer->EndAsUTC() - persistedTimer->StartAsUTC(); const std::shared_ptr childTimer = - CPVRTimerInfoTag::CreateReminderFromDate(nextStart, duration.GetSecondsTotal() / 60, + CPVRTimerInfoTag::CreateReminderFromDate(nextStart, duration.GetSecondsTotal(), persistedTimer); if (childTimer) { -- cgit v1.2.3 From 58db23532ede2a5987091682eb0234045ff87b1d Mon Sep 17 00:00:00 2001 From: ksooo <3226626+ksooo@users.noreply.github.com> Date: Fri, 4 Oct 2024 12:06:08 +0200 Subject: [PVR] CPVRGUIActionsTimers::AddTimer: Fix support for EPG gap tags. --- xbmc/pvr/guilib/PVRGUIActionsTimers.cpp | 33 +++++++++++++++++++++++++++++---- 1 file 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 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 newTimer( - epgTag ? CPVRTimerInfoTag::CreateFromEpg(epgTag, bCreateRule) - : CPVRTimerInfoTag::CreateInstantTimerTag(channel)); + std::shared_ptr 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) -- cgit v1.2.3