Created normalize method for video nodes only

Since no modification can happen to the theme naming.
This commit is contained in:
angelblue05 2015-08-02 19:28:13 -05:00
parent a7310dc634
commit 560abbcc5d
2 changed files with 37 additions and 19 deletions

View file

@ -190,7 +190,26 @@ 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
# 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.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
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("\\", "-")
@ -206,8 +225,7 @@ def normalize_string(text):
# 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:
pass
return text return text

View file

@ -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