epgsearch: use new plugin hooks instead of magic keys (requires enigma2 >= 4.3.2r4)
[enigma2-plugins.git] / valixdcontrol / src / comp / vRendChNumber.py
1 #######################################################################
2 #
3 #    Channel Number Renderer for Dreambox/Enigma-2
4 #    Coded by Vali (c)2010
5 #
6 #  This plugin is licensed under the Creative Commons 
7 #  Attribution-NonCommercial-ShareAlike 3.0 Unported License.
8 #  To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
9 #  or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
10 #
11 #  Alternatively, this plugin may be distributed and executed on hardware which
12 #  is licensed by Dream Property GmbH.
13 #
14 #  This plugin is NOT free software. It is open source, you are allowed to
15 #  modify it (if you keep the license), but it may not be commercially 
16 #  distributed other than under the conditions noted above.
17 #
18 #######################################################################
19
20 from Components.VariableText import VariableText
21 from enigma import eLabel, eServiceCenter
22 from Renderer import Renderer
23 from Screens.InfoBar import InfoBar
24
25 MYCHANSEL = InfoBar.instance.servicelist
26
27 class vRendChNumber(Renderer, VariableText):
28         def __init__(self):
29                 Renderer.__init__(self)
30                 VariableText.__init__(self)
31         GUI_WIDGET = eLabel
32         
33         def changed(self, what):
34                 if not self.suspended:
35                         service = self.source.service
36                         info = service and service.info()
37                         if info is None:
38                                 self.text = " "
39                                 return
40                         markersOffset = 0
41                         myRoot = MYCHANSEL.getRoot()
42                         mySrv = MYCHANSEL.servicelist.getCurrent()
43                         chx = MYCHANSEL.servicelist.l.lookupService(mySrv)
44                         if not MYCHANSEL.inBouquet():
45                                 pass
46                         else:
47                                 serviceHandler = eServiceCenter.getInstance()
48                                 mySSS = serviceHandler.list(myRoot)
49                                 SRVList = mySSS and mySSS.getContent("SN", True)
50                                 for i in range(len(SRVList)):
51                                         if chx == i:
52                                                 break
53                                         testlinet = SRVList[i]
54                                         testline = testlinet[0].split(":")
55                                         if testline[1] == "64":
56                                                 markersOffset = markersOffset + 1
57                         chx = (chx - markersOffset) + 1
58                         rx = MYCHANSEL.getBouquetNumOffset(myRoot)
59                         self.text = str(chx + rx)
60