summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <wyskas@gmail.com>2009-08-22 09:38:00 +0200
committerAnton Khirnov <wyskas@gmail.com>2009-08-22 09:38:00 +0200
commit1abb1624473644fa3f7fb6963882ea4b98e1bf4d (patch)
tree894faf2c548286b38e03d0e0bcc7ec9020c91dcd
parent34fe7a8a759f8a5b43ae45af415d8664f4272be4 (diff)
Lyrics: use getArtist on lyricwiki
this fixes some issues with non-latin artist names.
-rw-r--r--nephilim/plugins/Lyrics.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/nephilim/plugins/Lyrics.py b/nephilim/plugins/Lyrics.py
index 1a88dd1..fe3e36d 100644
--- a/nephilim/plugins/Lyrics.py
+++ b/nephilim/plugins/Lyrics.py
@@ -144,9 +144,28 @@ class Lyrics(Plugin):
def fetch(self, song):
url = QtCore.QUrl('http://lyricwiki.org/api.php')
- url.setQueryItems([('func', 'getSong'), ('artist', song.artist()),
- ('song', song.title()), ('fmt', 'xml')])
+ url.setQueryItems([('func', 'getArtist'), ('artist', song.artist()),
+ ('fmt', 'xml')])
self.fetch2(song, url)
+ self.srep.finished.connect(self.__handle_artist_res)
+
+ def __handle_artist_res(self):
+ artist = None
+ xml = QtCore.QXmlStreamReader(self.srep)
+ while not xml.atEnd():
+ token = xml.readNext()
+ if token == QtCore.QXmlStreamReader.StartElement:
+ if xml.name() == 'artist':
+ artist = xml.readElementText()
+ xml.clear()
+ if not artist:
+ self.logger.error('Didn\'t find artist in %s artist search results.'%self.name)
+ return self.finish()
+
+ url = QtCore.QUrl('http://lyricwiki.org/api.php')
+ url.setQueryItems([('func', 'getSong'), ('artist', artist),
+ ('song', self.song.title()), ('fmt', 'xml')])
+ self.srep = self.nam.get(QtNetwork.QNetworkRequest(url))
self.srep.finished.connect(self.__handle_search_res)
def __handle_search_res(self):
@@ -162,7 +181,7 @@ class Lyrics(Plugin):
xml.clear()
return self.finish()
if xml.hasError():
- self.logger.error('Error parsing seach results.%s'%xml.errorString())
+ self.logger.error('Error parsing seach results: %s'%xml.errorString())
if not url:
self.logger.error('Didn\'t find the URL in Lyricwiki search results.')