Skip to content
Browse files

Merge branch 'wb/lyricwiki-redirect' into maint-1.6.2

* wb/lyricwiki-redirect:
  Improve lyricwiki REDIRECT handling
  • Loading branch information...
2 parents ca5384b + 2acaee2 commit 798730a7d3e3aff4fbe59a27d6a548d6d627e5be @bebarino bebarino committed Oct 15, 2009
Showing with 6 additions and 2 deletions.
  1. +6 −2 sonata/info.py
View
8 sonata/info.py
@@ -390,9 +390,13 @@ def get_lyrics_thread(self, search_artist, search_title, filename_artist, filena
try:
lyricpage = urllib.urlopen("http://lyricwiki.org/index.php?title=%s:%s&action=edit" % (self.lyricwiki_format(search_artist), self.lyricwiki_format(search_title))).read()
content = re.split("<textarea[^>]*>", lyricpage)[1].split("</textarea>")[0]
- if content.startswith("#REDIRECT [["):
+ content = content.strip()
+ redir_tag = "#redirect"
+ if content[:len(redir_tag)].lower() == redir_tag:
addr = "http://lyricwiki.org/index.php?title=%s&action=edit" % urllib.quote(content.split("[[")[1].split("]]")[0])
- content = urllib.urlopen(addr).read()
+ lyricpage = urllib.urlopen(addr).read()
+ content = re.split("<textarea[^>]*>", lyricpage)[1].split("</textarea>")[0]
+ content = content.strip()
lyrics = content.split("&lt;lyrics&gt;")[1].split("&lt;/lyrics&gt;")[0]
if lyrics.strip() != "&lt;!-- PUT LYRICS HERE (and delete this entire line) --&gt;":

0 comments on commit 798730a

Please sign in to comment.
Something went wrong with that request. Please try again.