1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-08-13 16:53:54 -04:00

Fixed a issue with the encodingKludge and decoding of unicode data

This commit is contained in:
echel0n 2014-11-24 19:37:43 -08:00
parent b67c186ed8
commit ded1e5d8a0
2 changed files with 7 additions and 2 deletions

View File

@ -34,6 +34,10 @@ def fixStupidEncodings(x, silent=False):
return str(ftfy.fix_text(u'' + x)).decode(sickbeard.SYS_ENCODING)
except UnicodeDecodeError:
logger.log(u"Unable to decode value: " + repr(x), logger.ERROR)
return x
except UnicodeEncodeError:
logger.log(u"Unable to encode value: " + repr(x), logger.ERROR)
return x
elif type(x) == unicode:
return x
else:
@ -48,12 +52,13 @@ def fixListEncodings(x):
else:
return filter(lambda x: x != None, map(fixStupidEncodings, x))
def ek(func, *args, **kwargs):
if os.name == 'nt':
result = func(*args, **kwargs)
else:
result = func(
*[ftfy.fix_text(u'' + x).encode(sickbeard.SYS_ENCODING) if type(x) in (str, unicode) else x for x in args],
*[fixStupidEncodings(x).encode(sickbeard.SYS_ENCODING) if type(x) in (str, unicode) else x for x in args],
**kwargs)
if type(result) in (list, tuple):

View File

@ -26,7 +26,7 @@ import os.path
import regexes
import sickbeard
from sickbeard import logger, helpers, scene_numbering, common, exceptions, scene_exceptions, encodingKludge as ek, db
from sickbeard import logger, helpers, scene_numbering, common, exceptions as ex, scene_exceptions, encodingKludge as ek, db
from dateutil import parser