From 63e106a12d632321cb672b06ead9ca49c3eba627 Mon Sep 17 00:00:00 2001 From: Ade Date: Wed, 1 Oct 2014 22:13:02 +1300 Subject: [PATCH] And another attempt to normalize --- headphones/helpers.py | 11 +++++++---- headphones/postprocessor.py | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/headphones/helpers.py b/headphones/helpers.py index c6089cfd..6437e2d1 100644 --- a/headphones/helpers.py +++ b/headphones/helpers.py @@ -177,10 +177,13 @@ def replace_all(text, dic, normalize=False): for i, j in dic.iteritems(): if normalize: - if sys.platform == 'darwin': - j = unicodedata.normalize('NFD', j) - else: - j = unicodedata.normalize('NFC', j) + try: + if sys.platform == 'darwin': + j = unicodedata.normalize('NFD', j) + else: + j = unicodedata.normalize('NFC', j) + except TypeError: + j = unicodedata.normalize('NFC', j.decode(headphones.SYS_ENCODING, 'replace')) text = text.replace(i, j) return text diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index a17c96b3..a1f0bcc7 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -629,10 +629,11 @@ def renameNFO(albumpath): logger.error(u'Could not rename file: %s. Error: %s' % (os.path.join(r, file).decode(headphones.SYS_ENCODING, 'replace'), e)) def moveFiles(albumpath, release, tracks): + logger.info("Moving files: %s" % albumpath) try: year = release['ReleaseDate'][:4] except TypeError: - year = '' + year = u'' artist = release['ArtistName'].replace('/', '_') album = release['AlbumTitle'].replace('/', '_')