Here is the diff file between the file before we added SNP and the current one
Code:
--- C:\Users\User\Downloads\!Satellite\picon file\Picon.py_preSNP 2019-12-02 23:24:09.727000000 -0000
+++ C:\Users\User\Downloads\!Satellite\picon file\Picon.py_20191202 2019-12-02 23:26:34.618000000 -0000
@@ -1,9 +1,10 @@
-import os
+import os, re, unicodedata
from Renderer import Renderer
from enigma import ePixmap, ePicLoad
from Tools.Alternatives import GetWithAlternative
from Tools.Directories import pathExists, SCOPE_ACTIVE_SKIN, resolveFilename
from Components.Harddisk import harddiskmanager
+from ServiceReference import ServiceReference
searchPaths = []
lastPiconPath = None
@@ -56,7 +57,7 @@
global searchPaths
pngname = ""
for path in searchPaths:
- if pathExists(path) and not path.startswith('/media/net'):
+ if pathExists(path) and not path.startswith('/media/net') and not path.startswith('/media/autofs'):
pngname = path + serviceName + ".png"
if pathExists(pngname):
lastPiconPath = path
@@ -73,15 +74,33 @@
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'
+ 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])
+ if not pngname and len(name) > 6:
+ series = re.sub(r's[0-9]*e[0-9]*$', '', name)
+ pngname = findPicon(series)
return pngname
class Picon(Renderer):