2 from Screens.MessageBox import MessageBox
5 from Components.config import config, ConfigSubsection, ConfigEnableDisable, \
6 ConfigNumber, ConfigSelection
8 # Initialize Configuration
9 config.plugins.autotimer = ConfigSubsection()
10 config.plugins.autotimer.autopoll = ConfigEnableDisable(default = False)
11 config.plugins.autotimer.interval = ConfigNumber(default = 3)
12 config.plugins.autotimer.refresh = ConfigSelection(choices = [
14 ("auto", _("Only AutoTimers created during this Session")),
15 ("all", _("All non-repeating Timers"))
18 config.plugins.autotimer.try_guessing = ConfigEnableDisable(default = True)
24 def autostart(reason, **kwargs):
29 if config.plugins.autotimer.autopoll.value and reason == 0:
30 # Initialize AutoTimer
31 from AutoTimer import AutoTimer
32 autotimer = AutoTimer()
35 from AutoPoller import AutoPoller
36 autopoller = AutoPoller()
41 if autopoller is not None:
42 # We might shutdown when configuring, timer won't be runnign then
45 except ValueError, ve:
50 if autotimer is not None:
58 def main(session, **kwargs):
63 from AutoTimer import AutoTimer
64 autotimer = AutoTimer()
66 from xml.parsers.expat import ExpatError
70 except ExpatError, ee:
73 "Your config file is not well-formed.\nError parsing in line: %s" % (ee.lineno),
74 type = MessageBox.TYPE_ERROR,
79 # Do not run in background while editing, this might screw things up
80 if autopoller is not None:
83 from AutoTimerOverview import AutoTimerOverview
84 session.openWithCallback(
90 def editCallback(session):
94 # XXX: canceling of GUI (Overview) won't affect config values which might have been changed - is this intended?
96 # Don't parse EPG if editing was canceled
97 if session is not None:
99 ret = autotimer.parseEPG()
102 "Found a total of %d matching Events.\n%d Timer were added and %d modified.." % (ret[0], ret[1], ret[2]),
103 type = MessageBox.TYPE_INFO,
107 # Start autopoller again if wanted
108 if config.plugins.autotimer.autopoll.value:
109 if autopoller is None:
110 from AutoPoller import AutoPoller
111 autopoller = AutoPoller()
112 autopoller.start(initial = False)
113 # Remove instance if not running in background
117 # Save xml (as long as we did not cancel)
118 session and autotimer.writeXml()
121 def Plugins(**kwargs):
122 from Plugins.Plugin import PluginDescriptor
125 PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart),
126 PluginDescriptor(name="AutoTimer", description = "Edit Timers and scan for new Events", where = PluginDescriptor.WHERE_PLUGINMENU, icon = "plugin.png", fnc = main),
127 PluginDescriptor(name="AutoTimer", description = "Edit Timers and scan for new Events", where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc = main)