another attempt at Theme music

For illegal characters - following the same pattern as TV Tunes to make
sure we match 100%
This commit is contained in:
angelblue05 2015-06-19 03:10:41 -05:00
parent 678efedd30
commit ae07e1b4c6
2 changed files with 16 additions and 2 deletions

View file

@ -174,12 +174,12 @@ def getThemeMedia():
for item in result[u'Items']: for item in result[u'Items']:
itemId = item[u'Id'] itemId = item[u'Id']
folderName = item[u'Name'] folderName = item[u'Name']
folderName = xbmc.makeLegalFilename(folderName) folderName = utils.normalize_string(folderName)
itemIds[itemId] = folderName itemIds[itemId] = folderName
# Get paths # Get paths
for itemId in itemIds: 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 # Create folders for each content
if not xbmcvfs.exists(nfo_path): if not xbmcvfs.exists(nfo_path):
xbmcvfs.mkdir(nfo_path) xbmcvfs.mkdir(nfo_path)

View file

@ -159,6 +159,20 @@ def CleanName(filename):
validFilenameChars = "-_.() %s%s" % (string.ascii_letters, string.digits) validFilenameChars = "-_.() %s%s" % (string.ascii_letters, string.digits)
cleanedFilename = unicodedata.normalize('NFKD', filename).encode('ASCII', 'ignore') cleanedFilename = unicodedata.normalize('NFKD', filename).encode('ASCII', 'ignore')
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):
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(): def reset():