2 from Screens.Screen import Screen
3 from Components.ConfigList import ConfigListScreen
4 from Screens.ChannelSelection import SimpleChannelSelection
5 from Screens.MessageBox import MessageBox
6 from Screens.ChoiceBox import ChoiceBox
9 from Screens.Setup import SetupSummary
12 from Components.ActionMap import ActionMap
13 from Components.Button import Button
16 from Components.config import getConfigListEntry, ConfigEnableDisable, \
17 ConfigYesNo, ConfigText, ConfigClock, ConfigNumber, ConfigSelection, \
21 from RecordTimer import AFTEREVENT
23 # Needed to convert our timestamp back and forth
24 from time import localtime, mktime
26 # Show ServiceName instead of ServiceReference
27 from ServiceReference import ServiceReference
29 # addAutotimerFromService
30 from enigma import eServiceCenter, iServiceInformation
35 ("2", _("Wednesday")),
40 ("weekend", _("Weekend")),
41 ("weekday", _("Weekday"))
44 class SimpleBouquetSelection(SimpleChannelSelection):
45 def __init__(self, session, title):
46 SimpleChannelSelection.__init__(self, session, title)
47 self.skinName = "SimpleChannelSelection"
49 def channelSelected(self): # just return selected service
50 ref = self.getCurrentSelection()
51 if (ref.flags & 7) == 7:
54 # We return the currently active path here
55 # Asking the user if this is what he wants might be better though
56 self.close(self.servicePath[-1])
58 class AutoTimerEditor(Screen, ConfigListScreen):
61 skin = """<screen name="AutoTimerEdit" title="Edit AutoTimer" position="75,155" size="565,280">
62 <widget name="config" position="5,5" size="555,225" scrollbarMode="showOnDemand" />
63 <ePixmap position="0,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
64 <ePixmap position="140,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
65 <ePixmap position="280,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
66 <ePixmap position="420,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
67 <widget name="key_red" position="0,235" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
68 <widget name="key_green" position="140,235" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
69 <widget name="key_yellow" position="280,235" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
70 <widget name="key_blue" position="420,235" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
73 def __init__(self, session, timer):
74 Screen.__init__(self, session)
80 self.setup_title = "AutoTimer Editor"
81 self.onChangedEntry = []
83 # See if we are filtering some strings
85 timer.getExcludedTitle(),
86 timer.getExcludedShort(),
87 timer.getExcludedDescription(),
88 timer.getExcludedDays()
91 timer.getIncludedTitle(),
92 timer.getIncludedShort(),
93 timer.getIncludedDescription(),
94 timer.getIncludedDays()
96 if len(self.excludes[0]) or len(self.excludes[1]) \
97 or len(self.excludes[2]) or len(self.excludes[3]) \
98 or len(self.includes[0]) or len(self.includes[1]) \
99 or len(self.includes[2]) or len(self.includes[3]):
100 self.filterSet = True
102 self.filterSet = False
104 # See if services are restricted
105 self.services = timer.getServices()
106 self.bouquets = timer.getBouquets()
107 if len(self.services) or len(self.bouquets):
108 self.serviceRestriction = True
110 self.serviceRestriction = False
112 self.createSetup(timer)
114 # We might need to change shown items, so add some notifiers
115 self.timespan.addNotifier(self.reloadList, initial_call = False)
116 self.offset.addNotifier(self.reloadList, initial_call = False)
117 self.duration.addNotifier(self.reloadList, initial_call = False)
118 self.afterevent.addNotifier(self.reloadList, initial_call = False)
119 self.afterevent_timespan.addNotifier(self.reloadList, initial_call = False)
120 self.counter.addNotifier(self.reloadList, initial_call = False)
124 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
127 self["key_red"] = Button(_("Cancel"))
128 self["key_green"] = Button(_("OK"))
129 self["key_yellow"] = Button()
130 self["key_blue"] = Button()
133 self.renameServiceButton()
134 self.renameFilterButton()
137 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
139 "cancel": self.cancel,
140 "save": self.maybeSave,
142 "yellow": self.editFilter,
143 "blue": self.editServices
150 def renameFilterButton(self):
152 self["key_yellow"].setText(_("Edit Filters"))
154 self["key_yellow"].setText(_("Add Filters"))
156 def renameServiceButton(self):
157 if self.serviceRestriction:
158 self["key_blue"].setText(_("Edit Services"))
160 self["key_blue"].setText(_("Add Services"))
163 for x in self.onChangedEntry:
169 def getCurrentEntry(self):
170 return self["config"].getCurrent()[0]
172 def getCurrentValue(self):
173 return str(self["config"].getCurrent()[1].getText())
175 def createSummary(self):
178 def createSetup(self, timer):
180 self.name = ConfigText(default = timer.name, fixed_size = False)
183 self.match = ConfigText(default = timer.match, fixed_size = False)
184 self.match.setUseableChars('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789') # XXX: what exactly is useable? :-)
187 self.justplay = ConfigSelection(choices = [("zap", _("zap")), ("record", _("record"))], default = {0: "record", 1: "zap"}[int(timer.justplay)])
190 now = [x for x in localtime()]
191 if timer.hasTimespan():
193 now[3] = timer.timespan[0][0]
194 now[4] = timer.timespan[0][1]
196 now[3] = timer.timespan[1][0]
197 now[4] = timer.timespan[1][1]
207 self.timespan = ConfigEnableDisable(default = default)
208 self.timespanbegin = ConfigClock(default = begin)
209 self.timespanend = ConfigClock(default = end)
211 # Services have their own Screen
214 if timer.hasOffset():
216 begin = timer.getOffsetBegin()
217 end = timer.getOffsetEnd()
222 self.offset = ConfigEnableDisable(default = default)
223 self.offsetbegin = ConfigNumber(default = begin)
224 self.offsetend = ConfigNumber(default = end)
227 if timer.hasAfterEvent():
228 afterevent = { None: "default", AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby"}[timer.afterevent[0][0]]
230 afterevent = "default"
231 self.afterevent = ConfigSelection(choices = [("default", _("standard")), ("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", _("go to deep standby"))], default = afterevent)
233 # AfterEvent (Timespan)
234 if timer.hasAfterEvent() and timer.afterevent[0][1][0] is not None:
236 now[3] = timer.afterevent[0][1][0][0]
237 now[4] = timer.afterevent[0][1][0][1]
239 now[3] = timer.afterevent[0][1][1][0]
240 now[4] = timer.afterevent[0][1][1][1]
250 self.afterevent_timespan = ConfigEnableDisable(default = default)
251 self.afterevent_timespanbegin = ConfigClock(default = begin)
252 self.afterevent_timespanend = ConfigClock(default = end)
255 self.enabled = ConfigYesNo(default = timer.enabled)
258 if timer.hasDuration():
260 duration = timer.getDuration()
264 self.duration = ConfigEnableDisable(default = default)
265 self.durationlength = ConfigNumber(default = duration)
268 if timer.hasCounter():
269 default = timer.matchCount
272 self.counter = ConfigNumber(default = default)
273 self.counterLeft = ConfigNumber(default = timer.matchLeft)
274 selection = [("", _("Never")), ("%m", _("Monthly")), ("%U", _("Weekly (Sunday)")), ("%W", _("Weekly (Monday)"))]
275 if timer.getCounterFormatString() not in ["", "%m", "%U", "%W"]:
276 selection.append((timer.getCounterFormatString(), _("Custom (%s)") % (timer.getCounterFormatString())))
277 self.counterFormatString = ConfigSelection(selection, default = timer.getCounterFormatString())
279 # Avoid Duplicate Description
280 self.avoidDuplicateDescription = ConfigEnableDisable(default = timer.getAvoidDuplicateDescription())
283 self.destination = ConfigSelection(choices = [timer.destination or "/hdd/movie/"])
286 # First four entries are always shown
288 getConfigListEntry(_("Enabled"), self.enabled),
289 getConfigListEntry(_("Description"), self.name),
290 getConfigListEntry(_("Match Title"), self.match),
291 getConfigListEntry(_("Timer Type"), self.justplay),
292 getConfigListEntry(_("Only match during Timespan"), self.timespan)
295 # Only allow editing timespan when it's enabled
296 if self.timespan.value:
298 getConfigListEntry(_("Begin of Timespan"), self.timespanbegin),
299 getConfigListEntry(_("End of Timespan"), self.timespanend)
302 self.list.append(getConfigListEntry(_("Custom offset"), self.offset))
304 # Only allow editing offsets when it's enabled
305 if self.offset.value:
307 getConfigListEntry(_("Offset before recording (in m)"), self.offsetbegin),
308 getConfigListEntry(_("Offset after recording (in m)"), self.offsetend)
311 self.list.append(getConfigListEntry(_("Set maximum Duration"), self.duration))
313 # Only allow editing maxduration when it's enabled
314 if self.duration.value:
316 getConfigListEntry(_("Maximum Duration (in m)"), self.durationlength)
319 self.list.append(getConfigListEntry(_("After event"), self.afterevent))
321 # Only allow setting afterevent timespan when afterevent is active
322 if self.afterevent.value != "default":
323 self.list.append(getConfigListEntry(_("Execute after Event during Timespan"), self.afterevent_timespan))
325 # Only allow editing timespan when it's enabled
326 if self.afterevent_timespan.value:
328 getConfigListEntry(_("Begin of after Event Timespan"), self.afterevent_timespanbegin),
329 getConfigListEntry(_("End of after Event Timespan"), self.afterevent_timespanend)
332 self.list.append(getConfigListEntry(_("Record a maximum of x times"), self.counter))
334 # Only allow setting matchLeft when counting hits
335 if self.counter.value:
336 self.list.append(getConfigListEntry(_("Ammount of recordings left"), self.counterLeft))
337 self.list.append(getConfigListEntry(_("Reset Count"), self.counterFormatString))
339 self.list.append(getConfigListEntry(_("Require Description to be unique"), self.avoidDuplicateDescription))
341 # We always add this option though its actually expert only
342 self.list.append(getConfigListEntry(_("Custom Location"), self.destination))
344 def reloadList(self, value):
346 self["config"].setList(self.list)
348 def editFilter(self):
349 self.session.openWithCallback(
350 self.editFilterCallback,
351 AutoTimerFilterEditor,
357 def editFilterCallback(self, ret):
359 self.filterSet = ret[0]
360 self.excludes = ret[1]
361 self.includes = ret[2]
362 self.renameFilterButton()
364 def editServices(self):
365 self.session.openWithCallback(
366 self.editServicesCallback,
367 AutoTimerServiceEditor,
368 self.serviceRestriction,
373 def editServicesCallback(self, ret):
375 self.serviceRestriction = ret[0]
376 self.services = ret[1][0]
377 self.bouquets = ret[1][1]
378 self.renameServiceButton()
381 cur = self["config"].getCurrent()
383 if cur == self.destination:
384 from Screens.LocationBox import LocationBox
386 self.session.openWithCallback(
389 text = _("Choose target folder"),
391 currDir = self.destination.value
394 ConfigListScreen.keyOK(self)
396 def pathSelected(self, res):
398 self.destination.choices.append(res)
399 self.destination.description[res] = res
400 self.destination.value = res
403 if self["config"].isChanged():
404 self.session.openWithCallback(
407 _("Really close without saving settings?")
412 def cancelConfirm(self, ret):
417 # Check if we have a trailing whitespace
418 if self.match.value[-1:] == " ":
419 self.session.openWithCallback(
422 _('You entered "%s" as Text to match.\nDo you want to remove trailing whitespaces?') % (self.match.value)
428 def saveCallback(self, ret):
431 self.match.value = self.match.value.rstrip()
433 # Don't to anything if MessageBox was canceled!
437 self.timer.match = self.match.value
440 self.timer.name = self.name.value or self.timer.match
443 self.timer.enabled = self.enabled.value
446 self.timer.justplay = self.justplay.value == "zap"
449 if self.timespan.value:
450 start = self.timespanbegin.value
451 end = self.timespanend.value
452 self.timer.timespan = (start, end)
454 self.timer.timespan = None
457 if self.serviceRestriction:
458 self.timer.services = self.services
459 self.timer.bouquets = self.bouquets
461 self.timer.services = None
462 self.timer.bouquets = None
465 if self.offset.value:
466 self.timer.offset = (self.offsetbegin.value*60, self.offsetend.value*60)
468 self.timer.offset = None
471 if self.afterevent.value == "default":
472 self.timer.afterevent = []
474 afterevent = {"nothing": AFTEREVENT.NONE, "deepstandby": AFTEREVENT.DEEPSTANDBY, "standby": AFTEREVENT.STANDBY}[self.afterevent.value]
475 # AfterEvent Timespan
476 if self.afterevent_timespan.value:
477 start = self.afterevent_timespanbegin.value
478 end = self.afterevent_timespanend.value
479 self.timer.afterevent = [(afterevent, (start, end))]
481 self.timer.afterevent = [(afterevent, None)]
484 if self.duration.value:
485 self.timer.maxduration = self.durationlength.value*60
487 self.timer.maxduration = None
491 self.timer.exclude = self.excludes
492 self.timer.include = self.includes
494 self.timer.exclude = None
495 self.timer.include = None
498 if self.counter.value:
499 self.timer.matchCount = self.counter.value
500 if self.counterLeft.value <= self.counter.value:
501 self.timer.matchLeft = self.counterLeft.value
503 self.timer.matchLeft = self.counter.value
504 if self.counterFormatString.value:
505 self.timer.matchFormatString = self.counterFormatString.value
507 self.timer.matchFormatString = ''
509 self.timer.matchCount = 0
510 self.timer.matchLeft = 0
511 self.timer.matchFormatString = ''
513 self.timer.avoidDuplicateDescription = self.avoidDuplicateDescription.value
515 if self.destination.value == "/hdd/movie/":
516 self.timer.destination = None
518 self.timer.destination = self.destination.value
521 self.close(self.timer)
523 class AutoTimerFilterEditor(Screen, ConfigListScreen):
524 """Edit AutoTimer Filter"""
526 skin = """<screen name="AutoFilterEditor" title="Edit AutoTimer Filters" position="75,150" size="565,245">
527 <widget name="config" position="5,5" size="555,200" scrollbarMode="showOnDemand" />
528 <ePixmap position="5,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
529 <ePixmap position="145,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
530 <ePixmap position="285,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
531 <ePixmap position="425,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
532 <widget name="key_red" position="5,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
533 <widget name="key_green" position="145,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
534 <widget name="key_yellow" position="285,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
535 <widget name="key_blue" position="425,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
538 def __init__(self, session, filterset, excludes, includes):
539 Screen.__init__(self, session)
542 self.setup_title = "AutoTimer Filters"
543 self.onChangedEntry = []
545 self.typeSelection = ConfigSelection(choices = [("title", _("in Title")), ("short", _("in Shortdescription")), ("desc", _("in Description")), ("day", _("on Weekday"))])
546 self.typeSelection.addNotifier(self.refresh, initial_call = False)
548 self.enabled = ConfigEnableDisable(default = filterset)
550 self.excludes = excludes
551 self.includes = includes
555 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
558 self["key_red"] = Button(_("Cancel"))
559 self["key_green"] = Button(_("Save"))
560 self["key_yellow"] = Button(_("delete"))
561 self["key_blue"] = Button(_("New"))
564 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
566 "cancel": self.cancel,
568 "yellow": self.remove,
577 for x in self.onChangedEntry:
583 def getCurrentEntry(self):
584 return self["config"].getCurrent()[0]
586 def getCurrentValue(self):
587 return str(self["config"].getCurrent()[1].getText())
589 def createSummary(self):
592 def saveCurrent(self):
593 del self.excludes[self.idx][:]
594 del self.includes[self.idx][:]
596 # Warning, accessing a ConfigListEntry directly might be considered evil!
599 for item in self["config"].getList():
601 # Skip empty entries (and those which are no filters)
602 if item[1].value == "" or idx < 2:
604 elif idx < self.lenExcludes:
605 self.excludes[self.idx].append(item[1].value.encode("UTF-8"))
607 self.includes[self.idx].append(item[1].value.encode("UTF-8"))
609 def refresh(self, value):
613 self["config"].setList(self.list)
615 def reloadList(self):
617 getConfigListEntry(_("Enable Filtering"), self.enabled),
618 getConfigListEntry(_("Filter"), self.typeSelection)
621 if self.typeSelection.value == "day":
624 # Weekdays are presented as ConfigSelection
626 getConfigListEntry(_("Exclude"), ConfigSelection(choices = weekdays, default = x))
627 for x in self.excludes[3]
629 self.lenExcludes = len(self.list)
631 getConfigListEntry(_("Include"), ConfigSelection(choices = weekdays, default = x))
632 for x in self.includes[3]
635 elif self.typeSelection.value == "title":
637 elif self.typeSelection.value == "short":
639 else: # self.typeSelection.value == "desc":
643 getConfigListEntry(_("Exclude"), ConfigText(default = x, fixed_size = False))
644 for x in self.excludes[self.idx]
646 self.lenExcludes = len(self.list)
648 getConfigListEntry(_("Include"), ConfigText(default = x, fixed_size = False))
649 for x in self.includes[self.idx]
653 idx = self["config"].getCurrentIndex()
655 if idx < self.lenExcludes:
656 self.lenExcludes -= 1
658 list = self["config"].getList()
659 list.remove(self["config"].getCurrent())
660 self["config"].setList(list)
663 self.session.openWithCallback(
666 _("Select type of Filter"),
673 def typeSelected(self, ret):
675 list = self["config"].getList()
678 pos = self.lenExcludes
679 self.lenExcludes += 1
685 if self.typeSelection.value == "day":
686 entry = getConfigListEntry(text, ConfigSelection(choices = weekdays))
688 entry = getConfigListEntry(text, ConfigText(fixed_size = False))
690 list.insert(pos, entry)
691 self["config"].setList(list)
694 if self["config"].isChanged():
695 self.session.openWithCallback(
698 _("Really close without saving settings?")
703 def cancelConfirm(self, ret):
716 class AutoTimerServiceEditor(Screen, ConfigListScreen):
717 """Edit allowed Services of a AutoTimer"""
719 skin = """<screen name="AutoTimerServiceEditor" title="Edit AutoTimer Services" position="75,150" size="565,245">
720 <widget name="config" position="5,5" size="555,200" scrollbarMode="showOnDemand" />
721 <ePixmap position="5,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
722 <ePixmap position="145,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
723 <ePixmap position="285,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
724 <ePixmap position="425,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
725 <widget name="key_red" position="5,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
726 <widget name="key_green" position="145,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
727 <widget name="key_yellow" position="285,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
728 <widget name="key_blue" position="425,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
731 def __init__(self, session, servicerestriction, servicelist, bouquetlist):
732 Screen.__init__(self, session)
735 self.setup_title = "AutoTimer Services"
736 self.onChangedEntry = []
743 self.enabled = ConfigEnableDisable(default = servicerestriction)
744 self.typeSelection = ConfigSelection(choices = [("channels", _("Channels")), ("bouquets", _("Bouquets"))])
745 self.typeSelection.addNotifier(self.refresh, initial_call = False)
749 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
752 self["key_red"] = Button(_("Cancel"))
753 self["key_green"] = Button(_("OK"))
754 self["key_yellow"] = Button(_("delete"))
755 self["key_blue"] = Button(_("New"))
758 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
760 "cancel": self.cancel,
762 "yellow": self.remove,
771 def saveCurrent(self):
772 del self.services[self.idx][:]
774 # Warning, accessing a ConfigListEntry directly might be considered evil!
776 myl = self["config"].getList()
780 self.services[self.idx].append(item[1].value)
782 def refresh(self, value):
786 self["config"].setList(self.list)
788 def reloadList(self):
790 getConfigListEntry(_("Enable Service Restriction"), self.enabled),
791 getConfigListEntry(_("Editing"), self.typeSelection)
794 if self.typeSelection.value == "channels":
796 else: # self.typeSelection.value == "bouquets":
800 getConfigListEntry(_("Record on"), ConfigSelection(choices = [(str(x), ServiceReference(str(x)).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))]))
801 for x in self.services[self.idx]
805 for x in self.onChangedEntry:
811 def getCurrentEntry(self):
812 return self["config"].getCurrent()[0]
814 def getCurrentValue(self):
815 return str(self["config"].getCurrent()[1].getText())
817 def createSummary(self):
821 if self["config"].getCurrentIndex() != 0:
822 list = self["config"].getList()
823 list.remove(self["config"].getCurrent())
824 self["config"].setList(list)
827 if self.typeSelection.value == "channels":
828 self.session.openWithCallback(
829 self.finishedServiceSelection,
830 SimpleChannelSelection,
831 _("Select channel to record on")
833 else: # self.typeSelection.value == "bouquets":
834 self.session.openWithCallback(
835 self.finishedServiceSelection,
836 SimpleBouquetSelection,
837 _("Select bouquet to record on")
840 def finishedServiceSelection(self, *args):
842 list = self["config"].getList()
843 sname = args[0].toString()
845 if self.typeSelection.value == "channels":
846 # strip all after last : when adding a channel
847 pos = sname.rfind(':')
849 sname = sname[:pos+1]
851 list.append(getConfigListEntry(_("Record on"), ConfigSelection(choices = [(sname, ServiceReference(args[0]).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))])))
852 self["config"].setList(list)
855 if self["config"].isChanged():
856 self.session.openWithCallback(
859 _("Really close without saving settings?")
864 def cancelConfirm(self, ret):
876 def addAutotimerFromEvent(session, evt = None, service = None):
877 from AutoTimerComponent import AutoTimerComponent
878 from plugin import autotimer
880 # Create instance if needed
881 if autotimer is None:
882 from AutoTimer import AutoTimer
883 autotimer = AutoTimer()
885 match = evt and evt.getEventName() or ""
886 name = match or "New AutoTimer"
888 if service is not None:
889 service = str(service)
890 # strip all after last :
891 pos = service.rfind(':')
893 service = service[:pos+1]
895 servicelist.append(service)
897 begin = evt.getBeginTime()
898 end = begin + evt.getDuration()
899 timetuple = (localtime(begin-3600)[3:5], localtime(end+3600)[3:5]) # timespan defaults to +- 1h
903 session.openWithCallback(
907 autotimer.getUniqueId(), # Id
911 timespan = timetuple,
912 services = servicelist
916 def addAutotimerFromService(session, service = None):
917 from AutoTimerComponent import AutoTimerComponent
918 from plugin import autotimer
920 # Create instance if needed
921 if autotimer is None:
922 from AutoTimer import AutoTimer
923 autotimer = AutoTimer()
925 serviceHandler = eServiceCenter.getInstance()
926 info = serviceHandler.info(service)
928 match = info and info.getName(service) or ""
929 name = match or "New AutoTimer"
931 recordservice = info.getInfoString(service, iServiceInformation.sServiceref)
933 # strip all after last :
934 pos = recordservice.rfind(':')
936 recordservice = recordservice[:pos+1]
938 servicelist.append(recordservice)
940 begin = info.getInfo(service, iServiceInformation.sTimeCreate)
941 end = begin + info.getLength(service)
942 timetuple = (localtime(begin)[3:5], localtime(end)[3:5])
946 session.openWithCallback(
950 autotimer.getUniqueId(), # Id
954 timespan = timetuple,
955 services = servicelist
959 def addCallback(ret):
961 from plugin import autotimer
963 # Create instance if needed (should have been created by addAutotimerFrom* above though)
964 if autotimer is None:
965 from AutoTimer import AutoTimer
966 autotimer = AutoTimer()
970 # Remove instance if not running in background
971 if not config.plugins.autotimer.autopoll.value: