1 from Components.Sources.Source import Source
2 from enigma import eServiceCenter, eServiceReference, eEPGCache
13 def __init__(self, navcore, func=BOUQUETNOW, endtm=False):
16 self.navcore = navcore
17 self.epgcache = eEPGCache.getInstance()
21 def handleCommand(self, cmd):
25 if not self.command is None:
26 if self.func is self.SEARCHSIMILAR:
27 func = self.searchSimilarEvent
28 elif self.func is self.SEARCH:
29 func = self.searchEvent
30 elif self.func is self.SERVICE:
31 func = self.getEPGofService
32 elif self.func is self.BOUQUETNOW:
33 func = self.getBouquetEPGNow
34 elif self.func is self.BOUQUETNEXT:
35 func = self.getBouquetEPGNext
36 elif self.func is self.BOUQUET:
37 func = self.getEPGofBouquet
38 elif self.func is self.SERVICENOW:
39 func = self.getServiceEPGNow
40 elif self.func is self.SERVICENEXT:
41 func = self.getServiceEPGNext
43 return func(self.command)
46 def getBouquetEPGNow(self, ref):
47 return self.getEPGNowNext(ref, 0)
49 def getBouquetEPGNext(self, ref):
50 return self.getEPGNowNext(ref, 1)
52 def getServiceEPGNow(self, ref):
53 return self.getEPGNowNext(ref, 0, True)
55 def getServiceEPGNext(self, ref):
56 return self.getEPGNowNext(ref, 1, True)
58 def getEPGNowNext(self, ref, type, service=False):
59 print "[WebComponents.EPG] getting EPG NOW/NEXT", ref
62 events = self.epgcache.lookupEvent(['IBDCTSERNX', (ref, type, -1)])
64 serviceHandler = eServiceCenter.getInstance()
65 list = serviceHandler.list(eServiceReference(ref))
66 services = list and list.getContent('S')
67 search = ['IBDCTSERNX']
69 if services: # It's a Bouquet
70 search.extend([(service, type, -1) for service in services])
72 events = self.epgcache.lookupEvent(search)
78 def getEPGofService(self, ref, options='IBDCTSERN'):
79 print "getting EPG of Service", ref
80 events = self.epgcache.lookupEvent([options , (ref, 0, -1, -1)]);
83 list = self.insertEndTime(events)
89 def insertEndTime(self, events):
94 end = event[1] + event[2]
107 def getEPGofBouquet(self, param):
108 print "[WebComponents.EPG] getting EPG for Bouquet", param
110 if 'bRef' not in param:
115 if param['time'] is not None:
116 time = int(float(param['time']))
122 serviceHandler = eServiceCenter.getInstance()
123 sl = serviceHandler.list(eServiceReference(bRef))
124 services = sl and sl.getContent('S')
126 search = ['IBDCTSERN']
127 search.extend([(service, 0, time) for service in services])
129 events = self.epgcache.lookupEvent(search)
135 def searchEvent(self, needle):
136 print "[WebComponents.EPG] searching EPG: ", needle
138 events = self.epgcache.search(('IBDCTSERN', 256, eEPGCache.PARTIAL_TITLE_SEARCH, needle, 1));
143 def searchSimilarEvent(self, needle):
144 print "[WebComponents.EPG] searching similar eventid: ",needle
146 events = self.epgcache.search(('IBDCTSERN', 256, eEPGCache.SIMILAR_BROADCASTINGS_SEARCH, needle['sRef'], int(needle['eventid'])));
161 "DescriptionExtended": 7,
162 "ServiceReference": 8,
174 "DescriptionExtended": 6,
175 "ServiceReference": 7,
181 list = property(do_func)
183 lut = property(getLut)