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)
27 def autostart(reason, **kwargs):
32 if config.plugins.autotimer.autopoll.value and reason == 0:
33 # Initialize AutoTimer
34 from AutoTimer import AutoTimer
35 autotimer = AutoTimer()
38 from AutoPoller import AutoPoller
39 autopoller = AutoPoller()
44 if autopoller is not None:
45 # We might shutdown when configuring, timer won't be running then
48 except ValueError, ve:
53 if autotimer is not None:
61 def main(session, **kwargs):
66 from AutoTimer import AutoTimer
67 autotimer = AutoTimer()
69 from xml.parsers.expat import ExpatError
73 except ExpatError, ee:
76 "Your config file is not well-formed.\nError parsing in line: %s" % (ee.lineno),
77 type = MessageBox.TYPE_ERROR,
82 # Do not run in background while editing, this might screw things up
83 if autopoller is not None:
86 from AutoTimerOverview import AutoTimerOverview
87 session.openWithCallback(
93 def editCallback(session):
97 # XXX: canceling of GUI (Overview) won't affect config values which might have been changed - is this intended?
99 # Don't parse EPG if editing was canceled
100 if session is not None:
102 ret = autotimer.parseEPG()
105 "Found a total of %d matching Events.\n%d Timer were added and %d modified.." % (ret[0], ret[1], ret[2]),
106 type = MessageBox.TYPE_INFO,
110 # Start autopoller again if wanted
111 if config.plugins.autotimer.autopoll.value:
112 if autopoller is None:
113 from AutoPoller import AutoPoller
114 autopoller = AutoPoller()
115 autopoller.start(initial = False)
116 # Remove instance if not running in background
120 # Save xml (as long as we did not cancel)
121 session and autotimer.writeXml()
125 def movielist(session, service, **kwargs):
126 from AutoTimerEditor import addAutotimerFromService
127 addAutotimerFromService(session, service)
129 def Plugins(**kwargs):
130 from Plugins.Plugin import PluginDescriptor
133 PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart),
134 PluginDescriptor(name="AutoTimer", description = _("Edit Timers and scan for new Events"), where = PluginDescriptor.WHERE_PLUGINMENU, icon = "plugin.png", fnc = main),
135 PluginDescriptor(name="AutoTimer", description = _("Edit Timers and scan for new Events"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc = main),
136 PluginDescriptor(name="AutoTimer", description= _("Add AutoTimer..."), where = PluginDescriptor.WHERE_MOVIELIST, fnc = movielist)