Quote:
tracks = client2.get('/tracks', q = sys.argv[1], limit=10, filter="streamable")
i = 1
temp = {} #initalize dictionary
for track in tracks:
track.id, i)
temp.update({i:track.id}) #set dictionary key
i=i + 1
queryb = i-1
trackid = temp.get(queryb) #retrieve key
track = client2.get('/tracks/{0}'.format(trackid))
stream_url = client2.get(track.stream_url, allow_redirects=False)
subprocess.Popen(['mplayer','-identify',"{0}".format(stream_url.location)])
|
gives fairly solid results (95% of the time) as you can see I just use q = sys.argv[1] to get the search term in at runtime