Created
October 24, 2011 17:06
-
-
Save shadyabhi/1309527 to your computer and use it in GitHub Desktop.
For theone
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
| #!/usr/bin/python2 | |
| import os | |
| import pylast | |
| MPD_LIBRARY_LOCATION = "/var/lib/mpd/music/" | |
| API_KEY = "your api key" | |
| API_SECRET = "your secret" | |
| username = "shadyabhi" | |
| #Enter the hash directly. | |
| password_hash = pylast.md5("mysupersecret") | |
| print "Deleting the song" | |
| mpcProcess = os.popen("mpc -f %file%") | |
| try: | |
| # [:-1] to delete the trailing newline | |
| os.remove(MPD_LIBRARY_LOCATION+mpcProcess.readline()[:-1]) | |
| #Deleting song from playlist | |
| os.popen("mpc del $(mpc -f %position% | head -n 1)") | |
| except: | |
| print "Something really went wrong" |
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
| #!/usr/bin/python2 | |
| import os | |
| import pylast | |
| MPD_LIBRARY_LOCATION = "/var/lib/mpd/music/" | |
| API_KEY = "your api key" | |
| API_SECRET = "your secret" | |
| username = "shadyabhi" | |
| #Enter the hash directly. | |
| password_hash = pylast.md5("mysupersecret") | |
| print "Loving track on last.fm" | |
| network = pylast.LastFMNetwork(api_key = API_KEY, api_secret = API_SECRET, username = username, password_hash = password_hash) | |
| artist = os.popen('mpc -f "%artist%" | head -n 1').read() | |
| title = os.popen('mpc -f "%title%" | head -n 1').read() | |
| track = network.get_track(artist, title) | |
| track.love() | |
| #Confirming the user that the track has been loved by retrieving the last loved track from last.fm | |
| last_loved_track = str(network.get_user(username).get_loved_tracks(limit=1)[0][0]) | |
| print "Last loved track confirmation" + last_loved_track + " is your last loved track" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool piece of code for sure!