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] != '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]) 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 '_' 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 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] != '1': fields[2] = '1' if len(fields) > 0 and fields[0] != '1': fields[0] = '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): 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(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) 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] != '1': #fallback to 1 for services with different service types fields[2] = '1' if len(fields ) > 0 and fields[0] != '1': #fallback to 1 for IPTV streams fields[0] = '1' pngname = findLcdPicon('_'.join(fields)) if not pngname: # picon by channel name name = ServiceReference(serviceName).getServiceName() if six.PY3: name = unicodedata.normalize('NFKD', name) else: name = unicodedata.normalize( 'NFKD', six.text_type(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): #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: 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, 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 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() name = unicodedata.normalize( "NFKD", six.text_type(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 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 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 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 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 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 cname1 = cname.replace('\xc2\x86', '').replace('\xc2\x87', '').replace( '/', '_').encode('utf-8', 'ignore') if fileExists(getPiconPath() + 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 = getPiconPath() + cname + ".png" if fileExists(filename): return "/picon/" + cname + ".png" if len(cname) > 2 and cname.endswith('hd') and fileExists( getPiconPath() + cname[:-2] + ".png"): return "/picon/" + cname[:-2] + ".png" return "/images/default_picon.png"
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 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): # 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]) 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]) 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 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 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()
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 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"