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"))
32 def autostart(reason, **kwargs):
37 if config.plugins.autotimer.autopoll.value and reason == 0:
38 # Initialize AutoTimer
39 from AutoTimer import AutoTimer
40 autotimer = AutoTimer()
43 from AutoPoller import AutoPoller
44 autopoller = AutoPoller()
49 if autopoller is not None:
53 if autotimer is not None:
54 # We re-read the config so we won't save wrong information
67 def main(session, **kwargs):
72 from AutoTimer import AutoTimer
73 autotimer = AutoTimer()
75 from xml.parsers.expat import ExpatError
79 except ExpatError, ee:
82 "Your config file is not well-formed.\nError parsing in line: %s" % (ee.lineno),
83 type = MessageBox.TYPE_ERROR,
88 # Do not run in background while editing, this might screw things up
89 if autopoller is not None:
92 from AutoTimerOverview import AutoTimerOverview
93 session.openWithCallback(
99 def editCallback(session):
103 # XXX: canceling of GUI (Overview) won't affect config values which might have been changed - is this intended?
105 # Don't parse EPG if editing was canceled
106 if session is not None:
108 ret = autotimer.parseEPG()
111 "Found a total of %d matching Events.\n%d Timer were added and %d modified.." % (ret[0], ret[1], ret[2]),
112 type = MessageBox.TYPE_INFO,
116 # Start autopoller again if wanted
117 if config.plugins.autotimer.autopoll.value:
118 if autopoller is None:
119 from AutoPoller import AutoPoller
120 autopoller = AutoPoller()
121 autopoller.start(initial = False)
122 # Remove instance if not running in background
126 # Save xml (as long as we did not cancel)
127 session and autotimer.writeXml()
131 def movielist(session, service, **kwargs):
132 from AutoTimerEditor import addAutotimerFromService
133 addAutotimerFromService(session, service)
135 def Plugins(**kwargs):
136 from Plugins.Plugin import PluginDescriptor
139 PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart),
140 PluginDescriptor(name="AutoTimer", description = _("Edit Timers and scan for new Events"), where = PluginDescriptor.WHERE_PLUGINMENU, icon = "plugin.png", fnc = main),
141 PluginDescriptor(name="AutoTimer", description = _("Edit Timers and scan for new Events"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc = main),
142 PluginDescriptor(name="AutoTimer", description= _("Add AutoTimer..."), where = PluginDescriptor.WHERE_MOVIELIST, fnc = movielist)