add extended description of timers
[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 from enigma import eServiceCenter, eServiceReference
6
7 class EPG( Source):
8     NOW=0
9     SERVICE=1
10     TITLE=2
11     
12     def __init__(self, navcore,func=NOW):
13         self.func = func
14         Source.__init__(self)        
15         self.navcore = navcore
16         self.epgcache = eEPGCache.getInstance()
17         
18     def handleCommand(self,cmd):
19         self.command = cmd
20
21     def do_func(self):
22         if self.func is self.TITLE:
23             func = self.searchEvent
24         elif self.func is self.SERVICE:
25             func = self.getEPGofService
26         else:
27             func = self.getEPGNow
28             
29         return func(self.command)
30     
31     def getEPGNow(self,bouqetref):
32         print "getting EPG NOW", bouqetref
33         serviceHandler = eServiceCenter.getInstance()
34         list = serviceHandler.list(eServiceReference(bouqetref))
35         services = list and list.getContent('S')
36         search = ['IBDTSERN']
37         for service in services:
38             search.append((service,0,-1))        
39         events = self.epgcache.lookupEvent(search);
40         if events:
41                 return events
42         else:
43                 return []
44     
45     def getEPGofService(self,cmd):
46         print "getting EPG of Service", cmd
47         events = self.epgcache.lookupEvent(['IBDTSERN',(cmd,0,-1,-1)]);
48         if events:
49                 return events
50         else:
51                 return []
52     
53     def searchEvent(self,cmd):
54         print "getting EPG by title",cmd
55         events = self.epgcache.search(('IBDTSERN',256,eEPGCache.PARTIAL_TITLE_SEARCH,cmd,1));
56         if events:
57             return events
58         else:
59             return []
60         
61     list = property(do_func)
62     lut = {"EventID": 0, "TimeStart": 1,"Duration": 2, "Title": 3, "Description": 4, "DescriptionExtended": 5, "ServiceReference": 6, "ServiceName": 7 }
63
64