1 # for localized messages
5 from Screens.MessageBox import MessageBox
8 from Components.config import config, ConfigSubsection, ConfigEnableDisable, \
9 ConfigNumber, ConfigSelection
11 # Initialize Configuration
12 config.plugins.autotimer = ConfigSubsection()
13 config.plugins.autotimer.autopoll = ConfigEnableDisable(default = False)
14 config.plugins.autotimer.interval = ConfigNumber(default = 3)
15 config.plugins.autotimer.refresh = ConfigSelection(choices = [
17 ("auto", _("Only AutoTimers created during this Session")),
18 ("all", _("All non-repeating Timers"))
21 config.plugins.autotimer.try_guessing = ConfigEnableDisable(default = True)
22 config.plugins.autotimer.editor = ConfigSelection(choices = [
23 ("plain", _("Classic")),
24 ("wizard", _("Wizard"))
27 config.plugins.autotimer.disabled_on_conflict = ConfigEnableDisable(default = False)
33 def autostart(reason, **kwargs):
38 if config.plugins.autotimer.autopoll.value and reason == 0:
39 # Initialize AutoTimer
40 from AutoTimer import AutoTimer
41 autotimer = AutoTimer()
44 from AutoPoller import AutoPoller
45 autopoller = AutoPoller()
50 if autopoller is not None:
54 if autotimer is not None:
55 # We re-read the config so we won't save wrong information
68 def main(session, **kwargs):
73 from AutoTimer import AutoTimer
74 autotimer = AutoTimer()
78 except SyntaxError, se:
81 _("Your config file is not well-formed:\n%s") % (str(se)),
82 type = MessageBox.TYPE_ERROR,
87 # Do not run in background while editing, this might screw things up
88 if autopoller is not None:
91 from AutoTimerOverview import AutoTimerOverview
92 session.openWithCallback(
98 def editCallback(session):
102 # XXX: canceling of GUI (Overview) won't affect config values which might have been changed - is this intended?
104 # Don't parse EPG if editing was canceled
105 if session is not None:
107 ret = autotimer.parseEPG()
110 _("Found a total of %d matching Events.\n%d Timer were added and %d modified.") % (ret[0], ret[1], ret[2]),
111 type = MessageBox.TYPE_INFO,
118 # Start autopoller again if wanted
119 if config.plugins.autotimer.autopoll.value:
120 if autopoller is None:
121 from AutoPoller import AutoPoller
122 autopoller = AutoPoller()
123 autopoller.start(initial = False)
124 # Remove instance if not running in background
130 def movielist(session, service, **kwargs):
131 from AutoTimerEditor import addAutotimerFromService
132 addAutotimerFromService(session, service)
135 def eventinfo(session, servicelist, **kwargs):
136 from AutoTimerEditor import AutoTimerEPGSelection
137 ref = session.nav.getCurrentlyPlayingServiceReference()
138 session.open(AutoTimerEPGSelection, ref)
140 def Plugins(**kwargs):
141 from Plugins.Plugin import PluginDescriptor
144 PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart),
145 PluginDescriptor(name="AutoTimer", description = _("Edit Timers and scan for new Events"), where = PluginDescriptor.WHERE_PLUGINMENU, icon = "plugin.png", fnc = main),
146 PluginDescriptor(name="AutoTimer", description = _("Edit Timers and scan for new Events"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc = main),
147 PluginDescriptor(name="AutoTimer", description= _("Add AutoTimer..."), where = PluginDescriptor.WHERE_MOVIELIST, fnc = movielist),
148 PluginDescriptor(name="AutoTimer", description= _("Add AutoTimer..."), where = PluginDescriptor.WHERE_EVENTINFO, fnc = eventinfo),