Added TransponderInfo parameter for Servicename in skin. It can be limite for using...
authorims <ims21@users.sourceforge.net>
Sun, 22 Feb 2015 13:59:35 +0000 (14:59 +0100)
committerlittlesat <littlesat99@yahoo.com>
Sun, 22 Feb 2015 14:46:49 +0000 (15:46 +0100)
Signed-off-by: littlesat <littlesat99@yahoo.com>

lib/python/Components/Converter/ServiceName.py

index 1ad1694..601e0b8 100644 (file)
@@ -1,23 +1,35 @@
 # -*- coding: utf-8 -*-
 from Components.Converter.Converter import Converter
-from enigma import iServiceInformation, iPlayableService, iPlayableServicePtr
+from enigma import iServiceInformation, iPlayableService, iPlayableServicePtr, eServiceCenter
 from Components.Element import cached
-from ServiceReference import resolveAlternate
+from ServiceReference import resolveAlternate,  ServiceReference
+from Tools.Transponder import ConvertToHumanReadable
+from Components.NimManager import nimmanager
+from Components.Converter.ChannelNumbers import channelnumbers
+import Screens.InfoBar
 
 class ServiceName(Converter, object):
        NAME = 0
        PROVIDER = 1
        REFERENCE = 2
        EDITREFERENCE = 3
+       TRANSPONDER = 4
 
        def __init__(self, type):
                Converter.__init__(self, type)
+
+               self.mode = ""
+               if ';' in type:
+                       type, self.mode = type.split(';')
+
                if type == "Provider":
                        self.type = self.PROVIDER
                elif type == "Reference":
                        self.type = self.REFERENCE
                elif type == "EditReference":
                        self.type = self.EDITREFERENCE
+               elif type == "TransponderInfo":
+                       self.type = self.TRANSPONDER
                else:
                        self.type = self.NAME
 
@@ -46,9 +58,64 @@ class ServiceName(Converter, object):
                        if nref:
                                ref = nref
                        return ref.toString()
+               elif self.type == self.TRANSPONDER:
+                       if ref:
+                               nref = resolveAlternate(ref)
+                               if nref:
+                                       ref = nref
+                                       info = eServiceCenter.getInstance().info(ref)
+                               transponder_info = info.getInfoObject(ref, iServiceInformation.sTransponderData)
+                       else:
+                               transponder_info = info.getInfoObject(iServiceInformation.sTransponderData)
+                       if "InRootOnly" in self.mode and not self.rootBouquet():
+                               return ""
+                       if transponder_info:
+                               self.t_info = ConvertToHumanReadable(transponder_info)
+                               if "DVB-T" in self.system():
+                                       return  self.dvb_t()
+                               elif "DVB-C" in self.system():
+                                       return self.dvb_c()
+                               return  self.dvb_s()
+                       return ""
 
        text = property(getText)
 
        def changed(self, what):
                if what[0] != self.CHANGED_SPECIFIC or what[1] in (iPlayableService.evStart,):
                        Converter.changed(self, what)
+
+       def dvb_s(self):
+               return "%s %d %s %d %s %s" % (self.system(), self.freq()/1000, self.polar(), self.s_rate()/1000, self.fec(), self.orb_pos())
+       def dvb_t(self):
+               return "%s %s %d/%s" % (self.system(), self.ch_number(), self.freq()/1000000 + 0.5 , self.bandwidth())
+       def dvb_c(self):
+               return "%s %d %s %s" % (self.system(), self.freq()/1000, _("kHz"), self.bandwidth())
+       def system(self):
+               return self.t_info["system"]
+       def freq(self):
+               return self.t_info["frequency"]
+       def bandwidth(self):
+               return self.t_info["bandwidth"]
+       def s_rate(self):
+               return self.t_info["symbol_rate"]
+       def polar(self):
+               return self.t_info["polarization"][0]
+       def orb_pos(self):
+               op = self.t_info["orbital_position"].split(' ')[0]
+               return "%s°%s" % (op[:-1],op[-1:])
+       def fec(self):
+               return self.t_info["fec_inner"]
+       def ch_number(self):
+               for n in nimmanager.nim_slots:
+                       if n.isCompatible("DVB-T"):
+                               channel = channelnumbers.getChannelNumber(self.freq(), n.slot)
+                               if channel:
+                                       return _("CH") + "%s" % channel
+               return ""
+
+       def rootBouquet(self):
+               servicelist = Screens.InfoBar.InfoBar.instance.servicelist
+               epg_bouquet = servicelist and servicelist.getRoot()
+               if ServiceReference(epg_bouquet).getServiceName():
+                       return False
+               return True
\ No newline at end of file