parent
3d58b93107
commit
73d6bfde89
2 changed files with 19 additions and 4 deletions
|
@ -49,7 +49,7 @@ from xbmcvfs import exists
|
|||
import clientinfo as client
|
||||
from downloadutils import DownloadUtils
|
||||
from utils import window, settings, language as lang, tryDecode, tryEncode, \
|
||||
DateToKodi, exists_dir
|
||||
DateToKodi, exists_dir, slugify
|
||||
from PlexFunctions import PMSHttpsEnabled
|
||||
import plexdb_functions as plexdb
|
||||
import variables as v
|
||||
|
@ -2395,9 +2395,14 @@ class API():
|
|||
log.error('Could not temporarily download subtitle %s' % url)
|
||||
return
|
||||
else:
|
||||
r.encoding = 'utf-8'
|
||||
with open(path, 'wb') as f:
|
||||
f.write(r.content)
|
||||
log.debug('Writing temp subtitle to %s' % path)
|
||||
try:
|
||||
with open(path, 'wb') as f:
|
||||
f.write(r.content)
|
||||
except UnicodeEncodeError:
|
||||
log.debug('Need to slugify the filename %s' % path)
|
||||
with open(slugify(path), 'wb') as f:
|
||||
f.write(r.content)
|
||||
return path
|
||||
|
||||
def GetKodiPremierDate(self):
|
||||
|
|
|
@ -221,6 +221,16 @@ def tryDecode(string, encoding='utf-8'):
|
|||
return string
|
||||
|
||||
|
||||
def slugify(text):
|
||||
"""
|
||||
Normalizes text (in unicode or string) to e.g. enable safe filenames.
|
||||
Returns unicode
|
||||
"""
|
||||
if not isinstance(text, unicode):
|
||||
text = unicode(text)
|
||||
return unicode(normalize('NFKD', text).encode('ascii', 'ignore'))
|
||||
|
||||
|
||||
def escape_html(string):
|
||||
"""
|
||||
Escapes the following:
|
||||
|
|
Loading…
Reference in a new issue