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.setEvent(self.event)
43 self.setService(self.currentService)
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):
65 self.currentService=service
67 self["channel"].setText(_("Recording"))
69 name = self.currentService.getServiceName()
71 self["channel"].setText(name)
73 self["channel"].setText(_("unknown service"))
75 def sort_func(self,x,y):
83 def setEvent(self, event):
85 id = event.getEventId()
87 refstr = str(self.currentService)
88 epgcache = eEPGCache.getInstance()
89 text = event.getEventName()
90 short = event.getShortDescription()
91 ext = event.getExtendedDescription()
92 if len(short) > 0 and short != text:
93 text = text + '\n\n' + short
99 # search similar broadcastings
100 ret = epgcache.search(('NB', 100, eEPGCache.SIMILAR_BROADCASTINGS_SEARCH, refstr, id))
102 text += '\n\n' + _('Similar broadcasts:')
103 ret.sort(self.sort_func)
106 text += '\n%d.%d.%d, %02d:%02d - %s'%(t[2], t[1], t[0], t[3], t[4], x[0])
108 self.setTitle(event.getEventName())
109 self["epg_description"].setText(text)
110 self["datetime"].setText(event.getBeginTimeString())
111 self["duration"].setText(_("%d min")%(event.getDuration()/60))
114 self["epg_description"].pageUp()
117 self["epg_description"].pageDown()
119 class EventViewSimple(Screen, EventViewBase):
120 def __init__(self, session, Event, Ref, callback=None):
121 Screen.__init__(self, session)
122 self.skinName = "EventView"
123 EventViewBase.__init__(self, Event, Ref, callback)
125 class EventViewEPGSelect(Screen, EventViewBase):
126 def __init__(self, session, Event, Ref, callback=None, singleEPGCB=None, multiEPGCB=None):
127 Screen.__init__(self, session)
128 self.skinName = "EventView"
129 EventViewBase.__init__(self, Event, Ref, callback)
130 self["key_yellow"].setText(_("Single EPG"))
131 self["key_blue"].setText(_("Multi EPG"))
132 self["epgactions"] = ActionMap(["EventViewEPGActions"],
134 "openSingleServiceEPG": singleEPGCB,
135 "openMultiServiceEPG": multiEPGCB