adding lyricsfly module
This commit is contained in:
parent
209e754d35
commit
791f19a4e1
1 changed files with 21 additions and 0 deletions
21
ox/lyricsfly.py
Normal file
21
ox/lyricsfly.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
from oxutils.cache import getUrl
|
||||||
|
from oxutils.html import decodeHtml
|
||||||
|
from oxutils.text import findRe
|
||||||
|
|
||||||
|
|
||||||
|
def getLyrics(title, artist):
|
||||||
|
html = getUrl('http://lyricsfly.com/api/')
|
||||||
|
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)
|
||||||
|
xml = getUrl(url)
|
||||||
|
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__':
|
||||||
|
print getLyrics('Election Day', 'Arcadia')
|
||||||
|
print getLyrics('Kool Thing', 'Sonic Youth')
|
||||||
|
getLyrics('Material Girl', 'Madonna')
|
Loading…
Reference in a new issue