1818# Advertise with this Plugin is not allowed.
1919# For other uses, permission from the author is necessary.
2020
21- # PYTHON IMPORTS
2221from __future__ import print_function, absolute_import, division
22+
23+ # PYTHON IMPORTS
2324from base64 import b64encode
2425from calendar import Calendar, mdays, weekday, weekheader, month_name
2526from colorsys import rgb_to_hls, hls_to_rgb
9394from Screens.InputBox import InputBox
9495from Screens.MessageBox import MessageBox
9596from Screens.Screen import Screen
96- from Screens.Standby import TryQuitMainloop
9797from Tools.BoundFunction import boundFunction
9898from Tools.Directories import SCOPE_PLUGINS, SCOPE_CONFIG, SCOPE_FONTS, SCOPE_LIBDIR, SCOPE_SYSETC, resolveFilename
9999
127127else:
128128 ssl._create_default_https_context = _create_unverified_https_context
129129
130- if not PY3:
130+ if PY3:
131+ from html import unescape as _unescape
132+ else:
131133 from HTMLParser import HTMLParser
132134 _unescape = HTMLParser().unescape
133- else:
134- from html import unescape as _unescape
135135
136136try:
137137 from enigma import iDVBFrontend
176176 get_backend(find_library=lambda x: "/lib64/libusb-1.0.so.0")
177177 print("[LCD4linux] libusb found :-)", getEnigmaVersionString())
178178 USBok = True
179- Version = "V5.0-r22 "
179+ Version = "V5.0-r23 "
180180L4LElist = L4Lelement()
181181L4LdoThread = True
182182LCD4enigma2config = resolveFilename(SCOPE_CONFIG) # /etc/enigma2/
433433LCD4linux.MJPEGHeader = ConfigSelection(choices=[("0", _("normal")), ("1", _("reduced"))], default="1")
434434LCD4linux.MJPEGCycle = ConfigSelectionNumber(1, 10, 1, default=2)
435435LCD4linux.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")
437437LCD4linux.WebIfRefresh = ConfigSelectionNumber(1, 60, 1, default=3)
438438LCD4linux.WebIfType = ConfigSelection(choices=[("0", _("Javascript")), ("01", _("Javascript no Refresh")), ("1", _("Reload"))], default="0")
439439LCD4linux.WebIfInitDelay = ConfigYesNo(default=False)
@@ -2393,7 +2393,7 @@ def Code_utf8(wert):
23932393def L4log(nfo, wert=""):
23942394 if str(LCD4linux.EnableEventLog.value) != "0":
23952395 print("[LCD4linux] %s %s" % (nfo, wert))
2396- if str(LCD4linux.EnableEventLog.value) != "3":
2396+ if nfo and str(LCD4linux.EnableEventLog.value) != "3":
23972397 try:
23982398 with open("/tmp/L4log.txt", "a") as f:
23992399 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):
29832983 PD = ""
29842984 PIC = []
29852985 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:
29872992 name2 = "%s.png" % channelname.decode("utf-8").encode("latin-1", "ignore")
29882993 name4 = "%s.png" % channelname.decode("utf-8").encode("utf-8", "ignore")
29892994 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'))
29962996 name = "%s.png" % sub(r'[^a-z0-9]', '', str(name).replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower())
29972997 PIC.append(join(P2, name3))
29982998 PIC.append(join(P2, name2))
@@ -4618,7 +4618,7 @@ def NcidLCD4Linux(Date, number, caller):
46184618 from Plugins.Extensions.Netatmo.NetatmoCore import NetatmoUnit
46194619 NetatmoOK = True
46204620 L4log("Register Netatmo ok")
4621- L4log("Error:", format_exc())
4621+ L4log("Error:", format_exc().strip() )
46224622except Exception:
46234623 NetatmoOK = False
46244624 L4log("Netatmo not registered")
@@ -8204,9 +8204,9 @@ def KeyDown(self):
82048204 self["config"].setCurrentIndex((len(self["config"].getList()) - 1))
82058205
82068206 def restartGUI(self, answer):
8207- if answer is True :
8207+ if answer:
82088208 L4log("GUI Restart")
8209- self.session.open(TryQuitMainloop, 3)
8209+ self.session.open(Standby. TryQuitMainloop, 3)
82108210 else:
82118211 self.close(True, self.session)
82128212
@@ -9573,9 +9573,7 @@ def downloadwwwBox(self, elements):
95739573 if len(Auth) > 1 and len(Auth[0].split(":", 1)[-1].split(":")) == 2:
95749574 username, password = Auth[0].split(":", 1)[-1].split(":")
95759575 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))
95799577 Header = {"Authorization": "Basic %s" % basicAuth}
95809578 if wwwURL[1] == 0:
95819579 feedurl = "http://%s/web/subservices" % URL
@@ -9628,9 +9626,7 @@ def downloadwwwBoxTimer(self, elements):
96289626 if len(Auth) > 1 and len(Auth[0].split(":", 1)[-1].split(":")) == 2:
96299627 username, password = Auth[0].split(":", 1)[-1].split(":")
96309628 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))
96349630 Header = {"Authorization": "Basic %s" % basicAuth}
96359631 feedurl = "http://%s/web/timerlist" % URL
96369632 L4log("wwwBoxTimer %d" % i, feedurl)
@@ -10296,10 +10292,9 @@ def LCD4linuxPICThread(self, session):
1029610292 ThreadRunning = 0
1029710293
1029810294
10299- def getNumber(actservice):
10300- # actservice must be an instance of eServiceReference
10295+ def getNumber(actservice): # actservice must be an instance of eServiceReference
1030110296 Servicelist = None
10302- if InfoBar and InfoBar.instance:
10297+ if InfoBar and InfoBar.instance and InfoBar.instance.servicelist :
1030310298 Servicelist = InfoBar.instance.servicelist
1030410299 mask = (eServiceReference.isMarker | eServiceReference.isDirectory)
1030510300 number = 0
@@ -10834,21 +10829,23 @@ def getShowCover(BildFile):
1083410829 P2A = LCD4linux.PiconPathAlt.value
1083510830 PIC = []
1083610831 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:
1083810838 name2 = "%s.png" % self.Lchannel_name.decode("utf-8").encode("latin-1", "ignore")
1083910839 name4 = "%s.png" % self.Lchannel_name.decode("utf-8").encode("utf-8", "ignore")
1084010840 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'))
1084710842 name = "%s.png" % sub(r'[^a-z0-9]', '', str(name).replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower())
10843+ name5 = getPiconName(self.LsreftoString)
1084810844 PIC.append(join(P2, name3))
1084910845 PIC.append(join(P2, name2))
1085010846 PIC.append(join(P2, name))
1085110847 PIC.append(join(P2, name4))
10848+ PIC.append(join(P2, name5))
1085210849 fields = picon.split("_", 3)
1085310850 if fields[0] in ("4097", "5001", "5002", "5003"):
1085410851 fields[0] = "1"
@@ -10941,7 +10938,7 @@ def putWetter(workaround, draw, im):
1094110938 global OldFeel
1094210939 global OldHum
1094310940 global OldWind
10944- MAX_W, MAX_H = 0, 0
10941+ MAX_W, MAX_H, MAX_Wc = 0, 0, 0
1094510942 MAX_Wi, MAX_Hi = self.im[im].size
1094610943 if ConfigSplit == True:
1094710944 MAX_Wi = int(MAX_Wi / 2)
@@ -11207,7 +11204,7 @@ def putWetter(workaround, draw, im):
1120711204 ShadowText(Wim, POSX - minus5, POSY + int(56 * Wmulti), Wind, font, ConfigColor, ConfigShadow)
1120811205 font = ImageFont.truetype(ConfigFont, int((24 if largesize else 20) * Wmulti), encoding='unic')
1120911206 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
1121111208 w = int(w * (0.57 if trendarrows else 0.66))
1121211209 PX = MAX_Wc - int(w)
1121311210 PY = POSY + int((8 if largesize else 16) * Wmulti)
@@ -11233,15 +11230,15 @@ def putWetter(workaround, draw, im):
1123311230
1123411231 font = ImageFont.truetype(ConfigFont, int((15 if largesize else 12) * Wmulti), encoding='unic')
1123511232 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
1123711234 w = int(w * (0.58 if trendarrows else 0.67))
1123811235 PX = MAX_Wc - int(w)
1123911236 PY = POSY + int((28 if largesize else 34) * Wmulti)
1124011237 ShadowText(Wim, PX, PY, Feel, font, LCD4linux.WetterExtraColorFeel.value, ConfigShadow)
1124111238
1124211239 font = ImageFont.truetype(ConfigFont, int((18 if largesize else 14) * Wmulti), encoding='unic')
1124311240 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
1124511242 w = int(w * (0.72 if trendarrows else 0.98)) if largesize else int(w * (0.72 if trendarrows else 0.98))
1124611243 PX = MAX_Wc - int(w)
1124711244 PY = POSY + int((40 if largesize else 44) * Wmulti)
@@ -12045,16 +12042,16 @@ def putPicon(workaround, draw, im):
1204512042 useCache = False
1204612043 PIC = []
1204712044 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:
1204912051 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")
1205112053 name3 = "%s.png" % self.Lchannel_name2.replace('\xc2\x87', '').replace('\xc2\x86', '').decode("utf-8").encode("utf-8")
1205212054 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)
1205812055 name = "%s.png" % sub(r'[^a-z0-9]', '', str(name).replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower())
1205912056 name5 = getPiconName(self.LsreftoString)
1206012057 PIC.append(join(P2, name3))
@@ -12181,10 +12178,7 @@ def putChannel(workaround, draw, im):
1218112178 channel_name = ""
1218212179 Progress = getProgess(MAX_W, ConfigProzent)
1218312180 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
1218812182 ch = self.LsreftoString.split("::")
1218912183 if len(ch) > 1:
1219012184 channel_name = Code_utf8(ch[1])
@@ -12604,7 +12598,7 @@ def putSat(workaround, draw, im):
1260412598 self.im[im].paste(imW, (POSX, ConfigPos), imW)
1260512599 else:
1260612600 self.im[im].paste(imW, (POSX, ConfigPos))
12607- if not PY3: # no correction for PY3
12601+ if not PY3: # correction for Python 2
1260812602 POSX += x
1260912603 if ConfigType[1:] == "C":
1261012604 ShadowText(draw, POSX, ConfigPos + int(ConfigSize / 4), Code_utf8(orbital), font, ConfigColor, ConfigShadow)
@@ -14475,32 +14469,33 @@ def Lput4(LCD, SCR, FUNC, PARA):
1447514469 rmFile(MP3tmp)
1447614470# rmFile(GoogleCover)
1447714471 if self.SonosRunning:
14478- L4log("detected Sonos")
14479- isMediaPlayer = "sonos"
14472+ isMediaPlayer, logtext = ("sonos", "detected Sonos")
1448014473 elif self.YMCastRunning:
14481- L4log("detected YMC")
14482- isMediaPlayer = "ymc"
14474+ isMediaPlayer, logtext = ("ymc", "detected YMC")
1448314475 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")
1448914479 self.CoverIm = None
1449014480 self.CoverName = ["-", "-"]
1449114481 elif sref.startswith(("4097:0", "5001:0", "5002:0", "5003:0")):
1449214482 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")
1449514490 else:
14496- L4log("detected VOD Media")
14497- isMediaPlayer = "mp3"
14491+ isMediaPlayer, logtext = ("mp3", "detected VOD Media")
1449814492 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")
1450114494 else:
1450214495 self.CoverIm = None
1450314496 self.CoverName = ["-", "-"]
14497+ logtext = ""
14498+ L4log(logtext)
1450414499 if isMediaPlayer != "mp3" and isMediaPlayer != "record":
1450514500 rmFile("/tmp/.cover")
1450614501 rmFile("/tmp/.wbrfs_pic")
0 commit comments