# 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"""
")>"
))
+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)
))
def addAutotimerFromSearchString(session, match):
- from AutoTimerComponent import AutoTimerComponent
+ from AutoTimerComponent import preferredAutoTimerComponent
from AutoTimerImporter import AutoTimerImporter
from plugin import autotimer
session.openWithCallback(
importerCallback,
AutoTimerImporter,
- AutoTimerComponent(
+ preferredAutoTimerComponent(
autotimer.getUniqueId(),
match,
'', # Match
)
def addAutotimerFromEvent(session, evt = None, service = None):
- from AutoTimerComponent import AutoTimerComponent
+ from AutoTimerComponent import preferredAutoTimerComponent
from AutoTimerImporter import AutoTimerImporter
from plugin import autotimer
session.openWithCallback(
importerCallback,
AutoTimerImporter,
- AutoTimerComponent(
+ preferredAutoTimerComponent(
autotimer.getUniqueId(),
name,
'', # Match
)
def addAutotimerFromService(session, service = None):
- from AutoTimerComponent import AutoTimerComponent
+ from AutoTimerComponent import preferredAutoTimerComponent
from AutoTimerImporter import AutoTimerImporter
from plugin import autotimer
session.openWithCallback(
importerCallback,
AutoTimerImporter,
- AutoTimerComponent(
+ preferredAutoTimerComponent(
autotimer.getUniqueId(),
name,
'', # Match
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