18
18
# Advertise with this Plugin is not allowed.
19
19
# For other uses, permission from the author is necessary.
20
20
21
- # PYTHON IMPORTS
22
21
from __future__ import print_function, absolute_import, division
22
+
23
+ # PYTHON IMPORTS
23
24
from base64 import b64encode
24
25
from calendar import Calendar, mdays, weekday, weekheader, month_name
25
26
from colorsys import rgb_to_hls, hls_to_rgb
93
94
from Screens.InputBox import InputBox
94
95
from Screens.MessageBox import MessageBox
95
96
from Screens.Screen import Screen
96
- from Screens.Standby import TryQuitMainloop
97
97
from Tools.BoundFunction import boundFunction
98
98
from Tools.Directories import SCOPE_PLUGINS, SCOPE_CONFIG, SCOPE_FONTS, SCOPE_LIBDIR, SCOPE_SYSETC, resolveFilename
99
99
127
127
else:
128
128
ssl._create_default_https_context = _create_unverified_https_context
129
129
130
- if not PY3:
130
+ if PY3:
131
+ from html import unescape as _unescape
132
+ else:
131
133
from HTMLParser import HTMLParser
132
134
_unescape = HTMLParser().unescape
133
- else:
134
- from html import unescape as _unescape
135
135
136
136
try:
137
137
from enigma import iDVBFrontend
176
176
get_backend(find_library=lambda x: "/lib64/libusb-1.0.so.0")
177
177
print("[LCD4linux] libusb found :-)", getEnigmaVersionString())
178
178
USBok = True
179
- Version = "V5.0-r22 "
179
+ Version = "V5.0-r23 "
180
180
L4LElist = L4Lelement()
181
181
L4LdoThread = True
182
182
LCD4enigma2config = resolveFilename(SCOPE_CONFIG) # /etc/enigma2/
433
433
LCD4linux.MJPEGHeader = ConfigSelection(choices=[("0", _("normal")), ("1", _("reduced"))], default="1")
434
434
LCD4linux.MJPEGCycle = ConfigSelectionNumber(1, 10, 1, default=2)
435
435
LCD4linux.MJPEGRestart = ConfigYesNo(default=True)
436
- LCD4linux.Streaming = ConfigSelection(choices=[("0", _("Media ")), ("1", _("On"))], default="0")
436
+ LCD4linux.Streaming = ConfigSelection(choices=[("0", _("Auto ")), ("1", _("On")), ("2", _("Media "))], default="0")
437
437
LCD4linux.WebIfRefresh = ConfigSelectionNumber(1, 60, 1, default=3)
438
438
LCD4linux.WebIfType = ConfigSelection(choices=[("0", _("Javascript")), ("01", _("Javascript no Refresh")), ("1", _("Reload"))], default="0")
439
439
LCD4linux.WebIfInitDelay = ConfigYesNo(default=False)
@@ -2393,7 +2393,7 @@ def Code_utf8(wert):
2393
2393
def L4log(nfo, wert=""):
2394
2394
if str(LCD4linux.EnableEventLog.value) != "0":
2395
2395
print("[LCD4linux] %s %s" % (nfo, wert))
2396
- if str(LCD4linux.EnableEventLog.value) != "3":
2396
+ if nfo and str(LCD4linux.EnableEventLog.value) != "3":
2397
2397
try:
2398
2398
with open("/tmp/L4log.txt", "a") as f:
2399
2399
f.write("%s %s %s\r\n" % (strftime("%H:%M:%S"), nfo, wert))
@@ -2983,16 +2983,16 @@ def getpiconres(x, y, full, picon, channelname, channelname2, P2, P2A, P2C):
2983
2983
PD = ""
2984
2984
PIC = []
2985
2985
PIC.append(join(P2, picon))
2986
- if not PY3:
2986
+ if PY3:
2987
+ name2 = "%s.png" % channelname.encode("latin-1", "ignore").decode("utf-8")
2988
+ name4 = "%s.png" % channelname.encode("utf-8", "ignore").decode("utf-8")
2989
+ name3 = "%s.png" % channelname2.replace('\x87', '').replace('\x86', '')
2990
+ name = normalize('NFKD', channelname)
2991
+ else:
2987
2992
name2 = "%s.png" % channelname.decode("utf-8").encode("latin-1", "ignore")
2988
2993
name4 = "%s.png" % channelname.decode("utf-8").encode("utf-8", "ignore")
2989
2994
name3 = "%s.png" % channelname2.replace('\xc2\x87', '').replace('\xc2\x86', '').decode("utf-8").encode("utf-8")
2990
- name = normalize('NFKD', unicode(str("" + channelname), 'utf-8', errors='ignore')).encode('ASCII', 'ignore')
2991
- else:
2992
- name2 = "%s.png" % channelname
2993
- name4 = "%s.png" % channelname
2994
- name3 = "%s.png" % channelname2.replace('\x87', '').replace('\x86', '')
2995
- name = normalize('NFKD', str("" + channelname))
2995
+ name = normalize('NFKD', channelname.decode('unicode-escape'))
2996
2996
name = "%s.png" % sub(r'[^a-z0-9]', '', str(name).replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower())
2997
2997
PIC.append(join(P2, name3))
2998
2998
PIC.append(join(P2, name2))
@@ -4618,7 +4618,7 @@ def NcidLCD4Linux(Date, number, caller):
4618
4618
from Plugins.Extensions.Netatmo.NetatmoCore import NetatmoUnit
4619
4619
NetatmoOK = True
4620
4620
L4log("Register Netatmo ok")
4621
- L4log("Error:", format_exc())
4621
+ L4log("Error:", format_exc().strip() )
4622
4622
except Exception:
4623
4623
NetatmoOK = False
4624
4624
L4log("Netatmo not registered")
@@ -8204,9 +8204,9 @@ def KeyDown(self):
8204
8204
self["config"].setCurrentIndex((len(self["config"].getList()) - 1))
8205
8205
8206
8206
def restartGUI(self, answer):
8207
- if answer is True :
8207
+ if answer:
8208
8208
L4log("GUI Restart")
8209
- self.session.open(TryQuitMainloop, 3)
8209
+ self.session.open(Standby. TryQuitMainloop, 3)
8210
8210
else:
8211
8211
self.close(True, self.session)
8212
8212
@@ -9573,9 +9573,7 @@ def downloadwwwBox(self, elements):
9573
9573
if len(Auth) > 1 and len(Auth[0].split(":", 1)[-1].split(":")) == 2:
9574
9574
username, password = Auth[0].split(":", 1)[-1].split(":")
9575
9575
up = "%s:%s" % (username, password)
9576
- basicAuth = b64encode(ensure_binary(up))
9577
- if PY3:
9578
- basicAuth = basicAuth.decode()
9576
+ basicAuth = b64encode(ensure_binary(up)).decode() if PY3 else b64encode(ensure_binary(up))
9579
9577
Header = {"Authorization": "Basic %s" % basicAuth}
9580
9578
if wwwURL[1] == 0:
9581
9579
feedurl = "http://%s/web/subservices" % URL
@@ -9628,9 +9626,7 @@ def downloadwwwBoxTimer(self, elements):
9628
9626
if len(Auth) > 1 and len(Auth[0].split(":", 1)[-1].split(":")) == 2:
9629
9627
username, password = Auth[0].split(":", 1)[-1].split(":")
9630
9628
up = "%s:%s" % (username, password)
9631
- basicAuth = b64encode(ensure_binary(up))
9632
- if PY3:
9633
- basicAuth = basicAuth.decode()
9629
+ basicAuth = b64encode(ensure_binary(up)).decode() if PY3 else b64encode(ensure_binary(up))
9634
9630
Header = {"Authorization": "Basic %s" % basicAuth}
9635
9631
feedurl = "http://%s/web/timerlist" % URL
9636
9632
L4log("wwwBoxTimer %d" % i, feedurl)
@@ -10296,10 +10292,9 @@ def LCD4linuxPICThread(self, session):
10296
10292
ThreadRunning = 0
10297
10293
10298
10294
10299
- def getNumber(actservice):
10300
- # actservice must be an instance of eServiceReference
10295
+ def getNumber(actservice): # actservice must be an instance of eServiceReference
10301
10296
Servicelist = None
10302
- if InfoBar and InfoBar.instance:
10297
+ if InfoBar and InfoBar.instance and InfoBar.instance.servicelist :
10303
10298
Servicelist = InfoBar.instance.servicelist
10304
10299
mask = (eServiceReference.isMarker | eServiceReference.isDirectory)
10305
10300
number = 0
@@ -10834,21 +10829,23 @@ def getShowCover(BildFile):
10834
10829
P2A = LCD4linux.PiconPathAlt.value
10835
10830
PIC = []
10836
10831
PIC.append(join(P2, picon))
10837
- if not PY3:
10832
+ if PY3:
10833
+ name2 = "%s.png" % self.Lchannel_name.encode("latin-1", "ignore").decode("utf-8")
10834
+ name4 = "%s.png" % self.Lchannel_name.encode("utf-8", "ignore").decode("utf-8")
10835
+ name3 = "%s.png" % self.Lchannel_name2.replace('\x87', '').replace('\x86', '')
10836
+ name = normalize('NFKD', self.Lchannel_name)
10837
+ else:
10838
10838
name2 = "%s.png" % self.Lchannel_name.decode("utf-8").encode("latin-1", "ignore")
10839
10839
name4 = "%s.png" % self.Lchannel_name.decode("utf-8").encode("utf-8", "ignore")
10840
10840
name3 = "%s.png" % self.Lchannel_name2.replace('\xc2\x87', '').replace('\xc2\x86', '').decode("utf-8").encode("utf-8")
10841
- name = normalize('NFKD', unicode(str("" + self.Lchannel_name), 'utf-8', errors='ignore')).encode('ASCII', 'ignore')
10842
- else:
10843
- name2 = "%s.png" % self.Lchannel_name
10844
- name4 = "%s.png" % self.Lchannel_name
10845
- name3 = "%s.png" % self.Lchannel_name2.replace('\x87', '').replace('\x86', '')
10846
- name = normalize('NFKD', str("" + self.Lchannel_name))
10841
+ name = normalize('NFKD', self.Lchannel_name.decode('unicode-escape'))
10847
10842
name = "%s.png" % sub(r'[^a-z0-9]', '', str(name).replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower())
10843
+ name5 = getPiconName(self.LsreftoString)
10848
10844
PIC.append(join(P2, name3))
10849
10845
PIC.append(join(P2, name2))
10850
10846
PIC.append(join(P2, name))
10851
10847
PIC.append(join(P2, name4))
10848
+ PIC.append(join(P2, name5))
10852
10849
fields = picon.split("_", 3)
10853
10850
if fields[0] in ("4097", "5001", "5002", "5003"):
10854
10851
fields[0] = "1"
@@ -10941,7 +10938,7 @@ def putWetter(workaround, draw, im):
10941
10938
global OldFeel
10942
10939
global OldHum
10943
10940
global OldWind
10944
- MAX_W, MAX_H = 0, 0
10941
+ MAX_W, MAX_H, MAX_Wc = 0, 0, 0
10945
10942
MAX_Wi, MAX_Hi = self.im[im].size
10946
10943
if ConfigSplit == True:
10947
10944
MAX_Wi = int(MAX_Wi / 2)
@@ -11207,7 +11204,7 @@ def putWetter(workaround, draw, im):
11207
11204
ShadowText(Wim, POSX - minus5, POSY + int(56 * Wmulti), Wind, font, ConfigColor, ConfigShadow)
11208
11205
font = ImageFont.truetype(ConfigFont, int((24 if largesize else 20) * Wmulti), encoding='unic')
11209
11206
w, h = getFsize(Temp_c, font)
11210
- if not PY3: # for equal results, w needs an correction under Python 2
11207
+ if not PY3: # for equal results, 'w' needs an correction under Python 2
11211
11208
w = int(w * (0.57 if trendarrows else 0.66))
11212
11209
PX = MAX_Wc - int(w)
11213
11210
PY = POSY + int((8 if largesize else 16) * Wmulti)
@@ -11233,15 +11230,15 @@ def putWetter(workaround, draw, im):
11233
11230
11234
11231
font = ImageFont.truetype(ConfigFont, int((15 if largesize else 12) * Wmulti), encoding='unic')
11235
11232
w, h = getFsize(Feel, font)
11236
- if not PY3: # for equal results, w needs an correction under Python 2
11233
+ if not PY3: # for equal results, 'w' needs an correction under Python 2
11237
11234
w = int(w * (0.58 if trendarrows else 0.67))
11238
11235
PX = MAX_Wc - int(w)
11239
11236
PY = POSY + int((28 if largesize else 34) * Wmulti)
11240
11237
ShadowText(Wim, PX, PY, Feel, font, LCD4linux.WetterExtraColorFeel.value, ConfigShadow)
11241
11238
11242
11239
font = ImageFont.truetype(ConfigFont, int((18 if largesize else 14) * Wmulti), encoding='unic')
11243
11240
w, h = getFsize(Hum, font)
11244
- if not PY3: # for equal results, w needs an correction under Python 2
11241
+ if not PY3: # for equal results, 'w' needs an correction under Python 2
11245
11242
w = int(w * (0.72 if trendarrows else 0.98)) if largesize else int(w * (0.72 if trendarrows else 0.98))
11246
11243
PX = MAX_Wc - int(w)
11247
11244
PY = POSY + int((40 if largesize else 44) * Wmulti)
@@ -12045,16 +12042,16 @@ def putPicon(workaround, draw, im):
12045
12042
useCache = False
12046
12043
PIC = []
12047
12044
PIC.append(join(P2, picon))
12048
- if not PY3:
12045
+ if PY3:
12046
+ name2 = "%s.png" % self.Lchannel_name.encode("latin-1", "ignore").decode("utf-8", "ignore")
12047
+ name4 = "%s.png" % self.Lchannel_name.encode("utf-8", "ignore").decode("utf-8", "ignore")
12048
+ name3 = "%s.png" % self.Lchannel_name2.replace('\x87', '').replace('\x86', '')
12049
+ name = normalize('NFKD', self.Lchannel_name)
12050
+ else:
12049
12051
name2 = "%s.png" % self.Lchannel_name.decode("utf-8").encode("latin-1", "ignore")
12050
- name4 = "%s.png" % self.Lchannel_name.decode("utf-8").encode("utf-8 ", "ignore")
12052
+ name4 = "%s.png" % self.Lchannel_name.decode("utf-8").encode("latin-1 ", "ignore")
12051
12053
name3 = "%s.png" % self.Lchannel_name2.replace('\xc2\x87', '').replace('\xc2\x86', '').decode("utf-8").encode("utf-8")
12052
12054
name = normalize('NFKD', self.Lchannel_name.decode('unicode-escape'))
12053
- else:
12054
- name2 = "%s.png" % self.Lchannel_name
12055
- name4 = "%s.png" % self.Lchannel_name
12056
- name3 = "%s.png" % self.Lchannel_name2.replace('\x87', '').replace('\x86', '')
12057
- name = normalize('NFKD', self.Lchannel_name)
12058
12055
name = "%s.png" % sub(r'[^a-z0-9]', '', str(name).replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower())
12059
12056
name5 = getPiconName(self.LsreftoString)
12060
12057
PIC.append(join(P2, name3))
@@ -12181,10 +12178,7 @@ def putChannel(workaround, draw, im):
12181
12178
channel_name = ""
12182
12179
Progress = getProgess(MAX_W, ConfigProzent)
12183
12180
if self.Lchannel_name is not None:
12184
- if not PY3:
12185
- channel_name = self.Lchannel_name
12186
- else:
12187
- channel_name = self.Lchannel_name.replace('\x87', '').replace('\x86', '')
12181
+ channel_name = self.Lchannel_name.replace('\x87', '').replace('\x86', '') if PY3 else self.Lchannel_name
12188
12182
ch = self.LsreftoString.split("::")
12189
12183
if len(ch) > 1:
12190
12184
channel_name = Code_utf8(ch[1])
@@ -12604,7 +12598,7 @@ def putSat(workaround, draw, im):
12604
12598
self.im[im].paste(imW, (POSX, ConfigPos), imW)
12605
12599
else:
12606
12600
self.im[im].paste(imW, (POSX, ConfigPos))
12607
- if not PY3: # no correction for PY3
12601
+ if not PY3: # correction for Python 2
12608
12602
POSX += x
12609
12603
if ConfigType[1:] == "C":
12610
12604
ShadowText(draw, POSX, ConfigPos + int(ConfigSize / 4), Code_utf8(orbital), font, ConfigColor, ConfigShadow)
@@ -14475,32 +14469,33 @@ def Lput4(LCD, SCR, FUNC, PARA):
14475
14469
rmFile(MP3tmp)
14476
14470
# rmFile(GoogleCover)
14477
14471
if self.SonosRunning:
14478
- L4log("detected Sonos")
14479
- isMediaPlayer = "sonos"
14472
+ isMediaPlayer, logtext = ("sonos", "detected Sonos")
14480
14473
elif self.YMCastRunning:
14481
- L4log("detected YMC")
14482
- isMediaPlayer = "ymc"
14474
+ isMediaPlayer, logtext = ("ymc", "detected YMC")
14483
14475
elif self.BlueRunning:
14484
- L4log("detected BlueSound")
14485
- isMediaPlayer = "blue"
14486
- elif sref.startswith("1:0:2") is True:
14487
- L4log("detected Radio")
14488
- isMediaPlayer = "radio"
14476
+ isMediaPlayer, logtext = ("blue", "detected BlueSound")
14477
+ elif sref.startswith("1:0:2"):
14478
+ isMediaPlayer, logtext = ("radio", "detected Radio")
14489
14479
self.CoverIm = None
14490
14480
self.CoverName = ["-", "-"]
14491
14481
elif sref.startswith(("4097:0", "5001:0", "5002:0", "5003:0")):
14492
14482
if self.Lpath and self.Lpath.startswith("http") and self.Llength and self.Llength[0] == -1:
14493
- L4log("detected AudioMedia or IPTV")
14494
- isMediaPlayer = "mp3"
14483
+ if LCD4linux.Streaming.value == "0": # autodetect mode?
14484
+ if InfoBar and InfoBar.instance and InfoBar.instance.servicelist: # current E2 mode: 0=TV, 1=Radio
14485
+ isMediaPlayer, logtext = ("", "detected IPTV") if InfoBar.instance.servicelist.mode == 0 else ("mp3", "detected AudioMedia")
14486
+ else:
14487
+ isMediaPlayer, logtext = ("", "detection error: 'InfoBar.instance.servicelist.mode' is not available")
14488
+ else:
14489
+ isMediaPlayer, logtext = ("", "forced IPTV by setting") if LCD4linux.Streaming.value == "1" else ("mp3", "forced AudioMedia by setting")
14495
14490
else:
14496
- L4log("detected VOD Media")
14497
- isMediaPlayer = "mp3"
14491
+ isMediaPlayer, logtext = ("mp3", "detected VOD Media")
14498
14492
elif "0:0:0:0:0:0:0:0:0:" in sref:
14499
- L4log("detected Video")
14500
- isMediaPlayer = "record"
14493
+ isMediaPlayer, logtext = ("record", "detected Video")
14501
14494
else:
14502
14495
self.CoverIm = None
14503
14496
self.CoverName = ["-", "-"]
14497
+ logtext = ""
14498
+ L4log(logtext)
14504
14499
if isMediaPlayer != "mp3" and isMediaPlayer != "record":
14505
14500
rmFile("/tmp/.cover")
14506
14501
rmFile("/tmp/.wbrfs_pic")
0 commit comments