X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/911466bd5e018b80dfbbd5e12c4923e89a980792..11743a3babfd9e108eaea357354683aa11d7575f:/lib/python/Components/Converter/ServiceName.py diff --git a/lib/python/Components/Converter/ServiceName.py b/lib/python/Components/Converter/ServiceName.py index 78a3dca2..210c1aab 100644 --- a/lib/python/Components/Converter/ServiceName.py +++ b/lib/python/Components/Converter/ServiceName.py @@ -1,36 +1,51 @@ +# -*- coding: utf-8 -*- from Components.Converter.Converter import Converter -from enigma import iServiceInformation, iPlayableService +from enigma import iServiceInformation, iPlayableService, iPlayableServicePtr +from Components.Element import cached class ServiceName(Converter, object): NAME = 0 PROVIDER = 1 + REFERENCE = 2 def __init__(self, type): Converter.__init__(self, type) if type == "Provider": self.type = self.PROVIDER + elif type == "Reference": + self.type = self.REFERENCE else: self.type = self.NAME - def getServiceInfoValue(self, info, what): - v = info.getInfo(what) - if v != -2: + def getServiceInfoValue(self, info, what, ref=None): + v = ref and info.getInfo(ref, what) or info.getInfo(what) + if v != iServiceInformation.resIsString: return "N/A" - return info.getInfoString(what) + return ref and info.getInfoString(ref, what) or info.getInfoString(what) + @cached def getText(self): service = self.source.service - info = service and service.info() + if isinstance(service, iPlayableServicePtr): + info = service and service.info() + ref = None + else: # reference + info = service and self.source.info + ref = service if info is None: return "" - if self.type == self.NAME: - return info.getName() + name = ref and info.getName(ref) + if name is None: + name = info.getName() + return name.replace('\xc2\x86', '').replace('\xc2\x87', '') elif self.type == self.PROVIDER: - return self.getServiceInfoValue(info, iServiceInformation.sProvider) + return self.getServiceInfoValue(info, iServiceInformation.sProvider, ref) + elif self.type == self.REFERENCE: + return self.getServiceInfoValue(info, iServiceInformation.sServiceref, ref) text = property(getText) - def changed(self, *args): - if not len(args) or args[0] in [iPlayableService.evStart, iPlayableService.evEnd]: - Converter.changed(self) + def changed(self, what): + if what[0] != self.CHANGED_SPECIFIC or what[1] in (iPlayableService.evStart,): + Converter.changed(self, what)