-
Notifications
You must be signed in to change notification settings - Fork 29
/
SerienRecorder.py
12717 lines (10924 loc) · 534 KB
/
SerienRecorder.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
# -*- coding: utf-8 -*-
from __init__ import _
from Components.ActionMap import ActionMap, HelpableActionMap
from Components.Label import Label
from Components.MenuList import MenuList
from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmap, MultiContentEntryPixmapAlphaTest
from Tools.LoadPixmap import LoadPixmap
from Components.Pixmap import Pixmap
from Components.AVSwitch import AVSwitch
from Screens.InfoBar import MoviePlayer
from Components.PluginComponent import plugins
from Components.Button import Button
from Components.VideoWindow import VideoWindow
from Screens.Screen import Screen
from Plugins.Plugin import PluginDescriptor
from twisted.web.client import getPage
from twisted.web.client import downloadPage
from Components.ServicePosition import ServicePositionGauge
from Tools.NumericalTextInput import NumericalTextInput
from Components.ConfigList import ConfigList, ConfigListScreen
from Components.config import config, ConfigInteger, ConfigSelection, getConfigListEntry, ConfigText, ConfigDirectory, ConfigYesNo, configfile, ConfigSelection, ConfigSubsection, ConfigPIN, NoSave, ConfigNothing, ConfigClock, ConfigSelectionNumber
from Components.ScrollLabel import ScrollLabel
from Components.FileList import FileList
from Components.Sources.StaticText import StaticText
from Screens.HelpMenu import HelpableScreen
from Screens.InputBox import InputBox
from Screens.ChoiceBox import ChoiceBox
from Screens.MessageBox import MessageBox
import Screens.Standby
from enigma import eListboxPythonMultiContent, eListbox, gFont, RT_HALIGN_LEFT, RT_HALIGN_RIGHT, RT_HALIGN_CENTER, loadPNG, RT_WRAP, eServiceReference, getDesktop, loadJPG, RT_VALIGN_CENTER, RT_VALIGN_TOP, RT_VALIGN_BOTTOM, gPixmapPtr, ePicLoad, eTimer, eServiceCenter, eConsoleAppContainer
from Tools.Directories import pathExists, fileExists, SCOPE_SKIN_IMAGE, resolveFilename
import sys, os, base64, re, time, shutil, datetime, codecs, urllib, urllib2, random
from twisted.web import client, error as weberror
from twisted.internet import reactor, defer
from skin import parseColor, loadSkin, parseFont
if fileExists("/usr/lib/enigma2/python/Plugins/SystemPlugins/Toolkit/NTIVirtualKeyBoard.pyo"):
from Plugins.SystemPlugins.Toolkit.NTIVirtualKeyBoard import NTIVirtualKeyBoard
else:
from Screens.VirtualKeyBoard import VirtualKeyBoard as NTIVirtualKeyBoard
from ServiceReference import ServiceReference
# Tageditor
from Screens.MovieSelection import getPreferredTagEditor
from Components.UsageConfig import preferredTimerPath, preferredInstantRecordPath
# Navigation (RecordTimer)
import NavigationInstance
# Timer
from RecordTimer import RecordTimerEntry, RecordTimer, parseEvent, AFTEREVENT
from Components.TimerSanityCheck import TimerSanityCheck
# EPGCache & Event
from enigma import eEPGCache, iServiceInformation
from Tools import Notifications
import sqlite3, httplib
import cPickle as pickle
try:
import simplejson as json
except ImportError:
import json
from SerienRecorderHelpers import *
from SerienRecorderSplashScreen import *
from SerienRecorderStartupInfoScreen import *
from SerienRecorderUpdateScreen import *
from SerienRecorderAboutScreen import *
colorRed = 0xf23d21
colorGreen = 0x389416
colorBlue = 0x0064c7
colorYellow = 0xbab329
colorWhite = 0xffffff
serienRecMainPath = "/usr/lib/enigma2/python/Plugins/Extensions/serienrecorder/"
serienRecCoverPath = "/tmp/serienrecorder/"
InfoFile = "%sStartupInfoText" % serienRecMainPath
try:
default_before = int(config.recording.margin_before.value)
default_after = int(config.recording.margin_after.value)
except Exception:
default_before = 0
default_after = 0
showAllButtons = False
longButtonText = False
buttonText_na = _("-----")
skinName = "SerienRecorder3.0"
skin = "%sskins/SR_Skin.xml" % serienRecMainPath
default_skinName = skinName
default_skin = skin
skinFactor = 1
# Check if is Full HD 1920x1080
DESKTOP_WIDTH = getDesktop(0).size().width()
if DESKTOP_WIDTH > 1280:
skinFactor = 1.5
else:
skinFactor = 1
print "[SerienRecorder] Skinfactor: %s" % skinFactor
def SelectSkin():
global showAllButtons
showAllButtons = False
global longButtonText
longButtonText = False
global buttonText_na
buttonText_na = _("-----")
global skinName
skinName = default_skinName
global skin
skin = default_skin
if config.plugins.serienRec.SkinType.value == "Skinpart":
try:
from skin import lookupScreen
x, path = lookupScreen("SerienRecorder", 0)
if x:
skinName = "SerienRecorder"
showAllButtons = config.plugins.serienRec.showAllButtons.value
except:
writeErrorLog(" SelectSkin(): Error")
pass
elif config.plugins.serienRec.SkinType.value in ("", "Skin2", "AtileHD", "StyleFHD", "Black Box"):
skin = "%sskins/%s/SR_Skin.xml" % (serienRecMainPath, config.plugins.serienRec.SkinType.value)
skin = skin.replace("//", "/")
if config.plugins.serienRec.SkinType.value in ("Skin2", "StyleFHD", "Black Box"):
showAllButtons = True
if config.plugins.serienRec.SkinType.value in ("Skin2", "AtileHD", "Black Box"):
buttonText_na = ""
else:
if fileExists("%sskins/%s/SR_Skin.xml" % (serienRecMainPath, config.plugins.serienRec.SkinType.value)):
skin = "%sskins/%s/SR_Skin.xml" % (serienRecMainPath, config.plugins.serienRec.SkinType.value)
showAllButtons = config.plugins.serienRec.showAllButtons.value
buttonText_na = ""
def ReadConfigFile():
config.plugins.serienRec = ConfigSubsection()
config.plugins.serienRec.savetopath = ConfigText(default = "/media/hdd/movie/", fixed_size=False, visible_width=80)
config.plugins.serienRec.databasePath = ConfigText(default = serienRecMainPath, fixed_size=False, visible_width=80)
config.plugins.serienRec.coverPath = ConfigText(default = serienRecCoverPath, fixed_size=False, visible_width=80)
choices = [("Skinpart", _("Skinpart")), ("", _("SerienRecorder 1")), ("Skin2", _("SerienRecorder 2")), ("AtileHD", _("AtileHD")), ("StyleFHD", _("StyleFHD")), ("Black Box", _("Black Box"))]
try:
t = list(os.walk("%sskins" % serienRecMainPath))
for x in t[0][1]:
if x not in ("Skin2", "AtileHD", "StyleFHD", "Black Box"):
choices.append((x, x))
except:
writeErrorLog(" ReadConfigFile(): Error creating Skin-List")
pass
config.plugins.serienRec.SkinType = ConfigSelection(choices = choices, default="")
config.plugins.serienRec.showAllButtons = ConfigYesNo(default = False)
config.plugins.serienRec.DisplayRefreshRate = ConfigInteger(10, (1,60))
choices = [("Original", _("Original")), ]
try:
t = list(os.walk("%simages" % serienRecMainPath))
for x in t[0][1]:
if x not in ("sender", "Original"):
choices.append((x, x))
except:
writeErrorLog(" ReadConfigFile(): Error creating Picon-List")
pass
config.plugins.serienRec.piconPath = ConfigSelection(choices = choices, default="Original")
#config.plugins.serienRec.fake_entry = NoSave(ConfigNothing())
config.plugins.serienRec.BoxID = ConfigSelectionNumber(1, 16, 1, default = 1)
config.plugins.serienRec.activateNewOnThisSTBOnly = ConfigYesNo(default = False)
config.plugins.serienRec.setupType = ConfigSelection(choices = [("0", _("einfach")), ("1", _("Experte"))], default = "0")
config.plugins.serienRec.seriensubdir = ConfigYesNo(default = False)
config.plugins.serienRec.seasonsubdir = ConfigYesNo(default = False)
config.plugins.serienRec.seasonsubdirnumerlength = ConfigInteger(1, (1,4))
config.plugins.serienRec.seasonsubdirfillchar = ConfigSelection(choices = [("0","'0'"), ("<SPACE>", "<SPACE>")], default="0")
config.plugins.serienRec.justplay = ConfigYesNo(default = False)
config.plugins.serienRec.justremind = ConfigYesNo(default = False)
config.plugins.serienRec.zapbeforerecord = ConfigYesNo(default = False)
config.plugins.serienRec.afterEvent = ConfigSelection(choices = [("0", _("nichts")), ("1", _("in Standby gehen")), ("2", _("in Deep-Standby gehen")), ("3", _("automatisch"))], default="3")
config.plugins.serienRec.AutoBackup = ConfigYesNo(default = False)
config.plugins.serienRec.BackupPath = ConfigText(default = "/media/hdd/SR_Backup/", fixed_size=False, visible_width=80)
config.plugins.serienRec.eventid = ConfigYesNo(default = True)
# Remove EPGRefresh action for VU+ Boxes
try:
from Tools.HardwareInfoVu import HardwareInfoVu
config.plugins.serienRec.autochecktype = ConfigSelection(choices = [("0", _("Manuell")), ("1", _("zur gewählten Uhrzeit"))], default = "1")
except:
config.plugins.serienRec.autochecktype = ConfigSelection(choices = [("0", _("Manuell")), ("1", _("zur gewählten Uhrzeit")), ("2", _("nach EPGRefresh"))], default = "1")
config.plugins.serienRec.update = ConfigYesNo(default = False)
config.plugins.serienRec.updateInterval = ConfigInteger(0, (0,24))
config.plugins.serienRec.timeUpdate = ConfigYesNo(default = False)
config.plugins.serienRec.deltime = ConfigClock(default = (2*3600)+time.timezone)
config.plugins.serienRec.maxDelayForAutocheck = ConfigInteger(15, (0,60))
config.plugins.serienRec.maxWebRequests = ConfigInteger(1, (1,99))
config.plugins.serienRec.checkfordays = ConfigInteger(1, (1,14))
config.plugins.serienRec.globalFromTime = ConfigClock(default = 0+time.timezone)
config.plugins.serienRec.globalToTime = ConfigClock(default = (((23*60)+59)*60)+time.timezone)
config.plugins.serienRec.forceRecording = ConfigYesNo(default = False)
config.plugins.serienRec.TimerForSpecials = ConfigYesNo(default = False)
config.plugins.serienRec.TimeSpanForRegularTimer = ConfigInteger(7, (int(config.plugins.serienRec.checkfordays.value),999))
config.plugins.serienRec.forceManualRecording = ConfigYesNo(default = False)
config.plugins.serienRec.margin_before = ConfigInteger(default_before, (0,99))
config.plugins.serienRec.margin_after = ConfigInteger(default_after, (0,99))
config.plugins.serienRec.max_season = ConfigInteger(30, (1,999))
config.plugins.serienRec.Autoupdate = ConfigYesNo(default = True)
config.plugins.serienRec.updateType = ConfigSelection(choices = [("0", _("nur Released")), ("1", _("alle (auch beta)"))], default = "0")
config.plugins.serienRec.wakeUpDSB = ConfigYesNo(default = False)
config.plugins.serienRec.afterAutocheck = ConfigSelection(choices = [("0", _("keine")), ("1", _("in Standby gehen")), ("2", _("in Deep-Standby gehen"))], default = "0")
config.plugins.serienRec.DSBTimeout = ConfigInteger(20, (0,999))
config.plugins.serienRec.showNotification = ConfigSelection(choices = [("0", _("keine")), ("1", _("bei Suchlauf-Start")), ("2", _("bei Suchlauf-Ende")), ("3", _("bei Suchlauf-Start und Ende"))], default = "1")
config.plugins.serienRec.LogFilePath = ConfigText(default = serienRecMainPath, fixed_size=False, visible_width=80)
config.plugins.serienRec.longLogFileName = ConfigYesNo(default = False)
config.plugins.serienRec.deleteLogFilesOlderThan = ConfigInteger(14, (0,999))
config.plugins.serienRec.writeLog = ConfigYesNo(default = True)
config.plugins.serienRec.writeLogChannels = ConfigYesNo(default = True)
config.plugins.serienRec.writeLogAllowedSender = ConfigYesNo(default = True)
config.plugins.serienRec.writeLogAllowedEpisodes = ConfigYesNo(default = True)
config.plugins.serienRec.writeLogAdded = ConfigYesNo(default = True)
config.plugins.serienRec.writeLogDisk = ConfigYesNo(default = True)
config.plugins.serienRec.writeLogTimeRange = ConfigYesNo(default = True)
config.plugins.serienRec.writeLogTimeLimit = ConfigYesNo(default = True)
config.plugins.serienRec.writeLogTimerDebug = ConfigYesNo(default = True)
config.plugins.serienRec.writeLogVersion = ConfigYesNo(default = True)
config.plugins.serienRec.confirmOnDelete = ConfigYesNo(default = True)
config.plugins.serienRec.ActionOnNew = ConfigSelection(choices = [("0", _("keine")), ("1", _("nur Benachrichtigung")), ("4", _("nur Suchen"))], default="0")
config.plugins.serienRec.ActionOnNewManuell = ConfigYesNo(default = True)
config.plugins.serienRec.deleteOlderThan = ConfigInteger(7, (1,99))
config.plugins.serienRec.autoSearchForCovers = ConfigYesNo(default = False)
config.plugins.serienRec.planerCacheEnabled = ConfigYesNo(default = True)
config.plugins.serienRec.planerCacheSize = ConfigInteger((int(config.plugins.serienRec.checkfordays.value)), (1,4))
config.plugins.serienRec.NoOfRecords = ConfigInteger(1, (1,9))
config.plugins.serienRec.showMessageOnConflicts = ConfigYesNo(default = True)
config.plugins.serienRec.showPicons = ConfigYesNo(default = True)
config.plugins.serienRec.listFontsize = ConfigSelectionNumber(-5, 5, 1, default = 0)
config.plugins.serienRec.intensiveTimersuche = ConfigYesNo(default = True)
config.plugins.serienRec.breakTimersuche = ConfigYesNo(default = False)
config.plugins.serienRec.sucheAufnahme = ConfigYesNo(default = True)
config.plugins.serienRec.selectNoOfTuners = ConfigYesNo(default = True)
config.plugins.serienRec.tuner = ConfigInteger(4, (1,4))
config.plugins.serienRec.logScrollLast = ConfigYesNo(default = False)
config.plugins.serienRec.logWrapAround = ConfigYesNo(default = False)
config.plugins.serienRec.TimerName = ConfigSelection(choices = [("0", _("<Serienname> - SnnEmm - <Episodentitel>")), ("1", _("<Serienname>")), ("2", _("SnnEmm - <Episodentitel>"))], default="0")
config.plugins.serienRec.refreshViews = ConfigYesNo(default = True)
config.plugins.serienRec.defaultStaffel = ConfigSelection(choices = [("0","'Alle'"), ("1", "'Manuell'")], default="0")
config.plugins.serienRec.openMarkerScreen = ConfigYesNo(default = True)
config.plugins.serienRec.runAutocheckAtExit = ConfigYesNo(default = False)
config.plugins.serienRec.showCover = ConfigYesNo(default = False)
config.plugins.serienRec.showAdvice = ConfigYesNo(default = True)
config.plugins.serienRec.showStartupInfoText = ConfigYesNo(default = True)
config.plugins.serienRec.writeErrorLog = ConfigYesNo(default = False)
config.plugins.serienRec.selectBouquets = ConfigYesNo(default = False)
#config.plugins.serienRec.MainBouquet = ConfigSelection(choices = [("Favourites (TV)", _("Favourites (TV)")), ("Favourites-SD (TV)", _("Favourites-SD (TV)"))], default="Favourites (TV)")
#config.plugins.serienRec.AlternativeBouquet = ConfigSelection(choices = [("Favourites (TV)", _("Favourites (TV)")), ("Favourites-SD (TV)", _("Favourites-SD (TV)"))], default="Favourites-SD (TV)")
config.plugins.serienRec.bouquetList = ConfigText(default = "")
choices = [(x.strip(),x.strip()) for x in config.plugins.serienRec.bouquetList.value.replace('"','').replace("'",'').replace('[','').replace(']','').split(',')]
if len(choices) > 0:
config.plugins.serienRec.MainBouquet = ConfigSelection(choices = choices, default = choices[0][0])
else:
config.plugins.serienRec.MainBouquet = ConfigSelection(choices = choices)
if len(choices) > 1:
config.plugins.serienRec.AlternativeBouquet = ConfigSelection(choices = choices, default = choices[1][0])
else:
config.plugins.serienRec.AlternativeBouquet = ConfigSelection(choices = choices)
config.plugins.serienRec.useAlternativeChannel = ConfigYesNo(default = False)
config.plugins.serienRec.splitEventTimer = ConfigSelection(choices = [("0", "nein"), ("1", "Timer anlegen"), ("2", "Einzelepisoden bevorzugen")], default = "0")
config.plugins.serienRec.firstscreen = ConfigSelection(choices = [("0","SerienPlaner"), ("1", "SerienMarker")], default="0")
# interne
config.plugins.serienRec.version = NoSave(ConfigText(default="032"))
config.plugins.serienRec.showversion = NoSave(ConfigText(default="3.2"))
config.plugins.serienRec.screenmode = ConfigInteger(0, (0,2))
config.plugins.serienRec.screenplaner = ConfigInteger(1, (1,5))
config.plugins.serienRec.recordListView = ConfigInteger(0, (0,1))
config.plugins.serienRec.addedListSorted = ConfigYesNo(default = False)
config.plugins.serienRec.wishListSorted = ConfigYesNo(default = False)
config.plugins.serienRec.serienRecShowSeasonBegins_filter = ConfigYesNo(default = False)
config.plugins.serienRec.dbversion = NoSave(ConfigText(default="3.2"))
# Override settings for maxWebRequests, AutoCheckInterval and due to restrictions of Wunschliste.de
config.plugins.serienRec.maxWebRequests.setValue(1)
config.plugins.serienRec.maxWebRequests.save()
if config.plugins.serienRec.autochecktype.value == "0":
config.plugins.serienRec.updateInterval.setValue(0)
else:
if int(config.plugins.serienRec.updateInterval.value) > 0:
config.plugins.serienRec.updateInterval.setValue(24)
config.plugins.serienRec.updateInterval.save()
config.plugins.serienRec.autoSearchForCovers.setValue(False)
config.plugins.serienRec.autoSearchForCovers.save()
configfile.save()
SelectSkin()
ReadConfigFile()
UpdateAvailable = False
if config.plugins.serienRec.firstscreen.value == "0":
showMainScreen = True
else:
showMainScreen = False
#logFile = "%slog" % serienRecMainPath
logFile = "%slog" % config.plugins.serienRec.LogFilePath.value
serienRecDataBase = "%sSerienRecorder.db" % config.plugins.serienRec.databasePath.value
#dbTmp = sqlite3.connect("%sSR_Tmp.db" % config.plugins.serienRec.databasePath.value)
dbTmp = sqlite3.connect(":memory:")
dbTmp.text_factory = lambda x: str(x.decode("utf-8"))
dbSerRec = None
#dbSerRec = sqlite3.connect(serienRecDataBase)
# dbSerRec.text_factory = lambda x: str(x.decode("utf-8"))
autoCheckFinished = False
refreshTimer = None
refreshTimerConnection = None
coverToShow = None
runAutocheckAtExit = False
startTimer = None
startTimerConnection = None
dayCache = {}
termineCache = {}
# init EPGTranslator
if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/EPGTranslator/plugin.pyo"):
from Plugins.Extensions.EPGTranslator.plugin import searchYouTube
epgTranslatorInstalled = True
else:
epgTranslatorInstalled = False
# check VPS availability
try:
from Plugins.SystemPlugins.vps import Vps
except ImportError as ie:
VPSPluginAvailable = False
else:
VPSPluginAvailable = True
SR_OperatingManual = "file://usr/lib/enigma2/python/Plugins/Extensions/serienrecorder/Help/SerienRecorder.html"
# init Opera Webbrowser
if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/HbbTV/browser.pyo"):
from Plugins.Extensions.HbbTV.browser import Browser
OperaBrowserInstalled = True
else:
OperaBrowserInstalled = False
# init DMM Webbrowser
if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/Browser/Browser.pyo"):
from Plugins.Extensions.Browser.Browser import Browser
DMMBrowserInstalled = True
else:
DMMBrowserInstalled = False
# init Wikipedia
if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/Wikipedia/plugin.pyo"):
from Plugins.Extensions.Wikipedia.plugin import wikiSearch
WikipediaInstalled = True
else:
WikipediaInstalled = False
import keymapparser
try:
keymapparser.removeKeymap("%skeymap.xml" % serienRecMainPath)
except:
pass
try:
keymapparser.readKeymap("%skeymap.xml" % serienRecMainPath)
except:
pass
#---------------------------------- Common Functions ------------------------------------------
def getUrl(url):
req = urllib2.Request(url)
res = urllib2.urlopen(req)
finalurl = res.geturl()
return finalurl
def retry(times, func, *args, **kwargs):
"""retry a defer function
@param times: how many times to retry
@param func: defer function
"""
errorList = []
deferred = defer.Deferred()
def run():
#writeLog(_("[Serien Recorder] Versuche Webseite abzurufen..."), True)
d = func(*args, **kwargs)
d.addCallbacks(deferred.callback, error)
def error(retryError):
errorList.append(retryError)
# Retry
if len(errorList) < times:
writeLog(_("[Serien Recorder] Fehler beim Abrufen von ' %s ', versuche es noch %d mal...") % (args[1], times - len(errorList)), True)
run()
# Fail
else:
writeLog(_("[Serien Recorder] Abrufen von ' %s ' auch nach mehreren Versuchen nicht möglich!") % args[1], True)
deferred.errback(errorList)
run()
return deferred
def getCover(self, serien_name, serien_id):
if not config.plugins.serienRec.showCover.value:
return
serien_nameCover = "%s%s.jpg" % (config.plugins.serienRec.coverPath.value, serien_name)
png_serien_nameCover = "%s%s.png" % (config.plugins.serienRec.coverPath.value, serien_name)
if self is not None:
self['cover'].hide()
global coverToShow
coverToShow = serien_nameCover
if not fileExists(config.plugins.serienRec.coverPath.value):
try:
shutil.os.mkdir(config.plugins.serienRec.coverPath.value)
except:
Notifications.AddPopup(_("[Serien Recorder]\nCover Pfad (%s) kann nicht angelegt werden.\n\nÜberprüfen Sie den Pfad und die Rechte!") % config.plugins.serienRec.coverPath.value, MessageBox.TYPE_INFO, timeout=10, id="[Serien Recorder] checkFileAccess")
# Change PNG cover file extension to correct file extension JPG
if fileExists(png_serien_nameCover):
os.rename(png_serien_nameCover, serien_nameCover)
if fileExists(serien_nameCover):
if self is not None: showCover(serien_nameCover, self, serien_nameCover)
elif serien_id:
url = "http://www.wunschliste.de%s/links" % serien_id
getPage(getURLWithProxy(url), timeout=WebTimeout, agent=getUserAgent(), headers=getHeaders()).addCallback(getImdblink, self, serien_nameCover).addErrback(getCoverDataError, self, serien_nameCover)
def getCoverDataError(error, self, serien_nameCover):
if self is not None:
#self['title'].setText(_("Cover-Suche auf 'Wunschliste.de' erfolglos"))
#self['title'].instance.setForegroundColor(parseColor("white"))
writeLog(_("[Serien Recorder] Fehler bei: %s (%s)") % (self.ErrorMsg, serien_nameCover), True)
writeErrorLog(" getCover(): %s\n Serie: %s\n %s" % (error, serien_nameCover, self.ErrorMsg))
print "[Serien Recorder] Fehler bei: %s" % self.ErrorMsg
else:
ErrorMsg = _("Cover-Suche (%s) auf 'Wunschliste.de' erfolglos") % serien_nameCover
writeLog(_("[Serien Recorder] Fehler: %s") % ErrorMsg, True)
writeErrorLog(" getCover(): %s\n Serie: %s" % (error, serien_nameCover))
print "[Serien Recorder] Fehler: %s" % ErrorMsg
writeLog(_(" %s") % str(error), True)
print error
def getImdblink(data, self, serien_nameCover):
data = processDownloadedData(data)
imdbID = re.findall('<a href="http://www.imdb.com/title/(.*?)/.*?"', data, re.S)
if imdbID:
omdbURL = "http://www.omdbapi.com/?i=%s" % imdbID[0]
getPage(omdbURL, timeout=WebTimeout, agent=getUserAgent(), headers=getHeaders()).addCallback(loadImdbCover, self, serien_nameCover).addErrback(getCoverDataError, self, serien_nameCover)
else:
print "[Serien Recorder] es wurde kein imdb-link für ein cover gefunden."
def loadImdbCover(data, self, serien_nameCover):
data = processDownloadedData(data)
parsed_json = json.loads(data)
posterURL = str(parsed_json['Poster'])
if posterURL:
print posterURL
downloadPage(posterURL, serien_nameCover).addCallback(showCover, self, serien_nameCover, False).addErrback(getCoverDataError, self, serien_nameCover)
def showCover(data, self, serien_nameCover, force_show=True):
if self is not None:
if not force_show:
global coverToShow
if coverToShow == serien_nameCover:
coverToShow = None
else:
return
if fileExists(serien_nameCover):
self['cover'].instance.setPixmap(gPixmapPtr())
scale = AVSwitch().getFramebufferScale()
size = self['cover'].instance.size()
self.picload.setPara((size.width(), size.height(), scale[0], scale[1], False, 1, "#00000000"))
self.picLoaderResult = 1
if isDreamboxOS:
self.picLoaderResult = self.picload.startDecode(serien_nameCover, False)
else:
self.picLoaderResult = self.picload.startDecode(serien_nameCover, 0, 0, False)
if self.picLoaderResult == 0:
ptr = self.picload.getData()
if ptr != None:
self['cover'].instance.setPixmap(ptr)
self['cover'].show()
else:
print "Coverfile not found: %s" % serien_nameCover
def setSkinProperties(self, isLayoutFinshed=True):
global longButtonText
if isLayoutFinshed:
try:
x = self['text_3'].instance.size()
if x.width() > 250:
longButtonText = True
else:
longButtonText = False
except:
longButtonText = False
if longButtonText:
self.num_bt_text = ([_("Zeige Log"), buttonText_na, _("Abbrechen")],
[buttonText_na, _("Konflikt-Liste"), _("YouTube (lang: Wikipedia)")],
[buttonText_na, _("Merkzettel"), ""],
[_("Neue Serienstarts"), buttonText_na, _("Hilfe")],
[_("Serien Beschreibung"), buttonText_na, _("globale Einstellungen")])
else:
self.num_bt_text = ([_("Zeige Log"), buttonText_na, _("Abbrechen")],
[buttonText_na, _("Konflikt-Liste"), _("YouTube/Wikipedia")],
[buttonText_na, _("Merkzettel"), ""],
[_("Neue Serienstarts"), buttonText_na, _("Hilfe")],
[_("Serien Beschreibung"), buttonText_na, _("globale Einstellungen")])
if showAllButtons:
Skin1_Settings(self)
def InitSkin(self):
global showAllButtons
global longButtonText
global buttonText_na
global skin
global skinName
self.skinName = skinName
if skin:
try:
SRSkin = open(skin)
self.skin = SRSkin.read()
SRSkin.close()
except:
showAllButtons = False
longButtonText = False
buttonText_na = _("-----")
skinName = default_skinName
skin = default_skin
SRSkin = open(skin)
self.skin = SRSkin.read()
SRSkin.close()
self['bt_red'] = Pixmap()
self['bt_green'] = Pixmap()
self['bt_yellow'] = Pixmap()
self['bt_blue'] = Pixmap()
self['bt_ok'] = Pixmap()
self['bt_exit'] = Pixmap()
self['bt_text'] = Pixmap()
self['bt_epg'] = Pixmap()
self['bt_info'] = Pixmap()
self['bt_menu'] = Pixmap()
self['bt_0'] = Pixmap()
self['bt_1'] = Pixmap()
self['bt_2'] = Pixmap()
self['bt_3'] = Pixmap()
self['bt_4'] = Pixmap()
self['bt_5'] = Pixmap()
self['bt_6'] = Pixmap()
self['bt_7'] = Pixmap()
self['bt_8'] = Pixmap()
self['bt_9'] = Pixmap()
self['text_red'] = Label("")
self['text_green'] = Label("")
self['text_yellow'] = Label("")
self['text_blue'] = Label(_(""))
self['text_ok'] = Label("")
self['text_exit'] = Label("")
self['text_text'] = Label("")
self['text_epg'] = Label("")
self['text_info'] = Label("")
self['text_menu'] = Label("")
self['text_0'] = Label("")
self['text_1'] = Label("")
self['text_2'] = Label("")
self['text_3'] = Label("")
self['text_4'] = Label("")
self['text_5'] = Label("")
self['text_6'] = Label("")
self['text_7'] = Label("")
self['text_8'] = Label("")
self['text_9'] = Label("")
self['Web_Channel'] = Label("")
self['Web_Channel'].hide()
self['STB_Channel'] = Label("")
self['STB_Channel'].hide()
self['alt_STB_Channel'] = Label("")
self['alt_STB_Channel'].hide()
self['separator'] = Label("")
self['separator'].hide()
self['path'] = Label("")
self['path'].hide()
self['menu_list'] = MenuList([])
self['menu_list'].hide()
self['config'] = MenuList([])
self['config'].hide()
self['log'] = MenuList([])
self['log'].hide()
self['list'] = MenuList([])
self['list'].hide()
self['popup_list'] = MenuList([])
self['popup_list'].hide()
self['popup_list2'] = MenuList([])
self['popup_list2'].hide()
self['popup_bg'] = Pixmap()
self['popup_bg'].hide()
self['cover'] = Pixmap()
self['cover'].hide()
self['config_information'] = Label("")
self['config_information'].hide()
self['config_information_text'] = Label("")
self['config_information_text'].hide()
self['info'] = ScrollLabel()
self['info'].hide()
desktopSize = getDesktop(0).size()
self["video"] = VideoWindow(decoder=0, fb_width=desktopSize.width(), fb_height=desktopSize.height())
self['title'] = Label("")
self['version'] = Label(_("Serien Recorder v%s") % config.plugins.serienRec.showversion.value)
self['headline'] = Label("")
setSkinProperties(self, False)
if not showAllButtons:
self['bt_red'].hide()
self['bt_green'].hide()
self['bt_yellow'].hide()
self['bt_blue'].hide()
self['bt_ok'].hide()
self['bt_exit'].hide()
self['bt_text'].hide()
self['bt_epg'].hide()
self['bt_info'].hide()
self['bt_menu'].hide()
self['bt_0'].hide()
self['bt_1'].hide()
self['bt_2'].hide()
self['bt_3'].hide()
self['bt_4'].hide()
self['bt_5'].hide()
self['bt_6'].hide()
self['bt_7'].hide()
self['bt_8'].hide()
self['bt_9'].hide()
self['text_red'].hide()
self['text_green'].hide()
self['text_yellow'].hide()
self['text_blue'].hide()
self['text_ok'].hide()
self['text_0'].hide()
self['text_1'].hide()
self['text_2'].hide()
self['text_3'].hide()
self['text_4'].hide()
self['text_5'].hide()
self['text_6'].hide()
self['text_7'].hide()
self['text_8'].hide()
self['text_9'].hide()
def Skin1_Settings(self):
self['text_0'].setText(self.num_bt_text[0][0])
self['text_1'].setText(self.num_bt_text[1][0])
self['text_2'].setText(self.num_bt_text[2][0])
self['text_3'].setText(self.num_bt_text[3][0])
self['text_4'].setText(self.num_bt_text[4][0])
self['text_5'].setText(self.num_bt_text[0][1])
self['text_6'].setText(self.num_bt_text[1][1])
self['text_7'].setText(self.num_bt_text[2][1])
self['text_8'].setText(self.num_bt_text[3][1])
self['text_9'].setText(self.num_bt_text[4][1])
self['text_exit'].setText(self.num_bt_text[0][2])
self['text_text'].setText(self.num_bt_text[1][2])
self['text_epg'].setText(self.num_bt_text[2][2])
self['text_info'].setText(self.num_bt_text[3][2])
self['text_menu'].setText(self.num_bt_text[4][2])
def updateMenuKeys(self):
if self.displayMode == 0:
self.displayMode = 1
self['bt_0'].hide()
self['bt_1'].hide()
self['bt_2'].hide()
self['bt_3'].hide()
self['bt_4'].hide()
elif self.displayMode == 1:
self.displayMode = 2
self['bt_5'].hide()
self['bt_6'].hide()
self['bt_7'].hide()
self['bt_8'].hide()
self['bt_9'].hide()
else:
self.displayMode = 0
self['bt_0'].show()
self['bt_1'].show()
self['bt_2'].show()
self['bt_3'].show()
self['bt_4'].show()
self['bt_5'].show()
self['bt_6'].show()
self['bt_7'].show()
self['bt_8'].show()
self['bt_9'].show()
self['text_0'].setText(self.num_bt_text[0][self.displayMode])
self['text_1'].setText(self.num_bt_text[1][self.displayMode])
self['text_2'].setText(self.num_bt_text[2][self.displayMode])
self['text_3'].setText(self.num_bt_text[3][self.displayMode])
self['text_4'].setText(self.num_bt_text[4][self.displayMode])
def writeLog(text, forceWrite=False):
if config.plugins.serienRec.writeLog.value or forceWrite:
if not fileExists(logFile):
open(logFile, 'w').close()
writeLogFile = open(logFile, "a")
writeLogFile.write('%s\n' % (text))
writeLogFile.close()
def writeLogFilter(type, text, forceWrite=False):
if config.plugins.serienRec.writeLog.value or forceWrite:
if not fileExists(logFile):
open(logFile, 'w').close()
writeLogFile = open(logFile, "a")
if (type == "channels" and config.plugins.serienRec.writeLogChannels.value) or \
(type == "allowedSender" and config.plugins.serienRec.writeLogAllowedSender.value) or \
(type == "allowedEpisodes" and config.plugins.serienRec.writeLogAllowedEpisodes.value) or \
(type == "added" and config.plugins.serienRec.writeLogAdded.value) or \
(type == "disk" and config.plugins.serienRec.writeLogDisk.value) or \
(type == "timeRange" and config.plugins.serienRec.writeLogTimeRange.value) or \
(type == "timeLimit" and config.plugins.serienRec.writeLogTimeLimit.value) or \
(type == "timerDebug" and config.plugins.serienRec.writeLogTimerDebug.value):
# write log
writeLogFile.write('%s\n' % (text))
writeLogFile.close()
def checkTuner(check_start, check_end, check_stbRef):
if not config.plugins.serienRec.selectNoOfTuners.value:
return True
cRecords = 1
lTuner = []
lTimerStart = {}
lTimerEnd = {}
check_stbRef = check_stbRef.split(":")[4:7]
timers = serienRecAddTimer.getTimersTime()
for name, begin, end, service_ref in timers:
#print name, begin, end, service_ref
if not ((int(check_end) < int(begin)) or (int(check_start) > int(end))):
#print "between"
cRecords += 1
service_ref = str(service_ref).split(":")[4:7]
if str(check_stbRef).lower() == str(service_ref).lower():
if int(check_start) > int(begin): begin = check_start
if int(check_end) < int(end): end = check_end
lTimerStart.update({int(begin) : int(end)})
lTimerEnd.update({int(end) : int(begin)})
else:
if not lTuner.count(service_ref):
lTuner.append(service_ref)
if int(check_start) in lTimerStart:
l = lTimerStart.items()
l.sort(key=lambda x: x[0])
for each in l:
if (each[0] <= lTimerStart[int(check_start)]) and (each[1] > lTimerStart[int(check_start)]):
lTimerStart.update({int(check_start) : each[1]})
if int(check_end) in lTimerEnd:
l = lTimerEnd.items()
l.sort(key=lambda x: x[0], reverse=True)
for each in l:
if (each[0] >= lTimerEnd[int(check_end)]) and (each[1] < lTimerEnd[int(check_end)]):
lTimerEnd.update({int(check_end) : each[1]})
if lTimerStart[int(check_start)] >= lTimerEnd[int(check_end)]:
lTuner.append(check_stbRef)
if lTuner.count(check_stbRef):
return True
else:
return (len(lTuner) < int(config.plugins.serienRec.tuner.value))
def checkFileAccess():
# überprüfe ob logFile als Datei erzeigt werden kann
global logFile
logFileValid = True
if not os.path.exists(config.plugins.serienRec.LogFilePath.value):
try:
os.makedirs(config.plugins.serienRec.LogFilePath.value)
except:
logFileValid = False
if not logFileValid:
try:
open(logFile, 'a').close()
except:
logFileValid = False
if not logFileValid:
logFile = "%slog" % serienRecMainPath
Notifications.AddPopup(_("[Serien Recorder]\nDatei 'log' kann nicht im angegebenen Pfad (%s) erzeugt werden.\n\nEs wird '%s' verwendet!") % (config.plugins.serienRec.LogFilePath.value, logFile), MessageBox.TYPE_INFO, timeout=10, id="[Serien Recorder] checkFileAccess")
def checkTimerAdded(sender, serie, staffel, episode, start_unixtime):
#"Castle" "S03E20 - Die Pizza-Connection" "1392997800" "1:0:19:EF76:3F9:1:C00000:0:0:0:" "kabel eins"
found = False
cCursor = dbSerRec.cursor()
sql = "SELECT * FROM AngelegteTimer WHERE LOWER(webChannel)=? AND LOWER(Serie)=? AND LOWER(Staffel)=? AND LOWER(Episode)=? AND StartZeitstempel>=? AND StartZeitstempel<=?"
cCursor.execute(sql, (sender.lower(), serie.lower(), str(staffel).lower(), episode.lower(), int(start_unixtime)-(int(STBHelpers.getEPGTimeSpan())*60), int(start_unixtime)+(int(STBHelpers.getEPGTimeSpan())*60)))
row = cCursor.fetchone()
if row:
found = True
cCursor.close()
return found
def checkAlreadyAdded(serie, staffel, episode, title = None, searchOnlyActiveTimers = False):
Anzahl = 0
cCursor = dbSerRec.cursor()
if searchOnlyActiveTimers:
if title is None:
cCursor.execute("SELECT COUNT(*) FROM AngelegteTimer WHERE LOWER(Serie)=? AND LOWER(Staffel)=? AND LOWER(Episode)=? AND TimerAktiviert=1", (serie.lower(), str(staffel).lower(), episode.lower()))
else:
cCursor.execute("SELECT COUNT(*) FROM AngelegteTimer WHERE LOWER(Serie)=? AND LOWER(Staffel)=? AND LOWER(Episode)=? AND LOWER(Titel)=? AND TimerAktiviert=1", (serie.lower(), str(staffel).lower(), episode.lower(), title.lower()))
else:
if title is None:
cCursor.execute("SELECT COUNT(*) FROM AngelegteTimer WHERE LOWER(Serie)=? AND LOWER(Staffel)=? AND LOWER(Episode)=?", (serie.lower(), str(staffel).lower(), episode.lower()))
else:
cCursor.execute("SELECT COUNT(*) FROM AngelegteTimer WHERE LOWER(Serie)=? AND LOWER(Staffel)=? AND LOWER(Episode)=? AND LOWER(Titel)=?", (serie.lower(), str(staffel).lower(), episode.lower(), title.lower()))
(Anzahl,) = cCursor.fetchone()
cCursor.close()
return Anzahl
def getAlreadyAdded(serie, searchOnlyActiveTimers = False):
cCursor = dbSerRec.cursor()
if searchOnlyActiveTimers:
cCursor.execute("SELECT Staffel, Episode, Titel, LOWER(webChannel), StartZeitstempel FROM AngelegteTimer WHERE LOWER(Serie)=? AND TimerAktiviert=1 ORDER BY Staffel, Episode", (serie.lower(),))
else:
cCursor.execute("SELECT Staffel, Episode, Titel, LOWER(webChannel), StartZeitstempel FROM AngelegteTimer WHERE LOWER(Serie)=? ORDER BY Staffel, Episode", (serie.lower(),))
rows = cCursor.fetchall()
cCursor.close()
return rows
def getDirname(serien_name, staffel):
if config.plugins.serienRec.seasonsubdirfillchar.value == '<SPACE>':
seasonsubdirfillchar = ' '
else:
seasonsubdirfillchar = config.plugins.serienRec.seasonsubdirfillchar.value
cCursor = dbSerRec.cursor()
cCursor.execute("SELECT AufnahmeVerzeichnis, Staffelverzeichnis FROM SerienMarker WHERE LOWER(Serie)=?", (serien_name.lower(),))
row = cCursor.fetchone()
if not row:
dirname = config.plugins.serienRec.savetopath.value
dirname_serie = dirname
if config.plugins.serienRec.seriensubdir.value:
dirname = "%s%s/" % (dirname, serien_name)
dirname_serie = dirname
if config.plugins.serienRec.seasonsubdir.value:
dirname = "%sSeason %s/" % (dirname, str(staffel).lstrip('0 ').rjust(config.plugins.serienRec.seasonsubdirnumerlength.value, seasonsubdirfillchar))
else:
(dirname, seasonsubdir) = row
if dirname:
if not re.search('.*?/\Z', dirname):
dirname = "%s/" % dirname
dirname_serie = dirname
if ((seasonsubdir == -1) and config.plugins.serienRec.seasonsubdir.value) or (seasonsubdir == 1):
dirname = "%sSeason %s/" % (dirname, str(staffel).lstrip('0 ').rjust(config.plugins.serienRec.seasonsubdirnumerlength.value, seasonsubdirfillchar))
else:
dirname = config.plugins.serienRec.savetopath.value
dirname_serie = dirname
if config.plugins.serienRec.seriensubdir.value:
dirname = "%s%s/" % (dirname, serien_name)
dirname_serie = dirname
if config.plugins.serienRec.seasonsubdir.value:
dirname = "%sSeason %s/" % (dirname, str(staffel).lstrip('0 ').rjust(config.plugins.serienRec.seasonsubdirnumerlength.value, seasonsubdirfillchar))
cCursor.close()
return (dirname, dirname_serie)
def CreateDirectory(serien_name, staffel):
(dirname, dirname_serie) = getDirname(serien_name, staffel)
if not fileExists(dirname):
print "[Serien Recorder] Erstelle Verzeichnis %s" % dirname
writeLog(_("[Serien Recorder] Erstelle Verzeichnis: ' %s '") % dirname)
os.makedirs(dirname)
if fileExists(dirname):
if fileExists("%s%s.jpg" % (config.plugins.serienRec.coverPath.value, serien_name)) and not fileExists("%s%s.jpg" % (dirname_serie, serien_name)):
shutil.copy("%s%s.jpg" % (config.plugins.serienRec.coverPath.value, serien_name), "%s%s.jpg" % (dirname_serie, serien_name))
if config.plugins.serienRec.seasonsubdir.value:
if config.plugins.serienRec.seasonsubdirfillchar.value == '<SPACE>':
seasonsubdirfillchar = ' '
else:
seasonsubdirfillchar = config.plugins.serienRec.seasonsubdirfillchar.value
season_dirname = "Season %s" % (str(staffel).lstrip('0 ').rjust(config.plugins.serienRec.seasonsubdirnumerlength.value, seasonsubdirfillchar), )
if fileExists("%s%s.jpg" % (config.plugins.serienRec.coverPath.value, serien_name)) and not fileExists("%s%s.jpg" % (dirname, season_dirname)):
shutil.copy("%s%s.jpg" % (config.plugins.serienRec.coverPath.value, serien_name), "%s%s.jpg" % (dirname, season_dirname))
def getMargins(serien_name, webSender):
cCursor = dbSerRec.cursor()
cCursor.execute("SELECT Vorlaufzeit, Nachlaufzeit FROM SerienMarker WHERE LOWER(Serie)=?", (serien_name.lower(), ))
data = cCursor.fetchone()
if not data:
data = (None, None)
(Vorlaufzeit1, Nachlaufzeit1) = data
if not str(Vorlaufzeit1).isdigit():
Vorlaufzeit1 = None
if not str(Nachlaufzeit1).isdigit():
Nachlaufzeit1 = None
cCursor.execute("SELECT Vorlaufzeit, Nachlaufzeit FROM Channels WHERE LOWER(WebChannel)=?", (webSender.lower(), ))
data = cCursor.fetchone()
if not data:
data = (None, None)
(Vorlaufzeit2, Nachlaufzeit2) = data
if not str(Vorlaufzeit2).isdigit():
Vorlaufzeit2 = None
if not str(Nachlaufzeit2).isdigit():
Nachlaufzeit2 = None
margin_before = max(Vorlaufzeit1, Vorlaufzeit2)
margin_after = max(Nachlaufzeit1, Nachlaufzeit2)
if not str(margin_before).isdigit():
margin_before = config.plugins.serienRec.margin_before.value
if not str(margin_after).isdigit():
margin_after = config.plugins.serienRec.margin_after.value
cCursor.close()
return (margin_before, margin_after)
def getVPS(webSender, serien_name):
result = 0
cCursor = dbSerRec.cursor()
cCursor.execute("SELECT CASE WHEN SerienMarker.vps IS NOT NULL AND SerienMarker.vps IS NOT '' THEN SerienMarker.vps ELSE Channels.vps END as vps FROM Channels,SerienMarker WHERE LOWER(Channels.WebChannel)=? AND LOWER(SerienMarker.Serie)=?", (webSender.lower(), serien_name.lower()))
raw = cCursor.fetchone()
if raw:
(result,) = raw
cCursor.close()
return (bool(result & 0x1), bool(result & 0x2))
def getTags(serien_name):
tags = []
cCursor = dbSerRec.cursor()
cCursor.execute("SELECT tags FROM SerienMarker WHERE LOWER(Serie)=?", (serien_name.lower(), ))
data = cCursor.fetchone()
if data:
(tagString,) = data
if tagString is not None and len(tagString) > 0:
tags = pickle.loads(tagString)
cCursor.close()
return tags
def getSpecialsAllowed(serien_name):
cCursor = dbSerRec.cursor()
cCursor.execute("SELECT AlleStaffelnAb, TimerForSpecials FROM SerienMarker WHERE LOWER(Serie)=?", (serien_name.lower(), ))
data = cCursor.fetchone()
if data:
(AlleStaffelnAb, TimerForSpecials,) = data