+# for localized messages
+from . import _
+
# GUI (Screens)
from Screens.MessageBox import MessageBox
-# Plugin definition
-from Plugins.Plugin import PluginDescriptor
-
-# ExpatError
-from xml.parsers.expat import ExpatError
-
# Config
from Components.config import config, ConfigSubsection, ConfigEnableDisable, \
- ConfigInteger, ConfigSelection
+ ConfigNumber, ConfigSelection
# Initialize Configuration
config.plugins.autotimer = ConfigSubsection()
config.plugins.autotimer.autopoll = ConfigEnableDisable(default = False)
-config.plugins.autotimer.interval = ConfigInteger(default = 3, limits=(1, 24))
-config.plugins.autotimer.refresh = ConfigSelection(choices = [("none", _("None")), ("auto", _("Only AutoTimers created during this Session")), ("all", _("All non-repeating Timers"))], default = "none")
+config.plugins.autotimer.interval = ConfigNumber(default = 3)
+config.plugins.autotimer.refresh = ConfigSelection(choices = [
+ ("none", _("None")),
+ ("auto", _("Only AutoTimers created during this Session")),
+ ("all", _("All non-repeating Timers"))
+ ], default = "none"
+)
config.plugins.autotimer.try_guessing = ConfigEnableDisable(default = True)
+config.plugins.autotimer.editor = ConfigSelection(choices = [
+ ("plain", _("Classic")),
+ ("wizard", _("Wizard"))
+ ], default = "wizard"
+)
+config.plugins.autotimer.disabled_on_conflict = ConfigEnableDisable(default = False)
autotimer = None
autopoller = None
# Stop Poller
if autopoller is not None:
autopoller.stop()
-
autopoller = None
if autotimer is not None:
+ # We re-read the config so we won't save wrong information
+ try:
+ autotimer.readXml()
+ except:
+ pass
+
# Save xml
autotimer.writeXml()
try:
autotimer.readXml()
- except ExpatError, ee:
+ except SyntaxError, se:
session.open(
MessageBox,
- "Your config file is not well-formed.\nError parsing in line: %s" % (ee.lineno),
+ _("Your config file is not well-formed:\n%s") % (str(se)),
type = MessageBox.TYPE_ERROR,
timeout = 10
)
return
- except Exception, e:
- # Don't crash during development
- import traceback, sys
- traceback.print_exc(file=sys.stdout)
- session.open(
- MessageBox,
- "An unexpected error occured: %s" % (e),
- type = MessageBox.TYPE_ERROR,
- timeout = 15
- )
- return
# Do not run in background while editing, this might screw things up
if autopoller is not None:
global autotimer
global autopoller
- # Start autopoller again if wanted
- if config.plugins.autotimer.autopoll.value:
- if autopoller is None:
- from AutoPoller import AutoPoller
- autopoller = AutoPoller()
- autopoller.start(initial = False)
-
- # Don't do anything when editing was canceled
- if session is None:
- return
+ # XXX: canceling of GUI (Overview) won't affect config values which might have been changed - is this intended?
- # We might re-parse Xml so catch parsing error
- try:
+ # Don't parse EPG if editing was canceled
+ if session is not None:
+ # Poll EPGCache
ret = autotimer.parseEPG()
session.open(
MessageBox,
- "Found a total of %d matching Events.\n%d Timer were added and %d modified.." % (ret[0], ret[1], ret[2]),
+ _("Found a total of %d matching Events.\n%d Timer were added and %d modified.") % (ret[0], ret[1], ret[2]),
type = MessageBox.TYPE_INFO,
timeout = 10
)
- except Exception, e:
- # Don't crash during development
- import traceback, sys
- traceback.print_exc(file=sys.stdout)
- session.open(
- MessageBox,
- "An unexpected error occured: %s" % (e),
- type = MessageBox.TYPE_ERROR,
- timeout = 15
- )
-
- # Remove instance if not running in background
- if not config.plugins.autotimer.autopoll.value:
- autopoller = None
# Save xml
autotimer.writeXml()
+
+ # Start autopoller again if wanted
+ if config.plugins.autotimer.autopoll.value:
+ if autopoller is None:
+ from AutoPoller import AutoPoller
+ autopoller = AutoPoller()
+ autopoller.start(initial = False)
+ # Remove instance if not running in background
+ else:
+ autopoller = None
autotimer = None
+# Movielist
+def movielist(session, service, **kwargs):
+ from AutoTimerEditor import addAutotimerFromService
+ addAutotimerFromService(session, service)
+
+# Event Info
+def eventinfo(session, servicelist, **kwargs):
+ from AutoTimerEditor import AutoTimerEPGSelection
+ ref = session.nav.getCurrentlyPlayingServiceReference()
+ session.open(AutoTimerEPGSelection, ref)
+
def Plugins(**kwargs):
+ from Plugins.Plugin import PluginDescriptor
+
return [
PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart),
- PluginDescriptor(name="AutoTimer", description = "Edit Timers and scan for new Events", where = PluginDescriptor.WHERE_PLUGINMENU, icon = "plugin.png", fnc = main),
- PluginDescriptor(name="AutoTimer", description = "Edit Timers and scan for new Events", where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc = main)
+ PluginDescriptor(name="AutoTimer", description = _("Edit Timers and scan for new Events"), where = PluginDescriptor.WHERE_PLUGINMENU, icon = "plugin.png", fnc = main),
+ PluginDescriptor(name="AutoTimer", description = _("Edit Timers and scan for new Events"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc = main),
+ PluginDescriptor(name="AutoTimer", description= _("Add AutoTimer..."), where = PluginDescriptor.WHERE_MOVIELIST, fnc = movielist),
+ PluginDescriptor(name="AutoTimer", description= _("Add AutoTimer..."), where = PluginDescriptor.WHERE_EVENTINFO, fnc = eventinfo),
]
+