1 # -*- coding: utf-8 -*-
2 from Components.Converter.Converter import Converter
3 from enigma import iServiceInformation, iPlayableService, iPlayableServicePtr
4 from Components.Element import cached
6 class ServiceName(Converter, object):
11 def __init__(self, type):
12 Converter.__init__(self, type)
13 if type == "Provider":
14 self.type = self.PROVIDER
15 elif type == "Reference":
16 self.type = self.REFERENCE
20 def getServiceInfoValue(self, info, what, ref=None):
21 v = ref and info.getInfo(ref, what) or info.getInfo(what)
22 if v != iServiceInformation.resIsString:
24 return ref and info.getInfoString(ref, what) or info.getInfoString(what)
28 service = self.source.service
29 if isinstance(service, iPlayableServicePtr):
30 info = service and service.info()
33 info = service and self.source.info
37 if self.type == self.NAME:
38 name = ref and info.getName(ref)
41 return name.replace('\xc2\x86', '').replace('\xc2\x87', '')
42 elif self.type == self.PROVIDER:
43 return self.getServiceInfoValue(info, iServiceInformation.sProvider, ref)
44 elif self.type == self.REFERENCE:
45 return self.getServiceInfoValue(info, iServiceInformation.sServiceref, ref)
47 text = property(getText)
49 def changed(self, what):
50 if what[0] != self.CHANGED_SPECIFIC or what[1] in (iPlayableService.evStart,):
51 Converter.changed(self, what)