From 1e6c56c2fc42d280dad87ce6a5d6dfde2842f6f0 Mon Sep 17 00:00:00 2001 From: Remy Date: Sun, 17 Jul 2011 14:39:22 -0700 Subject: [PATCH] Possible fix for unicode/ascii errors. Please test --- headphones/importer.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/headphones/importer.py b/headphones/importer.py index dbd4721f..4259be51 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -16,14 +16,16 @@ def scanMusic(dir=None): results = [] - for r,d,f in os.walk(unicode(dir)): + for r,d,f in os.walk(str(dir)): for files in f: - try: - if any(files.endswith(x) for x in (".mp3", ".flac", ".aac", ".ogg", ".ape")): - results.append(os.path.join(r,files)) - except Exception, e: - logger.warn('Can not decode file %s. Error: ' % (files, e)) - continue + if any(files.endswith(x) for x in (".mp3", ".flac", ".aac", ".ogg", ".ape")): + try: + file = unicode(files) + root = unicode(r) + results.append(os.path.join(root,file)) + except UnicodeDecodeError, e: + logger.error('Can not decode file %s. Error: %s' % (str(files), str(e))) + continue logger.info(u'%i music files found' % len(results))