Permalink
Browse files

lyrics: substitute more punctuation (fixes #270)

  • Loading branch information...
sampsyo committed May 12, 2013
1 parent a5cb343 commit a0ef886801de8dcc179c8be3f66b6862fcd13af1
Showing with 16 additions and 2 deletions.
  1. +16 −2 beetsplug/lyrics.py
View
@@ -36,6 +36,20 @@
COMMENT_RE = re.compile(r'<!--.*-->', re.S)
TAG_RE = re.compile(r'<[^>]*>')
BREAK_RE = re.compile(r'<br\s*/?>')
URL_CHARACTERS = {
u'\u2018': u"'",
u'\u2019': u"'",
u'\u201c': u'"',
u'\u201d': u'"',
u'\u2010': u'-',
u'\u2011': u'-',
u'\u2012': u'-',
u'\u2013': u'-',
u'\u2014': u'-',
u'\u2015': u'-',
u'\u2016': u'-',
u'\u2026': u'...',
}
# Utilities.
@@ -115,8 +129,8 @@ def _encode(s):
LyricsWiki and Lyrics.com).
"""
if isinstance(s, unicode):
# Replace "fancy" apostrophes with straight ones.
s = s.replace(u'\u2019', u"'")
for char, repl in URL_CHARACTERS.items():
s = s.replace(char, repl)
s = s.encode('utf8', 'ignore')
return urllib.quote(s)

0 comments on commit a0ef886

Please sign in to comment.