A2K avatar 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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.