fix epg now/next
[enigma2-plugins.git] / webinterface / src / WebComponents / Sources / EPG.py
1 from enigma import *
2
3 from Components.Sources.Source import Source
4 from ServiceReference import ServiceReference
5
6 class EPG( Source):
7     NOWNEXT=0
8     SERVICE=1
9     TITLE=2
10     
11     def __init__(self, navcore,func=NOWNEXT):
12         self.func = func
13         Source.__init__(self)        
14         self.navcore = navcore
15         self.epgcache = eEPGCache.getInstance()
16         
17     def handleCommand(self,cmd):
18         self.command = cmd
19
20     def do_func(self):
21         if self.func is self.TITLE:
22             func = self.searchEvent
23         elif self.func is self.SERVICE:
24             func = self.getEPGofService
25         else:
26             func = self.getEPGNowNext
27             
28         return func(self.command)
29     
30     def getEPGNowNext(self,serviceref):
31         print "getting EPG NOWNEXT", serviceref
32         events = self.epgcache.lookupEvent( ['IBDTSERNn',(serviceref,0,0,-1),(serviceref,0,1,-1)]);
33         if events:
34                 return events
35         else:
36                 return []
37     
38     def getEPGofService(self,cmd):
39         print "getting EPG of Service", cmd
40         events = self.epgcache.lookupEvent(['IBDTSERNn',(cmd,0,-1,-1)]);
41         if events:
42                 return events
43         else:
44                 return []
45     
46     def searchEvent(self,cmd):
47         print "getting EPG by title",cmd
48         events = self.epgcache.search(('IBDTSERNn',256,eEPGCache.PARTIAL_TITLE_SEARCH,cmd,1));
49         if events:
50             return events
51         else:
52             return []
53         
54     list = property(do_func)
55     lut = {"EventID": 0, "TimeStart": 1,"Duration": 2, "Title": 3, "Description": 4, "DescriptionExtended": 5, "ServiceReference": 6, "ServiceName": 7,"ShortServiceName": 8}
56
57