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 eServiceEventPtr, eEPGCachePtr, eEPGCache
7 from ServiceReference import ServiceReference
8 from RecordTimer import RecordTimerEntry, parseEvent
9 from TimerEntry import TimerEntry
10 from time import localtime, asctime
13 def __init__(self, Event, Ref, callback=None):
14 self.cbFunc = callback
15 self.currentService=Ref
16 self.isRecording = 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("")
24 self["key_green"] = Button("")
26 self["key_green"] = Button(_("Add timer"))
27 self["key_yellow"] = Button("")
28 self["key_blue"] = Button("")
29 self["actions"] = ActionMap(["OkCancelActions", "EventViewActions"],
33 "pageUp": self.pageUp,
34 "pageDown": self.pageDown,
35 "prevEvent": self.prevEvent,
36 "nextEvent": self.nextEvent,
37 "timerAdd": self.timerAdd
39 self.onShown.append(self.onCreate)
42 self.setService(self.currentService)
43 self.setEvent(self.event)
46 if self.cbFunc is not None:
47 self.cbFunc(self.setEvent, self.setService, -1)
50 if self.cbFunc is not None:
51 self.cbFunc(self.setEvent, self.setService, +1)
54 if not self.isRecording:
55 newEntry = RecordTimerEntry(self.currentService, *parseEvent(self.event))
56 self.session.openWithCallback(self.timerEditFinished, TimerEntry, newEntry)
58 def timerEditFinished(self, answer):
60 self.session.nav.RecordTimer.record(answer[1])
62 print "Timeredit aborted"
64 def setService(self, service):
66 self.currentService=service
68 self["channel"].setText(_("Recording"))
70 name = self.currentService.getServiceName()
72 self["channel"].setText(name)
74 self["channel"].setText(_("unknown service"))
76 def sort_func(self,x,y):
84 def setEvent(self, event):
86 id = event.getEventId()
88 refstr = str(self.currentService)
89 epgcache = eEPGCache.getInstance()
90 text = event.getEventName()
91 short = event.getShortDescription()
92 ext = event.getExtendedDescription()
93 if len(short) > 0 and short != text:
94 text = text + '\n\n' + short
100 # search similar broadcastings
101 ret = epgcache.search(('NB', 100, eEPGCache.SIMILAR_BROADCASTINGS_SEARCH, refstr, id))
103 text += '\n\n' + _('Similar broadcasts:')
104 ret.sort(self.sort_func)
107 text += '\n%d.%d.%d, %02d:%02d - %s'%(t[2], t[1], t[0], t[3], t[4], x[0])
109 self.setTitle(event.getEventName())
110 self["epg_description"].setText(text)
111 self["datetime"].setText(event.getBeginTimeString())
112 self["duration"].setText(_("%d min")%(event.getDuration()/60))
115 self["epg_description"].pageUp()
118 self["epg_description"].pageDown()
120 class EventViewSimple(Screen, EventViewBase):
121 def __init__(self, session, Event, Ref, callback=None):
122 Screen.__init__(self, session)
123 self.skinName = "EventView"
124 EventViewBase.__init__(self, Event, Ref, callback)
126 class EventViewEPGSelect(Screen, EventViewBase):
127 def __init__(self, session, Event, Ref, callback=None, singleEPGCB=None, multiEPGCB=None):
128 Screen.__init__(self, session)
129 self.skinName = "EventView"
130 EventViewBase.__init__(self, Event, Ref, callback)
131 self["key_yellow"].setText(_("Single EPG"))
132 self["key_blue"].setText(_("Multi EPG"))
133 self["epgactions"] = ActionMap(["EventViewEPGActions"],
135 "openSingleServiceEPG": singleEPGCB,
136 "openMultiServiceEPG": multiEPGCB