It would load but not work it I removed the line about importing unescape.
Sorry about that. I thought the unescape function came with the component. Here's the code for that function:
http://codeviewer.org/view/code:5289
Save the code as unescape.py, and store it in your "C:\Users\Gonzo\AppData\Roaming\foobar2000\user-components\foo_lyricsgrabber2\pygrabber\system\" directory.
For future reference (in case the codeviewer link breaks), here's the unescape function:
import re, htmlentitydefs
##
# Removes HTML or XML character references and entities from a text string.
#
# @param text The HTML (or XML) source text.
# @return The plain text, as a Unicode string, if necessary.
def unescape(text):
def fixup(m):
text = m.group(0)
if text[:2] == "&#":
# character reference
try:
if text[:3] == "&#x":
return unichr(int(text[3:-1], 16))
else:
return unichr(int(text[2:-1]))
except ValueError:
pass
else:
# named entity
try:
text = unichr(htmlentitydefs.name2codepoint[text[1:-1]])
except KeyError:
pass
return text # leave as is
return re.sub("&#?\w+;", fixup, text)
That worked! Of course when I tried to copy and paste the code I got an indent error but when I just downloaded the text it worked beautifully! Gracias, phot0nic