2008-06-19 09:47:02 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vi:si:et:sw=4:sts=4:ts=4
|
2009-10-12 15:18:59 +00:00
|
|
|
from oxlib.cache import readUrl
|
|
|
|
from oxlib.html import decodeHtml
|
|
|
|
from oxlib.text import findRe
|
2008-05-08 07:17:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
def getLyrics(title, artist):
|
2009-10-12 11:47:43 +00:00
|
|
|
html = readUrl('http://lyricsfly.com/api/')
|
2008-05-08 07:17:04 +00:00
|
|
|
key = findRe(html, '<font color=green><b>(.*?)</b></font>')
|
|
|
|
url = 'http://lyricsfly.com/api/api.php?i=%s&a=%s&t=%s' % (key, artist, title)
|
2009-10-12 11:47:43 +00:00
|
|
|
xml = readUrl(url)
|
2008-05-08 07:17:04 +00:00
|
|
|
lyrics = findRe(xml, '<tx>(.*?)\[br\] Lyrics [a-z]* by lyricsfly.com')
|
|
|
|
lyrics = lyrics.replace('\n', '').replace('\r', '')
|
|
|
|
lyrics = lyrics.replace('[br]', '\n').strip()
|
|
|
|
lyrics.replace('\n\n\n', '\n\n')
|
|
|
|
lyrics = decodeHtml(lyrics.replace('&', '&'))
|
|
|
|
return lyrics
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2008-06-19 09:47:02 +00:00
|
|
|
print getLyrics('Election Day', 'Arcadia')
|