restructure a bit, add autoconf/automake for movietagger and antiscrollbar
[enigma2-plugins.git] / webinterface / src / usr / lib / enigma2 / python / Components / Sources / EPG.py
1 from enigma import *
2
3 from 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,cmd):
31         print "getting EPG NOWNEXT", cmd
32         events = self.epgcache.lookupEvent(['IBDTSERN',(cmd,0,0,-1)]);
33         if events:
34                 return self.convert(events)
35         else:
36                 return []
37     
38     def getEPGofService(self,cmd):
39         print "getting EPG of Service", cmd
40         events = self.epgcache.lookupEvent(['IBDTSERN',(cmd,0,-1,-1)]);
41         if events:
42                 return self.convert(events) 
43         else:
44                 return []
45     
46     def searchEvent(self,cmd):
47         print "getting EPG by title",cmd
48         events = self.epgcache.search(('IBDTSERN',1024,eEPGCache.PARTIAL_TITLE_SEARCH,cmd,1));
49         if events:
50             
51             return self.convert(events)
52         else:
53             return []
54     
55     def convert(self,input):
56         #this is not nice, but ",',<,> and & are controlchars in xml and must be replaced
57         output = []
58         for i in input:
59             o = []
60             for key in i:
61                 o.append(str(key).replace("<","&lt;").replace(">","&gt;").replace("&","&amp;").replace("\"","&quot;").replace("'","&apos;"))
62             output.append(o)
63             
64         return output
65     
66     list = property(do_func)
67     lut = {"EventID": 0, "TimeStart": 1,"Duration": 2, "Title": 3, "Description": 4, "DescriptionExtended": 5, "ServiceReference": 6, "ServiceName": 7}
68
69