Skip to content

Commit

Permalink
[RecordTimer] optimize code isInTimer
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima73 committed Nov 23, 2024
1 parent c95af44 commit c7a7740
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions lib/python/RecordTimer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ def isInRepeatTimer(self, timer, event):
bt = localtime(begin)
bday = bt.tm_wday
begin2 = 1440 + bt.tm_hour * 60 + bt.tm_min
end2 = begin2 + duration / 60
end2 = begin2 + duration // 60
xbt = localtime(timer.begin)
xet = localtime(timer_end)
offset_day = False
Expand All @@ -1178,7 +1178,7 @@ def isInRepeatTimer(self, timer, event):
oday = 6
offset_day = timer.repeated & (1 << oday)
xbegin = 1440 + xbt.tm_hour * 60 + xbt.tm_min
xend = xbegin + ((timer_end - timer.begin) / 60)
xend = xbegin + ((timer_end - timer.begin) // 60)
if xend < xbegin:
xend += 1440
if timer.repeated & (1 << bday) and checking_time:
Expand Down Expand Up @@ -1261,36 +1261,35 @@ def getDisabledTimers(self):

def isInTimer(self, eventid, begin, duration, service, disabledTimers=False):
returnValue = None
type = 0
time_match = 0
bt = None
check_offset_time = not config.recording.margin_before.value and not config.recording.margin_after.value
end = begin + duration
refstr = ':'.join(service.split(':')[:11])
timersList = self.getAllTimersList() if not disabledTimers else self.getDisabledTimers()
timersList = self.getAllTimersList()[:] if not disabledTimers else self.getDisabledTimers()[:]
for x in timersList:
if disabledTimers and not x.disabled:
continue
check = ':'.join(x.service_ref.ref.toString().split(':')[:11]) == refstr
if check:
time_match = type = type_offset = 0
timer_end = x.end
timer_begin = x.begin
type_offset = 0
if not x.repeated and check_offset_time:
timer_repeat = x.repeated

if not timer_repeat and check_offset_time:
if 0 < end - timer_end <= 59:
timer_end = end
elif 0 < timer_begin - begin <= 59:
if 0 < timer_begin - begin <= 59:
timer_begin = begin
if x.justplay:
type_offset = 5
if (timer_end - x.begin) <= 1:
timer_end += 60
if x.pipzap and not x.repeated:
if x.pipzap and not timer_repeat:
type_offset = 30
if x.always_zap:
type_offset = 10

timer_repeat = x.repeated
# if set 'don't stop current event but disable coming events' for repeat timer
running_only_curevent = x.disabled and x.isRunning() and timer_repeat
if running_only_curevent:
Expand All @@ -1303,7 +1302,7 @@ def isInTimer(self, eventid, begin, duration, service, disabledTimers=False):
bt = localtime(begin)
bday = bt.tm_wday
begin2 = 1440 + bt.tm_hour * 60 + bt.tm_min
end2 = begin2 + duration / 60
end2 = begin2 + duration // 60
xbt = localtime(x.begin)
xet = localtime(timer_end)
offset_day = False
Expand All @@ -1312,12 +1311,12 @@ def isInTimer(self, eventid, begin, duration, service, disabledTimers=False):
oday = bday - 1
if oday == -1:
oday = 6
offset_day = x.repeated & (1 << oday)
offset_day = timer_repeat & (1 << oday)
xbegin = 1440 + xbt.tm_hour * 60 + xbt.tm_min
xend = xbegin + ((timer_end - x.begin) / 60)
xend = xbegin + ((timer_end - x.begin) // 60)
if xend < xbegin:
xend += 1440
if x.repeated & (1 << bday) and checking_time:
if timer_repeat & (1 << bday) and checking_time:
if begin2 < xbegin <= end2:
if xend < end2:
# recording within event
Expand Down

0 comments on commit c7a7740

Please sign in to comment.