Thread: Native SoundKloud
View Single Post
Old 12-06-2012, 07:47 PM   #63
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 711
Karma: 2290994
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
Quote:
Originally Posted by twobob View Post
evidently they were...
I can't beleive! Are you sure? But why? And why to raise barriers? Maybe they are like good guardian angels?

Here is my variant of code:
Spoiler:
Code:
#!/usr/bin/env python

# -*- encoding: utf-8 -*-

from subprocess import call
import soundcloud

client = soundcloud.Client(client_id='FILL_ME,
                           client_secret='FILL_ME_TOO')

query = raw_input("What do you want to search for?  ")
tracks = client.get('/tracks', q=query, limit=10, filter="streamable")

for idx, track in enumerate(tracks, start=1):
    print(u'[{0}] Title: {1}'.format(idx, track.title))
    print(u' ID: {0}'.format(track.id))
track_idx = int(input("Which track would you like to play?")) - 1

track = client.get('/tracks/{0}'.format(tracks[track_idx].id))
print("Artist: {0}".format(track.user.get(u'username')))
print("Duration (in milliseconds): {0}".format(track.duration))

stream_url = client.get(track.stream_url, allow_redirects=False).location
call(["mplayer", "{0}".format(stream_url)])
eureka is offline   Reply With Quote