Last active
August 29, 2015 14:08
-
-
Save Achifaifa/370cd2a2b82811fa67ea to your computer and use it in GitHub Desktop.
Reads author and title from input and plays a random matching song via VLC
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
#! /usr/bin/env python | |
import json,subprocess,urllib2 | |
jsonshit=json.loads(urllib2.urlopen("http://developer.echonest.com/api/v4/song/search?bucket=id:spotify&bucket=tracks&results=100&api_key=MZFEPELDSKFX4WAMA&artist=%s&title=%s"%(raw_input("group? ",),raw_input("title? ",))).read()) | |
print jsonshit["response"]["songs"][0]["artist_name"],jsonshit["response"]["songs"][0]["title"] | |
processeddata=json.loads(urllib2.urlopen("https://api.spotify.com/v1/tracks/"+jsonshit["response"]["songs"][0]["tracks"][0]["foreign_id"].split(':')[2]).read()) | |
subprocess.call(["vlc", processeddata["preview_url"]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment