Created normalize method for video nodes only
Since no modification can happen to the theme naming.
This commit is contained in:
parent
a7310dc634
commit
560abbcc5d
2 changed files with 37 additions and 19 deletions
|
@ -190,24 +190,42 @@ def CleanName(filename):
|
||||||
return ''.join(c for c in cleanedFilename if c in validFilenameChars)
|
return ''.join(c for c in cleanedFilename if c in validFilenameChars)
|
||||||
|
|
||||||
def normalize_string(text):
|
def normalize_string(text):
|
||||||
try:
|
# For theme media, do not modify unless
|
||||||
text = text.replace(":", "")
|
# modified in TV Tunes
|
||||||
text = text.replace("/", "-")
|
text = text.replace(":", "")
|
||||||
text = text.replace("\\", "-")
|
text = text.replace("/", "-")
|
||||||
text = text.replace("<", "")
|
text = text.replace("\\", "-")
|
||||||
text = text.replace(">", "")
|
text = text.replace("<", "")
|
||||||
text = text.replace("*", "")
|
text = text.replace(">", "")
|
||||||
text = text.replace("?", "")
|
text = text.replace("*", "")
|
||||||
text = text.replace('|', "")
|
text = text.replace("?", "")
|
||||||
text = text.replace('(', "")
|
text = text.replace('|', "")
|
||||||
text = text.replace(')', "")
|
text = text.strip()
|
||||||
text = text.strip()
|
# Remove dots from the last character as windows can not have directories
|
||||||
# Remove dots from the last character as windows can not have directories
|
# with dots at the end
|
||||||
# with dots at the end
|
text = text.rstrip('.')
|
||||||
text = text.rstrip('.')
|
text = unicodedata.normalize('NFKD', unicode(text, 'utf-8')).encode('ascii', 'ignore')
|
||||||
text = unicodedata.normalize('NFKD', unicode(text, 'utf-8')).encode('ascii', 'ignore')
|
|
||||||
except:
|
return text
|
||||||
pass
|
|
||||||
|
def normalize_nodes(text):
|
||||||
|
# For video nodes
|
||||||
|
text = text.replace(":", "")
|
||||||
|
text = text.replace("/", "-")
|
||||||
|
text = text.replace("\\", "-")
|
||||||
|
text = text.replace("<", "")
|
||||||
|
text = text.replace(">", "")
|
||||||
|
text = text.replace("*", "")
|
||||||
|
text = text.replace("?", "")
|
||||||
|
text = text.replace('|', "")
|
||||||
|
text = text.replace('(', "")
|
||||||
|
text = text.replace(')', "")
|
||||||
|
text = text.strip()
|
||||||
|
# Remove dots from the last character as windows can not have directories
|
||||||
|
# with dots at the end
|
||||||
|
text = text.rstrip('.')
|
||||||
|
text = unicodedata.normalize('NFKD', unicode(text, 'utf-8')).encode('ascii', 'ignore')
|
||||||
|
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class VideoNodes():
|
||||||
def buildVideoNodeForView(self, tagname, type, windowPropId):
|
def buildVideoNodeForView(self, tagname, type, windowPropId):
|
||||||
#this method will build a video node for a particular Emby view (= tag in kodi)
|
#this method will build a video node for a particular Emby view (= tag in kodi)
|
||||||
#we set some window props here to for easy future reference and to be used in skins (for easy access only)
|
#we set some window props here to for easy future reference and to be used in skins (for easy access only)
|
||||||
tagname_normalized = utils.normalize_string(tagname)
|
tagname_normalized = utils.normalize_nodes(tagname)
|
||||||
|
|
||||||
libraryPath = xbmc.translatePath("special://profile/library/video/Emby - %s/" %tagname_normalized)
|
libraryPath = xbmc.translatePath("special://profile/library/video/Emby - %s/" %tagname_normalized)
|
||||||
kodiVersion = 14
|
kodiVersion = 14
|
||||||
|
|
Loading…
Reference in a new issue