Commits

A2K committed a53cdec

Lyrics are working again

Comments (0)

Files changed (1)

         url = 'http://lyricwiki.org/api.php'
         vars = {}
         vars['func'] = 'getSong'
-        vars['artist'] =  unicode(track.artist).encode('utf-8')#track.artist
-        vars['song'] =  unicode(track.title).encode('utf-8')#track.title
+        vars['artist'] =  unicode(track.artist).encode('utf-8')
+        vars['song'] =  unicode(track.title).encode('utf-8')
         vars['fmt'] = 'text'
         url = url + '?' + urllib.urlencode(vars)
         try:
-            self.lyrics = unicode(urllib.urlopen(url).read(),'utf8')
+            self.lyrics = unicode(urllib.urlopen(url).read(), 'utf-8')
         except:
             return self.tr("Could not receive track lyrics :(")
+        f = open('l.html', 'w')
+        f.write(self.lyrics)
+        f.close()
 
-        if 'The lyrics for this song can be found at the following URL:' in self.lyrics:
-            text = self.lyrics[self.lyrics.index('ollowing URL:')+14:]
-            url = text[:text.index('\n')]
-        else:
-            return self.tr("Could not receive track lyrics :(")
-
+        url = self.lyrics
+        print url
         page = urllib.urlopen(url).read()
-        res = re.findall('lyricbox\' >(.*)\n', page)
+        res = re.findall('lyricbox\' >(.*)<!--', page)
         if len(res) == 0: return self.tr("Could not receive track lyrics :(")
         else:
             self.lyrics = unicode(res[0].replace('<br />', '\n'), 'utf-8', 'replace')
-            #self.lyrics = self.lyrics.decode('cp1251')
 
         return self.lyrics