Last active 1440822420

Opens a webbrowser with the azlyrics page for the now-playing song

Revision 6be7726ba82f03beb4980d42ac59b36db07c786a

lfm_getlyrics.py Raw
1import pylast, webbrowser, urllib, re
2
3key = "9eefecb15b3891540eb66748f37bf539"
4use = "blha303"
5
6def strip(string):
7 return re.sub(r'[\W_]+', '', string.replace("&", " and "))
8
9lfm = pylast.LastFMNetwork(api_key=key, username=use)
10track = lfm.get_user(use).get_now_playing()
11if track:
12 webbrowser.open("http://www.azlyrics.com/lyrics/{}/{}.html".format(strip(str(track.artist).lower()),
13 strip(str(track.title).lower())
14 ))
15else:
16 webbrowser.open("data:text/html,You don't have a track playing according to last.fm.")