def getPicon(sname): pp = getPiconPath() if pp is not None: # remove URL part if ("://" in sname) or ("%3a//" in sname) or ("%3A//" in sname): sname = unquote(sname) sname = ":".join(sname.split(":")[:10]) + "::" + sname.split(":")[-1] sname = GetWithAlternative(sname) if sname is not None: pos = sname.rfind(':') else: return "/images/default_picon.png" cname = None if pos != -1: cname = ServiceReference(sname[:pos].rstrip(':')).getServiceName() sname = sname[:pos].rstrip(':').replace(':','_') + ".png" filename = pp + sname if fileExists(filename): return "/picon/" + sname fields = sname.split('_', 8) if len(fields) > 7 and not fields[6].endswith("0000"): #remove "sub-network" from namespace fields[6] = fields[6][:-4] + "0000" sname='_'.join(fields) filename = pp + sname if fileExists(filename): return "/picon/" + sname if len(fields) > 1 and fields[0] != '1': #fallback to 1 for other reftypes fields[0] = '1' sname='_'.join(fields) filename = pp + sname if fileExists(filename): return "/picon/" + sname if len(fields) > 3 and fields[2] != '1': #fallback to 1 for tv services with nonstandard servicetypes fields[2] = '1' sname='_'.join(fields) filename = pp + sname if fileExists(filename): return "/picon/" + sname if cname is not None: # picon by channel name cname1 = cname.replace('\xc2\x86','').replace('\xc2\x87', '').replace('/', '_').encode('utf-8', 'ignore') if fileExists(pp + cname1 + ".png"): return "/picon/" + cname1 + ".png" cname = unicodedata.normalize('NFKD', unicode(cname, 'utf_8', errors='ignore')).encode('ASCII', 'ignore') cname = re.sub('[^a-z0-9]', '', cname.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if len(cname) > 0: filename = pp + cname + ".png" if fileExists(filename): return "/picon/" + cname + ".png" if len(cname) > 2 and cname.endswith('hd') and fileExists(pp + cname[:-2] + ".png"): return "/picon/" + cname[:-2] + ".png" return "/images/default_picon.png"
def getPiconName(serviceName): #remove the path and name fields, and replace ':' by '_' sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10]) pngname = findPicon(sname) if not pngname: fields = sname.split('_', 3) if len(fields) > 2 and fields[ 2] != '2': #fallback to 1 for tv services with nonstandard servicetypes fields[2] = '1' if fields[0] == '4097': #fallback to 1 for IPTV streams fields[0] = '1' pngname = findPicon('_'.join(fields)) if not pngname: # picon by channel name try: name = ServiceReference(serviceName).getServiceName() # print "[Picon] unicodedata.normalize: ", name name = unicodedata.normalize( 'NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore') name = re.sub( '[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if name: pngname = findPicon(name) if not pngname and len(name) > 2 and name.endswith('hd'): pngname = findPicon(name[:-2]) except: pass return pngname
def getPiconName(serviceName): #remove the path and name fields, and replace ':' by '_' fields = GetWithAlternative(serviceName).split(':', 10)[:10] if not fields or len(fields) < 10: return "" pngname = findPicon('_'.join(fields)) if not pngname and not fields[6].endswith("0000"): #remove "sub-network" from namespace fields[6] = fields[6][:-4] + "0000" pngname = findPicon('_'.join(fields)) if not pngname and fields[0] != '1': #fallback to 1 for IPTV streams fields[0] = '1' pngname = findPicon('_'.join(fields)) if not pngname and fields[2] != '2': #fallback to 1 for TV services with non-standard service types fields[2] = '1' pngname = findPicon('_'.join(fields)) if not pngname: # picon by channel name name = ServiceReference(serviceName).getServiceName() name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore') name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if len(name) > 0: pngname = findPicon(name) if not pngname and len(name) > 2 and name.endswith('hd'): pngname = findPicon(name[:-2]) return pngname
def getPiconName(serviceName): sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10]) pngname = findPicon(sname) if not pngname: # picon by channel name name = ServiceReference(serviceName).getServiceName() name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore') name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if len(name) > 0: pngname = findPicon(name) if not pngname and len(name) > 2 and name.endswith('hd'): pngname = findPicon(name[:-2]) if not pngname: fields = sname.split('_', 3) if len(fields) > 0 and fields[0] != '1': fields[0] = '1' pngname = findPicon('_'.join(fields)) if len(fields) > 2: while not pngname: tmp = '' for i in range(256): tmp = hex(i)[2:].upper().zfill(2) fields[2] = tmp pngname = findPicon('_'.join(fields)) if pngname: newpng = '/usr/share/enigma2/picon/' + name + '.png' try: os.symlink(pngname, newpng) except: pass break if tmp == "FF": break return pngname
def getPiconName(serviceName): #remove the path and name fields, and replace ':' by '_' name = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10]) pngname = findPicon(name) if not pngname: fields = name.split('_', 3) if len(fields) > 2: if fields[0] != '1': #fallback to 1 for other reftypes fields[0] = '1' pngname = findPicon('_'.join(fields)) if not pngname and fields[2] != '1': #fallback to 1 for services with different service types fields[2] = '1' pngname = findPicon('_'.join(fields)) if not pngname: # picon by channel name name = ServiceReference(serviceName).getServiceName() name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode( 'ASCII', 'ignore') name = re.sub( '[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if name: pngname = findPicon(name) if not pngname and len(name) > 2 and name.endswith('hd'): pngname = findPicon(name[:-2]) return pngname
def changed(self, rjvsyr): global mzrynz global otzqir if self.instance: koprvn = ePicLoad() koprvn.setPara((int(self.lxktpt[0]), int(self.lxktpt[1]), 1, 1, 0, 1, '#00000000')) nlqmqs = None try: qystrq = self.source.service if rjvsyr[0] != self.CHANGED_CLEAR: nlqmqs = findCoolPicon(qystrq.toString()) except: qystrq = self.source.text if rjvsyr[0] != self.CHANGED_CLEAR: nlqmqs = findCoolPicon(qystrq) if not nlqmqs: kklrrq = ServiceReference(qystrq).getServiceName() try: kklrrq = kklrrq.replace('\xc2\x87', '').replace('\xc2\x86', '').decode('utf-8').encode('latin1') except: pass nlqmqs = findCoolPicon(kklrrq) if not nlqmqs: nlqmqs = '/usr/lib/enigma2/python/Plugins/Extensions/CoolTVGuide/Cool3D/dummy.png' koprvn.setPara((1, 1, 1, 1, 0, 1, '#00000000')) if otzqir: nlqmqs = '' mzrynz = '' koprvn = findCoolPicon(kklrrq) klyrok = koprvn.startDecode rjyixi = koprvn.setPara rjyixi((int(self.lxktpt[0]), int(self.lxktpt[1]), 1, 1, 0, 1, '#00000000')) elif mzrynz == '': uunuoo = zrlpzx.rfind(':') if uunuoo != -1: otzqir = True zrlpzx = zrlpzx[:uunuoo].rstrip(':').replace(':', '_') for srrllp in self.vzxowj: nlqmqs = srrllp + zrlpzx + '.png' if fileExists(nlqmqs): self.Setpixmap(nlqmqs) if not otzqir: koprvn.startDecode(nlqmqs, 0, 0, False) nlqmqs = koprvn.getData() self.instance.setPixmap(nlqmqs)
def getPiconName(serviceName): #remove the path and name fields, and replace ':' by '_' sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10]) pngname = findPicon(sname) if not pngname: fields = sname.split('_', 3) if len(fields) > 2: if fields[0] != '1': #fallback to 1 for other reftypes fields[0] = '1' pngname = findPicon('_'.join(fields)) if not pngname and fields[2] != '2': #fallback to 1 for tv services with nonstandard servicetypes fields[2] = '1' pngname = findPicon('_'.join(fields)) if not pngname: # picon by channel name name = ServiceReference(serviceName).getServiceName() name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore') piconname = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if piconname: pngname = findPicon(piconname) if not pngname and len(piconname) > 2 and name.endswith('hd'): pngname = findPicon(piconname[:-2]) if not pngname: # try picon by channel name without last word piconname = ' '.join(name.split(' ')[:-1]) piconname = re.sub('[^a-z0-9]', '', piconname.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) pngname = findPicon(piconname) if not pngname: tmp = resolveFilename(SCOPE_CURRENT_SKIN, "picon_default.png") if pathExists(tmp): pngname = tmp else: pngname = resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/picon_default.png") return pngname
def getPiconName(serviceName): fields = GetWithAlternative(serviceName).split(':', 10)[:10] if not fields or len(fields) < 10: return '' pngname = findPicon('_'.join(fields)) if not pngname and not fields[6].endswith('0000'): fields[6] = fields[6][:-4] + '0000' pngname = findPicon('_'.join(fields)) if not pngname and fields[0] != '1': fields[0] = '1' pngname = findPicon('_'.join(fields)) if not pngname and fields[2] != '1': fields[2] = '1' pngname = findPicon('_'.join(fields)) if not pngname: name = ServiceReference(serviceName).getServiceName() name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode( 'ASCII', 'ignore') name = re.sub( '[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if len(name) > 0: pngname = findPicon(name) if not pngname and len(name) > 2 and name.endswith('hd'): pngname = findPicon(name[:-2]) return pngname
def getPiconName(serviceName): #remove the path and name fields, and replace ':' by '_' sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10]) pngname = findPicon(sname) if not pngname: fields = sname.split('_', 3) if len(fields) > 2: if fields[0] != '1': #fallback to 1 for other reftypes fields[0] = '1' pngname = findPicon('_'.join(fields)) if not pngname and fields[2] != '1': #fallback to 1 for services with different service types fields[2] = '1' pngname = findPicon('_'.join(fields)) if not pngname: # picon by channel name try: name = ServiceReference(serviceName).getServiceName() #print "[Picon] unicodedata.normalize: ", name name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore') name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) #print "[Picon] picon by channel name: ", name if name: pngname = findPicon(name) if not pngname and len(name) > 2 and name.endswith('hd'): pngname = findPicon(name[:-2]) except: pass return pngname
def getLcdPiconName(serviceName): #remove the path and name fields, and replace ':' by '_' fields = GetWithAlternative(serviceName).split(':', 10)[:10] if not fields or len(fields) < 10: return "" pngname = findLcdPicon('_'.join(fields)) if not pngname and not fields[6].endswith("0000"): #remove "sub-network" from namespace fields[6] = fields[6][:-4] + "0000" pngname = findLcdPicon('_'.join(fields)) if not pngname and fields[0] != '1': #fallback to 1 for IPTV streams fields[0] = '1' pngname = findLcdPicon('_'.join(fields)) if not pngname and fields[2] != '2': #fallback to 1 for TV services with non-standard service types fields[2] = '1' pngname = findLcdPicon('_'.join(fields)) if not pngname and fields[9] != '0': #fallback to 0 for iptv buffering fields[9] = '0' pngname = findLcdPicon('_'.join(fields)) if not pngname: # picon by channel name name = ServiceReference(serviceName).getServiceName() name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore') name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if len(name) > 0: pngname = findLcdPicon(name) if not pngname and len(name) > 2 and name.endswith('hd'): pngname = findLcdPicon(name[:-2]) return pngname
def getPicon(sname): # remove URL part if ("://" in sname) or ("%3a//" in sname) or ("%3A//" in sname): sname = unquote(sname) sname = ":".join(sname.split(":")[:10]) + "::" + sname.split(":")[-1] sname = GetWithAlternative(sname) if sname is not None: pos = sname.rfind(':') else: return "/images/default_picon.png" cname = None if pos != -1: cname = ServiceReference(sname[:pos].rstrip(':')).getServiceName() sname = sname[:pos].rstrip(':').replace(':','_') + ".png" filename = getPiconPath() + sname if fileExists(filename): return "/picon/" + sname fields = sname.split('_', 3) if len(fields) > 2 and fields[2] != '2': #fallback to 1 for tv services with nonstandard servicetypes fields[2] = '1' sname='_'.join(fields) filename = getPiconPath() + sname if fileExists(filename): return "/picon/" + sname if cname is not None: # picon by channel name cname = unicodedata.normalize('NFKD', unicode(cname, 'utf_8')).encode('ASCII', 'ignore') cname = re.sub('[^a-z0-9]', '', cname.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if len(cname) > 0: filename = getPiconPath() + cname + ".png" if fileExists(filename): return "/picon/" + cname + ".png" return "/images/default_picon.png"
def SavePic(self): import datetime now = datetime.datetime.now() day = str(now.day) month = str(now.month) year = str(now.year) hour = str(now.hour) second = str(now.second) datestr = day + month + year + '-' + hour + second if fileExists(self.whatPic): srvName = ServiceReference( self.session.nav.getCurrentlyPlayingServiceReference( )).getServiceName() srvName = srvName.replace('\xc2\x86', '').replace('\xc2\x87', '') srvName = srvName.replace(' ', '_') if config.plugins.PPrestige.storedir.value == 'tmp': self.folder = '/tmp/' else: self.folder = '/media/hdd/' try: if pathExists(self.folder): if self.pictureformat.endswith('jpg'): filename = self.folder + self.srvName + '-' + datestr + '.jpg' else: filename = self.folder + self.srvName + '-' + datestr + '.png' command = 'cp ' + self.pictureformat + ' ' + filename mtext = 'saving picture to...\n' + filename copyfile(self.pictureformat, filename) self.session.open(MessageBox, text=_(filename), type=MessageBox.TYPE_INFO, timeout=3, close_on_any_key=True) else: self.session.open(MessageBox, text=_('Location not available!'), type=MessageBox.TYPE_ERROR, timeout=5, close_on_any_key=True) except: self.session.open(MessageBox, text=_('Failed saving file!'), type=MessageBox.TYPE_ERROR, timeout=5, close_on_any_key=True) self.dexit()
def firstStart(self): myServicelist.servicelist.moveToIndex(0) myServicelist.zap() srvName = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference()).getServiceName() srvName = srvName.replace('\xc2\x86', '').replace('\xc2\x87', '') self["wohin"].setText(srvName + _(" (AutoZap)")) delay = config.plugins.epgrefresh_extra.timeout_autozap.value self.AutoZap.start(int(delay * 1000))
def changed(self, what): if self.instance: pngname = "" if what[0] != self.CHANGED_CLEAR: sname = self.source.text pos = sname.rfind(':') if pos != -1: sname = sname[:pos].rstrip(':').replace(':', '_') sname = sname.split("_http")[0] pngname = self.nameCache.get(sname, "") if pngname == "": pngname = self.findPicon(sname) if pngname == "": fields = sname.split('_', 3) if len(fields) > 2 and fields[ 2] != '2': #fallback to 1 for tv services with nonstandard servicetypes fields[2] = '1' if fields[ 0] == '4097': #fallback to 1 for IPTV streams fields[0] = '1' pngname = self.findPicon('_'.join(fields)) if not pngname: # picon by channel name name = ServiceReference( self.source.text).getServiceName() name = unicodedata.normalize( 'NFKD', unicode(name, 'utf_8', errors='ignore')).encode( 'ASCII', 'ignore') name = re.sub( '[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace( '*', 'star').lower()) if len(name) > 0: pngname = self.findPicon(name) if not pngname and len(name) > 2 and name.endswith( 'hd'): pngname = self.findPicon(name[:-2]) if pngname != "": self.nameCache[sname] = pngname if pngname == "": # no picon for service found pngname = self.nameCache.get("default", "") if pngname == "": # no default yet in cache.. pngname = self.findPicon("picon_default") if pngname == "": tmp = resolveFilename(SCOPE_CURRENT_SKIN, "picon_default.png") if fileExists(tmp): pngname = tmp else: pngname = resolveFilename( SCOPE_SKIN_IMAGE, "skin_default/picon_default.png") self.nameCache["default"] = pngname if self.pngname != pngname: self.instance.setScale(1) self.instance.setPixmapFromFile(pngname) self.pngname = pngname
def getPiconName(self, serviceName): #remove the path and name fields, and replace ':' by '_' fields = GetWithAlternative(serviceName).split(':', 10)[:10] if not fields or len(fields) < 10: return "" pngname = self.findPicon('_'.join(fields)) if not pngname and not fields[6].endswith("0000"): #remove "sub-network" from namespace fields[6] = fields[6][:-4] + "0000" pngname = self.findPicon('_'.join(fields)) if not pngname and fields[0] != '1': #fallback to 1 for IPTV streams fields[0] = '1' pngname = self.findPicon('_'.join(fields)) if not pngname and fields[2] != '2': #fallback to 1 for TV services with non-standard service types fields[2] = '1' pngname = self.findPicon('_'.join(fields)) if not pngname: # picon by channel name name = ServiceReference(serviceName).getServiceName() if PY2: name = unicodedata.normalize( 'NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore') else: name = unicodedata.normalize('NFKD', str(name)).encode( 'ASCII', 'ignore').decode('ASCII', 'ignore') name = re.sub( '[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if len(name) > 0: pngname = self.findPicon(name) if not pngname and len(name) > 2 and name.endswith('hd'): pngname = self.findPicon(name[:-2]) if not pngname and len(name) > 6: series = re.sub(r's[0-9]*e[0-9]*$', '', name) pngname = self.findPicon(series) if not pngname: # picon default tmp = resolveFilename( SCOPE_GUISKIN, 'picon_default.png') # picon_default in current active skin tmp2 = self.findPicon( "picon_default") # picon_default in picon folder if pathExists(tmp2): pngname = tmp2 else: if pathExists(tmp): pngname = tmp else: pngname = resolveFilename(SCOPE_GUISKIN, 'picon_default.png') return pngname
def zapForRefresh(self): myServicelist.moveDown() NewService = myServicelist.getCurrentSelection() if (NewService.flags & 7) == 7: myServicelist.enterPath(NewService) elif not (NewService.flags & eServiceReference.isMarker): myServicelist.zap() srvName = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference()).getServiceName() srvName = srvName.replace('\xc2\x86', '').replace('\xc2\x87', '') self["wohin"].setText(srvName + _(" (AutoZap)"))
def SavePic(self): if fileExists(self.whatPic): srvName = ServiceReference( self.session.nav.getCurrentlyPlayingServiceReference( )).getServiceName() srvName = srvName.replace('\xc2\x86', '').replace('\xc2\x87', '') srvName = srvName.replace(' ', '_') if pathExists(config.usage.timeshift_path.value): filename = config.usage.timeshift_path.value + srvName + "-" + str( randint(1000, 9999)) + ".jpg" command = "cp /tmp/standbild.jpg " + filename mtext = "saving picture to...\n" + filename self.session.open(MessageBox, text=_(mtext), type=MessageBox.TYPE_INFO) system(command) else: self.session.open(MessageBox, text=_("Location not aviable!"), type=MessageBox.TYPE_ERROR)
def getPiconName(serviceRef): service = eServiceReference(serviceRef) if service.getPath().startswith("/") and serviceRef.startswith("1:"): info = eServiceCenter.getInstance().info(eServiceReference(serviceRef)) refstr = info and info.getInfoString(service, iServiceInformation.sServiceref) serviceRef = refstr and eServiceReference(refstr).toCompareString() #remove the path and name fields, and replace ':' by '_' fields = GetWithAlternative(serviceRef).split(':', 10)[:10] if not fields or len(fields) < 10: return "" pngname = findPicon('_'.join(fields)) if not pngname and not fields[6].endswith("0000"): #remove "sub-network" from namespace fields[6] = fields[6][:-4] + "0000" pngname = findPicon('_'.join(fields)) if not pngname and fields[0] != '1': #fallback to 1 for IPTV streams fields[0] = '1' pngname = findPicon('_'.join(fields)) if not pngname and fields[2] != '2': #fallback to 1 for TV services with non-standard service types fields[2] = '1' pngname = findPicon('_'.join(fields)) if not pngname: # picon by channel name name = ServiceReference(serviceRef).getServiceName() name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode( 'ASCII', 'ignore') name = re.sub( '[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if name: pngname = findPicon(name) if not pngname and len(name) > 2 and name.endswith('hd'): pngname = findPicon(name[:-2]) if not pngname and len(name) > 6: series = re.sub(r's[0-9]*e[0-9]*$', '', name) pngname = findPicon(series) if not pngname: tmp = resolveFilename(SCOPE_CURRENT_SKIN, 'picon_default.png') tmp2 = findPicon("picon_default") if pathExists(tmp2): pngname = tmp2 else: if pathExists(tmp): pngname = tmp else: pngname = resolveFilename(SCOPE_CURRENT_SKIN, 'picon_default.png') return pngname
def changed(self, rjvsyr): global mzrynz global otzqir if self.instance: koprvn = ePicLoad() koprvn.setPara((int(self.lxktpt[0]), int(self.lxktpt[1]), 1, 1, 0, 1, '#00000000')) nlqmqs = None try: qystrq = self.source.service if rjvsyr[0] != self.CHANGED_CLEAR: nlqmqs = findCoolPicon(qystrq.toString()) except: qystrq = self.source.text if rjvsyr[0] != self.CHANGED_CLEAR: nlqmqs = findCoolPicon(qystrq) if not nlqmqs: kklrrq = ServiceReference(qystrq).getServiceName() try: kklrrq = kklrrq.replace('\xc2\x87', '').replace( '\xc2\x86', '').decode('utf-8').encode('latin1') except: pass nlqmqs = findCoolPicon(kklrrq) if not nlqmqs: nlqmqs = '/usr/lib/enigma2/python/Plugins/Extensions/CoolTVGuide/Cool3D/dummy.png' koprvn.setPara((1, 1, 1, 1, 0, 1, '#00000000')) if otzqir: nlqmqs = '' mzrynz = '' koprvn = findCoolPicon(kklrrq) klyrok = koprvn.startDecode rjyixi = koprvn.setPara rjyixi((int(self.lxktpt[0]), int(self.lxktpt[1]), 1, 1, 0, 1, '#00000000')) elif mzrynz == '': uunuoo = zrlpzx.rfind(':') if uunuoo != -1: otzqir = True zrlpzx = zrlpzx[:uunuoo].rstrip(':').replace(':', '_') for srrllp in self.vzxowj: nlqmqs = srrllp + zrlpzx + '.png' if fileExists(nlqmqs): self.Setpixmap(nlqmqs) if not otzqir: koprvn.startDecode(nlqmqs, 0, 0, False) nlqmqs = koprvn.getData() self.instance.setPixmap(nlqmqs)
def writeName(self): if (config.plugins.vfdicon.displayshow.value != "date" and config.plugins.vfdicon.displayshow.value != "day_date" and config.plugins.vfdicon.displayshow.value != "time_date" and config.plugins.vfdicon.displayshow.value != "time" and config.plugins.vfdicon.displayshow.value != "timeHM"): servicename = " " if config.plugins.vfdicon.displayshow.value != "nothing": service = self.session.nav.getCurrentlyPlayingServiceOrGroup() if service: path = service.getPath() if path: self.play = True servicename = "Play" currPlay = self.session.nav.getCurrentService() if currPlay != None and self.mp3Available: # show the MP3 tag servicename = currPlay.info().getInfoString( iServiceInformation.sTagTitle ) + " - " + currPlay.info().getInfoString( iServiceInformation.sTagArtist) else: # show the file name self.service = self.session.nav.getCurrentlyPlayingServiceReference( ) if not self.service is None: service = self.service.toCompareString() servicename = ServiceReference( service).getServiceName().replace( '\xc2\x87', '').replace('\xc2\x86', '') else: if config.plugins.vfdicon.displayshow.value == "channel number": #show the channel number servicename = str(service.getChannelNum()) if len(servicename) == 1: servicename = '000' + servicename elif len(servicename) == 2: servicename = '00' + servicename elif len(servicename) == 3: servicename = '0' + servicename elif config.plugins.vfdicon.displayshow.value == "channel namenumber": #show the channel number & name servicename = str(service.getChannelNum() ) + ' ' + ServiceReference( service).getServiceName() else: servicename = ServiceReference( service).getServiceName( ) #show the channel name self.play = False if config.plugins.vfdicon.uppercase.value == True: servicename = servicename.upper() servicename = servicename.replace(' ', ' ') evfd.getInstance().vfd_write_string(servicename[0:63])
def writeName(self): if (config.plugins.vfdicon.displayshow.value != "date" and config.plugins.vfdicon.displayshow.value != "day_date" and config.plugins.vfdicon.displayshow.value != "time_date" and config.plugins.vfdicon.displayshow.value != "time"): servicename = " " if config.plugins.vfdicon.displayshow.value != "nothing": service = self.session.nav.getCurrentlyPlayingServiceOrGroup() if service: path = service.getPath() if path: self.play = True servicename = "Play" currPlay = self.session.nav.getCurrentService() if currPlay != None and self.mp3Available: # show the MP3 tag servicename = currPlay.info().getInfoString(iServiceInformation.sTagTitle) + " - " + currPlay.info().getInfoString(iServiceInformation.sTagArtist) Console().ePopen("fp_control -i 27 0 -i 29 0 -i 31 0 -i 32 0 -i 38 0 -i 39 1") #Radio icon on, TV off else: # show the file name Console().ePopen("fp_control -i 38 1 -i 39 0") #Radio icon off, TV on self.service = self.session.nav.getCurrentlyPlayingServiceReference() if not self.service is None: service = self.service.toCompareString() # servicename = ServiceReference(service).getServiceName().replace('\xc2\x87', '').replace('\xc2\x86', '').ljust(63) servicename = ServiceReference(service).getServiceName().replace('\xc2\x87', '').replace('\xc2\x86', '') Console().ePopen("fp_control -i 15 1 -i 16 1 -i 25 1") #play, file else: if config.plugins.vfdicon.displayshow.value == "channel number": #show the channel number servicename = str(service.getChannelNum()) if len(servicename) == 1: servicename = '000' + servicename elif len(servicename) == 2: servicename = '00' + servicename elif len(servicename) == 3: servicename = '0' + servicename elif config.plugins.vfdicon.displayshow.value == "channel namenumber": #show the channel number & name servicename = str(service.getChannelNum()) + ' ' + ServiceReference(service).getServiceName() else: servicename = ServiceReference(service).getServiceName() #show the channel name self.play = False Console().ePopen("fp_control -i 15 0 -i 16 0 -i 25 0") #play, file off #evaluate radio or tv if config.plugins.vfdicon.showicons.value == "all": if config.servicelist.lastmode.value == 'tv': Console().ePopen("fp_control -i 38 1 -i 39 0") #TV icon on, Radio off else: Console().ePopen("fp_control -i 27 0 -i 29 0 -i 31 0 -i 32 0 -i 38 0 -i 39 1") #Radio icon on, TV off if config.plugins.vfdicon.uppercase.value == True: servicename = servicename.upper() servicename = servicename.replace(' ', ' ') evfd.getInstance().vfd_write_string(servicename[0:63])
def changed(self, what): if self.instance: pngname = "" if what[0] != self.CHANGED_CLEAR: self.instance.show() sname = self.source.text pos = sname.rfind(":") if pos != -1: sname = sname[:pos].rstrip(":").replace(":", "_") sname = sname.split("_http")[0] pngname = self.nameCache.get(sname, "") if pngname == "": pngname = self.findPicon(sname) if pngname == "": fields = sname.split("_", 3) if len(fields) > 2 and fields[2] != "2": fields[2] = "1" if fields[0] == "4097" or fields[0] == "5002": fields[0] = "1" pngname = self.findPicon("_".join(fields)) if not pngname: name = ServiceReference(self.source.text).getServiceName() name = unicodedata.normalize("NFKD", unicode(name, "utf_8", errors="ignore")).encode("ASCII", "ignore") name = re.sub("[^a-z0-9]", "", name.replace("&", "and").replace("+", "plus").replace("*", "star").lower()) if len(name) > 0: pngname = self.findPicon(name) if not pngname and len(name) > 2 and name.endswith("hd"): pngname = self.findPicon(name[:-2]) if pngname != "": self.nameCache[sname] = pngname if pngname == "": pngname = self.nameCache.get("default", "") if pngname == "": pngname = self.findPicon("picon_default") if pngname == "": tmp = resolveFilename(SCOPE_CURRENT_SKIN, "picon_default.png") if os.path.exists(tmp): pngname = tmp else: pngname = resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/picon_default.png") self.nameCache["default"] = pngname if self.pngname != pngname: self.instance.setScale(1) self.instance.setPixmapFromFile(pngname) self.pngname = pngname else: self.pngname = "" self.instance.hide()
def getLcdPiconName(serviceName): sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10]) pngname = findLcdPicon(sname) if not pngname: fields = sname.split('_', 3) if len(fields) > 0 and fields[0] != '1': fields[0] = '1' pngname = findLcdPicon('_'.join(fields)) if not pngname: # picon by channel name name = ServiceReference(serviceName).getServiceName() name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore') name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if len(name) > 0: pngname = findLcdPicon(name) if not pngname and len(name) > 2 and name.endswith('hd'): pngname = findLcdPicon(name[:-2]) return pngname
def getPiconName(serviceName): sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10]) pngname = findPicon(sname) if not pngname: fields = sname.split('_', 3) if len(fields) > 2 and fields[2] != '2': fields[2] = '1' if len(fields) > 0 and fields[0] == '4097': fields[0] = '1' pngname = findPicon('_'.join(fields)) if not pngname: name = ServiceReference(serviceName).getServiceName() name = unicodedata.normalize('NFKD', unicode(name, 'utf_8')).encode('ASCII', 'ignore') name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if len(name) > 0: pngname = findPicon(name) return pngname
def getPiconName(serviceName): #remove the path and name fields, and replace ':' by '_' sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10]) pngname = findPicon(sname) if not pngname: fields = sname.split('_', 3) if len(fields) > 2: if fields[0] != '1': #fallback to 1 for other reftypes fields[0] = '1' pngname = findPicon('_'.join(fields)) if not pngname and fields[2] != '2': #fallback to 1 for tv services with nonstandard servicetypes fields[2] = '1' pngname = findPicon('_'.join(fields)) if not pngname: # picon by channel name name = ServiceReference(serviceName).getServiceName() name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode( 'ASCII', 'ignore') piconname = re.sub( '[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if piconname: pngname = findPicon(piconname) if not pngname and len(piconname) > 2 and name.endswith('hd'): pngname = findPicon(piconname[:-2]) if not pngname: # try picon by channel name without last word piconname = ' '.join(name.split(' ')[:-1]) piconname = re.sub( '[^a-z0-9]', '', piconname.replace('&', 'and').replace('+', 'plus').replace( '*', 'star').lower()) pngname = findPicon(piconname) if not pngname: tmp = resolveFilename(SCOPE_CURRENT_SKIN, "picon_default.png") if pathExists(tmp): pngname = tmp else: pngname = resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/picon_default.png") return pngname
def getLcdPiconName(serviceName): #remove the path and name fields, and replace ':' by '_' sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10]) pngname = findLcdPicon(sname) if not pngname: fields = sname.split('_', 3) if len(fields) > 2 and fields[2] != '2': #fallback to 1 for tv services with nonstandard servicetypes fields[2] = '1' if len(fields) > 0 and fields[0] == '4097': #fallback to 1 for IPTV streams fields[0] = '1' pngname = findLcdPicon('_'.join(fields)) if not pngname: # picon by channel name name = ServiceReference(serviceName).getServiceName() name = unicodedata.normalize('NFKD', unicode(name, 'utf_8')).encode('ASCII', 'ignore') name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if len(name) > 0: pngname = findLcdPicon(name) return pngname
def getPiconName(serviceName): # remove the path and name fields, and replace ':' by '_' sname = "_".join(GetWithAlternative(serviceName).split(":", 10)[:10]) pngname = findPicon(sname) if not pngname: fields = sname.split("_", 3) if len(fields) > 2 and fields[2] != "2": # fallback to 1 for tv services with nonstandard servicetypes fields[2] = "1" if len(fields) > 0 and fields[0] == "4097": # fallback to 1 for IPTV streams fields[0] = "1" pngname = findPicon("_".join(fields)) if not pngname: # picon by channel name name = ServiceReference(serviceName).getServiceName() name = unicodedata.normalize("NFKD", unicode(name, "utf_8")).encode("ASCII", "ignore") name = re.sub("[^a-z0-9]", "", name.replace("&", "and").replace("+", "plus").replace("*", "star").lower()) if len(name) > 0: pngname = findPicon(name) return pngname
def changed(self, what): if self.instance: pngname = "" if what[0] != self.CHANGED_CLEAR: sname = self.source.text pos = sname.rfind(':') if pos != -1: sname = sname[:pos].rstrip(':').replace(':','_') sname = sname.split("_http")[0] pngname = self.nameCache.get(sname, "") if pngname == "": pngname = self.findPicon(sname) if pngname == "": fields = sname.split('_', 3) if len(fields) > 2 and fields[2] != '2': #fallback to 1 for tv services with nonstandard servicetypes fields[2] = '1' if fields[0] == '4097': #fallback to 1 for IPTV streams fields[0] = '1' pngname = self.findPicon('_'.join(fields)) if not pngname: # picon by channel name name = ServiceReference(self.source.text).getServiceName() name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore') name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if len(name) > 0: pngname = self.findPicon(name) if not pngname and len(name) > 2 and name.endswith('hd'): pngname = self.findPicon(name[:-2]) if pngname != "": self.nameCache[sname] = pngname if pngname == "": # no picon for service found pngname = self.nameCache.get("default", "") if pngname == "": # no default yet in cache.. pngname = self.findPicon("picon_default") if pngname == "": tmp = resolveFilename(SCOPE_CURRENT_SKIN, "picon_default.png") if fileExists(tmp): pngname = tmp else: pngname = resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/picon_default.png") self.nameCache["default"] = pngname if self.pngname != pngname: self.instance.setScale(1) self.instance.setPixmapFromFile(pngname) self.pngname = pngname
def getPiconName(serviceName): sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10]) pngname = findPicon(sname) if not pngname: # picon by channel name name = ServiceReference(serviceName).getServiceName() if sys.version_info[0] >= 3: name = six.ensure_str( unicodedata.normalize('NFKD', name).encode('ASCII', 'ignore')) else: name = unicodedata.normalize( 'NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore') name = re.sub( '[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if len(name) > 0: pngname = findPicon(name) if not pngname and len(name) > 2 and name.endswith('hd'): pngname = findPicon(name[:-2]) if not pngname: fields = sname.split('_', 3) if len(fields) > 0 and fields[0] != '1': fields[0] = '1' pngname = findPicon('_'.join(fields)) if len(fields) > 2: while not pngname: tmp = '' for i in list(range(256)): tmp = hex(i)[2:].upper().zfill(2) fields[2] = tmp pngname = findPicon('_'.join(fields)) if pngname: newpng = '/usr/share/enigma2/picon/' + name + '.png' try: os.symlink(pngname, newpng) except: pass break if tmp == "FF": break return pngname
def getText(self): if self.streamServer is None: return "" clients = [] refs = [] ips = [] names = [] encoders = [] for x in self.streamServer.getConnectedClients(): refs.append((x[1])) servicename = ServiceReference(x[1]).getServiceName() or "" service_name = servicename.replace('\xc2\x86', '').replace('\xc2\x87', '') names.append((service_name)) if '::ffff:' in x[0]: ip = 'ipv6' ips.append((ip)) else: ip = x[0]#[7:] ips.append((ip)) if int(x[2]) == 0: encoder = _('NO') else: encoder = _('YES') encoders.append((encoder)) clients.append((ip, service_name, encoder)) if not clients: return "" if self.type == self.REF: return ' '.join(refs) elif self.type == self.IP: return ' '.join(ips) elif self.type == self.NAME: return ' '.join(names) elif self.type == self.ENCODER: return _("Transcoding: ") + ' '.join(encoders) elif self.type == self.NUMBEP: return str(len(clients)) elif self.type == self.SHORT_ALL: return _("Total clients streaming: %d (%s)") % (len(clients), ' '.join(names)) else: return '\n'.join(' '.join(elems) for elems in clients) return ""
def getChannelName(source): service = source.service if isinstance(service, iPlayableServicePtr): info = service and service.info() ref = None elif type(source) == ExtEvent: ref = service elif str(type(source) ) == "<class 'Components.Sources.extEventInfo.extEventInfo'>": ref = service else: # reference info = service and source.info ref = service try: name = ref and info.getName(ref) except Exception: name = ServiceReference(str(ref)).getServiceName() return name.replace('\xc2\x86', '').replace('\xc2\x87', '')
def getPiconName(serviceName, mode=1): #remove the path and name fields, and replace ':' by '_' sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10]) pngname = findPicon(sname) if not pngname: fields = sname.split('_', 3) if len(fields) > 2 and fields[2] != '2': #fallback to 1 for tv services with nonstandard servicetypes fields[2] = '1' pngname = findPicon('_'.join(fields)) if not pngname: # picon by channel name name = ServiceReference(serviceName).getServiceName() name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore') name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if name: pngname = findPicon(name) if not pngname and len(name) > 2 and name.endswith('hd'): pngname = findPicon(name[:-2]) if not pngname and mode == 1: pngname = "/usr/share/enigma2/skin_default/picon_default.png" return pngname
def getPiconName(serviceName): #remove the path and name fields, and replace ':' by '_' sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10]) pngname = findPicon(sname) if not pngname: fields = sname.split('_', 3) if len(fields) > 2 and fields[2] != '2': #fallback to 1 for tv services with nonstandard servicetypes fields[2] = '1' if len(fields) > 0 and fields[0] == '4097': #fallback to 1 for IPTV streams fields[0] = '1' pngname = findPicon('_'.join(fields)) if not pngname: # picon by channel name name = ServiceReference(serviceName).getServiceName() name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore') name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if len(name) > 0: pngname = findPicon(name) if not pngname and len(name) > 2 and name.endswith('hd'): pngname = findPicon(name[:-2]) if pathExists(pngname): return pngname else: return resolveFilename(SCOPE_ACTIVE_SKIN, "picon_default.png")
def getPiconName(serviceName): #remove the path and name fields, and replace ':' by '_' fields = GetWithAlternative(serviceName).split(':', 10)[:10] if not fields or len(fields) < 10: return "" pngname = findPicon('_'.join(fields)) if not pngname and not fields[6].endswith("0000"): #remove "sub-network" from namespace fields[6] = fields[6][:-4] + "0000" pngname = findPicon('_'.join(fields)) if not pngname and fields[0] != '1': #fallback to 1 for other reftypes fields[0] = '1' pngname = findPicon('_'.join(fields)) if not pngname and fields[2] != '1': #fallback to 1 for services with different service types fields[2] = '1' pngname = findPicon('_'.join(fields)) if not pngname: # picon by channel name name = ServiceReference(serviceName).getServiceName() name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore') name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if name: pngname = findPicon(name) if not pngname and len(name) > 2 and name.endswith('hd'): pngname = findPicon(name[:-2]) if not pngname: tmp = resolveFilename(SCOPE_CURRENT_SKIN, 'picon_default.png') tmp2 = findPicon("picon_default") if pathExists(tmp2): pngname = tmp2 else: if pathExists(tmp): pngname = tmp else: pngname = resolveFilename(SCOPE_SKIN_IMAGE, 'skin_default/picon_default.png') return pngname
def getPiconName(serviceName, selfPiconType): if DBG: j00zekDEBUG('[j00zekPicons:getPiconName] >>>') name = 'unknown' sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10]) pngname = findPicon(sname, selfPiconType) if not pngname: fields = sname.split('_', 3) isChanged = False if len(fields) > 2 and fields[2] != '2' and fields[2] != '1': fields[2] = '1' isChanged = True if len(fields) > 0 and fields[0] == '4097': fields[0] = '1' isChanged = True if isChanged == True: pngname = findPicon('_'.join(fields), selfPiconType) if not pngname: name = ServiceReference(serviceName).getServiceName() name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode( 'ASCII', 'ignore') name = re.sub( '[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if len(name) > 0: pngname = findPicon(name, selfPiconType) if not pngname and len(name) > 2 and name.endswith('hd'): pngname = findPicon(name[:-2], selfPiconType) if DBG: j00zekDEBUG( '[j00zekPicons:getPiconName] serviceName=%s, picon=%s, %s, piconFile=%s, selfPiconType=%s' % (str(serviceName), sname, name, str(pngname), selfPiconType)) return pngname
def getPicon(sname): pp = PICON_PATH if pp is not None: # remove URL part if ("://" in sname) or ("%3a//" in sname) or ("%3A//" in sname): cname = unquote(sname.split(":")[-1]) sname = unquote(sname) # sname = ":".join(sname.split(":")[:10]) -> old way sname = ":".join(sname.split("://")[:1]) sname = GetWithAlternative(sname) cname = unicodedata.normalize( 'NFKD', unicode(cname, 'utf_8', errors='ignore')).encode('ASCII', 'ignore') cname = re.sub( '[^a-z0-9]', '', cname.replace('&', 'and').replace('+', 'plus').replace( '*', 'star').replace(':', '').lower()) # picon by channel name for URL if len(cname) > 0 and fileExists(pp + cname + ".png"): return "/picon/" + cname + ".png" if len(cname) > 2 and cname.endswith('hd') and fileExists( pp + cname[:-2] + ".png"): return "/picon/" + cname[:-2] + ".png" if len(cname) > 5: series = re.sub(r's[0-9]*e[0-9]*$', '', cname) if fileExists(pp + series + ".png"): return "/picon/" + series + ".png" sname = GetWithAlternative(sname) if sname is not None: pos = sname.rfind(':') else: return "/images/default_picon.png" cname = None if pos != -1: cname = ServiceReference(sname[:pos].rstrip(':')).getServiceName() sname = sname[:pos].rstrip(':').replace(':', '_') + ".png" filename = pp + sname if fileExists(filename): return "/picon/" + sname fields = sname.split('_', 8) if len(fields) > 7 and not fields[6].endswith("0000"): # remove "sub-network" from namespace fields[6] = fields[6][:-4] + "0000" sname = '_'.join(fields) filename = pp + sname if fileExists(filename): return "/picon/" + sname if len(fields) > 1 and fields[0] != '1': # fallback to 1 for other reftypes fields[0] = '1' sname = '_'.join(fields) filename = pp + sname if fileExists(filename): return "/picon/" + sname if len(fields) > 3 and fields[2] != '1': # fallback to 1 for tv services with nonstandard servicetypes fields[2] = '1' sname = '_'.join(fields) filename = pp + sname if fileExists(filename): return "/picon/" + sname if cname is not None: # picon by channel name cname1 = cname.replace('\xc2\x86', '').replace('\xc2\x87', '').replace( '/', '_').encode('utf-8', 'ignore') if fileExists(pp + cname1 + ".png"): return "/picon/" + cname1 + ".png" cname = unicodedata.normalize( 'NFKD', unicode(cname, 'utf_8', errors='ignore')).encode('ASCII', 'ignore') cname = re.sub( '[^a-z0-9]', '', cname.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if len(cname) > 0: filename = pp + cname + ".png" if fileExists(filename): return "/picon/" + cname + ".png" if len(cname) > 2 and cname.endswith('hd') and fileExists( pp + cname[:-2] + ".png"): return "/picon/" + cname[:-2] + ".png" return "/images/default_picon.png"
def getPicon(sname): if not PICON_PATH: return FALLBACK_PICON_LOCATION # remove URL part if ("://" in sname) or ("%3a//" in sname) or ("%3A//" in sname): sname = unquote(sname) sname = ":".join(sname.split(":")[:10]) + "::" + sname.split(":")[-1] sname = GetWithAlternative(sname) if sname is not None: pos = sname.rfind(':') else: return FALLBACK_PICON_LOCATION cname = None if pos != -1: cname = ServiceReference(sname[:pos].rstrip(':')).getServiceName() sname = sname[:pos].rstrip(':').replace(':', '_') + PICON_EXT filename = PICON_PATH + sname if os.path.isfile(filename): return PICON_ENDPOINT_PATH + sname fields = sname.split('_', 8) if len(fields) > 7 and not fields[6].endswith("0000"): # remove "sub-network" from namespace fields[6] = fields[6][:-4] + "0000" sname = '_'.join(fields) filename = PICON_PATH + sname if os.path.isfile(filename): return PICON_ENDPOINT_PATH + sname if len(fields) > 1 and fields[0] != '1': # fallback to 1 for other reftypes fields[0] = '1' sname = '_'.join(fields) filename = PICON_PATH + sname if os.path.isfile(filename): return PICON_ENDPOINT_PATH + sname if len(fields) > 3 and fields[2] != '1': # fallback to 1 for tv services with nonstandard servicetypes fields[2] = '1' sname = '_'.join(fields) filename = PICON_PATH + sname if os.path.isfile(filename): return PICON_ENDPOINT_PATH + sname if cname is not None: # picon by channel name cname1 = mangle_epg_text(cname).replace('/', '_').encode('utf-8', 'ignore') if os.path.isfile(PICON_PATH + cname1 + PICON_EXT): return PICON_ENDPOINT_PATH + cname1 + PICON_EXT cname = unicodedata.normalize('NFKD', unicode(cname, 'utf_8', errors='ignore')).encode( 'ASCII', 'ignore') cname = re.sub( '[^a-z0-9]', '', cname.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if len(cname) > 0: filename = PICON_PATH + cname + PICON_EXT if os.path.isfile(filename): return PICON_ENDPOINT_PATH + cname + PICON_EXT if len(cname) > 2 and cname.endswith('hd') and os.path.isfile( PICON_PATH + cname[:-2] + PICON_EXT): return PICON_ENDPOINT_PATH + cname[:-2] + PICON_EXT
def changed(self, what): if self.instance: pngname = '' if what[0] != self.CHANGED_CLEAR: self.instance.show() sname = self.source.text pos = sname.rfind(':') if pos != -1: sname = sname[:pos].rstrip(':').replace(':', '_') sname = sname.split('_http')[0] pngname = self.nameCache.get(sname, '') if pngname == '' or not fileExists(pngname): pngname = self.findPicon(sname) if pngname == '': fields = sname.split('_', 3) if len(fields) > 0 and fields[0] != '1': fields[0] = '1' pngname = self.findPicon('_'.join(fields)) if pngname == '' and len(fields) > 2 and fields[2] != '2': fields[2] = '1' pngname = self.findPicon('_'.join(fields)) if not pngname: name = ServiceReference(self.source.text).getServiceName() name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore') name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if len(name) > 0: pngname = self.findPicon(name) if not pngname and len(name) > 2 and name.endswith('hd'): pngname = self.findPicon(name[:-2]) if pngname != '' and sname.split('_', 1)[0] == '1': self.nameCache[sname] = pngname if pngname == '': pngname = self.nameCache.get('default', '') if pngname == '': pngname = self.findPicon('picon_default') if pngname == '': tmp = resolveFilename(SCOPE_CURRENT_SKIN, 'picon_default.png') if fileExists(tmp): pngname = tmp else: pngname = resolveFilename(SCOPE_SKIN_IMAGE, 'skin_default/picon_default.png') self.nameCache['default'] = pngname if self.pngname != pngname: if config.plugins.MyMetrixLiteOther.piconresize_experimental.value: try: im = Image.open(pngname).convert('RGBA') except: print '[MetrixHDXPicon] cant load image:', pngname tmp = resolveFilename(SCOPE_CURRENT_SKIN, 'picon_default.png') if fileExists(tmp): pngname = tmp else: pngname = resolveFilename(SCOPE_SKIN_IMAGE, 'skin_default/picon_default.png') im = Image.open(pngname).convert('RGBA') imw, imh = im.size inh = self.instance.size().height() if imh != inh: sf = float(inh) / imh im = im.resize((int(imw * sf), int(imh * sf)), Image.ANTIALIAS) ims = ImageEnhance.Sharpness(im) im = ims.enhance(float(config.plugins.MyMetrixLiteOther.piconsharpness_experimental.value)) tempfile = '/tmp/picon.png' im.save(tempfile) self.instance.setPixmapFromFile(tempfile) else: self.instance.setPixmapFromFile(pngname) else: self.instance.setPixmapFromFile(pngname) self.instance.setScale(1) self.pngname = pngname else: self.pngname = '' self.instance.hide()
def changed(self, what): if self.instance: pngname = "" if what[0] != self.CHANGED_CLEAR: self.instance.show() sname = self.source.text.upper() pos = sname.rfind(":") if pos != -1: sname = sname[:pos].rstrip(":").replace(":", "_") sname = sname.split("_HTTP")[0] pngname = self.nameCache.get(sname, "") if pngname == "": pngname = self.findPicon(sname) if pngname == "": fields = sname.split("_", 3) if len(fields) > 2 and fields[2] != "2": fields[2] = "1" if fields[0] == "4097" or fields[0] == "5002": fields[0] = "1" pngname = self.findPicon("_".join(fields)) if not pngname: name = ServiceReference( self.source.text).getServiceName() if six.PY3: name = six.ensure_str( unicodedata.normalize('NFKD', name).encode( 'ASCII', 'ignore')) else: name = unicodedata.normalize( 'NFKD', unicode(name, 'utf_8', errors='ignore')).encode( 'ASCII', 'ignore') name = re.sub( '[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace( '*', 'star').lower()) if len(name) > 0: pngname = self.findPicon(name) if not pngname and len(name) > 2 and name.endswith( "hd"): pngname = self.findPicon(name[:-2]) if pngname != "": self.nameCache[sname] = pngname if pngname == "": self.pngname = "" self.instance.hide() #pngname = self.nameCache.get("default", "") #if pngname == "": #pngname = self.findPicon("picon_default") #if pngname == "": #tmp = resolveFilename(SCOPE_CURRENT_SKIN, "picon_default.png") #if os.path.exists(tmp): #pngname = tmp #else: #pngname = resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/picon_default.png") #self.nameCache["default"] = pngname if self.pngname != pngname: self.instance.setScale(1) self.instance.setPixmapFromFile(pngname) self.pngname = pngname else: self.pngname = "" self.instance.hide()
def changed(self, what): if self.instance: pngname = "" if what[0] != self.CHANGED_CLEAR: self.instance.show() sname = self.source.text pos = sname.rfind(':') if pos != -1: sname = sname[:pos].rstrip(':').replace(':', '_') sname = sname.split("_http")[0] pngname = self.nameCache.get(sname, "") if pngname == "": pngname = self.findPicon(sname) if pngname == "": fields = sname.split('_', 3) if len(fields) > 0 and fields[ 0] != '1': #fallback to 1 for IPTV streams fields[0] = '1' pngname = self.findPicon('_'.join(fields)) if pngname == "" and len(fields) > 2 and fields[ 2] != '2': #fallback to 1 for find picons with not defined stream quality fields[2] = '1' pngname = self.findPicon('_'.join(fields)) if not pngname: # picon by channel name name = ServiceReference( self.source.text).getServiceName() name = unicodedata.normalize( 'NFKD', unicode(name, 'utf_8', errors='ignore')).encode( 'ASCII', 'ignore') name = re.sub( '[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace( '*', 'star').lower()) if len(name) > 0: pngname = self.findPicon(name) if not pngname and len(name) > 2 and name.endswith( 'hd'): pngname = self.findPicon(name[:-2]) if pngname != "": self.nameCache[sname] = pngname if pngname == "": # no picon for service found pngname = self.nameCache.get("default", "") if pngname == "": # no default yet in cache.. pngname = self.findPicon("picon_default") if pngname == "": tmp = resolveFilename(SCOPE_CURRENT_SKIN, "picon_default.png") if fileExists(tmp): pngname = tmp else: pngname = resolveFilename( SCOPE_SKIN_IMAGE, "skin_default/picon_default.png") self.nameCache["default"] = pngname if self.pngname != pngname: if config.plugins.MyMetrixLiteOther.piconresize_experimental.value: im = Image.open(pngname).convert('RGBA') imw, imh = im.size inh = self.instance.size().height() if imh != inh: sf = float(inh) / imh im = im.resize((int(imw * sf), int(imh * sf)), Image.ANTIALIAS) ims = ImageEnhance.Sharpness(im) im = ims.enhance( float(config.plugins.MyMetrixLiteOther. piconsharpness_experimental.value)) tempfile = '/tmp/picon.png' im.save(tempfile) self.instance.setPixmapFromFile(tempfile) else: self.instance.setPixmapFromFile(pngname) else: self.instance.setPixmapFromFile(pngname) self.instance.setScale(1) self.pngname = pngname else: self.pngname = "" self.instance.hide()