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
10 from Components.config import config
13 def __init__(self, Event, Ref, callback=None, similarEPGCB=None):
14 self.similarEPGCB = similarEPGCB
15 self.cbFunc = callback
16 self.currentService=Ref
17 self.isRecording = (not Ref.ref.flags & eServiceReference.isGroup) and len(Ref.ref.getPath())
19 self["epg_description"] = ScrollLabel()
20 self["datetime"] = Label()
21 self["channel"] = Label()
22 self["duration"] = Label()
23 self["key_red"] = Button("")
24 if similarEPGCB is not None:
25 self.SimilarBroadcastTimer = eTimer()
26 self.SimilarBroadcastTimer.callback.append(self.getSimilarEvents)
28 self.SimilarBroadcastTimer = None
30 self["key_green"] = Button("")
32 self["key_green"] = Button(_("Add timer"))
33 self["key_yellow"] = Button("")
34 self["key_blue"] = Button("")
35 self["actions"] = ActionMap(["OkCancelActions", "EventViewActions"],
39 "pageUp": self.pageUp,
40 "pageDown": self.pageDown,
41 "prevEvent": self.prevEvent,
42 "nextEvent": self.nextEvent,
43 "timerAdd": self.timerAdd,
44 "openSimilarList": self.openSimilarList
46 self.onShown.append(self.onCreate)
49 self.setService(self.currentService)
50 self.setEvent(self.event)
53 if self.cbFunc is not None:
54 self.cbFunc(self.setEvent, self.setService, -1)
57 if self.cbFunc is not None:
58 self.cbFunc(self.setEvent, self.setService, +1)
61 if not self.isRecording:
62 newEntry = RecordTimerEntry(self.currentService, checkOldTimers = True, dirname = config.movielist.last_timer_videodir.value, *parseEvent(self.event))
63 self.session.openWithCallback(self.timerEditFinished, TimerEntry, newEntry)
65 def timerEditFinished(self, answer):
67 self.session.nav.RecordTimer.record(answer[1])
69 print "Timeredit aborted"
71 def setService(self, service):
72 self.currentService=service
74 self["channel"].setText(_("Recording"))
76 name = self.currentService.getServiceName()
78 self["channel"].setText(name)
80 self["channel"].setText(_("unknown service"))
82 def sort_func(self,x,y):
90 def setEvent(self, event):
94 text = event.getEventName()
95 short = event.getShortDescription()
96 ext = event.getExtendedDescription()
97 if len(short) > 0 and short != text:
98 text = text + '\n\n' + short
104 self.setTitle(event.getEventName())
105 self["epg_description"].setText(text)
106 self["datetime"].setText(event.getBeginTimeString())
107 self["duration"].setText(_("%d min")%(event.getDuration()/60))
108 self["key_red"].setText("")
109 if self.SimilarBroadcastTimer is not None:
110 self.SimilarBroadcastTimer.start(400,True)
113 self["epg_description"].pageUp()
116 self["epg_description"].pageDown()
118 def getSimilarEvents(self):
119 # search similar broadcastings
120 refstr = str(self.currentService)
121 id = self.event.getEventId()
122 epgcache = eEPGCache.getInstance()
123 ret = epgcache.search(('NB', 100, eEPGCache.SIMILAR_BROADCASTINGS_SEARCH, refstr, id))
125 descr = self["epg_description"]
126 text = descr.getText()
127 text += '\n\n' + _('Similar broadcasts:')
128 ret.sort(self.sort_func)
131 text += '\n%d.%d.%d, %02d:%02d - %s'%(t[2], t[1], t[0], t[3], t[4], x[0])
133 self["key_red"].setText(_("Similar"))
135 def openSimilarList(self):
136 if self.similarEPGCB is not None and len(self["key_red"].getText()):
137 id = self.event and self.event.getEventId()
138 refstr = str(self.currentService)
140 self.similarEPGCB(id, refstr)
142 class EventViewSimple(Screen, EventViewBase):
143 def __init__(self, session, Event, Ref, callback=None, similarEPGCB=None):
144 Screen.__init__(self, session)
145 self.skinName = "EventView"
146 EventViewBase.__init__(self, Event, Ref, callback, similarEPGCB)
148 class EventViewEPGSelect(Screen, EventViewBase):
149 def __init__(self, session, Event, Ref, callback=None, singleEPGCB=None, multiEPGCB=None, similarEPGCB=None):
150 Screen.__init__(self, session)
151 self.skinName = "EventView"
152 EventViewBase.__init__(self, Event, Ref, callback, similarEPGCB)
153 self["key_yellow"].setText(_("Single EPG"))
154 self["key_blue"].setText(_("Multi EPG"))
155 self["epgactions"] = ActionMap(["EventViewEPGActions"],
157 "openSingleServiceEPG": singleEPGCB,
158 "openMultiServiceEPG": multiEPGCB,