1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.Button import Button
4 from Components.Label import Label
5 from Components.ScrollLabel import ScrollLabel
6 from enigma import eEPGCache, eTimer, eServiceReference
7 from RecordTimer import RecordTimerEntry, parseEvent
8 from TimerEntry import TimerEntry
9 from time import localtime
12 def __init__(self, Event, Ref, callback=None, similarEPGCB=None):
13 self.similarEPGCB = similarEPGCB
14 self.cbFunc = callback
15 self.currentService=Ref
16 self.isRecording = (not Ref.ref.flags & eServiceReference.isGroup) and len(Ref.ref.getPath())
18 self["epg_description"] = ScrollLabel()
19 self["datetime"] = Label()
20 self["channel"] = Label()
21 self["duration"] = Label()
22 self["key_red"] = Button("")
23 if similarEPGCB is not None:
24 self.SimilarBroadcastTimer = eTimer()
25 self.SimilarBroadcastTimer.timeout.get().append(self.getSimilarEvents)
27 self.SimilarBroadcastTimer = None
29 self["key_green"] = Button("")
31 self["key_green"] = Button(_("Add timer"))
32 self["key_yellow"] = Button("")
33 self["key_blue"] = Button("")
34 self["actions"] = ActionMap(["OkCancelActions", "EventViewActions"],
38 "pageUp": self.pageUp,
39 "pageDown": self.pageDown,
40 "prevEvent": self.prevEvent,
41 "nextEvent": self.nextEvent,
42 "timerAdd": self.timerAdd,
43 "openSimilarList": self.openSimilarList
45 self.onShown.append(self.onCreate)
48 self.setService(self.currentService)
49 self.setEvent(self.event)
52 if self.cbFunc is not None:
53 self.cbFunc(self.setEvent, self.setService, -1)
56 if self.cbFunc is not None:
57 self.cbFunc(self.setEvent, self.setService, +1)
60 if not self.isRecording:
61 newEntry = RecordTimerEntry(self.currentService, checkOldTimers = True, *parseEvent(self.event))
62 self.session.openWithCallback(self.timerEditFinished, TimerEntry, newEntry)
64 def timerEditFinished(self, answer):
66 self.session.nav.RecordTimer.record(answer[1])
68 print "Timeredit aborted"
70 def setService(self, service):
71 self.currentService=service
73 self["channel"].setText(_("Recording"))
75 name = self.currentService.getServiceName()
77 self["channel"].setText(name)
79 self["channel"].setText(_("unknown service"))
81 def sort_func(self,x,y):
89 def setEvent(self, event):
93 text = event.getEventName()
94 short = event.getShortDescription()
95 ext = event.getExtendedDescription()
96 if len(short) > 0 and short != text:
97 text = text + '\n\n' + short
103 self.setTitle(event.getEventName())
104 self["epg_description"].setText(text)
105 self["datetime"].setText(event.getBeginTimeString())
106 self["duration"].setText(_("%d min")%(event.getDuration()/60))
107 self["key_red"].setText("")
108 if self.SimilarBroadcastTimer is not None:
109 self.SimilarBroadcastTimer.start(400,True)
112 self["epg_description"].pageUp()
115 self["epg_description"].pageDown()
117 def getSimilarEvents(self):
118 # search similar broadcastings
119 refstr = str(self.currentService)
120 id = self.event.getEventId()
121 epgcache = eEPGCache.getInstance()
122 ret = epgcache.search(('NB', 100, eEPGCache.SIMILAR_BROADCASTINGS_SEARCH, refstr, id))
124 descr = self["epg_description"]
125 text = descr.getText()
126 text += '\n\n' + _('Similar broadcasts:')
127 ret.sort(self.sort_func)
130 text += '\n%d.%d.%d, %02d:%02d - %s'%(t[2], t[1], t[0], t[3], t[4], x[0])
132 self["key_red"].setText(_("Similar"))
134 def openSimilarList(self):
135 if self.similarEPGCB is not None and len(self["key_red"].getText()):
136 id = self.event and self.event.getEventId()
137 refstr = str(self.currentService)
139 self.similarEPGCB(id, refstr)
141 class EventViewSimple(Screen, EventViewBase):
142 def __init__(self, session, Event, Ref, callback=None, similarEPGCB=None):
143 Screen.__init__(self, session)
144 self.skinName = "EventView"
145 EventViewBase.__init__(self, Event, Ref, callback, similarEPGCB)
147 class EventViewEPGSelect(Screen, EventViewBase):
148 def __init__(self, session, Event, Ref, callback=None, singleEPGCB=None, multiEPGCB=None, similarEPGCB=None):
149 Screen.__init__(self, session)
150 self.skinName = "EventView"
151 EventViewBase.__init__(self, Event, Ref, callback, similarEPGCB)
152 self["key_yellow"].setText(_("Single EPG"))
153 self["key_blue"].setText(_("Multi EPG"))
154 self["epgactions"] = ActionMap(["EventViewEPGActions"],
156 "openSingleServiceEPG": singleEPGCB,
157 "openMultiServiceEPG": multiEPGCB,