def setAutoincreaseEnd(self, entry = None):
if not self.autoincrease:
return False
if entry is None:
new_end = int(time()) + self.autoincreasetime
else:
new_end = entry.begin -30
dummyentry = RecordTimerEntry(self.service_ref, self.begin, new_end, self.name, self.description, self.eit, disabled=True, justplay = self.justplay, afterEvent = self.afterEvent, dirname = self.dirname, tags = self.tags)
dummyentry.disabled = self.disabled
timersanitycheck = TimerSanityCheck(NavigationInstance.instance.RecordTimer.timer_list, dummyentry)
if not timersanitycheck.check():
simulTimerList = timersanitycheck.getSimulTimerList()
if simulTimerList is not None and len(simulTimerList) > 1:
new_end = simulTimerList[1].begin
new_end -= 30 # allow 30 seconds for prepare
if new_end <= time():
return False
self.end = new_end
return True
python类justplay()的实例源码
def setAutoincreaseEnd(self, entry = None):
if not self.autoincrease:
return False
if entry is None:
new_end = int(time()) + self.autoincreasetime
else:
new_end = entry.begin - 30
dummyentry = RecordTimerEntry(self.service_ref, self.begin, new_end, self.name, self.description, self.eit, disabled=True, justplay = self.justplay, afterEvent = self.afterEvent, dirname = self.dirname, tags = self.tags)
dummyentry.disabled = self.disabled
timersanitycheck = TimerSanityCheck(NavigationInstance.instance.RecordTimer.timer_list, dummyentry)
if not timersanitycheck.check():
simulTimerList = timersanitycheck.getSimulTimerList()
if simulTimerList is not None and len(simulTimerList) > 1:
new_end = simulTimerList[1].begin
new_end -= 30 # 30 Sekunden Prepare-Zeit lassen
if new_end <= time():
return False
self.end = new_end
return True
def setAutoincreaseEnd(self, entry = None):
if not self.autoincrease:
return False
if entry is None:
new_end = int(time()) + self.autoincreasetime
else:
new_end = entry.begin -30
dummyentry = RecordTimerEntry(self.service_ref, self.begin, new_end, self.name, self.description, self.eit, disabled=True, justplay = self.justplay, afterEvent = self.afterEvent, dirname = self.dirname, tags = self.tags)
dummyentry.disabled = self.disabled
timersanitycheck = TimerSanityCheck(NavigationInstance.instance.RecordTimer.timer_list, dummyentry)
if not timersanitycheck.check():
simulTimerList = timersanitycheck.getSimulTimerList()
if simulTimerList is not None and len(simulTimerList) > 1:
new_end = simulTimerList[1].begin
new_end -= 30 # 30 Sekunden Prepare-Zeit lassen
if new_end <= time():
return False
self.end = new_end
return True
def setAutoincreaseEnd(self, entry = None):
if not self.autoincrease:
return False
if entry is None:
new_end = int(time()) + self.autoincreasetime
else:
new_end = entry.begin - 30
dummyentry = RecordTimerEntry(self.service_ref, self.begin, new_end, self.name, self.description, self.eit, disabled=True, justplay = self.justplay, afterEvent = self.afterEvent, dirname = self.dirname, tags = self.tags)
dummyentry.disabled = self.disabled
timersanitycheck = TimerSanityCheck(NavigationInstance.instance.RecordTimer.timer_list, dummyentry)
if not timersanitycheck.check():
simulTimerList = timersanitycheck.getSimulTimerList()
if simulTimerList is not None and len(simulTimerList) > 1:
new_end = simulTimerList[1].begin
new_end -= 30 # 30 Sekunden Prepare-Zeit lassen
if new_end <= time():
return False
self.end = new_end
return True
def __repr__(self):
if not self.disabled:
return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s, isAutoTimer=%s)" % (self.name, ctime(self.begin), self.service_ref, self.justplay, self.isAutoTimer)
else:
return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s, isAutoTimer=%s, Disabled)" % (self.name, ctime(self.begin), self.service_ref, self.justplay, self.isAutoTimer)
def isRecording(self):
isRunning = False
for timer in self.timer_list:
if timer.isRunning() and not timer.justplay:
isRunning = True
break
return isRunning
def getNextZapTime(self):
now = time()
for timer in self.timer_list:
if not timer.justplay or timer.begin < now:
continue
return timer.begin
return -1
def isNextRecordAfterEventActionAuto(self):
for timer in self.timer_list:
# all types needed True for ident in Navigation.py
return True
if timer.justplay:
continue
if timer.afterEvent == AFTEREVENT.AUTO or timer.afterEvent == AFTEREVENT.DEEPSTANDBY:
return True
return False
def __repr__(self):
return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s, isAutoTimer=%s)" % (self.name, ctime(self.begin), self.service_ref, self.justplay, self.isAutoTimer)
def isRecording(self):
for timer in self.timer_list:
if timer.isRunning() and not timer.justplay:
return True
return False
def getNextRecordingTime(self):
now = time()
for timer in self.timer_list:
next_act = timer.getNextActivation()
if timer.justplay or next_act < now:
continue
return next_act
return -1
def getNextTimerTime(self, isWakeup=False):
now = time()
for timer in self.timer_list:
next_act = timer.getNextActivation()
if next_act < now or isWakeup and timer.justplay and timer.zap_wakeup in ("from_standby", "never"):
continue
return next_act
return -1
def isNextRecordAfterEventActionAuto(self):
now = time()
t = None
for timer in self.timer_list:
if timer.justplay or timer.begin < now:
continue
if t is None or t.begin == timer.begin:
t = timer
if t.afterEvent == AFTEREVENT.AUTO:
return True
return False
def __repr__(self):
if not self.disabled:
return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s, isAutoTimer=%s)" % (self.name, ctime(self.begin), self.service_ref, self.justplay, self.isAutoTimer)
else:
return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s, isAutoTimer=%s, Disabled)" % (self.name, ctime(self.begin), self.service_ref, self.justplay, self.isAutoTimer)
def isRecording(self):
for timer in self.timer_list:
if timer.isRunning() and not timer.justplay:
return True
return False
def getNextRecordingTimeOld(self):
now = time()
for timer in self.timer_list:
next_act = timer.getNextActivation()
if timer.justplay or next_act < now:
continue
return next_act
return -1
def isNextRecordAfterEventActionAuto(self):
for timer in self.timer_list:
if timer.justplay:
continue
if timer.afterEvent == AFTEREVENT.AUTO or timer.afterEvent == AFTEREVENT.DEEPSTANDBY:
return True
return False
def __repr__(self):
return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s)" % (self.name, ctime(self.begin), self.service_ref, self.justplay)
def isRecording(self):
for timer in self.timer_list:
if timer.isRunning() and not timer.justplay:
return True
return False
def getNextRecordingTime(self):
now = time()
for timer in self.timer_list:
next_act = timer.getNextActivation()
if timer.justplay or next_act < now:
continue
return next_act
return -1
def getNextTimerTime(self, isWakeup=False):
now = time()
for timer in self.timer_list:
next_act = timer.getNextActivation()
if next_act < now or isWakeup and timer.justplay and timer.zap_wakeup in ("from_standby", "never"):
continue
return next_act
return -1
def isNextRecordAfterEventActionAuto(self):
now = time()
t = None
for timer in self.timer_list:
if timer.justplay or timer.begin < now:
continue
if t is None or t.begin == timer.begin:
t = timer
if t.afterEvent == AFTEREVENT.AUTO:
return True
return False
def createTimer(xml):
begin = int(xml.get("begin"))
end = int(xml.get("end"))
serviceref = ServiceReference(xml.get("serviceref").encode("utf-8"))
description = xml.get("description").encode("utf-8")
repeated = xml.get("repeated").encode("utf-8")
rename_repeat = long(xml.get("rename_repeat") or "0")
disabled = long(xml.get("disabled") or "0")
justplay = long(xml.get("justplay") or "0")
always_zap = long(xml.get("always_zap") or "0")
conflict_detection = long(xml.get("conflict_detection") or "1")
afterevent = str(xml.get("afterevent") or "nothing")
afterevent = {
"nothing": AFTEREVENT.NONE,
"standby": AFTEREVENT.STANDBY,
"deepstandby": AFTEREVENT.DEEPSTANDBY,
"auto": AFTEREVENT.AUTO
}[afterevent]
eit = xml.get("eit")
if eit and eit != "None":
eit = long(eit)
else:
eit = None
location = xml.get("location")
if location and location != "None":
location = location.encode("utf-8")
else:
location = None
tags = xml.get("tags")
if tags and tags != "None":
tags = tags.encode("utf-8").split(' ')
else:
tags = None
descramble = int(xml.get("descramble") or "1")
record_ecm = int(xml.get("record_ecm") or "0")
isAutoTimer = int(xml.get("isAutoTimer") or "0")
name = xml.get("name").encode("utf-8")
#filename = xml.get("filename").encode("utf-8")
entry = RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled, justplay, afterevent, dirname = location, tags = tags, descramble = descramble, record_ecm = record_ecm, conflict_detection = conflict_detection, isAutoTimer = isAutoTimer, always_zap = always_zap, rename_repeat = rename_repeat)
entry.repeated = int(repeated)
flags = xml.get("flags")
if flags:
entry.flags = set(flags.encode("utf-8").split(' '))
for l in xml.findall("log"):
time = int(l.get("time"))
code = int(l.get("code"))
msg = l.text.strip().encode("utf-8")
entry.log_entries.append((time, code, msg))
return entry
def openChoiceActionBeforeZap(self):
if self.ts_dialog is None:
type = _("record")
if self.justplay:
type = _("zap")
elif self.always_zap:
type = _("zap and record")
message = _("You must switch to the service %s (%s - '%s')!\n") % (type, self.service_ref.getServiceName(), self.name)
if self.repeated:
message += _("Attention, this is repeated timer!\n")
message += _("Timeshift is running. Select an action.\n")
choice = [(_("Zap"), "zap"), (_("Don't zap and disable timer"), "disable"), (_("Don't zap and remove timer"), "remove")]
if not self.InfoBarInstance.save_timeshift_file:
choice.insert(1, (_("Save timeshift in movie dir and zap"), "save_movie"))
if self.InfoBarInstance.timeshiftActivated():
choice.insert(0, (_("Save timeshift and zap"), "save"))
else:
choice.insert(1, (_("Save timeshift and zap"), "save"))
else:
message += _("Reminder, you have chosen to save timeshift file.")
#if self.justplay or self.always_zap:
# choice.insert(2, (_("Don't zap"), "continue"))
choice.insert(2, (_("Don't zap"), "continue"))
def zapAction(choice):
start_zap = True
if choice:
if choice in ("zap", "save", "save_movie"):
self.log(8, "zap to recording service")
if choice in ("save", "save_movie"):
ts = self.InfoBarInstance.getTimeshift()
if ts and ts.isTimeshiftEnabled():
if choice =="save_movie":
self.InfoBarInstance.save_timeshift_in_movie_dir = True
self.InfoBarInstance.save_timeshift_file = True
ts.saveTimeshiftFile()
del ts
self.InfoBarInstance.saveTimeshiftFiles()
elif choice == "disable":
self.disable()
NavigationInstance.instance.RecordTimer.timeChanged(self)
start_zap = False
self.log(8, "zap canceled by the user, timer disabled")
elif choice == "remove":
start_zap = False
self.afterEvent = AFTEREVENT.NONE
NavigationInstance.instance.RecordTimer.removeEntry(self)
self.log(8, "zap canceled by the user, timer removed")
elif choice == "continue":
if self.justplay:
self.end = self.begin
start_zap = False
self.log(8, "zap canceled by the user")
if start_zap:
if not self.justplay:
self.setRecordingPreferredTuner()
self.failureCB(True)
else:
self.log(8, "zapping")
NavigationInstance.instance.playService(self.service_ref.ref)
self.ts_dialog = self.InfoBarInstance.session.openWithCallback(zapAction, MessageBox, message, simple=True, list=choice, timeout=20)
def createTimer(xml):
begin = int(xml.get("begin"))
end = int(xml.get("end"))
serviceref = ServiceReference(xml.get("serviceref").encode("utf-8"))
description = xml.get("description").encode("utf-8")
repeated = xml.get("repeated").encode("utf-8")
rename_repeat = long(xml.get("rename_repeat") or "1")
disabled = long(xml.get("disabled") or "0")
justplay = long(xml.get("justplay") or "0")
always_zap = long(xml.get("always_zap") or "0")
zap_wakeup = str(xml.get("zap_wakeup") or "always")
conflict_detection = long(xml.get("conflict_detection") or "1")
afterevent = str(xml.get("afterevent") or "nothing")
afterevent = {
"nothing": AFTEREVENT.NONE,
"standby": AFTEREVENT.STANDBY,
"deepstandby": AFTEREVENT.DEEPSTANDBY,
"auto": AFTEREVENT.AUTO
}[afterevent]
eit = xml.get("eit")
if eit and eit != "None":
eit = long(eit)
else:
eit = None
location = xml.get("location")
if location and location != "None":
location = location.encode("utf-8")
else:
location = None
tags = xml.get("tags")
if tags and tags != "None":
tags = tags.encode("utf-8").split(' ')
else:
tags = None
descramble = int(xml.get("descramble") or "1")
record_ecm = int(xml.get("record_ecm") or "0")
isAutoTimer = int(xml.get("isAutoTimer") or "0")
name = xml.get("name").encode("utf-8")
#filename = xml.get("filename").encode("utf-8")
entry = RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled, justplay, afterevent, dirname = location, tags = tags, descramble = descramble, record_ecm = record_ecm, isAutoTimer = isAutoTimer, always_zap = always_zap, zap_wakeup = zap_wakeup, rename_repeat = rename_repeat, conflict_detection = conflict_detection)
entry.repeated = int(repeated)
flags = xml.get("flags")
if flags:
entry.flags = set(flags.encode("utf-8").split(' '))
for l in xml.findall("log"):
time = int(l.get("time"))
code = int(l.get("code"))
msg = l.text.strip().encode("utf-8")
entry.log_entries.append((time, code, msg))
return entry
def openChoiceActionBeforeZap(self):
if self.ts_dialog is None:
type = _("record")
if self.justplay:
type = _("zap")
elif self.always_zap:
type = _("zap and record")
message = _("You must switch to the service %s (%s - '%s')!\n") % (type, self.service_ref.getServiceName(), self.name)
if self.repeated:
message += _("Attention, this is repeated timer!\n")
message += _("Timeshift is running. Select an action.\n")
choice = [(_("Zap"), "zap"), (_("Don't zap and disable timer"), "disable"), (_("Don't zap and remove timer"), "remove")]
if not self.InfoBarInstance.save_timeshift_file:
choice.insert(0, (_("Save timeshift and zap"), "save"))
else:
message += _("Reminder, you have chosen to save timeshift file.")
#if self.justplay or self.always_zap:
# choice.insert(2, (_("Don't zap"), "continue"))
choice.insert(2, (_("Don't zap"), "continue"))
def zapAction(choice):
start_zap = True
if choice:
if choice in ("zap", "save"):
self.log(8, "zap to recording service")
if choice == "save":
ts = self.InfoBarInstance.getTimeshift()
if ts and ts.isTimeshiftEnabled():
del ts
self.InfoBarInstance.save_timeshift_file = True
self.InfoBarInstance.SaveTimeshift()
elif choice == "disable":
self.disable()
NavigationInstance.instance.RecordTimer.timeChanged(self)
start_zap = False
self.log(8, "zap canceled by the user, timer disabled")
elif choice == "remove":
start_zap = False
self.afterEvent = AFTEREVENT.NONE
NavigationInstance.instance.RecordTimer.removeEntry(self)
self.log(8, "zap canceled by the user, timer removed")
elif choice == "continue":
if self.justplay:
self.end = self.begin
start_zap = False
self.log(8, "zap canceled by the user")
if start_zap:
if not self.justplay:
self.setRecordingPreferredTuner()
self.failureCB(True)
else:
self.log(8, "zapping")
NavigationInstance.instance.playService(self.service_ref.ref)
self.ts_dialog = self.InfoBarInstance.session.openWithCallback(zapAction, MessageBox, message, simple=True, list=choice, timeout=20)
def createTimer(xml):
begin = int(xml.get("begin"))
end = int(xml.get("end"))
serviceref = ServiceReference(xml.get("serviceref").encode("utf-8"))
description = xml.get("description").encode("utf-8")
repeated = xml.get("repeated").encode("utf-8")
rename_repeat = long(xml.get("rename_repeat") or "1")
disabled = long(xml.get("disabled") or "0")
justplay = long(xml.get("justplay") or "0")
always_zap = long(xml.get("always_zap") or "0")
pipzap = long(xml.get("pipzap") or "0")
conflict_detection = long(xml.get("conflict_detection") or "1")
afterevent = str(xml.get("afterevent") or "nothing")
afterevent = {
"nothing": AFTEREVENT.NONE,
"standby": AFTEREVENT.STANDBY,
"deepstandby": AFTEREVENT.DEEPSTANDBY,
"auto": AFTEREVENT.AUTO
}[afterevent]
eit = xml.get("eit")
if eit and eit != "None":
eit = long(eit)
else:
eit = None
location = xml.get("location")
if location and location != "None":
location = location.encode("utf-8")
else:
location = None
tags = xml.get("tags")
if tags and tags != "None":
tags = tags.encode("utf-8").split(' ')
else:
tags = None
descramble = int(xml.get("descramble") or "1")
record_ecm = int(xml.get("record_ecm") or "0")
isAutoTimer = int(xml.get("isAutoTimer") or "0")
name = xml.get("name").encode("utf-8")
#filename = xml.get("filename").encode("utf-8")
entry = RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled, justplay, afterevent, dirname = location, tags = tags, descramble = descramble, record_ecm = record_ecm, isAutoTimer = isAutoTimer, always_zap = always_zap, rename_repeat = rename_repeat, conflict_detection = conflict_detection, pipzap = pipzap)
entry.repeated = int(repeated)
flags = xml.get("flags")
if flags:
entry.flags = set(flags.encode("utf-8").split(' '))
for l in xml.findall("log"):
time = int(l.get("time"))
code = int(l.get("code"))
msg = l.text.strip().encode("utf-8")
entry.log_entries.append((time, code, msg))
return entry
def openChoiceActionBeforeZap(self):
if self.ts_dialog is None:
type = _("record")
if self.justplay:
type = _("zap")
elif self.always_zap:
type = _("zap and record")
message = _("You must switch to the service %s (%s - '%s')!\n") % (type, self.service_ref.getServiceName(), self.name)
if self.repeated:
message += _("Attention, this is repeated timer!\n")
message += _("Timeshift is running. Select an action.\n")
choice = [(_("Zap"), "zap"), (_("Don't zap and disable timer"), "disable"), (_("Don't zap and remove timer"), "remove")]
if not self.InfoBarInstance.save_timeshift_file:
choice.insert(1, (_("Save timeshift in movie dir and zap"), "save_movie"))
if self.InfoBarInstance.timeshiftActivated():
choice.insert(0, (_("Save timeshift and zap"), "save"))
else:
choice.insert(1, (_("Save timeshift and zap"), "save"))
else:
message += _("Reminder, you have chosen to save timeshift file.")
#if self.justplay or self.always_zap:
# choice.insert(2, (_("Don't zap"), "continue"))
choice.insert(2, (_("Don't zap"), "continue"))
def zapAction(choice):
start_zap = True
if choice:
if choice in ("zap", "save", "save_movie"):
self.log(8, "zap to recording service")
if choice in ("save", "save_movie"):
ts = self.InfoBarInstance.getTimeshift()
if ts and ts.isTimeshiftEnabled():
if choice =="save_movie":
self.InfoBarInstance.save_timeshift_in_movie_dir = True
self.InfoBarInstance.save_timeshift_file = True
ts.saveTimeshiftFile()
del ts
self.InfoBarInstance.saveTimeshiftFiles()
elif choice == "disable":
self.disable()
NavigationInstance.instance.RecordTimer.timeChanged(self)
start_zap = False
self.log(8, "zap canceled by the user, timer disabled")
elif choice == "remove":
start_zap = False
self.afterEvent = AFTEREVENT.NONE
NavigationInstance.instance.RecordTimer.removeEntry(self)
self.log(8, "zap canceled by the user, timer removed")
elif choice == "continue":
if self.justplay:
self.end = self.begin
start_zap = False
self.log(8, "zap canceled by the user")
if start_zap:
if not self.justplay:
self.setRecordingPreferredTuner()
self.failureCB(True)
else:
self.log(8, "zapping")
NavigationInstance.instance.playService(self.service_ref.ref)
self.ts_dialog = self.InfoBarInstance.session.openWithCallback(zapAction, MessageBox, message, simple=True, list=choice, timeout=20)
def createTimer(xml):
begin = int(xml.get("begin"))
end = int(xml.get("end"))
serviceref = ServiceReference(xml.get("serviceref").encode("utf-8"))
description = xml.get("description").encode("utf-8")
repeated = xml.get("repeated").encode("utf-8")
rename_repeat = long(xml.get("rename_repeat") or "1")
disabled = long(xml.get("disabled") or "0")
justplay = long(xml.get("justplay") or "0")
always_zap = long(xml.get("always_zap") or "0")
zap_wakeup = str(xml.get("zap_wakeup") or "always")
conflict_detection = long(xml.get("conflict_detection") or "1")
afterevent = str(xml.get("afterevent") or "nothing")
afterevent = {
"nothing": AFTEREVENT.NONE,
"standby": AFTEREVENT.STANDBY,
"deepstandby": AFTEREVENT.DEEPSTANDBY,
"auto": AFTEREVENT.AUTO
}[afterevent]
eit = xml.get("eit")
if eit and eit != "None":
eit = long(eit)
else:
eit = None
location = xml.get("location")
if location and location != "None":
location = location.encode("utf-8")
else:
location = None
tags = xml.get("tags")
if tags and tags != "None":
tags = tags.encode("utf-8").split(' ')
else:
tags = None
descramble = int(xml.get("descramble") or "1")
record_ecm = int(xml.get("record_ecm") or "0")
name = xml.get("name").encode("utf-8")
#filename = xml.get("filename").encode("utf-8")
entry = RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled, justplay, afterevent, dirname = location, tags = tags, descramble = descramble, record_ecm = record_ecm, always_zap = always_zap, zap_wakeup = zap_wakeup, rename_repeat = rename_repeat, conflict_detection = conflict_detection)
entry.repeated = int(repeated)
flags = xml.get("flags")
if flags:
entry.flags = set(flags.encode("utf-8").split(' '))
for l in xml.findall("log"):
time = int(l.get("time"))
code = int(l.get("code"))
msg = l.text.strip().encode("utf-8")
entry.log_entries.append((time, code, msg))
return entry