Added Partnerbox Plugin (Remote Timer and Remote TV Player)
[enigma2-plugins.git] / partnerbox / src / Services.py
1 #
2 #  Partnerbox E2
3 #  Release: 0.93
4 #  Coded by Dr.Best (c) 2009
5 #  Support: www.dreambox-tools.info
6 #
7 #  This program is free software; you can redistribute it and/or
8 #  modify it under the terms of the GNU General Public License
9 #  as published by the Free Software Foundation; either version 2
10 #  of the License, or (at your option) any later version.
11 #
12 #  This program is distributed in the hope that it will be useful,
13 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #  GNU General Public License for more details.
16 #
17
18 from Components.Sources.Source import Source
19 from Components.Sources.ServiceList import ServiceList
20 from Screens.ChannelSelection import service_types_tv
21 from enigma import eServiceReference, eEPGCache
22
23
24 class E2EPGListAllData:
25         def __init__(self, servicereference = "", servicename = "", eventid = 0, eventstart = 0, eventduration = 0, eventtitle = "", eventdescription = "", eventdescriptionextended = ""):
26                 self.servicereference = servicereference
27                 self.servicename = servicename
28                 self.eventid = eventid
29                 self.eventstart = eventstart
30                 self.eventduration = eventduration
31                 self.eventtitle = eventtitle
32                 self.eventdescription = eventdescription
33                 self.eventdescriptionextended = eventdescriptionextended
34
35 class E2ServiceList:
36         def __init__(self, servicereference = "", servicename = ""):
37                 self.servicereference = servicereference
38                 self.servicename = servicename
39
40 class Services( Source ):
41         def __init__(self, session):
42                 Source.__init__(self)
43                 self.session = session
44                 self.servicelist = {}
45                 self.epgcache = eEPGCache.getInstance()
46         
47         def buildList(self, ref, epg):
48                 self.servicelist = ServiceList(ref, command_func = self.getServiceList, validate_commands=False)
49                 list = self.servicelist.getServicesAsList()
50                 E2List = [] 
51                 for index in range(len(list)): 
52                         item = list[index]
53                         servicereference = item[0]
54                         servicename = item[1]
55                         eventstart = 0
56                         eventduration = 0
57                         eventtitle = ""
58                         eventid = 0
59                         eventdescription = ""
60                         eventdescriptionextended = ""
61                         if epg:
62                                 epgref = item[0]
63                                 events = self.epgcache.lookupEvent(['IBDTSERNX', (epgref, 0, -1)])
64                                 if events:
65                                         if events[0][0] is not None:
66                                                 eventid =  events[0][0]
67                                         if events[0][1] is not None:
68                                                 eventstart =  events[0][1]
69                                         if events[0][2] is not None:
70                                                 eventduration =  events[0][2]
71                                         if events[0][3] is not None:
72                                                 eventtitle = events[0][3]
73                                         if events[0][4] is not None:
74                                                 eventdescription= events[0][4]
75                                         if events[0][5] is not None:
76                                                 eventdescriptionextended= events[0][5]
77                                 E2List.append(E2EPGListAllData(servicereference = servicereference, servicename = servicename, eventstart = eventstart, eventduration = eventduration, eventtitle = eventtitle, eventid = eventid, eventdescription= eventdescription, eventdescriptionextended = eventdescriptionextended))
78                         else:
79                                         E2List.append(E2ServiceList(servicereference = item[0], servicename = item[1]))
80                 return E2List
81
82         def buildEPGList(self, ref):
83                 E2List = [] 
84                 events = self.epgcache.lookupEvent(['IBDTSERN',(ref,0,-1,-1)]);
85                 if events:
86                         for item in events:
87                                 servicereference = ""
88                                 servicename = ""
89                                 eventstart = 0
90                                 eventduration = 0
91                                 eventtitle = ""
92                                 eventid = 0
93                                 eventdescription = ""
94                                 eventdescriptionextended = ""
95                                 if item[6] is not None:
96                                         servicereference = item[6]
97                                 if item[7] is not None:
98                                         servicename = item[7]
99                                 if item[1] is not None:
100                                         eventstart = item[1]
101                                 if item[2] is not None:
102                                         eventduration = item[2]
103                                 if item[3] is not None:
104                                         eventtitle = item[3]
105                                 if item[0] is not None:
106                                         eventid = item[0]
107                                 if item[4] is not None:
108                                         eventdescription = item[4]
109                                 if item[5] is not None:
110                                         eventdescriptionextended = item[5]
111                                 if eventstart != 0:
112                                         E2List.append(E2EPGListAllData(servicereference = servicereference, servicename = servicename, eventstart = eventstart, eventduration = eventduration, eventtitle = eventtitle, eventid = eventid, eventdescription= eventdescription, eventdescriptionextended = eventdescriptionextended))
113                 return E2List
114         
115         def getServiceList(self, ref):
116                 self.servicelist.root = ref