diff --git a/resources/lib/Entrypoint.py b/resources/lib/Entrypoint.py index 9940d285..1b9deec4 100644 --- a/resources/lib/Entrypoint.py +++ b/resources/lib/Entrypoint.py @@ -174,12 +174,12 @@ def getThemeMedia(): for item in result[u'Items']: itemId = item[u'Id'] folderName = item[u'Name'] - folderName = xbmc.makeLegalFilename(folderName) + folderName = utils.normalize_string(folderName) itemIds[itemId] = folderName # Get paths for itemId in itemIds: - nfo_path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/library/%s" % itemIds[itemId]) + nfo_path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/library/%s/" % itemIds[itemId]) # Create folders for each content if not xbmcvfs.exists(nfo_path): xbmcvfs.mkdir(nfo_path) diff --git a/resources/lib/Utils.py b/resources/lib/Utils.py index 6ff4685b..ff6b5506 100644 --- a/resources/lib/Utils.py +++ b/resources/lib/Utils.py @@ -159,6 +159,20 @@ def CleanName(filename): validFilenameChars = "-_.() %s%s" % (string.ascii_letters, string.digits) cleanedFilename = unicodedata.normalize('NFKD', filename).encode('ASCII', 'ignore') return ''.join(c for c in cleanedFilename if c in validFilenameChars) + +def normalize_string(text): + try: + 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') + except: + pass + return text def reset():