Created
September 16, 2013 00:37
-
-
Save np1/6575561 to your computer and use it in GitHub Desktop.
Play (almost) any song with 2 lines of python code (requires mplayer)
This file contains 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 urllib2 as u, sys as s, json as j, subprocess as p | |
p.call(["mplayer", u.urlopen(j.loads(u.urlopen("http://ex.fm/api/v3/song/search/%s" % "+".join(s.argv[1:])).read())['songs'][0]['url']).geturl().split("#")[0]]) | |
# usage: | |
# python playsong.py {artist and/or song name} | |
# | |
# eg: | |
# | |
# python playsong.py rolling stones paint it black | |
# or | |
# python playsong.py daft punk get lucky |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment