Last active
August 29, 2015 14:27
-
-
Save blha303/37f5a628da1b2ef36bb2 to your computer and use it in GitHub Desktop.
Opens a webbrowser with the azlyrics page for the now-playing song
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pylast, webbrowser, re, sys | |
| key = "9eefecb15b3891540eb66748f37bf539" | |
| use = sys.argv[1] if len(sys.argv) > 1 else "blha303" | |
| def strip(string): | |
| return re.sub(r'[\W_]+', '', string.replace("&", " and ")) | |
| lfm = pylast.LastFMNetwork(api_key=key, username=use) | |
| track = lfm.get_user(use).get_now_playing() | |
| if track: | |
| webbrowser.open("http://www.azlyrics.com/lyrics/{}/{}.html".format(strip(str(track.artist).lower()), | |
| strip(str(track.title).lower()) | |
| )) | |
| else: | |
| webbrowser.open("data:text/html,You don't have a track playing according to last.fm.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment