From 07aa7c4f56ead32aad37b8ff0cc82d91428d2db6 Mon Sep 17 00:00:00 2001 From: Moritz Venn Date: Sun, 16 Jan 2011 15:34:03 +0100 Subject: [PATCH] AutoTimer: add "Fast Scan" support --- autotimer/src/AutoTimer.py | 4 +- autotimer/src/AutoTimerComponent.py | 94 +++++++++++++++++++++++++++++++++ autotimer/src/AutoTimerConfiguration.py | 6 +-- autotimer/src/AutoTimerEditor.py | 12 ++--- autotimer/src/AutoTimerOverview.py | 3 -- autotimer/src/AutoTimerSettings.py | 1 + autotimer/src/plugin.py | 1 + 7 files changed, 107 insertions(+), 14 deletions(-) diff --git a/autotimer/src/AutoTimer.py b/autotimer/src/AutoTimer.py index b5919f8..ea72e13 100644 --- a/autotimer/src/AutoTimer.py +++ b/autotimer/src/AutoTimer.py @@ -21,7 +21,7 @@ from enigma import eEPGCache, eServiceReference from Components.config import config # AutoTimer Component -from AutoTimerComponent import AutoTimerComponent +from AutoTimerComponent import preferredAutoTimerComponent XML_CONFIG = "/etc/enigma2/autotimer.xml" @@ -60,7 +60,7 @@ class AutoTimer: self.timers = [] self.configMtime = -1 self.uniqueTimerId = 0 - self.defaultTimer = AutoTimerComponent( + self.defaultTimer = preferredAutoTimerComponent( 0, # Id "", # Name "", # Match diff --git a/autotimer/src/AutoTimerComponent.py b/autotimer/src/AutoTimerComponent.py index a4356ac..363e8e6 100644 --- a/autotimer/src/AutoTimerComponent.py +++ b/autotimer/src/AutoTimerComponent.py @@ -7,6 +7,9 @@ from re import compile as re_compile # Alternatives and service restriction from enigma import eServiceReference, eServiceCenter +# To get preferred component +from Components.config import config + class AutoTimerComponent(object): """AutoTimer Component which also handles validity checks""" @@ -575,3 +578,94 @@ class AutoTimerComponent(object): ")>" )) +class AutoTimerFastscanComponent(AutoTimerComponent): + def __init__(self, *args, **kwargs): + AutoTimerComponent.__init__(self, *args, **kwargs) + self._fastServices = None + + def setBouquets(self, bouquets): + AutoTimerComponent.setBouquets(self, bouquets) + self._fastServices = None + + def setServices(self, services): + AutoTimerComponent.setServices(self, services) + self._fastServices = None + + def getFastServices(self): + if self._fastServices is None: + fastServices = [] + append = fastServices.append + addbouquets = [] + for service in self.services: + myref = eServiceReference(str(service)) + if myref.flags & eServiceReference.isGroup: + addbouquets.append(service) + else: + comp = service.split(':') + append(':'.join(comp[3:])) + + serviceHandler = eServiceCenter.getInstance() + for bouquet in bouquets + addbouquets: + myref = eServiceReference(str(bouquet)) + mylist = serviceHandler.list(myref) + if mylist is not None: + while 1: + s = mylist.getNext() + # TODO: I wonder if its sane to assume we get services here (and not just new lists) + # We can ignore markers & directorys here because they won't match any event's service :-) + if s.valid(): + # strip all after last : + value = s.toString() + pos = value.rfind(':') + if pos != -1: + if value[pos-1] == ':': + pos -= 1 + value = value[:pos+1] + + comp = value.split(':') + append(':'.join(value[3:])) + else: + break + self._fastServices = fastServices + return self._fastServices + + def checkServices(self, check_service): + services = self.getFastServices() + if services: + check = ':'.join(check_service.split(':')[3:]) + for service in services: + if service == check: + return False # included + return True # not included + return False # no restriction + + def getAlternative(self, override_service): + services = self.services + if services: + override = ':'.join(override_service.split(':')[3:]) + serviceHandler = eServiceCenter.getInstance() + + for service in services: + myref = eServiceReference(str(service)) + if myref.flags & eServiceReference.isGroup: + mylist = serviceHandler.list(myref) + if mylist is not None: + while 1: + s = mylist.getNext() + if s.valid(): + # strip all after last : + value = s.toString() + pos = value.rfind(':') + if pos != -1: + if value[pos-1] == ':': + pos -= 1 + value = value[:pos+1] + + if ':'.join(value.split(':')[3:]) == override: + return service + else: + break + return override_service + +# very basic factory ;-) +preferredAutoTimerComponent = lambda *args, **kwargs: AutoTimerFastscanComponent(*args, **kwargs) if config.plugins.autotimer.fastscan.value else AutoTimerComponent(*args, **kwargs) diff --git a/autotimer/src/AutoTimerConfiguration.py b/autotimer/src/AutoTimerConfiguration.py index e490650..f31fd55 100644 --- a/autotimer/src/AutoTimerConfiguration.py +++ b/autotimer/src/AutoTimerConfiguration.py @@ -2,7 +2,7 @@ # for localized messages from . import _ -from AutoTimerComponent import AutoTimerComponent +from AutoTimerComponent import preferredAutoTimerComponent from RecordTimer import AFTEREVENT from Tools.XMLTools import stringToXML from ServiceReference import ServiceReference @@ -40,7 +40,7 @@ def parseConfig(configuration, list, version = None, uniqueTimerId = 0, defaultT for timer in configuration.findall("timer"): uniqueTimerId += 1 - baseTimer = AutoTimerComponent( + baseTimer = preferredAutoTimerComponent( uniqueTimerId, '', '', @@ -452,7 +452,7 @@ def parseConfigOld(configuration, list, uniqueTimerId = 0): tags.append(value.encode("UTF-8")) # Finally append timer - list.append(AutoTimerComponent( + list.append(preferredAutoTimerComponent( uniqueTimerId, name, match, diff --git a/autotimer/src/AutoTimerEditor.py b/autotimer/src/AutoTimerEditor.py index 3320013..0d623de 100644 --- a/autotimer/src/AutoTimerEditor.py +++ b/autotimer/src/AutoTimerEditor.py @@ -1142,7 +1142,7 @@ class AutoTimerServiceEditor(Screen, ConfigListScreen): )) def addAutotimerFromSearchString(session, match): - from AutoTimerComponent import AutoTimerComponent + from AutoTimerComponent import preferredAutoTimerComponent from AutoTimerImporter import AutoTimerImporter from plugin import autotimer @@ -1155,7 +1155,7 @@ def addAutotimerFromSearchString(session, match): session.openWithCallback( importerCallback, AutoTimerImporter, - AutoTimerComponent( + preferredAutoTimerComponent( autotimer.getUniqueId(), match, '', # Match @@ -1173,7 +1173,7 @@ def addAutotimerFromSearchString(session, match): ) def addAutotimerFromEvent(session, evt = None, service = None): - from AutoTimerComponent import AutoTimerComponent + from AutoTimerComponent import preferredAutoTimerComponent from AutoTimerImporter import AutoTimerImporter from plugin import autotimer @@ -1210,7 +1210,7 @@ def addAutotimerFromEvent(session, evt = None, service = None): session.openWithCallback( importerCallback, AutoTimerImporter, - AutoTimerComponent( + preferredAutoTimerComponent( autotimer.getUniqueId(), name, '', # Match @@ -1228,7 +1228,7 @@ def addAutotimerFromEvent(session, evt = None, service = None): ) def addAutotimerFromService(session, service = None): - from AutoTimerComponent import AutoTimerComponent + from AutoTimerComponent import preferredAutoTimerComponent from AutoTimerImporter import AutoTimerImporter from plugin import autotimer @@ -1272,7 +1272,7 @@ def addAutotimerFromService(session, service = None): session.openWithCallback( importerCallback, AutoTimerImporter, - AutoTimerComponent( + preferredAutoTimerComponent( autotimer.getUniqueId(), name, '', # Match diff --git a/autotimer/src/AutoTimerOverview.py b/autotimer/src/AutoTimerOverview.py index 64a8a25..b1dabfb 100644 --- a/autotimer/src/AutoTimerOverview.py +++ b/autotimer/src/AutoTimerOverview.py @@ -18,9 +18,6 @@ from Components.ActionMap import HelpableActionMap from Components.config import config from Components.Sources.StaticText import StaticText -# Plugin -from AutoTimerComponent import AutoTimerComponent - class AutoTimerOverviewSummary(Screen): skin = """ diff --git a/autotimer/src/AutoTimerSettings.py b/autotimer/src/AutoTimerSettings.py index 6dd070f..95a82b8 100644 --- a/autotimer/src/AutoTimerSettings.py +++ b/autotimer/src/AutoTimerSettings.py @@ -43,6 +43,7 @@ class AutoTimerSettings(Screen, ConfigListScreen): getConfigListEntry(_("Guess existing timer based on begin/end"), config.plugins.autotimer.try_guessing, _("If this is enabled an existing timer will also be considered recording an event if it records at least 80% of the it.")), getConfigListEntry(_("Add timer as disabled on conflict"), config.plugins.autotimer.disabled_on_conflict, _("This toggles the behavior on timer conflicts. If an AutoTimer matches an event that conflicts with an existing timer it will not ignore this event but add it disabled.")), getConfigListEntry(_("Editor for new AutoTimers"), config.plugins.autotimer.editor, _("The editor to be used for new AutoTimers. This can either be the Wizard or the classic editor.")), + getConfigListEntry(_("Support \"Fast Scan\"?"), config.plugins.autotimer.fastscan, _("When supporting \"Fast Scan\" the service type is ignored. You don't need to enable this unless your Image supports \"Fast Scan\" and you are using it.")), ], session = session, on_change = self.changed diff --git a/autotimer/src/plugin.py b/autotimer/src/plugin.py index e6645f6..f6a0cf1 100644 --- a/autotimer/src/plugin.py +++ b/autotimer/src/plugin.py @@ -30,6 +30,7 @@ config.plugins.autotimer.editor = ConfigSelection(choices = [ ) config.plugins.autotimer.disabled_on_conflict = ConfigEnableDisable(default = False) config.plugins.autotimer.show_in_extensionsmenu = ConfigYesNo(default = False) +config.plugins.autotimer.fastscan = ConfigYesNo(default = False) autotimer = None autopoller = None -- 2.7.4