-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathplugin.py
1628 lines (1463 loc) · 79.4 KB
/
plugin.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
################################################################################
# #
# BUYUKBANG PANEL 1.4.2 #
# I want to thank to all open source Enigma2 developers and community, #
# especially Crossepg and EPG Import plugin developers, since I inspired or #
# directly used their codes to make BuyukBang Panel Project come true! #
# #
# Buyukbang @27.11.2018 #
# #
################################################################################
import time
import enigma
import os
from Screens.Console import Console
from twisted.internet import threads
import twisted.python.runtime
import bbutill
log = bbutill
# EPG Copier + EPG Linker
from enigma import eEPGCache, eServiceCenter, eServiceReference
# EPG Linker
from enigma import iPlayableService, iServiceInformation
from Screens.EventView import EventViewEPGSelect
from ServiceReference import ServiceReference
from Components.Sources.EventInfo import EventInfo
from Screens.InfoBarGenerics import InfoBarEPG
# Hide Zap Errors
from enigma import iPlayableService
#Main Menu
from Tools.LoadPixmap import LoadPixmap
from Components.Sources.List import List
from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest
# Config
from Screens.Standby import TryQuitMainloop, Standby
from Tools import Notifications
from Components.config import config, ConfigText, ConfigEnableDisable, ConfigSubsection, ConfigYesNo, ConfigClock, getConfigListEntry, ConfigSelection, ConfigNumber, ConfigIP, ConfigLocations, configfile
import Screens.Standby
from Screens.MessageBox import MessageBox
from Screens.Screen import Screen
from Components.ConfigList import ConfigListScreen
from Components.ActionMap import ActionMap
from Components.Button import Button
from Components.Label import Label
from Components.SelectionList import SelectionList, SelectionEntryComponent
from Components.ScrollLabel import ScrollLabel
import Components.PluginComponent
from Tools.Directories import fileExists
################################################
import gettext
from Components.Language import language
from os import environ, popen
from Tools.Directories import resolveFilename, SCOPE_LANGUAGE, SCOPE_PLUGINS
def localeInit():
lang = language.getLanguage()
environ["LANGUAGE"] = lang[:2]
gettext.bindtextdomain("enigma2", resolveFilename(SCOPE_LANGUAGE))
gettext.textdomain("enigma2")
gettext.bindtextdomain("BuyukbangPanel", "%s%s" % (resolveFilename(SCOPE_PLUGINS), "Extensions/BuyukbangPanel/locale/"))
def _(txt):
t = gettext.dgettext("BuyukbangPanel", txt)
if t == txt:
t = gettext.gettext(txt)
return t
localeInit()
language.addCallback(localeInit)
################################################
#Set default configuration
config.plugins.buyukbangpanel = ConfigSubsection()
if hasattr(eEPGCache, 'importEvent'):
config.plugins.buyukbangpanel.periodic = ConfigEnableDisable(default=True)
config.plugins.buyukbangpanel.interval = ConfigNumber(default=60)
elif hasattr(eEPGCache, 'load'):
config.plugins.buyukbangpanel.periodic = ConfigEnableDisable(default=True)
config.plugins.buyukbangpanel.interval = ConfigNumber(default=600)
else:
config.plugins.buyukbangpanel.periodic = ConfigEnableDisable(default=False)
config.plugins.buyukbangpanel.interval = ConfigNumber(default=600)
config.plugins.buyukbangpanel.scheduled = ConfigEnableDisable(default=True)
config.plugins.buyukbangpanel.scheduledepgcopytime = ConfigClock(default=((21 * 60) + 00) * 60) # 21:00
config.plugins.buyukbangpanel.startupcopydelay = ConfigNumber(default=2)
config.plugins.buyukbangpanel.forceepgdat = ConfigYesNo(default=False)
config.plugins.buyukbangpanel.linkepg = ConfigSelection(choices=[("0", _("Only infoBar and EPG info")), ("1", _("All EPG queries")), ("2", _("Disable"))], default="0")
config.plugins.buyukbangpanel.readepgboquet = ConfigSelection(choices=[("0", _("At startup <Changes requires restart>")), ("1", _("In realtime <Uses more CPU>"))], default="0")
config.plugins.buyukbangpanel.filterdummy = ConfigEnableDisable(default=True)
config.plugins.buyukbangpanel.dummystring = ConfigText(default='Current,Next,dummyEventName,.,', fixed_size=False)
config.plugins.buyukbangpanel.epgencoding = ConfigSelection(choices=[("ISO6397", _("ISO6397")), ("ISO8859-1", _("ISO8859-1")), ("ISO8859-2", _("ISO8859-2")), ("ISO8859-3", _("ISO8859-3")), ("ISO8859-4", _("ISO8859-4")), ("ISO8859-5", _("ISO8859-5")), ("ISO8859-6", _("ISO8859-6")), ("ISO8859-7", _("ISO8859-7")), ("ISO8859-8", _("ISO8859-8")), ("ISO8859-9", _("ISO8859-9")), ("ISO8859-10", _("ISO8859-10")), ("ISO8859-11", _("ISO8859-11")), ("ISO8859-13", _("ISO8859-13")), ("ISO8859-14", _("ISO8859-14")), ("ISO8859-15", _("ISO8859-15")), ("ISO8859-16", _("ISO8859-16"))], default="ISO8859-9")
try: #some old images may not have this key and crashes. "Try" fixes this possible bug.
if config.osd.language.value == "tr_TR":
config.plugins.buyukbangpanel.fixepgencoding = ConfigSelection(choices=[("disable", _("Disable")), ("afg", _("Afghan")), ("alb", _("Albanian")), ("amh", _("Amharic")), ("ara", _("Arabic")), ("arm", _("Armenian")), ("ast", _("Asturian")), ("aze", _("Azerian")), ("bas", _("Basque")), ("bel", _("Belarusian")), ("ben", _("Bengali")), ("ber", _("Berbere")), ("bos", _("Bosnian")), ("bre", _("Breton")), ("bul", _("Bulgarian")), ("cat", _("Catalan")), ("chi", _("Chinese")), ("cro", _("Croatian")), ("cze", _("Czech")), ("den", _("Danish")), ("ned", _("Dutch")), ("eng", _("English")), ("est", _("Estonian")), ("far", _("Farsi")), ("fin", _("Finnish")), ("fra", _("French")), ("fri", _("Frisian")), ("gla", _("Gaelic")), ("gal", _("Galician")), ("geo", _("Georgian")), ("ger", _("German")), ("gre", _("Greek")), ("guj", _("Gujarati")), ("heb", _("Hebrew")), ("hin", _("Hindi")), ("hun", _("Hungarian")), ("ice", _("Icelandic")), ("ind", _("India")), ("iri", _("Irish")), ("ita", _("Italian")), ("jap", _("Japanese")), ("kaz", _("Kazakh")), ("khm", _("Khmer")), ("kor", _("Korean")), ("kur", _("Kurdish")), ("kyr", _("Kyrgyz")), ("lat", _("Latvian")), ("lit", _("Lithuanian")), ("lux", _("Luxembourg")), ("mac", _("Macedonian")), ("mal", _("Malayalam")), ("mlt", _("Maltese")), ("mdr", _("Mandarin")), ("mol", _("Moldovan")), ("mya", _("Myanmar")), ("nep", _("Nepali")), ("nor", _("Norwegian")), ("pus", _("Pashto")), ("per", _("Persian")), ("pol", _("Polish")), ("por", _("Portuguese")), ("pun", _("Punjabi")), ("rom", _("Romanian")), ("rus", _("Russian")), ("ser", _("Serbian")), ("snd", _("Sindhi")), ("sin", _("Sinhala")), ("slk", _("Slovakian")), ("slo", _("Slovenian")), ("som", _("Somali")), ("esp", _("Spanish")), ("swa", _("Swali")), ("swe", _("Sweden")), ("tag", _("Tagalog")), ("taj", _("Tajik")), ("tam", _("Tamil")), ("tel", _("Telugu")), ("tha", _("Thailand")), ("tig", _("Tigrinya")), ("tur", _("Turkish")), ("ukr", _("Ukrainian")), ("urd", _("Urdu")), ("vie", _("Vietnamese")), ("wel", _("Welsh"))], default="tur")
else:
config.plugins.buyukbangpanel.fixepgencoding = ConfigSelection(choices=[("disable", _("Disable")), ("afg", _("Afghan")), ("alb", _("Albanian")), ("amh", _("Amharic")), ("ara", _("Arabic")), ("arm", _("Armenian")), ("ast", _("Asturian")), ("aze", _("Azerian")), ("bas", _("Basque")), ("bel", _("Belarusian")), ("ben", _("Bengali")), ("ber", _("Berbere")), ("bos", _("Bosnian")), ("bre", _("Breton")), ("bul", _("Bulgarian")), ("cat", _("Catalan")), ("chi", _("Chinese")), ("cro", _("Croatian")), ("cze", _("Czech")), ("den", _("Danish")), ("ned", _("Dutch")), ("eng", _("English")), ("est", _("Estonian")), ("far", _("Farsi")), ("fin", _("Finnish")), ("fra", _("French")), ("fri", _("Frisian")), ("gla", _("Gaelic")), ("gal", _("Galician")), ("geo", _("Georgian")), ("ger", _("German")), ("gre", _("Greek")), ("guj", _("Gujarati")), ("heb", _("Hebrew")), ("hin", _("Hindi")), ("hun", _("Hungarian")), ("ice", _("Icelandic")), ("ind", _("India")), ("iri", _("Irish")), ("ita", _("Italian")), ("jap", _("Japanese")), ("kaz", _("Kazakh")), ("khm", _("Khmer")), ("kor", _("Korean")), ("kur", _("Kurdish")), ("kyr", _("Kyrgyz")), ("lat", _("Latvian")), ("lit", _("Lithuanian")), ("lux", _("Luxembourg")), ("mac", _("Macedonian")), ("mal", _("Malayalam")), ("mlt", _("Maltese")), ("mdr", _("Mandarin")), ("mol", _("Moldovan")), ("mya", _("Myanmar")), ("nep", _("Nepali")), ("nor", _("Norwegian")), ("pus", _("Pashto")), ("per", _("Persian")), ("pol", _("Polish")), ("por", _("Portuguese")), ("pun", _("Punjabi")), ("rom", _("Romanian")), ("rus", _("Russian")), ("ser", _("Serbian")), ("snd", _("Sindhi")), ("sin", _("Sinhala")), ("slk", _("Slovakian")), ("slo", _("Slovenian")), ("som", _("Somali")), ("esp", _("Spanish")), ("swa", _("Swali")), ("swe", _("Sweden")), ("tag", _("Tagalog")), ("taj", _("Tajik")), ("tam", _("Tamil")), ("tel", _("Telugu")), ("tha", _("Thailand")), ("tig", _("Tigrinya")), ("tur", _("Turkish")), ("ukr", _("Ukrainian")), ("urd", _("Urdu")), ("vie", _("Vietnamese")), ("wel", _("Welsh"))], default="disable")
except:
config.plugins.buyukbangpanel.fixepgencoding = ConfigSelection(choices=[("disable", _("Disable")), ("afg", _("Afghan")), ("alb", _("Albanian")), ("amh", _("Amharic")), ("ara", _("Arabic")), ("arm", _("Armenian")), ("ast", _("Asturian")), ("aze", _("Azerian")), ("bas", _("Basque")), ("bel", _("Belarusian")), ("ben", _("Bengali")), ("ber", _("Berbere")), ("bos", _("Bosnian")), ("bre", _("Breton")), ("bul", _("Bulgarian")), ("cat", _("Catalan")), ("chi", _("Chinese")), ("cro", _("Croatian")), ("cze", _("Czech")), ("den", _("Danish")), ("ned", _("Dutch")), ("eng", _("English")), ("est", _("Estonian")), ("far", _("Farsi")), ("fin", _("Finnish")), ("fra", _("French")), ("fri", _("Frisian")), ("gla", _("Gaelic")), ("gal", _("Galician")), ("geo", _("Georgian")), ("ger", _("German")), ("gre", _("Greek")), ("guj", _("Gujarati")), ("heb", _("Hebrew")), ("hin", _("Hindi")), ("hun", _("Hungarian")), ("ice", _("Icelandic")), ("ind", _("India")), ("iri", _("Irish")), ("ita", _("Italian")), ("jap", _("Japanese")), ("kaz", _("Kazakh")), ("khm", _("Khmer")), ("kor", _("Korean")), ("kur", _("Kurdish")), ("kyr", _("Kyrgyz")), ("lat", _("Latvian")), ("lit", _("Lithuanian")), ("lux", _("Luxembourg")), ("mac", _("Macedonian")), ("mal", _("Malayalam")), ("mlt", _("Maltese")), ("mdr", _("Mandarin")), ("mol", _("Moldovan")), ("mya", _("Myanmar")), ("nep", _("Nepali")), ("nor", _("Norwegian")), ("pus", _("Pashto")), ("per", _("Persian")), ("pol", _("Polish")), ("por", _("Portuguese")), ("pun", _("Punjabi")), ("rom", _("Romanian")), ("rus", _("Russian")), ("ser", _("Serbian")), ("snd", _("Sindhi")), ("sin", _("Sinhala")), ("slk", _("Slovakian")), ("slo", _("Slovenian")), ("som", _("Somali")), ("esp", _("Spanish")), ("swa", _("Swali")), ("swe", _("Sweden")), ("tag", _("Tagalog")), ("taj", _("Tajik")), ("tam", _("Tamil")), ("tel", _("Telugu")), ("tha", _("Thailand")), ("tig", _("Tigrinya")), ("tur", _("Turkish")), ("ukr", _("Ukrainian")), ("urd", _("Urdu")), ("vie", _("Vietnamese")), ("wel", _("Welsh"))], default="disable")
config.plugins.buyukbangpanel.hidezaperrors = ConfigEnableDisable(default=False)
config.plugins.buyukbangpanel.scheduledoperation = ConfigSelection(choices=[("0", _("Disable")), ("1", _("Shutdown")), ("2", _("Reboot")), ("3", _("Restart GUI")), ("4", _("Standby"))], default="0")
config.plugins.buyukbangpanel.scheduledoperationtime = ConfigClock(default=((5 * 60) + 00) * 60) # 5:00
config.plugins.buyukbangpanel.scheduledoperationmon = ConfigEnableDisable(default=True)
config.plugins.buyukbangpanel.scheduledoperationtue = ConfigEnableDisable(default=True)
config.plugins.buyukbangpanel.scheduledoperationwed = ConfigEnableDisable(default=True)
config.plugins.buyukbangpanel.scheduledoperationthu = ConfigEnableDisable(default=True)
config.plugins.buyukbangpanel.scheduledoperationfri = ConfigEnableDisable(default=True)
config.plugins.buyukbangpanel.scheduledoperationsat = ConfigEnableDisable(default=True)
config.plugins.buyukbangpanel.scheduledoperationsun = ConfigEnableDisable(default=True)
config.plugins.buyukbangpanel.restarttype = ConfigSelection(choices=[("3", _("Restart GUI")), ("2", _("Reboot"))], default="3")
config.plugins.buyukbangpanel.showinextensions = ConfigYesNo(default=True)
config.plugins.buyukbangpanel.lastcopyepgrestarttime = ConfigNumber(default=0)
config.plugins.buyukbangpanel.startuptostandby = ConfigSelection(choices=[("0", _("Disable")), ("1", _("Except GUI restarts")), ("2", _("On all startups"))], default="0")
# Plugin definition
from Plugins.Plugin import PluginDescriptor
# Global variable
_session = None
autoStartTimer = None
autostartExecuted = None
timerEpgCopyRunning = False
manualEpgCopyRunning = False
scheduledOperation = None
reboot = False
lastrestartallowedtime = int(config.plugins.buyukbangpanel.lastcopyepgrestarttime.value)
###################################### GETEPGMAP ###################################
def getEPGMap(self):
dst2src = {}
src2dst = {}
serviceHandler = eServiceCenter.getInstance()
services = serviceHandler.list(eServiceReference('1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17) || (type == 195) || (type == 25) FROM BOUQUET "bouquets.tv" ORDER BY bouquet'))
bouquets = services and services.getContent("SN", True)
#The first argument of getContent function is a format string to specify the order and
#the content of the returned list
#useable format options are
#R = Service Reference (as swig object .. this is very slow)
#S = Service Reference (as python string object .. same as ref.toString())
#C = Service Reference (as python string object .. same as ref.toCompareString())
#N = Service Name (as python string object)
#n = Short Service Name (short name brakets used) (as python string object)
#when exactly one return value per service is selected in the format string,
#then each value is directly a list entry
#when more than one value is returned per service, then the list is a list of
#python tuples
#unknown format string chars are returned as python None values !
for bouquet in bouquets:
if bouquet[1].replace('\xc2\x86', '').replace('\xc2\x87', '').lower() == "epg":
services = serviceHandler.list(eServiceReference(bouquet[0]))
channels = services and services.getContent("RSN", True)
srcref = {}
srcflag = '1'
for channel in channels:
if srcflag == '1':
srcref = channel
srcflag = '0'
elif channel[1].startswith("1:64:"):
srcflag = '1'
else:
#dst2src(ref string of destination channel)= destination channel ref swig object of, ref sting, name, source channel ref swig object of, ref sting, name)
dst2src[channel[1]] = (channel[0], channel[1], channel[2], srcref[0], srcref[1], srcref[2])
src2dst[srcref[1]] = (channel[0], channel[1], channel[2], srcref[0], srcref[1], srcref[2])
#f = open('/media/hdd/deneme.txt', 'a')
#f.write(channel[2].replace('\xc2\x86', '').replace('\xc2\x87', '') + "==>" + dst2src[channel[1]][5] + "\n")
#f.write(channel[1] + "==>" + dst2src[channel[1]][4] + "\n")
#f.close()
return (dst2src, src2dst)
eEPGCache.getEPGMap = getEPGMap
EventInfo.getEPGMap = getEPGMap
###################################### COPYEPG ###################################
def copyEpg(self):
global timerEpgCopyRunning, manualEpgCopyRunning, scheduledOperation, reboot
epgpath = None
epgfile = None
epgfilenew = None
epgdat = None
channels = None
if timerEpgCopyRunning or manualEpgCopyRunning:
print>>log, "\n"
print>>log, _("Another EPG copy operation is in progress. EPG copy will not start.")
if hasattr(self, 'save_pre'):
self.session.open(MessageBox, _("Buyukbang Panel\n\nAnother EPG copy operation is in progress. Please wait..."), MessageBox.TYPE_ERROR, timeout=10, close_on_any_key=True)
return
if hasattr(self, 'save_pre'):
print>>log, _("Manual EPG copy started")
self["statusbar"].setText(_("Manual EPG copy started"))
manualEpgCopyRunning = True
timerEpgCopyRunning = False
elif scheduledOperation == "SCHEDULED":
print>>log, _("Scheduled EPG copy started")
manualEpgCopyRunning = False
timerEpgCopyRunning = True
elif scheduledOperation == "PERIODIC":
print>>log, _("Periodic EPG copy started")
manualEpgCopyRunning = False
timerEpgCopyRunning = True
epgcache = eEPGCache.getInstance()
if not hasattr(eEPGCache, 'importEvent') or config.plugins.buyukbangpanel.forceepgdat.value:
epgpath = "/hdd"
epgfile = "/hdd/epg.dat"
cfFound = False
usbFound = False
hddFound = False
fmount = None
# Reported: Some images don't support popen, may be they have a bad/missing implementation.
try:
fmount = os.popen('mount', "r")
except:
try:
os.system('mount > /tmp/mount.log')
fmount = open('/tmp/mount.log', 'r')
except:
pass
if fmount:
for l in fmount.xreadlines():
if l.find('/media/cf') != -1:
cfFound = True
if l.find('/media/usb') != -1:
usbFound = True
if l.find('/media/hdd') != -1:
hddFound = True
fmount.close()
if cfFound:
epgpath = '/media/cf'
epgfile = '/media/cf/epg.dat'
if usbFound:
epgpath = '/media/usb'
epgfile = '/media/usb/epg.dat'
if hddFound:
epgpath = '/media/hdd'
epgfile = '/media/hdd/epg.dat'
try: #some old images do not have this key and crashes. "Try" fixes this bug.
if config.misc.epgcache_filename.value:
parent = os.path.split(config.misc.epgcache_filename.value)[0]
if os.path.exists(parent):
epgpath = parent
except:
pass
epgfilenew = os.path.join(epgpath, 'epg.dat.bb')
epgdat = epgdat_class(epgpath, '/etc/enigma2', epgfilenew)
serviceHandler = eServiceCenter.getInstance()
services = serviceHandler.list(eServiceReference('1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17) || (type == 195) || (type == 25) FROM BOUQUET "bouquets.tv" ORDER BY bouquet'))
bouquets = services and services.getContent("SN", True)
#The first argument of getContent function is a format string to specify the order and
#the content of the returned list
#useable format options are
#R = Service Reference (as swig object .. this is very slow)
#S = Service Reference (as python string object .. same as ref.toString())
#C = Service Reference (as python string object .. same as ref.toCompareString())
#N = Service Name (as python string object)
#n = Short Service Name (short name brakets used) (as python string object)
#when exactly one return value per service is selected in the format string,
#then each value is directly a list entry
#when more than one value is returned per service, then the list is a list of
#python tuples
#unknown format string chars are returned as python None values !
for bouquet in bouquets:
if bouquet[1].replace('\xc2\x86', '').replace('\xc2\x87', '').lower() == "epg":
services = serviceHandler.list(eServiceReference(bouquet[0]))
channels = services and services.getContent("RSN", True)
# Add one more dummy seperator at the end. So there will be no need to duplicate looped importEvents code part for just the last item.
channels.append([None, "1:64:", None])
srcChannel = None
dstChannelList = []
eventlist = {}
timeAdjustment = 0
if not channels:
manualEpgCopyRunning = False
timerEpgCopyRunning = False
print>>log, _("Bouquet named EPG not found, EPG copy aborted")
if hasattr(self, 'save_pre'):
self["statusbar"].setText(_("Bouquet named EPG not found, EPG copy aborted"))
return
for channel in channels:
if channel[1].startswith("1:64:"):
timeAdjustment = 0
timeAdjustmentStr = ''
if channel[2]:
timeAdjustmentStr = channel[2][channel[2].find('(') + 1: channel[2].find(')')]
if len(timeAdjustmentStr) > 0:
timeAdjustment = int(timeAdjustmentStr) * 3600
if eventlist and dstChannelList:
try:
if hasattr(eEPGCache, 'importEvents') and not config.plugins.buyukbangpanel.forceepgdat.value:
epgcache.importEvents(dstChannelList, eventlist)
else:
epgdat.importEvents(dstChannelList, eventlist)
print>>log, _("%s copied") % srcChannel
if hasattr(self, 'save_pre'):
self["statusbar"].setText(_("%s copied") % srcChannel)
except Exception, e:
print>>log, _("Copy failed for %s") % srcChannel
print>>log, e
if hasattr(self, 'save_pre'):
self["statusbar"].setText(_("Copy failed for %s") % srcChannel)
elif not eventlist and srcChannel and dstChannelList:
print>>log, _("No EPG data available for %s") % srcChannel
if hasattr(self, 'save_pre'):
self["statusbar"].setText(_("No EPG data available for %s") % srcChannel)
srcChannel = None
dstChannelList = []
eventlist = {}
elif srcChannel is None:
srcChannel = channel[2].replace('\xc2\x86', '').replace('\xc2\x87', '')
#B = Event Begin Time, D = Event Duration, T = Event Title, S = Event Short Description, E = Event Extended Description, 0 = PyLong(0)
eventlist = epgcache.lookupEvent(['BDTSE0', (channel[1], -1, -1, -1)])
for i in range(len(eventlist)):
eventlist[i] = (eventlist[i][0] + timeAdjustment, eventlist[i][1], eventlist[i][2], eventlist[i][3], eventlist[i][4], eventlist[i][5])
else:
dstChannelList.append(channel[1])
if epgdat is not None:
try:
print>>log, _("Writing %s") % epgfilenew
if hasattr(self, 'save_pre'):
self["statusbar"].setText(_("Writing %s") % epgfilenew)
epgdat.final_process()
except Exception, e:
print>>log, _("%s write failed") % epgfilenew
print>>log, e
if hasattr(self, 'save_pre'):
self["statusbar"].setText(_("%s write failed") % epgfilenew)
reboot = True
if hasattr(eEPGCache, 'load'):
print>>log, _("Loading %s") % epgfilenew
if hasattr(self, 'save_pre'):
self["statusbar"].setText(_("Loading %s") % epgfilenew)
try:
try:
os.unlink(epgfile)
except:
pass
os.symlink(epgfilenew, epgfile)
epgcache.load()
try:
os.unlink(epgfile)
except:
pass
try:
os.unlink(epgfilenew)
except:
pass
reboot = False
print>>log, _("%s loaded") % epgfilenew
if hasattr(self, 'save_pre'):
self["statusbar"].setText(_("%s loaded") % epgfilenew)
except Exception, e:
print>>log, _("%s load failed") % epgfilenew
print>>log, e
if hasattr(self, 'save_pre'):
self["statusbar"].setText(_("%s load failed") % epgfilenew)
manualEpgCopyRunning = False
timerEpgCopyRunning = False
if hasattr(self, 'save_pre'):
print>>log, _("Manual EPG copy completed")
self["statusbar"].setText(_("Manual EPG copy completed"))
elif scheduledOperation == "SCHEDULED":
print>>log, _("Scheduled EPG copy completed")
self.scheduledepgcopytime += 86400 # Tomorrow.
self.oldscheduledepgcopytime = self.scheduledepgcopytime
print>>log, _("Scheduled EPG copy time is set to %s") % time.strftime("%Y.%m.%d %H:%M:%S", time.localtime(self.scheduledepgcopytime))
elif scheduledOperation == "PERIODIC":
print>>log, _("Periodic EPG copy completed")
interval = int(config.plugins.buyukbangpanel.interval.value) * 60
nowt = time.time()
self.periodictime = nowt + interval
self.oldperiodictime = self.periodictime
print>>log, _("Periodic EPG copy time is set to %s") % time.strftime("%Y.%m.%d %H:%M:%S", time.localtime(self.periodictime))
##################### LOOKUPEVENTTIME #####################
baseeEPGCache_lookupEventTime = eEPGCache.lookupEventTime
def eEPGCache_lookupEventTime(self, ref, start_time, direction=None):
if not hasattr(eEPGCache, 'dst2src') or config.plugins.buyukbangpanel.readepgboquet.value == "1":
self.dst2src = self.getEPGMap()[0]
if self.dst2src.has_key(ref.toString()):
ref = self.dst2src[ref.toString()][3]
#f = open('/media/hdd/deneme.txt', 'a')
#f.write( "MAPPING IS " + ref.toString() + "==>" + self.dst2src[ref.toString()][4] + "\n")
#f.close()
if direction is None:
return baseeEPGCache_lookupEventTime(self, ref, start_time, 0)
else:
return baseeEPGCache_lookupEventTime(self, ref, start_time, direction)
if config.plugins.buyukbangpanel.linkepg.value != "2":
eEPGCache.lookupEventTime = eEPGCache_lookupEventTime
####################### LOOKUPEVENTID ######################
#baseeEPGCache_lookupeventid = eEPGCache.lookupeventid
def eEPGCache_lookupeventid(self, ref, eventid):
if not hasattr(eEPGCache, 'dst2src') or config.plugins.buyukbangpanel.readepgboquet.value == "1":
self.dst2src = self.getEPGMap()[0]
if self.dst2src.has_key(ref.toString()):
ref = self.dst2src[ref.toString()][3]
return baseeEPGCache_lookupeventid(self, ref, eventid)
if config.plugins.buyukbangpanel.linkepg.value != "2":
eEPGCache.lookupeventid = eEPGCache_lookupeventid
######################## LOOKUPEVENT #######################
baseeEPGCache_lookupEvent = eEPGCache.lookupEvent
# here we get a python list
# the first entry in the list is a python string to specify the format of the returned tuples (in a list)
# 0 = PyLong(0)
# I = Event Id
# B = Event Begin Time
# D = Event Duration
# T = Event Title
# S = Event Short Description
# E = Event Extended Description
# C = Current Time
# R = Service Reference
# N = Service Name
# n = Short Service Name
# X = Return a minimum of one tuple per service in the result list... even when no event was found.
# The returned tuple is filled with all available infos... non avail is filled as None
# The position and existence of 'X' in the format string has no influence on the result tuple... its completely ignored..
# then for each service follows a tuple
# first tuple entry is the servicereference (as string... use the ref.toString() function)
# the second is the type of query
# 2 = event_id
# -1 = event before given start_time
# 0 = event intersects given start_time
# +1 = event after given start_time
# the third
# when type is eventid it is the event_id
# when type is time then it is the start_time ( -1 for now_time )
# the fourth is the end_time .. ( optional .. for query all events in time range)
def eEPGCache_lookupEvent(self, listoftuple, buildFunc=None):
resultList = {}
if not hasattr(eEPGCache, 'dst2src') or not hasattr(eEPGCache, 'src2dst') or config.plugins.buyukbangpanel.readepgboquet.value == "1":
EPGMap = self.getEPGMap()
self.dst2src = EPGMap[0]
self.src2dst = EPGMap[1]
#sample graphmultiepg list of tuples: test = [ (service.ref.toString(), 0, self.time_base, self.time_epoch) for service in services ]
# test.insert(0, 'XRnITBD')
#sample multiepg list of tuples: test = [ (service.ref.toString(), 0, stime) for service in services ]
# test.insert(0, 'X0RIBDTCn')
#sample singleepg list of tuples: test = [ 'RIBDT', (service.ref.toString(), 0, -1, -1) ]
for i in range(len(listoftuple)):
if self.dst2src.has_key(listoftuple[i][0]):
if len(listoftuple[i]) == 4:
listoftuple[i] = (self.dst2src[listoftuple[i][0]][4], listoftuple[i][1], listoftuple[i][2], listoftuple[i][3])
else:
listoftuple[i] = (self.dst2src[listoftuple[i][0]][4], listoftuple[i][1], listoftuple[i][2])
if buildFunc is not None:
resultList = baseeEPGCache_lookupEvent(self, listoftuple, buildFunc)
else:
resultList = baseeEPGCache_lookupEvent(self, listoftuple)
#We now have a result with the linked service references. We need to replace this references with the original ones.
#ref_position = listoftuple[0].replace('X', '').find('R')
#f = open('/media/hdd/deneme.txt', 'a')
#f.write("ref_position=%d\n" % (ref_position))
#f.close
#if ref_position != -1:
# for i in range(len(resultList)):
# if self.src2dst.has_key(resultList[i][ref_position]):
# tmpresultList=list(resultList[i])
# tmpresultList[ref_position] = self.src2dst[resultList[i][ref_position]][1]
# resultList[i] = tuple(tmpresultList)
return resultList
if config.plugins.buyukbangpanel.linkepg.value == "1":
eEPGCache.lookupEvent = eEPGCache_lookupEvent
########################### INFOBAR FIX STARTS ###########################
EventInfo.lastdst = None
def EventInfo_gotEvent(self, what):
refstr = None
found = 0
ret = None
if what == iPlayableService.evEnd:
self.changed((self.CHANGED_CLEAR,))
return
else:
service = self.navcore.getCurrentService()
info = service and service.info()
refstr = info and info.getInfoString(iServiceInformation.sServiceref)
ret = info and info.getEvent(self.now_or_next)
if not ret and info:
ret = refstr and self.epgQuery(eServiceReference(refstr), -1, self.now_or_next and 1 or 0)
if ret and config.plugins.buyukbangpanel.filterdummy.value and config.plugins.buyukbangpanel.dummystring.value:
eventName = ret.getEventName()
if not eventName:
return
dummylist = config.plugins.buyukbangpanel.dummystring.value.split(',')
for dummytxt in dummylist:
if eventName.lower() == dummytxt.lower():
return
if ret:
if refstr and config.plugins.buyukbangpanel.linkepg.value != "2":
if not hasattr(eEPGCache, 'dst2src') or config.plugins.buyukbangpanel.readepgboquet.value == "1":
self.dst2src = self.getEPGMap()[0]
if self.dst2src.has_key(refstr):
if self.lastdst != refstr:
self.lastdst = refstr
self.changed((self.CHANGED_ALL,))
return
self.lastdst = None
self.changed((self.CHANGED_ALL,))
if config.plugins.buyukbangpanel.filterdummy.value:
EventInfo.gotEvent = EventInfo_gotEvent
######################### EPG INFO FIX STARTS ##########################
def InfoBarEPG_openEventView(self):
found = 0
ref = self.session.nav.getCurrentlyPlayingServiceReference()
self.epglist = []
epglist = self.epglist
self.is_now_next = False
epg = eEPGCache.getInstance()
ptr = ref and ref.valid() and epg.lookupEventTime(ref, -1)
if ptr is not None:
if config.plugins.buyukbangpanel.dummystring.value:
eventName = ptr.getEventName()
dummylist = config.plugins.buyukbangpanel.dummystring.value.split(',')
for dummytxt in dummylist:
if eventName.lower() == dummytxt.lower():
found = 1
if found == 0:
epglist.append(ptr)
if epglist:
self.eventView = self.session.openWithCallback(self.closed, EventViewEPGSelect, self.epglist[0], ServiceReference(ref), self.eventViewCallback, self.openSingleServiceEPG, self.openMultiServiceEPG, self.openSimilarList)
self.dlg_stack.append(self.eventView)
else:
print "No epg for the service available. So we show multiepg instead of eventinfo"
self.openMultiServiceEPG(False)
if config.plugins.buyukbangpanel.filterdummy.value:
InfoBarEPG.openEventView = InfoBarEPG_openEventView
########################## SERVICE LIST FIX STARTS ##########################
#Prevents updates when list is open. But does not help reopening of service list
#from Components.Sources.ServiceEvent import ServiceEvent
#
#def ServiceEvent_newService(self, ref):
# pass
#
#ServiceEvent.newService = ServiceEvent_newService
######################### ZAP ERRORS FIX STARTS ##########################
if config.plugins.buyukbangpanel.hidezaperrors.value:
iPlayableService.evTuneFailed = 121212
##################### IMPORTEVENTS WRAPPER #####################
def importEvents(self, services, events):
for service in services:
self.epgcache.importEvent(service, events)
if hasattr(eEPGCache, 'importEvent') and not hasattr(eEPGCache, 'importEvents'):
eEPGCache.importEvents = importEvents
###################################### MAIN SCREEN ###################################
class mainMenu(Screen):
skin = """
<screen position="center,center" size="640,400" title="Buyukbang Panel v1.4.2 buyukbang.blogspot.com">
<widget source="list" render="Listbox" position="0,0" size="640,400" scrollbarMode="showOnDemand">
<convert type="TemplatedMultiContent">
{"template": [
MultiContentEntryPixmapAlphaTest(pos = (12, 4), size = (32, 32), png = 0),
MultiContentEntryText(pos = (58, 5), size = (440, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 1),
],
"fonts": [gFont("Regular", 22)],
"itemHeight": 40
}
</convert>
</widget>
</screen>"""
def __init__(self, session, args=0):
self.session = session
self.setup_title = _("Buyukbang Panel v1.4.2 buyukbang.blogspot.com")
Screen.__init__(self, session)
l = []
l.append(self.buildListEntry(_("Copy EPG"), "copyepg.png"))
l.append(self.buildListEntry(_("Link EPG"), "linkepg.png"))
l.append(self.buildListEntry(_("Filter EPG"), "filter.png"))
l.append(self.buildListEntry(_("Fix EPG encoding"), "encoding.png"))
l.append(self.buildListEntry(_("EPG file operations"), "fileoperations.png"))
l.append(self.buildListEntry(_("Hide zap errors"), "zaperror.png"))
l.append(self.buildListEntry(_("Startup to standby"), "startuptostandby.png"))
l.append(self.buildListEntry(_("Scheduler"), "scheduler.png"))
l.append(self.buildListEntry(_("Show Log"), "log.png"))
l.append(self.buildListEntry(_("Configuration"), "configure.png"))
self["list"] = List(l)
self["setupActions"] = ActionMap(["SetupActions"],
{
"cancel": self.quit,
"ok": self.openSelected,
}, -2)
def buildListEntry(self, description, image):
pixmap = LoadPixmap(cached=True, path="/usr/lib/enigma2/python/Plugins/Extensions/BuyukbangPanel/images/%s" % image)
return((pixmap, description))
def openSelected(self):
global menuIndex
menuIndex = self["list"].getIndex()
if menuIndex == 0:
self.session.open(EPGMainSetup)
elif menuIndex == 1:
self.session.open(EPGMainSetup)
elif menuIndex == 2:
self.session.open(EPGMainSetup)
elif menuIndex == 3:
self.session.open(EPGMainSetup)
elif menuIndex == 4:
self.session.open(EPGFileOperationsScreen)
elif menuIndex == 5:
self.session.open(EPGMainSetup)
elif menuIndex == 6:
self.session.open(EPGMainSetup)
elif menuIndex == 7:
self.session.open(EPGMainSetup)
elif menuIndex == 8:
self.session.open(LogScreen)
elif menuIndex == 9:
self.session.open(EPGMainSetup)
def quit(self):
self.close()
class EPGMainSetup(ConfigListScreen, Screen):
skin = """
<screen position="center,center" size="640,400" title="Buyukbang Panel v1.4.2 buyukbang.blogspot.com" >
<ePixmap name="red" position="0,0" zPosition="2" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
<ePixmap name="green" position="160,0" zPosition="2" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
<ePixmap name="yellow" position="320,0" zPosition="2" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
<ePixmap name="blue" position="480,0" zPosition="2" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
<widget name="key_red" position="0,0" size="140,40" valign="center" halign="center" zPosition="4" foregroundColor="white" font="Regular;20" transparent="1" shadowColor="background" shadowOffset="-2,-2" />
<widget name="key_green" position="160,0" size="140,40" valign="center" halign="center" zPosition="4" foregroundColor="white" font="Regular;20" transparent="1" shadowColor="background" shadowOffset="-2,-2" />
<widget name="key_yellow" position="320,0" size="140,40" valign="center" halign="center" zPosition="4" foregroundColor="white" font="Regular;20" transparent="1" shadowColor="background" shadowOffset="-2,-2" />
<widget name="key_blue" position="480,0" size="140,40" valign="center" halign="center" zPosition="4" foregroundColor="white" font="Regular;20" transparent="1" shadowColor="background" shadowOffset="-2,-2" />
<widget name="config" position="10,60" size="620,300" scrollbarMode="showOnDemand" />
<ePixmap alphatest="on" pixmap="skin_default/icons/clock.png" position="560,378" size="14,14" zPosition="3"/>
<widget font="Regular;18" halign="left" position="585,375" render="Label" size="55,20" source="global.CurrentTime" transparent="1" valign="center" zPosition="3">
<convert type="ClockToText">Default</convert>
</widget>
<widget name="statusbar" position="10,375" size="530,20" font="Regular;18" />
<widget name="status" position="10,300" size="540,60" font="Regular;20" />
</screen>"""
def __init__(self, session, args=0):
global menuIndex
self.session = session
self.copyEpg = copyEpg
self.setup_title = _("Configuration")
Screen.__init__(self, session)
cfg = config.plugins.buyukbangpanel
self.list = []
if menuIndex == 0:
self.list.append(getConfigListEntry(_("Copy EPG periodically") + ":", cfg.periodic))
self.list.append(getConfigListEntry(_("Interval (>=2 min)") + ":", cfg.interval))
self.list.append(getConfigListEntry(_("Copy EPG at a scheduled time") + ":", cfg.scheduled))
self.list.append(getConfigListEntry(_("Scheduled EPG copy time") + ":", cfg.scheduledepgcopytime))
self.list.append(getConfigListEntry(_("Startup copy delay (>=2 min)") + ":", cfg.startupcopydelay))
self.list.append(getConfigListEntry(_("Force CrossEPG patch usage") + ":", cfg.forceepgdat))
self.list.append(getConfigListEntry(_("Read EPG bouquet") + ":", cfg.readepgboquet))
elif menuIndex == 1:
self.list.append(getConfigListEntry(_("Link EPG") + ":", cfg.linkepg))
self.list.append(getConfigListEntry(_("Read EPG bouquet") + ":", cfg.readepgboquet))
elif menuIndex == 2:
self.list.append(getConfigListEntry(_("Filter EPG") + ":", cfg.filterdummy))
self.list.append(getConfigListEntry(_("EPG titles") + ":", cfg.dummystring))
elif menuIndex == 3:
self.list.append(getConfigListEntry(_("Language") + ":", cfg.fixepgencoding))
self.list.append(getConfigListEntry(_("Encoding") + ":", cfg.epgencoding))
elif menuIndex == 5:
self.list.append(getConfigListEntry(_("Hide zap errors") + ":", cfg.hidezaperrors))
elif menuIndex == 6:
self.list.append(getConfigListEntry(_("Startup to standby") + ":", cfg.startuptostandby))
elif menuIndex == 7:
self.list.append(getConfigListEntry(_("Scheduled operation") + ":", cfg.scheduledoperation))
self.list.append(getConfigListEntry(_("Time") + ":", cfg.scheduledoperationtime))
self.list.append(getConfigListEntry(_("Monday") + ":", cfg.scheduledoperationmon))
self.list.append(getConfigListEntry(_("Tuesday") + ":", cfg.scheduledoperationtue))
self.list.append(getConfigListEntry(_("Wednesday") + ":", cfg.scheduledoperationwed))
self.list.append(getConfigListEntry(_("Thursday") + ":", cfg.scheduledoperationthu))
self.list.append(getConfigListEntry(_("Friday") + ":", cfg.scheduledoperationfri))
self.list.append(getConfigListEntry(_("Saturday") + ":", cfg.scheduledoperationsat))
self.list.append(getConfigListEntry(_("Sunday") + ":", cfg.scheduledoperationsun))
elif menuIndex == 9:
self.list.append(getConfigListEntry(_("When restart needed") + ":", cfg.restarttype))
self.list.append(getConfigListEntry(_("Show in extensions") + ":", cfg.showinextensions))
ConfigListScreen.__init__(self, self.list, session=self.session, on_change=self.changedEntry)
self["config"].onSelectionChanged.append(self.selectionChanged)
self["status"] = Label()
self["statusbar"] = Label()
self["key_red"] = Button(_("Cancel"))
self["key_green"] = Button(_("Ok"))
self["key_yellow"] = Button(_("Show Log"))
if menuIndex == 0:
self["key_blue"] = Button(_("Manual Copy"))
else:
self["key_blue"] = Button(_(" "))
self["setupActions"] = ActionMap(["SetupActions", "ColorActions", "TimerEditActions"],
{
"red": self.cancel,
"green": self.save_pre,
"yellow": self.yellowAction,
"blue": self.blueAction,
"save": self.save_pre,
"cancel": self.cancel,
"ok": self.save_pre,
"log": self.yellowAction,
}, -2)
self.onChangedEntry = []
self.oldscheduled = config.plugins.buyukbangpanel.scheduled.value
self.oldperiodic = config.plugins.buyukbangpanel.periodic.value
self.oldstartupcopydelay = config.plugins.buyukbangpanel.startupcopydelay.value
self.oldscheduledepgcopytime = config.plugins.buyukbangpanel.scheduledepgcopytime.value
self.oldinterval = config.plugins.buyukbangpanel.interval
self.oldlinkepg = config.plugins.buyukbangpanel.linkepg.value
self.oldreadepgboquet = config.plugins.buyukbangpanel.readepgboquet.value
self.oldfixepgencoding = config.plugins.buyukbangpanel.fixepgencoding.value
self.oldepgencoding = config.plugins.buyukbangpanel.epgencoding.value
self.oldhidezaperrors = config.plugins.buyukbangpanel.hidezaperrors.value
self.oldfilterdummy = config.plugins.buyukbangpanel.filterdummy.value
self.olddummystring = config.plugins.buyukbangpanel.dummystring.value
self.oldscheduledoperation = config.plugins.buyukbangpanel.scheduledoperation.value
self.oldscheduledoperationtime = config.plugins.buyukbangpanel.scheduledoperationtime.value
self.oldscheduledoperationmon = config.plugins.buyukbangpanel.scheduledoperationmon.value
self.oldscheduledoperationtue = config.plugins.buyukbangpanel.scheduledoperationtue.value
self.oldscheduledoperationwed = config.plugins.buyukbangpanel.scheduledoperationwed.value
self.oldscheduledoperationthu = config.plugins.buyukbangpanel.scheduledoperationthu.value
self.oldscheduledoperationfri = config.plugins.buyukbangpanel.scheduledoperationfri.value
self.oldscheduledoperationsat = config.plugins.buyukbangpanel.scheduledoperationsat.value
self.oldscheduledoperationsun = config.plugins.buyukbangpanel.scheduledoperationsun.value
self.oldstartuptostandby = config.plugins.buyukbangpanel.startuptostandby.value
# for summary:
def changedEntry(self):
for x in self.onChangedEntry:
x()
def getCurrentEntry(self):
return self["config"].getCurrent()[0]
def getCurrentValue(self):
return str(self["config"].getCurrent()[1].getText())
def createSummary(self):
from Screens.Setup import SetupSummary
return SetupSummary
def selectionChanged(self):
self["statusbar"].setText(" ")
def save_pre(self):
if config.plugins.buyukbangpanel.fixepgencoding.value != "disable" \
and (self.oldfixepgencoding != config.plugins.buyukbangpanel.fixepgencoding.value or self.oldepgencoding != config.plugins.buyukbangpanel.epgencoding.value):
encodingConfirmation = self.session.openWithCallback(self.save, MessageBox, _("Buyukbang Panel\n\nUpdating encoding settings requires internet connection to query Kingofsat and this may take a few minutes.\n\nDo you want to continue?"), MessageBox.TYPE_YESNO, timeout=15, default=True)
encodingConfirmation.setTitle(_("Continue?"))
else:
self.save(True)
def save(self, answer):
global autoStartTimer
if answer is True:
if config.plugins.buyukbangpanel.interval.value < 2:
config.plugins.buyukbangpanel.interval.setValue(2)
if config.plugins.buyukbangpanel.startupcopydelay.value < 2:
config.plugins.buyukbangpanel.startupcopydelay.setValue(2)
self.saveAll()
print>>log, _("Settings saved")
self["statusbar"].setText(_("Settings saved"))
if self.oldscheduled != config.plugins.buyukbangpanel.scheduled.value \
or self.oldperiodic != config.plugins.buyukbangpanel.periodic.value \
or self.oldstartupcopydelay != config.plugins.buyukbangpanel.startupcopydelay.value \
or self.oldscheduledepgcopytime != config.plugins.buyukbangpanel.scheduledepgcopytime.value \
or self.oldinterval != config.plugins.buyukbangpanel.interval.value \
or self.oldscheduledoperation != config.plugins.buyukbangpanel.scheduledoperation.value \
or self.oldscheduledoperationtime != config.plugins.buyukbangpanel.scheduledoperationtime.value \
or self.oldscheduledoperationmon != config.plugins.buyukbangpanel.scheduledoperationmon.value \
or self.oldscheduledoperationtue != config.plugins.buyukbangpanel.scheduledoperationtue.value \
or self.oldscheduledoperationwed != config.plugins.buyukbangpanel.scheduledoperationwed.value \
or self.oldscheduledoperationthu != config.plugins.buyukbangpanel.scheduledoperationthu.value \
or self.oldscheduledoperationfri != config.plugins.buyukbangpanel.scheduledoperationfri.value \
or self.oldscheduledoperationsat != config.plugins.buyukbangpanel.scheduledoperationsat.value \
or self.oldscheduledoperationsun != config.plugins.buyukbangpanel.scheduledoperationsun.value \
or self.oldstartuptostandby != config.plugins.buyukbangpanel.startuptostandby.value:
if autoStartTimer is not None:
autoStartTimer.update()
if self.oldfixepgencoding != config.plugins.buyukbangpanel.fixepgencoding.value \
or self.oldepgencoding != config.plugins.buyukbangpanel.epgencoding.value:
try:
os.rename('/usr/share/enigma2/encoding.conf_BuyukbangPanelBackup', '/usr/share/enigma2/encoding.conf')
#Assure that encoding.conf is updated with the new encoding
self.oldfixepgencoding = "disable"
except Exception, e:
print>>log, _("Updating EPG encoding setting failed")
print>>log, e
if config.plugins.buyukbangpanel.fixepgencoding.value != "disable" and (self.oldfixepgencoding != config.plugins.buyukbangpanel.fixepgencoding.value):
try:
if not os.path.exists('/usr/share/enigma2/encoding.conf') or not os.path.exists('/usr/share/enigma2/encoding.conf_BuyukbangPanelBackup'):
os.system('T=/usr/share/enigma2/encoding.conf && touch $T && (! grep -q "### BUYUKBANG PANEL ENCODING FIX ###" $T || [ ! -s $T"_BuyukbangPanelBackup" ]) && cp $T $T"_BuyukbangPanelBackup" && echo "" >> $T && echo "### BUYUKBANG PANEL ENCODING FIX ###" >> $T; wget -qO- "http://en.kingofsat.net/find2.php?cl=' + config.plugins.buyukbangpanel.fixepgencoding.value + '&ordre=freq" | grep ">NID:.*>TID:" | while read line ; do TSID="$(echo "$line" | cut -d":" -f3 | cut -d"<" -f1)"; ONID="$(echo "$line" | cut -d":" -f2 | cut -d"<" -f1)"; [ "$(echo $TSID | awk "/^[0-9]+$/")" != "" ] && [ "$(echo $ONID | awk "/^[0-9]+$/")" != "" ] && ELINE="$TSID $ONID ' + config.plugins.buyukbangpanel.epgencoding.value + '" && ! grep -q "$ELINE" $T && echo "$ELINE" >> $T; done')
except Exception, e:
print>>log, _("Fixing EPG encoding failed")
print>>log, e
if self.oldlinkepg != config.plugins.buyukbangpanel.linkepg.value \
or self.oldreadepgboquet != config.plugins.buyukbangpanel.readepgboquet.value \
or self.oldfilterdummy != config.plugins.buyukbangpanel.filterdummy.value \
or self.olddummystring != config.plugins.buyukbangpanel.dummystring.value \
or self.oldfixepgencoding != config.plugins.buyukbangpanel.fixepgencoding.value \
or self.oldepgencoding != config.plugins.buyukbangpanel.epgencoding.value and config.plugins.buyukbangpanel.fixepgencoding.value != "disable" \
or self.oldhidezaperrors != config.plugins.buyukbangpanel.hidezaperrors.value:
restartConfirmation = self.session.openWithCallback(self.restartEnigma, MessageBox, _("Buyukbang Panel\n\nRestart needed to apply the new settings.\n\nDo you want to restart now?"), MessageBox.TYPE_YESNO, timeout=15, default=True)
restartConfirmation.setTitle(_("Restart now?"))
def restartEnigma(self, answer):
#Notifications.AddNotification(Screens.Standby.TryQuitMainloop, 3)
#from enigma import quitMainloop
#quitMainloop(5)
if answer is True:
self.session.open(TryQuitMainloop, int(config.plugins.buyukbangpanel.restarttype.value))
def cancel(self):
global manualEpgCopyRunning
for x in self["config"].list:
x[1].cancel()
manualEpgCopyRunning = False
self.close(False, self.session)
def yellowAction(self):
self.session.open(LogScreen)
def blueAction(self):
global reboot
if menuIndex == 0:
if twisted.python.runtime.platform.supportsThreads():
threads.deferToThread(self.copyEpg, self).addCallback(lambda ignore: self.afterCopyEPG())
else:
self.copyEpg(self)
self.afterCopyEPG()
def onTimer(self):
self.timer.stop()
if twisted.python.runtime.platform.supportsThreads():
threads.deferToThread(self.copyEpg, self).addCallback(lambda ignore: self.afterCopyEPG())
else:
self.copyEpg(self)
self.afterCopyEPG()
def afterCopyEPG(self):
global reboot
if reboot:
restartConfirmation = self.session.openWithCallback(self.restartEnigma, MessageBox, _("Buyukbang Panel\n\nRestart needed to load the EPG data.\n\nDo you want to restart now?"), MessageBox.TYPE_YESNO, timeout=15, default=True)
restartConfirmation.setTitle(_("Restart now?"))
self.update()
###################################### LOG SCREEN ###################################
class LogScreen(Screen):
skin = """
<screen position="center,center" size="640,400" title="Buyukbang Panel v1.4.2 buyukbang.blogspot.com" >
<ePixmap name="red" position="0,0" zPosition="2" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
<ePixmap name="green" position="160,0" zPosition="2" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
<ePixmap name="yellow" position="320,0" zPosition="2" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
<ePixmap name="blue" position="480,0" zPosition="2" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
<widget name="key_red" position="0,0" size="140,40" valign="center" halign="center" zPosition="4" foregroundColor="white" font="Regular;20" transparent="1" shadowColor="background" shadowOffset="-2,-2" />
<widget name="key_green" position="160,0" size="140,40" valign="center" halign="center" zPosition="4" foregroundColor="white" font="Regular;20" transparent="1" shadowColor="background" shadowOffset="-2,-2" />
<widget name="key_yellow" position="320,0" size="140,40" valign="center" halign="center" zPosition="4" foregroundColor="white" font="Regular;20" transparent="1" shadowColor="background" shadowOffset="-2,-2" />
<widget name="key_blue" position="480,0" size="140,40" valign="center" halign="center" zPosition="4" foregroundColor="white" font="Regular;20" transparent="1" shadowColor="background" shadowOffset="-2,-2" />
<ePixmap alphatest="on" pixmap="skin_default/icons/clock.png" position="560,378" size="14,14" zPosition="3"/>
<widget font="Regular;18" halign="left" position="585,375" render="Label" size="55,20" source="global.CurrentTime" transparent="1" valign="center" zPosition="3">
<convert type="ClockToText">Default</convert>
</widget>
<widget name="list" position="10,60" size="620,320" />
</screen>"""
def __init__(self, session):
self.session = session
Screen.__init__(self, session)
self["key_red"] = Button(_("Clear"))
self["key_green"] = Button()
self["key_yellow"] = Button()
self["key_blue"] = Button(_("Save"))
self["list"] = ScrollLabel(log.getvalue())
self["actions"] = ActionMap(["DirectionActions", "OkCancelActions", "ColorActions"],
{
"red": self.clear,
"save": self.save,
"blue": self.save,
"cancel": self.cancel,
"ok": self.cancel,
"left": self["list"].pageUp,
"right": self["list"].pageDown,
"up": self["list"].pageUp,
"down": self["list"].pageDown,
"pageUp": self["list"].pageUp,
"pageDown": self["list"].pageDown
}, -2)
def save(self):
try:
f = open('/tmp/buyukbangpanel.log', 'w')
f.write(log.getvalue())
f.close()
except Exception, e:
self["list"].setText("Failed to write /tmp/buyukbangpanel.log")
self.close(True)
def cancel(self):
self.close(False)
def clear(self):
log.logfile.reset()
log.logfile.truncate()
self.close(False)
############################## EPG FILE OPERATIONS SCREEN ###########################
class EPGFileOperationsScreen(Screen):
skin = """
<screen position="center,center" size="640,400" title="Buyukbang Panel v1.4.2 buyukbang.blogspot.com" >
<ePixmap name="red" position="0,0" zPosition="2" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
<ePixmap name="green" position="160,0" zPosition="2" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
<ePixmap name="yellow" position="320,0" zPosition="2" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
<ePixmap name="blue" position="480,0" zPosition="2" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
<widget name="key_red" position="0,0" size="140,40" valign="center" halign="center" zPosition="4" foregroundColor="white" font="Regular;20" transparent="1" shadowColor="background" shadowOffset="-2,-2" />
<widget name="key_green" position="160,0" size="140,40" valign="center" halign="center" zPosition="4" foregroundColor="white" font="Regular;20" transparent="1" shadowColor="background" shadowOffset="-2,-2" />
<widget name="key_yellow" position="320,0" size="140,40" valign="center" halign="center" zPosition="4" foregroundColor="white" font="Regular;20" transparent="1" shadowColor="background" shadowOffset="-2,-2" />
<widget name="key_blue" position="480,0" size="140,40" valign="center" halign="center" zPosition="4" foregroundColor="white" font="Regular;20" transparent="1" shadowColor="background" shadowOffset="-2,-2" />
<ePixmap alphatest="on" pixmap="skin_default/icons/clock.png" position="560,378" size="14,14" zPosition="3"/>
<widget font="Regular;18" halign="left" position="585,375" render="Label" size="55,20" source="global.CurrentTime" transparent="1" valign="center" zPosition="3">
<convert type="ClockToText">Default</convert>
</widget>
</screen>"""
def __init__(self, session):
self.session = session
Screen.__init__(self, session)
self["key_red"] = Button(_("Delete"))
self["key_green"] = Button(_("Backup"))
self["key_yellow"] = Button(_("Restore"))
self["key_blue"] = Button()
self["actions"] = ActionMap(["DirectionActions", "OkCancelActions", "ColorActions"],
{
"red": self.deleteEpg,
"green": self.backupEpg,
"yellow": self.restoreEpg,