/
EpgSelection.py
1534 lines (1424 loc) · 58.3 KB
/
EpgSelection.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from time import localtime, time, strftime, mktime
from enigma import eServiceReference, eTimer, eServiceCenter, ePoint
from Screen import Screen
from Screens.HelpMenu import HelpableScreen
from Components.About import about
from Components.ActionMap import HelpableActionMap, HelpableNumberActionMap
from Components.Button import Button
from Components.config import config, configfile, ConfigClock
from Components.EpgList import EPGList, EPGBouquetList, TimelineText, EPG_TYPE_SINGLE, EPG_TYPE_SIMILAR, EPG_TYPE_MULTI, EPG_TYPE_ENHANCED, EPG_TYPE_INFOBAR, EPG_TYPE_INFOBARGRAPH, EPG_TYPE_GRAPH, MAX_TIMELINES
from Components.Label import Label
from Components.Pixmap import Pixmap
from Components.Sources.ServiceEvent import ServiceEvent
from Components.Sources.Event import Event
from Components.UsageConfig import preferredTimerPath
from Screens.TimerEdit import TimerSanityConflict
from Screens.EventView import EventViewEPGSelect, EventViewSimple
from Screens.ChoiceBox import ChoiceBox
from Screens.MessageBox import MessageBox
from Screens.PictureInPicture import PictureInPicture
from Screens.Setup import Setup
from TimeDateInput import TimeDateInput
from RecordTimer import RecordTimerEntry, parseEvent, AFTEREVENT
from TimerEntry import TimerEntry, InstantRecordTimerEntry
from ServiceReference import ServiceReference
from Tools.HardwareInfo import HardwareInfo
mepg_config_initialized = False
# PiPServiceRelation installed?
try:
from Plugins.SystemPlugins.PiPServiceRelation.plugin import getRelationDict
plugin_PiPServiceRelation_installed = True
except:
plugin_PiPServiceRelation_installed = False
class EPGSelection(Screen, HelpableScreen):
EMPTY = 0
ADD_TIMER = 1
REMOVE_TIMER = 2
ZAP = 1
def __init__(self, session, service = None, zapFunc = None, eventid = None, bouquetChangeCB=None, serviceChangeCB = None, EPGtype = None, StartBouquet = None, StartRef = None, bouquets = None):
Screen.__init__(self, session)
HelpableScreen.__init__(self)
self.zapFunc = zapFunc
self.serviceChangeCB = serviceChangeCB
self.bouquets = bouquets
graphic = False
if EPGtype == 'single':
self.type = EPG_TYPE_SINGLE
elif EPGtype == 'infobar':
self.type = EPG_TYPE_INFOBAR
elif EPGtype == 'enhanced':
self.type = EPG_TYPE_ENHANCED
elif EPGtype == 'graph':
self.type = EPG_TYPE_GRAPH
if config.epgselection.graph_type_mode.value == "graphics":
graphic = True
elif EPGtype == 'infobargraph':
self.type = EPG_TYPE_INFOBARGRAPH
if config.epgselection.infobar_type_mode.value == "graphics":
graphic = True
elif EPGtype == 'multi':
self.type = EPG_TYPE_MULTI
else:
self.type = EPG_TYPE_SIMILAR
if not self.type == EPG_TYPE_SINGLE:
self.StartBouquet = StartBouquet
self.StartRef = StartRef
self.servicelist = None
self.ChoiceBoxDialog = None
self.ask_time = -1
self.closeRecursive = False
self.eventviewDialog = None
self.eventviewWasShown = False
self.currch = None
self.session.pipshown = False
self.cureventindex = None
if plugin_PiPServiceRelation_installed:
self.pipServiceRelation = getRelationDict()
else:
self.pipServiceRelation = {}
self.zapnumberstarted = False
self.NumberZapTimer = eTimer()
self.NumberZapTimer.callback.append(self.dozumberzap)
self.NumberZapField = None
self.CurrBouquet = None
self.CurrService = None
self["number"] = Label()
self["number"].hide()
self['Service'] = ServiceEvent()
self['Event'] = Event()
self['lab1'] = Label(_('Please wait while gathering EPG data...'))
self.key_green_choice = self.EMPTY
self['key_red'] = Button(_('IMDb search'))
self['key_green'] = Button(_('Add timer'))
self['key_yellow'] = Button(_('EPG search'))
self['key_blue'] = Button(_('Add Autotimer'))
self['dialogactions'] = HelpableActionMap(self, 'WizardActions',
{
'back': (self.closeChoiceBoxDialog, _('Close dialog')),
}, -1)
self['dialogactions'].csel = self
self["dialogactions"].setEnabled(False)
self['okactions'] = HelpableActionMap(self, 'OkCancelActions',
{
'cancel': (self.closeScreen, _('Exit EPG')),
'OK': (self.OK, _('Zap to channel (setup in menu)')),
'OKLong': (self.OKLong, _('Zap to channel and close (setup in menu)'))
}, -1)
self['okactions'].csel = self
self['colouractions'] = HelpableActionMap(self, 'ColorActions',
{
'red': (self.redButtonPressed, _('IMDB search for current event')),
'redlong': (self.redButtonPressedLong, _('Sort EPG list')),
'green': (self.greenButtonPressed, _('Add/Remove timer for current event')),
'greenlong': (self.greenButtonPressedLong, _('Show timer list')),
'yellow': (self.yellowButtonPressed, _('Search for similar events')),
'blue': (self.blueButtonPressed, _('Add an autotimer for current event')),
'bluelong': (self.blueButtonPressedLong, _('Show Autotimer list'))
}, -1)
self['colouractions'].csel = self
self['recordingactions'] = HelpableActionMap(self, 'InfobarInstantRecord',
{
'ShortRecord': (self.recButtonPressed, _('Add a record timer for current event')),
'LongRecord': (self.recButtonPressedLong, _('Add a zap timer for current event'))
}, -1)
self['recordingactions'].csel = self
if self.type == EPG_TYPE_SIMILAR:
self.currentService = service
self.eventid = eventid
self['epgactions'] = HelpableActionMap(self, 'EPGSelectActions',
{
'info': (self.Info, _('Show detailed event info')),
'infolong': (self.InfoLong, _('Show single epg for current channel')),
'menu': (self.createSetup, _('Setup menu'))
}, -1)
self['epgactions'].csel = self
elif self.type == EPG_TYPE_SINGLE:
self.currentService = ServiceReference(service)
self['epgactions'] = HelpableActionMap(self, 'EPGSelectActions',
{
'info': (self.Info, _('Show detailed event info')),
'epg': (self.Info, _('Show detailed event info')),
'menu': (self.createSetup, _('Setup menu'))
}, -1)
self['epgactions'].csel = self
self['epgcursoractions'] = HelpableActionMap(self, 'DirectionActions',
{
'left': (self.prevPage, _('Move up a page')),
'right': (self.nextPage, _('Move down a page')),
'up': (self.moveUp, _('Go to previous channel')),
'down': (self.moveDown, _('Go to next channel'))
}, -1)
self['epgcursoractions'].csel = self
elif self.type == EPG_TYPE_INFOBAR or self.type == EPG_TYPE_ENHANCED:
if self.type == EPG_TYPE_INFOBAR:
self.skinName = 'QuickEPG'
self['epgactions'] = HelpableActionMap(self, 'EPGSelectActions',
{
'nextBouquet': (self.nextBouquet, _('Go to next bouquet')),
'prevBouquet': (self.prevBouquet, _('Go to previous bouquet')),
'nextService': (self.nextPage, _('Move down a page')),
'prevService': (self.prevPage, _('Move up a page')),
'input_date_time': (self.enterDateTime, _('Go to specific data/time')),
'epg': (self.epgButtonPressed, _('Show single epg for current channel')),
'info': (self.Info, _('Show detailed event info')),
'infolong': (self.InfoLong, _('Show single epg for current channel')),
'menu': (self.createSetup, _('Setup menu'))
}, -1)
self['epgactions'].csel = self
self['epgcursoractions'] = HelpableActionMap(self, 'DirectionActions',
{
'left': (self.prevService, _('Go to previous channel')),
'right': (self.nextService, _('Go to next channel')),
'up': (self.moveUp, _('Go to previous channel')),
'down': (self.moveDown, _('Go to next channel'))
}, -1)
self['epgcursoractions'].csel = self
elif self.type == EPG_TYPE_ENHANCED:
self['epgactions'] = HelpableActionMap(self, 'EPGSelectActions',
{
'nextBouquet': (self.nextBouquet, _('Go to next bouquet')),
'prevBouquet': (self.prevBouquet, _('Go to previous bouquet')),
'nextService': (self.nextService, _('Go to next channel')),
'prevService': (self.prevService, _('Go to previous channel')),
'input_date_time': (self.enterDateTime, _('Go to specific data/time')),
'info': (self.Info, _('Show detailed event info')),
'infolong': (self.InfoLong, _('Show single epg for current channel')),
'menu': (self.createSetup, _('Setup menu'))
}, -1)
self['epgactions'].csel = self
self['epgcursoractions'] = HelpableActionMap(self, 'DirectionActions',
{
'left': (self.prevPage, _('Move up a page')),
'right': (self.nextPage, _('Move down a page')),
'up': (self.moveUp, _('Go to previous channel')),
'down': (self.moveDown, _('Go to next channel'))
}, -1)
self['epgcursoractions'].csel = self
self['input_actions'] = HelpableNumberActionMap(self, 'NumberActions',
{
'0': (self.keyNumberGlobal, _('enter number to jump to channel.')),
'1': (self.keyNumberGlobal, _('enter number to jump to channel.')),
'2': (self.keyNumberGlobal, _('enter number to jump to channel.')),
'3': (self.keyNumberGlobal, _('enter number to jump to channel.')),
'4': (self.keyNumberGlobal, _('enter number to jump to channel.')),
'5': (self.keyNumberGlobal, _('enter number to jump to channel.')),
'6': (self.keyNumberGlobal, _('enter number to jump to channel.')),
'7': (self.keyNumberGlobal, _('enter number to jump to channel.')),
'8': (self.keyNumberGlobal, _('enter number to jump to channel.')),
'9': (self.keyNumberGlobal, _('enter number to jump to channel.'))
}, -1)
self['input_actions'].csel = self
self.list = []
self.servicelist = service
self.currentService = self.session.nav.getCurrentlyPlayingServiceOrGroup()
elif self.type == EPG_TYPE_GRAPH or self.type == EPG_TYPE_INFOBARGRAPH:
if self.type == EPG_TYPE_GRAPH:
if not config.epgselection.graph_pig.value:
self.skinName = 'GraphicalEPG'
else:
self.skinName = 'GraphicalEPGPIG'
elif self.type == EPG_TYPE_INFOBARGRAPH:
self.skinName = 'GraphicalInfoBarEPG'
now = time() - int(config.epg.histminutes.value) * 60
if self.type == EPG_TYPE_GRAPH:
self.ask_time = self.ask_time = now - now % (int(config.epgselection.graph_roundto.value) * 60)
elif self.type == EPG_TYPE_INFOBARGRAPH:
self.ask_time = self.ask_time = now - now % (int(config.epgselection.infobar_roundto.value) * 60)
self.closeRecursive = False
self.bouquetlist_active = False
self['bouquetlist'] = EPGBouquetList(graphic=graphic)
self['bouquetlist'].hide()
self['timeline_text'] = TimelineText(type=self.type,graphic=graphic)
self['Event'] = Event()
self['primetime'] = Label(_('PRIMETIME'))
self['change_bouquet'] = Label(_('CHANGE BOUQUET'))
self['jump'] = Label(_('JUMP 24 HOURS'))
self['page'] = Label(_('PAGE UP/DOWN'))
self.time_lines = []
for x in range(0, MAX_TIMELINES):
pm = Pixmap()
self.time_lines.append(pm)
self['timeline%d' % x] = pm
self['timeline_now'] = Pixmap()
self.updateTimelineTimer = eTimer()
self.updateTimelineTimer.callback.append(self.moveTimeLines)
self.updateTimelineTimer.start(60000)
self['bouquetokactions'] = HelpableActionMap(self, 'OkCancelActions',
{
'cancel': (self.BouquetlistHide, _('Close bouquet list.')),
'OK': (self.BouquetOK, _('Change to bouquet')),
}, -1)
self['bouquetokactions'].csel = self
self["bouquetokactions"].setEnabled(False)
self['bouquetcursoractions'] = HelpableActionMap(self, 'DirectionActions',
{
'left': (self.moveBouquetPageUp, _('Go to previous event')),
'right': (self.moveBouquetPageDown, _('Go to next event')),
'up': (self.moveBouquetUp, _('Go to previous channel')),
'down': (self.moveBouquetDown, _('Go to next channel'))
}, -1)
self['bouquetcursoractions'].csel = self
self["bouquetcursoractions"].setEnabled(False)
self['epgcursoractions'] = HelpableActionMap(self, 'DirectionActions',
{
'left': (self.leftPressed, _('Go to previous event')),
'right': (self.rightPressed, _('Go to next event')),
'up': (self.moveUp, _('Go to previous channel')),
'down': (self.moveDown, _('Go to next channel'))
}, -1)
self['epgcursoractions'].csel = self
self['epgactions'] = HelpableActionMap(self, 'EPGSelectActions',
{
'nextService': (self.nextService, _('Jump forward 24 hours')),
'prevService': (self.prevService, _('Jump back 24 hours')),
'nextBouquet': (self.nextBouquet, _('Go to next bouquet')),
'prevBouquet': (self.prevBouquet, _('Go to previous bouquet')),
'input_date_time': (self.enterDateTime, _('Go to specific data/time')),
'epg': (self.epgButtonPressed, _('Show single epg for current channel')),
'info': (self.Info, _('Show detailed event info')),
'infolong': (self.InfoLong, _('Show single epg for current channel')),
'tv': (self.Bouquetlist, _('Toggle between bouquet/epg lists')),
'tvlong': (self.togglePIG, _('Toggle picture In graphics')),
'menu': (self.createSetup, _('Setup menu'))
}, -1)
self['epgactions'].csel = self
self['input_actions'] = HelpableNumberActionMap(self, 'NumberActions',
{
'1': (self.keyNumberGlobal, _('Reduce time scale')),
'2': (self.keyNumberGlobal, _('Page up')),
'3': (self.keyNumberGlobal, _('Increase time scale')),
'4': (self.keyNumberGlobal, _('page left')),
'5': (self.keyNumberGlobal, _('Jump to current time')),
'6': (self.keyNumberGlobal, _('Page right')),
'7': (self.keyNumberGlobal, _('No of items switch (increase or reduced)')),
'8': (self.keyNumberGlobal, _('Page down')),
'9': (self.keyNumberGlobal, _('Jump to prime time')),
'0': (self.keyNumberGlobal, _('Move to home of list'))
}, -1)
self['input_actions'].csel = self
elif self.type == EPG_TYPE_MULTI:
self.skinName = 'EPGSelectionMulti'
self['bouquetlist'] = EPGBouquetList(graphic=graphic)
self['bouquetlist'].hide()
self['now_button'] = Pixmap()
self['next_button'] = Pixmap()
self['more_button'] = Pixmap()
self['now_button_sel'] = Pixmap()
self['next_button_sel'] = Pixmap()
self['more_button_sel'] = Pixmap()
self['now_text'] = Label()
self['next_text'] = Label()
self['more_text'] = Label()
self['date'] = Label()
self.bouquetlist_active = False
self['bouquetokactions'] = HelpableActionMap(self, 'OkCancelActions',
{
'OK': (self.BouquetOK, _('Change to bouquet')),
}, -1)
self['bouquetokactions'].csel = self
self["bouquetokactions"].setEnabled(False)
self['bouquetcursoractions'] = HelpableActionMap(self, 'DirectionActions',
{
'left': (self.moveBouquetPageUp, _('Go to previous event')),
'right': (self.moveBouquetPageDown, _('Go to next event')),
'up': (self.moveBouquetUp, _('Go to previous channel')),
'down': (self.moveBouquetDown, _('Go to next channel'))
}, -1)
self['bouquetcursoractions'].csel = self
self['bouquetcursoractions'].setEnabled(False)
self['epgcursoractions'] = HelpableActionMap(self, 'DirectionActions',
{
'left': (self.leftPressed, _('Go to previous event')),
'right': (self.rightPressed, _('Go to next event')),
'up': (self.moveUp, _('Go to previous channel')),
'down': (self.moveDown, _('Go to next channel'))
}, -1)
self['epgcursoractions'].csel = self
self['epgactions'] = HelpableActionMap(self, 'EPGSelectActions',
{
'nextService': (self.nextPage, _('Move down a page')),
'prevService': (self.prevPage, _('Move up a page')),
'nextBouquet': (self.nextBouquet, _('Go to next bouquet')),
'prevBouquet': (self.prevBouquet, _('Go to previous bouquet')),
'input_date_time': (self.enterDateTime, _('Go to specific data/time')),
'epg': (self.epgButtonPressed, _('Show single epg for current channel')),
'info': (self.Info, _('Show detailed event info')),
'infolong': (self.InfoLong, _('Show single epg for current channel')),
'tv': (self.Bouquetlist, _('Toggle between bouquet/epg lists')),
'menu': (self.createSetup, _('Setup menu'))
}, -1)
self['epgactions'].csel = self
if self.type == EPG_TYPE_GRAPH:
time_epoch=int(config.epgselection.graph_prevtimeperiod.value)
elif self.type == EPG_TYPE_INFOBARGRAPH:
time_epoch=int(config.epgselection.infobar_prevtimeperiod.value)
else:
time_epoch=None
self['list'] = EPGList(type=self.type, selChangedCB=self.onSelectionChanged, timer=session.nav.RecordTimer, time_epoch=time_epoch, overjump_empty=config.epgselection.overjump.value, graphic=graphic)
self.refreshTimer = eTimer()
self.refreshTimer.timeout.get().append(self.refreshlist)
self.listTimer = eTimer()
self.listTimer.callback.append(self.hidewaitingtext)
if not HardwareInfo().is_nextgen():
self.createTimer = eTimer()
self.createTimer.callback.append(self.onCreate)
self.onLayoutFinish.append(self.LayoutFinish)
else:
self.onLayoutFinish.append(self.onCreate)
def createSetup(self):
self.closeEventViewDialog()
key = None
if self.type == EPG_TYPE_SINGLE:
key = 'epgsingle'
elif self.type == EPG_TYPE_MULTI:
key = 'epgmulti'
elif self.type == EPG_TYPE_ENHANCED:
key = 'epgenhanced'
elif self.type == EPG_TYPE_INFOBAR:
key = 'epginfobar'
elif self.type == EPG_TYPE_GRAPH:
key = 'epggraphical'
elif self.type == EPG_TYPE_INFOBARGRAPH:
key = 'epginfobargraphical'
if key:
self.session.openWithCallback(self.onSetupClose, Setup, key)
def onSetupClose(self, test = None):
if self.type == EPG_TYPE_GRAPH or self.type == EPG_TYPE_INFOBARGRAPH:
if self.type == EPG_TYPE_GRAPH:
self.close('reopengraph')
elif self.type == EPG_TYPE_INFOBARGRAPH:
self.close('reopeninfobargraph')
else:
if self.type == EPG_TYPE_INFOBAR:
self.close('reopeninfobar')
def togglePIG(self):
if not config.epgselection.graph_pig.value:
config.epgselection.graph_pig.setValue(True)
else:
config.epgselection.graph_pig.setValue(False)
config.epgselection.graph_pig.save()
configfile.save()
self.close('reopengraph')
def hidewaitingtext(self):
self.listTimer.stop()
if self.type == EPG_TYPE_MULTI:
self['list'].moveToService(self.session.nav.getCurrentlyPlayingServiceOrGroup())
self['lab1'].hide()
def getBouquetServices(self, bouquet):
services = []
servicelist = eServiceCenter.getInstance().list(bouquet)
if not servicelist is None:
while True:
service = servicelist.getNext()
if not service.valid(): #check if end of list
break
if service.flags & (eServiceReference.isDirectory | eServiceReference.isMarker): #ignore non playable services
continue
services.append(ServiceReference(service))
return services
def LayoutFinish(self):
self['lab1'].show()
self.createTimer.start(800)
def onCreate(self):
if not HardwareInfo().is_nextgen():
self.createTimer.stop()
serviceref = self.session.nav.getCurrentlyPlayingServiceOrGroup()
title = None
self['list'].recalcEntrySize()
self.BouquetRoot = False
if self.type == EPG_TYPE_GRAPH or self.type == EPG_TYPE_INFOBARGRAPH:
self.getCurrentCursorLocation = None
if self.StartBouquet.toString().startswith('1:7:0'):
self.BouquetRoot = True
self.services = self.getBouquetServices(self.StartBouquet)
self['list'].fillGraphEPG(self.services, self.ask_time)
self['list'].moveToService(serviceref)
self['list'].setCurrentlyPlaying(serviceref)
self['bouquetlist'].recalcEntrySize()
self['bouquetlist'].fillBouquetList(self.bouquets)
self['bouquetlist'].moveToService(self.StartBouquet)
self['bouquetlist'].setCurrentBouquet(self.StartBouquet)
self.setTitle(self['bouquetlist'].getCurrentBouquet())
if self.type == EPG_TYPE_GRAPH:
self['list'].setShowServiceMode(config.epgselection.graph_servicetitle_mode.value)
self.moveTimeLines()
if config.epgselection.graph_channel1.value:
self['list'].instance.moveSelectionTo(0)
elif self.type == EPG_TYPE_INFOBARGRAPH:
self['list'].setShowServiceMode(config.epgselection.infobar_servicetitle_mode.value)
self.moveTimeLines()
elif self.type == EPG_TYPE_MULTI:
self['bouquetlist'].recalcEntrySize()
self['bouquetlist'].fillBouquetList(self.bouquets)
self['bouquetlist'].moveToService(self.StartBouquet)
self['bouquetlist'].fillBouquetList(self.bouquets)
self.services = self.getBouquetServices(self.StartBouquet)
self['list'].fillMultiEPG(self.services, self.ask_time)
self['list'].setCurrentlyPlaying(serviceref)
self.setTitle(self['bouquetlist'].getCurrentBouquet())
elif self.type == EPG_TYPE_SINGLE or self.type == EPG_TYPE_ENHANCED or self.type == EPG_TYPE_INFOBAR:
if self.type == EPG_TYPE_SINGLE:
service = self.currentService
elif self.type == EPG_TYPE_ENHANCED or self.type == EPG_TYPE_INFOBAR:
service = ServiceReference(self.servicelist.getCurrentSelection())
title = ServiceReference(self.servicelist.getRoot()).getServiceName()
self['Service'].newService(service.ref)
if title:
title = title + ' - ' + service.getServiceName()
else:
title = service.getServiceName()
self.setTitle(title)
self['list'].fillSingleEPG(service)
self['list'].sortSingleEPG(int(config.epgselection.sort.value))
else:
self['list'].fillSimilarList(self.currentService, self.eventid)
self.listTimer.start(10)
def refreshlist(self):
self.refreshTimer.stop()
if self.type == EPG_TYPE_GRAPH or self.type == EPG_TYPE_INFOBARGRAPH:
if self.getCurrentCursorLocation:
self.ask_time = self.getCurrentCursorLocation
self.getCurrentCursorLocation = None
self['list'].fillGraphEPG(None, self.ask_time)
self.moveTimeLines()
elif self.type == EPG_TYPE_MULTI:
self['list'].fillMultiEPG(self.services, self.ask_time)
elif self.type == EPG_TYPE_SINGLE or self.type == EPG_TYPE_ENHANCED or self.type == EPG_TYPE_INFOBAR:
try:
if self.type == EPG_TYPE_SINGLE:
service = self.currentService
elif self.type == EPG_TYPE_ENHANCED or self.type == EPG_TYPE_INFOBAR:
service = ServiceReference(self.servicelist.getCurrentSelection())
if not self.cureventindex:
index = self['list'].getCurrentIndex()
else:
index = self.cureventindex
self.cureventindex = None
self['list'].fillSingleEPG(service)
self['list'].sortSingleEPG(int(config.epgselection.sort.value))
self['list'].setCurrentIndex(index)
except:
pass
def moveUp(self):
self['list'].moveTo(self['list'].instance.moveUp)
def moveDown(self):
self['list'].moveTo(self['list'].instance.moveDown)
def updEvent(self, dir, visible = True):
ret = self['list'].selEntry(dir, visible)
if ret:
self.moveTimeLines(True)
def nextPage(self):
self['list'].moveTo(self['list'].instance.pageDown)
def prevPage(self):
self['list'].moveTo(self['list'].instance.pageUp)
def toTop(self):
self['list'].moveTo(self['list'].instance.moveTop)
def toEnd(self):
self['list'].moveTo(self['list'].instance.moveEnd)
def leftPressed(self):
if self.type == EPG_TYPE_MULTI:
self['list'].updateMultiEPG(-1)
else:
self.updEvent(-1)
def rightPressed(self):
if self.type == EPG_TYPE_MULTI:
self['list'].updateMultiEPG(1)
else:
self.updEvent(+1)
def Bouquetlist(self):
if not self.bouquetlist_active:
self.BouquetlistShow()
else:
self.BouquetlistHide()
def BouquetlistShow(self):
self.curindex = self['bouquetlist'].l.getCurrentSelectionIndex()
self["epgcursoractions"].setEnabled(False)
self["okactions"].setEnabled(False)
self['bouquetlist'].show()
self["bouquetokactions"].setEnabled(True)
self["bouquetcursoractions"].setEnabled(True)
self.bouquetlist_active = True
def BouquetlistHide(self, cancel=True):
self["bouquetokactions"].setEnabled(False)
self["bouquetcursoractions"].setEnabled(False)
self['bouquetlist'].hide()
if cancel:
self['bouquetlist'].setCurrentIndex(self.curindex)
self["okactions"].setEnabled(True)
self["epgcursoractions"].setEnabled(True)
self.bouquetlist_active = False
def getCurrentBouquet(self):
if self.BouquetRoot:
return self.StartBouquet
elif self.has_key('bouquetlist'):
cur = self["bouquetlist"].l.getCurrentSelection()
return cur and cur[1]
else:
return self.servicelist.getRoot()
def BouquetOK(self):
self.BouquetRoot = False
now = time() - int(config.epg.histminutes.value) * 60
self.services = self.getBouquetServices(self.getCurrentBouquet())
if self.type == EPG_TYPE_GRAPH or self.type == EPG_TYPE_INFOBARGRAPH:
if self.type == EPG_TYPE_GRAPH:
self.ask_time = self.ask_time = now - now % (int(config.epgselection.graph_roundto.value) * 60)
elif self.type == EPG_TYPE_INFOBARGRAPH:
self.ask_time = self.ask_time = now - now % (int(config.epgselection.infobar_roundto.value) * 60)
self['list'].resetOffset()
self['list'].fillGraphEPG(self.services, self.ask_time)
self.moveTimeLines(True)
elif self.type == EPG_TYPE_MULTI:
self['list'].fillMultiEPG(self.services, self.ask_time)
self['list'].instance.moveSelectionTo(0)
self.setTitle(self['bouquetlist'].getCurrentBouquet())
self.BouquetlistHide(False)
def moveBouquetUp(self):
self['bouquetlist'].moveTo(self['bouquetlist'].instance.moveUp)
self['bouquetlist'].fillBouquetList(self.bouquets)
def moveBouquetDown(self):
self['bouquetlist'].moveTo(self['bouquetlist'].instance.moveDown)
self['bouquetlist'].fillBouquetList(self.bouquets)
def moveBouquetPageUp(self):
self['bouquetlist'].moveTo(self['bouquetlist'].instance.pageUp)
self['bouquetlist'].fillBouquetList(self.bouquets)
def moveBouquetPageDown(self):
self['bouquetlist'].moveTo(self['bouquetlist'].instance.pageDown)
self['bouquetlist'].fillBouquetList(self.bouquets)
def nextBouquet(self):
if self.type == EPG_TYPE_MULTI or self.type == EPG_TYPE_GRAPH or self.type == EPG_TYPE_INFOBARGRAPH:
self.moveBouquetDown()
self.BouquetOK()
elif (self.type == EPG_TYPE_ENHANCED or self.type == EPG_TYPE_INFOBAR) and config.usage.multibouquet.value:
self.CurrBouquet = self.servicelist.getCurrentSelection()
self.CurrService = self.servicelist.getRoot()
self.servicelist.nextBouquet()
self.onCreate()
def prevBouquet(self):
if self.type == EPG_TYPE_MULTI or self.type == EPG_TYPE_GRAPH or self.type == EPG_TYPE_INFOBARGRAPH:
self.moveBouquetUp()
self.BouquetOK()
elif (self.type == EPG_TYPE_ENHANCED or self.type == EPG_TYPE_INFOBAR) and config.usage.multibouquet.value:
self.CurrBouquet = self.servicelist.getCurrentSelection()
self.CurrService = self.servicelist.getRoot()
self.servicelist.prevBouquet()
self.onCreate()
def nextService(self):
if self.type == EPG_TYPE_ENHANCED or self.type == EPG_TYPE_INFOBAR:
self.CurrBouquet = self.servicelist.getCurrentSelection()
self.CurrService = self.servicelist.getRoot()
self['list'].instance.moveSelectionTo(0)
if self.servicelist.inBouquet():
prev = self.servicelist.getCurrentSelection()
if prev:
prev = prev.toString()
while True:
if config.usage.quickzap_bouquet_change.value and self.servicelist.atEnd():
self.servicelist.nextBouquet()
else:
self.servicelist.moveDown()
cur = self.servicelist.getCurrentSelection()
if not cur or (not (cur.flags & 64)) or cur.toString() == prev:
break
else:
self.servicelist.moveDown()
if self.isPlayable():
self.onCreate()
if not self['list'].getCurrent()[1] and config.epgselection.overjump.value:
self.nextService()
else:
self.nextService()
elif self.type == EPG_TYPE_GRAPH or self.type == EPG_TYPE_INFOBARGRAPH:
self.updEvent(+24)
elif self.serviceChangeCB:
self.serviceChangeCB(1, self)
def prevService(self):
if self.type == EPG_TYPE_ENHANCED or self.type == EPG_TYPE_INFOBAR:
self.CurrBouquet = self.servicelist.getCurrentSelection()
self.CurrService = self.servicelist.getRoot()
self['list'].instance.moveSelectionTo(0)
if self.servicelist.inBouquet():
prev = self.servicelist.getCurrentSelection()
if prev:
prev = prev.toString()
while True:
if config.usage.quickzap_bouquet_change.value:
if self.servicelist.atBegin():
self.servicelist.prevBouquet()
self.servicelist.moveUp()
cur = self.servicelist.getCurrentSelection()
if not cur or (not (cur.flags & 64)) or cur.toString() == prev:
break
else:
self.servicelist.moveUp()
if self.isPlayable():
self.onCreate()
if not self['list'].getCurrent()[1] and config.epgselection.overjump.value:
self.prevService()
else:
self.prevService()
elif self.type == EPG_TYPE_GRAPH or self.type == EPG_TYPE_INFOBARGRAPH:
self.updEvent(-24)
elif self.serviceChangeCB:
self.serviceChangeCB(-1, self)
def enterDateTime(self):
global mepg_config_initialized
if self.type == EPG_TYPE_MULTI:
if not mepg_config_initialized:
config.misc.prev_mepg_time = ConfigClock(default=time())
mepg_config_initialized = True
self.session.openWithCallback(self.onDateTimeInputClosed, TimeDateInput, config.misc.prev_mepg_time)
elif self.type == EPG_TYPE_GRAPH:
self.session.openWithCallback(self.onDateTimeInputClosed, TimeDateInput, config.epgselection.graph_prevtime)
elif self.type == EPG_TYPE_INFOBARGRAPH:
self.session.openWithCallback(self.onDateTimeInputClosed, TimeDateInput, config.epgselection.infobar_prevtime)
def onDateTimeInputClosed(self, ret):
if len(ret) > 1:
if ret[0]:
if self.type == EPG_TYPE_MULTI:
self.ask_time = ret[1]
self['list'].fillMultiEPG(self.services, ret[1])
elif self.type == EPG_TYPE_GRAPH or self.type == EPG_TYPE_INFOBARGRAPH:
now = time() - int(config.epg.histminutes.value) * 60
if self.type == EPG_TYPE_GRAPH:
self.ask_time -= self.ask_time % (int(config.epgselection.graph_roundto.value) * 60)
elif self.type == EPG_TYPE_INFOBARGRAPH:
self.ask_time -= self.ask_time % (int(config.epgselection.infobar_roundto.value) * 60)
l = self['list']
l.resetOffset()
l.fillGraphEPG(None, self.ask_time)
self.moveTimeLines(True)
if self.eventviewDialog and (self.type == EPG_TYPE_INFOBAR or self.type == EPG_TYPE_INFOBARGRAPH):
self.infoKeyPressed(True)
def infoKeyPressed(self, eventviewopen=False):
cur = self['list'].getCurrent()
event = cur[0]
service = cur[1]
if event is not None and not self.eventviewDialog and not eventviewopen:
if self.type != EPG_TYPE_SIMILAR:
if self.type == EPG_TYPE_INFOBARGRAPH:
self.eventviewDialog = self.session.instantiateDialog(EventViewSimple,event, service, skin='InfoBarEventView')
self.eventviewDialog.show()
else:
self.session.open(EventViewEPGSelect, event, service, callback=self.eventViewCallback, similarEPGCB=self.openSimilarList)
elif self.eventviewDialog and not eventviewopen:
self.eventviewDialog.hide()
del self.eventviewDialog
self.eventviewDialog = None
elif event is not None and self.eventviewDialog and eventviewopen:
if self.type != EPG_TYPE_SIMILAR:
if self.type == EPG_TYPE_INFOBAR or self.type == EPG_TYPE_INFOBARGRAPH:
self.eventviewDialog.hide()
self.eventviewDialog = self.session.instantiateDialog(EventViewSimple,event, service, skin='InfoBarEventView')
self.eventviewDialog.show()
def redButtonPressed(self):
self.closeEventViewDialog()
from InfoBar import InfoBar
InfoBarInstance = InfoBar.instance
if not InfoBarInstance.LongButtonPressed:
self.openIMDb()
def redButtonPressedLong(self):
self.closeEventViewDialog()
from InfoBar import InfoBar
InfoBarInstance = InfoBar.instance
if InfoBarInstance.LongButtonPressed:
self.sortEpg()
def greenButtonPressed(self):
self.closeEventViewDialog()
from InfoBar import InfoBar
InfoBarInstance = InfoBar.instance
if not InfoBarInstance.LongButtonPressed:
self.RecordTimerQuestion(True)
def greenButtonPressedLong(self):
self.closeEventViewDialog()
from InfoBar import InfoBar
InfoBarInstance = InfoBar.instance
if InfoBarInstance.LongButtonPressed:
self.showTimerList()
def yellowButtonPressed(self):
self.closeEventViewDialog()
from InfoBar import InfoBar
InfoBarInstance = InfoBar.instance
if not InfoBarInstance.LongButtonPressed:
self.openEPGSearch()
def blueButtonPressed(self):
self.closeEventViewDialog()
from InfoBar import InfoBar
InfoBarInstance = InfoBar.instance
if not InfoBarInstance.LongButtonPressed:
self.addAutoTimer()
def blueButtonPressedLong(self):
self.closeEventViewDialog()
from InfoBar import InfoBar
InfoBarInstance = InfoBar.instance
if InfoBarInstance.LongButtonPressed:
self.showAutoTimerList()
def openSimilarList(self, eventid, refstr):
self.session.open(EPGSelection, refstr, None, eventid)
def setServices(self, services):
self.services = services
self.onCreate()
def setService(self, service):
self.currentService = service
self.onCreate()
def eventViewCallback(self, setEvent, setService, val):
l = self['list']
old = l.getCurrent()
if self.type == EPG_TYPE_GRAPH or self.type == EPG_TYPE_INFOBARGRAPH:
self.updEvent(val, False)
elif val == -1:
self.moveUp()
elif val == +1:
self.moveDown()
cur = l.getCurrent()
if (self.type == EPG_TYPE_MULTI or self.type == EPG_TYPE_GRAPH or self.type == EPG_TYPE_INFOBARGRAPH) and cur[0] is None and cur[1].ref != old[1].ref:
self.eventViewCallback(setEvent, setService, val)
else:
setService(cur[1])
setEvent(cur[0])
def eventSelected(self):
self.infoKeyPressed()
def sortEpg(self):
if self.type == EPG_TYPE_SINGLE or self.type == EPG_TYPE_ENHANCED or self.type == EPG_TYPE_INFOBAR:
if config.epgselection.sort.value == '0':
config.epgselection.sort.setValue('1')
else:
config.epgselection.sort.setValue('0')
config.epgselection.sort.save()
configfile.save()
self['list'].sortSingleEPG(int(config.epgselection.sort.value))
def OpenSingleEPG(self):
cur = self['list'].getCurrent()
if cur[0] is not None:
event = cur[0]
serviceref = cur[1].ref
if serviceref is not None:
self.session.open(SingleEPG, serviceref)
def openIMDb(self):
try:
from Plugins.Extensions.IMDb.plugin import IMDB, IMDBEPGSelection
try:
cur = self['list'].getCurrent()
event = cur[0]
name = event.getEventName()
except:
name = ''
self.session.open(IMDB, name, False)
except ImportError:
self.session.open(MessageBox, _('The IMDb plugin is not installed!\nPlease install it.'), type=MessageBox.TYPE_INFO, timeout=10)
def openEPGSearch(self):
try:
from Plugins.Extensions.EPGSearch.EPGSearch import EPGSearch
try:
cur = self['list'].getCurrent()
event = cur[0]
name = event.getEventName()
except:
name = ''
self.session.open(EPGSearch, name, False)
except ImportError:
self.session.open(MessageBox, _('The EPGSearch plugin is not installed!\nPlease install it.'), type=MessageBox.TYPE_INFO, timeout=10)
def addAutoTimer(self):
try:
from Plugins.Extensions.AutoTimer.AutoTimerEditor import addAutotimerFromEvent
cur = self['list'].getCurrent()
event = cur[0]
if not event:
return
serviceref = cur[1]
addAutotimerFromEvent(self.session, evt=event, service=serviceref)
self.refreshTimer.start(3000)
except ImportError:
self.session.open(MessageBox, _('The AutoTimer plugin is not installed!\nPlease install it.'), type=MessageBox.TYPE_INFO, timeout=10)
def addAutoTimerSilent(self):
try:
from Plugins.Extensions.AutoTimer.AutoTimerEditor import addAutotimerFromEventSilent
cur = self['list'].getCurrent()
event = cur[0]
if not event:
return
serviceref = cur[1]
addAutotimerFromEventSilent(self.session, evt=event, service=serviceref)
self.refreshTimer.start(3000)
except ImportError:
self.session.open(MessageBox, _('The Autotimer plugin is not installed!\nPlease install it.'), type=MessageBox.TYPE_INFO, timeout=10)
def showTimerList(self):
from Screens.TimerEdit import TimerEditList
self.session.open(TimerEditList)
def showAutoTimerList(self):
global autopoller
global autotimer
try:
from Plugins.Extensions.AutoTimer.plugin import main, autostart
from Plugins.Extensions.AutoTimer.AutoTimer import AutoTimer
from Plugins.Extensions.AutoTimer.AutoPoller import AutoPoller
autopoller = AutoPoller()
autotimer = AutoTimer()
try:
autotimer.readXml()
except SyntaxError as se:
self.session.open(MessageBox, _('Your config file is not well formed:\n%s') % str(se), type=MessageBox.TYPE_ERROR, timeout=10)
return
if autopoller is not None:
autopoller.stop()
from Plugins.Extensions.AutoTimer.AutoTimerOverview import AutoTimerOverview
self.session.openWithCallback(self.editCallback, AutoTimerOverview, autotimer)
except ImportError:
self.session.open(MessageBox, _('The Autotimer plugin is not installed!\nPlease install it.'), type=MessageBox.TYPE_INFO, timeout=10)
def editCallback(self, session):
global autopoller
global autotimer
if session is not None:
autotimer.writeXml()
autotimer.parseEPG()
if config.plugins.autotimer.autopoll.value:
if autopoller is None:
from Plugins.Extensions.AutoTimer.AutoPoller import AutoPoller
autopoller = AutoPoller()
autopoller.start()
else:
autopoller = None
autotimer = None
def timerAdd(self):
self.RecordTimerQuestion(True)
def editTimer(self, timer):
self.session.open(TimerEntry, timer)
def removeTimer(self, timer):
self.closeChoiceBoxDialog()
timer.afterEvent = AFTEREVENT.NONE
self.session.nav.RecordTimer.removeEntry(timer)
self['key_green'].setText(_('Add Timer'))
self.key_green_choice = self.ADD_TIMER
self.getCurrentCursorLocation = self['list'].getCurrentCursorLocation()
self.refreshlist()
def disableTimer(self, timer):
self.closeChoiceBoxDialog()
timer.disable()
self.session.nav.RecordTimer.timeChanged(timer)
self['key_green'].setText(_('Add Timer'))
self.key_green_choice = self.ADD_TIMER
self.getCurrentCursorLocation = self['list'].getCurrentCursorLocation()
self.refreshlist()
def RecordTimerQuestion(self, manual=False):
cur = self['list'].getCurrent()
event = cur[0]
serviceref = cur[1]
if event is None:
return
eventid = event.getEventId()
refstr = ':'.join(serviceref.ref.toString().split(':')[:11])
title = None
for timer in self.session.nav.RecordTimer.timer_list:
if timer.eit == eventid and ':'.join(timer.service_ref.ref.toString().split(':')[:11]) == refstr:
cb_func1 = lambda ret: self.removeTimer(timer)
cb_func2 = lambda ret: self.editTimer(timer)
cb_func3 = lambda ret: self.disableTimer(timer)
menu = [(_("Delete timer"), 'CALLFUNC', self.RemoveChoiceBoxCB, cb_func1), (_("Edit timer"), 'CALLFUNC', self.RemoveChoiceBoxCB, cb_func2), (_("Disable timer"), 'CALLFUNC', self.RemoveChoiceBoxCB, cb_func3)]
title = _("Select action for timer %s:") % event.getEventName()
break
else:
if not manual:
menu = [(_("Add Timer"), 'CALLFUNC', self.ChoiceBoxCB, self.doRecordTimer), (_("Add AutoTimer"), 'CALLFUNC', self.ChoiceBoxCB, self.addAutoTimerSilent)]
title = "%s?" % event.getEventName()
else:
newEntry = RecordTimerEntry(serviceref, checkOldTimers=True, dirname=preferredTimerPath(), *parseEvent(event))
self.session.openWithCallback(self.finishedAdd, TimerEntry, newEntry)