981f12e4ea
crash on startup, so it is still broken.
51 lines
2.9 KiB
Plaintext
51 lines
2.9 KiB
Plaintext
$OpenBSD: patch-sonata_info_py,v 1.2 2012/05/05 09:40:43 ajacoutot Exp $
|
|
|
|
https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=3004&group_id=7323
|
|
https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=3193&group_id=7323
|
|
|
|
--- sonata/info.py.orig Mon Sep 21 23:02:16 2009
|
|
+++ sonata/info.py Sat May 5 11:37:48 2012
|
|
@@ -289,7 +289,7 @@ class Info(object):
|
|
if album is not None:
|
|
albuminfo = album + "\n"
|
|
playtime = 0
|
|
- if len(tracks) > 0:
|
|
+ if tracks is not None and len(tracks) > 0:
|
|
tracks.sort(key=lambda x: int(mpdh.getnum(x, 'track', '0', True, 0)))
|
|
for track in tracks:
|
|
playtime += int(mpdh.get(track, 'time', 0))
|
|
@@ -350,7 +350,7 @@ class Info(object):
|
|
def lyricwiki_editlink(self, songinfo):
|
|
artist, title = [self.lyricwiki_format(mpdh.get(songinfo, key))
|
|
for key in ('artist', 'title')]
|
|
- return "http://lyricwiki.org/index.php?title=%s:%s&action=edit" % (artist, title)
|
|
+ return "http://lyrics.wikia.com/index.php?title=%s:%s&action=edit" % (artist, title)
|
|
|
|
def get_lyrics_thread(self, search_artist, search_title, filename_artist, filename_title, song_dir):
|
|
filename_artist = misc.strip_all_slashes(filename_artist)
|
|
@@ -385,17 +385,18 @@ class Info(object):
|
|
else:
|
|
# Use default filename:
|
|
filename = self.target_lyrics_filename(filename_artist, filename_title, song_dir)
|
|
- # Fetch lyrics from lyricwiki.org
|
|
+ # Fetch lyrics from lyrics.wikia.com (formerly lyricwiki.org)
|
|
gobject.idle_add(self.info_show_lyrics, _("Fetching lyrics..."), filename_artist, filename_title)
|
|
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()
|
|
+ lyricpage = urllib.urlopen("http://lyrics.wikia.com/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 [["):
|
|
- addr = "http://lyricwiki.org/index.php?title=%s&action=edit" % urllib.quote(content.split("[[")[1].split("]]")[0])
|
|
+ addr = "http://lyrics.wikia.com/index.php?title=%s&action=edit" % urllib.quote(content.split("[[")[1].split("]]")[0])
|
|
content = urllib.urlopen(addr).read()
|
|
- lyrics = content.split("<lyrics>")[1].split("</lyrics>")[0]
|
|
- if lyrics.strip() != "<!-- PUT LYRICS HERE (and delete this entire line) -->":
|
|
- lyrics = misc.unescape_html(lyrics)
|
|
+ # To avoid problems with mixed escaped/unescaped characters unescape before extracting lyrics (fixes bug #631375)
|
|
+ content = misc.unescape_html(content)
|
|
+ lyrics = content.split("<lyrics>")[1].split("</lyrics>")[0]
|
|
+ if lyrics.strip() != "<!-- PUT LYRICS HERE (and delete this entire line) -->":
|
|
lyrics = misc.wiki_to_html(lyrics)
|
|
lyrics = lyrics.decode("utf-8")
|
|
# Save lyrics to file:
|