Permalink
Browse files

Lets make unicode work a little better, sadly by throwing it all away.

  • Loading branch information...
1 parent ab764dd commit af73da909f21e7eeaa885ec51b4fa1906c9d0019 @mythmon committed Jul 3, 2010
Showing with 8 additions and 9 deletions.
  1. +3 −0 .gitignore
  2. +5 −9 playlist_copier.py
View
@@ -0,0 +1,3 @@
+*.pyc
+scratch
+*.m3u
View
@@ -5,16 +5,12 @@
from progress import ProgressBar
from optparse import OptionParser
from mutagen.mp3 import HeaderNotFoundError
+import unicodedata
def sanitize(s):
- return re.sub(r'[\/:\?]', '_', s)
-
-def constrain(n,low,high):
- if n < low:
- return low
- if n > high:
- return high
- return n
+ s = unicodedata.normalize('NFKD', s).encode('ascii','ignore')
+ s = re.sub(r'[\/:\?]', '_', s)
+ return s
if len(sys.argv) < 3:
print("Usage " + sys.argv[0] + " playlist destination")
@@ -133,7 +129,7 @@ def constrain(n,low,high):
try:
shutil.copyfile(song.filename, newFile)
except (IOError):
- pass
+ print "Error copying {0}".format(newFile)
i += 1
bar.update(i)
else:

0 comments on commit af73da9

Please sign in to comment.