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): #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