1 from Components.Sources.Source import Source
2 from ServiceReference import ServiceReference
3 from enigma import eServiceCenter, eServiceReference, eEPGCache
14 def __init__(self, navcore, func=BOUQUETNOW, endtm=False):
17 self.navcore = navcore
18 self.epgcache = eEPGCache.getInstance()
22 def handleCommand(self, cmd):
26 if not self.command is None:
27 if self.func is self.SEARCHSIMILAR:
28 func = self.searchSimilarEvent
29 elif self.func is self.SEARCH:
30 func = self.searchEvent
31 elif self.func is self.SERVICE:
32 func = self.getEPGofService
33 elif self.func is self.BOUQUETNOW:
34 func = self.getBouquetEPGNow
35 elif self.func is self.BOUQUETNEXT:
36 func = self.getBouquetEPGNext
37 elif self.func is self.BOUQUET:
38 func = self.getEPGofBouquet
39 elif self.func is self.SERVICENOW:
40 func = self.getServiceEPGNow
41 elif self.func is self.SERVICENEXT:
42 func = self.getServiceEPGNext
44 return func(self.command)
47 def getBouquetEPGNow(self, ref):
48 return self.getEPGNowNext(ref, 0)
50 def getBouquetEPGNext(self, ref):
51 return self.getEPGNowNext(ref, 1)
53 def getServiceEPGNow(self, ref):
54 return self.getEPGNowNext(ref, 0, True)
56 def getServiceEPGNext(self, ref):
57 return self.getEPGNowNext(ref, 1, True)
59 def getEPGNowNext(self, ref, type, service=False):
60 print "[WebComponents.EPG] getting EPG NOW/NEXT", ref
63 events = self.epgcache.lookupEvent(['IBDTSERNX', (ref, type, -1)])
65 serviceHandler = eServiceCenter.getInstance()
66 list = serviceHandler.list(eServiceReference(ref))
67 services = list and list.getContent('S')
68 search = ['IBDTSERNX']
70 if services: # It's a Bouquet
71 search.extend([(service, type, -1) for service in services])
73 events = self.epgcache.lookupEvent(search)
79 def getEPGofService(self, ref, options='IBDTSERN'):
80 print "getting EPG of Service", ref
81 events = self.epgcache.lookupEvent([options , (ref, 0, -1, -1)]);
84 list = self.insertEndTime(events)
90 def insertEndTime(self, events):
95 end = event[1] + event[2]
108 def getEPGofBouquet(self, param):
109 print "[WebComponents.EPG] getting EPG for Bouquet", param
111 if not param.has_key('bRef'):
115 if param.has_key('time'):
116 if param['time'] is not None:
117 time = int(float(param['time']))
123 serviceHandler = eServiceCenter.getInstance()
124 sl = serviceHandler.list(eServiceReference(bRef))
125 services = sl and sl.getContent('S')
127 search = ['IBDTSERN']
128 search.extend([(service, 0, time) for service in services])
130 events = self.epgcache.lookupEvent(search)
136 def searchEvent(self, needle):
137 print "[WebComponents.EPG] searching EPG: ", needle
139 events = self.epgcache.search(('IBDTSERN', 256, eEPGCache.PARTIAL_TITLE_SEARCH, needle, 1));
144 def searchSimilarEvent(self, needle):
145 print "[WebComponents.EPG] searching similar eventid: ",needle
147 events = self.epgcache.search(('IBDTSERN', 256, eEPGCache.SIMILAR_BROADCASTINGS_SEARCH, needle['sRef'], int(needle['eventid'])));
161 "DescriptionExtended": 6,
162 "ServiceReference": 7,
173 "DescriptionExtended": 5,
174 "ServiceReference": 6,
180 list = property(do_func)
182 lut = property(getLut)