PHP Code:
#!python
# encoding: utf-8
# encoding declaration as specified here http://www.python.org/dev/peps/pep-0263/
import soundcloud
import subprocess
import sys
import os
from time import sleep
# create client object with app and user credentials
client = soundcloud.Client(client_id='8c882aabb8d9314021b236a291cd874c',
client_secret='yada')
try:
fullsearch = ""
for arg in sys.argv:
if not sys.argv[0] in arg:
fullsearch = fullsearch + " " + arg
tracks = client.get('/tracks', q = fullsearch, limit=15,filter="streamable")
i = 1
temp = {} #initalize dictionary
for track in tracks:
titleage = track.title.encode('utf-8')
tempy = titleage+'\n'
temp.update({i:track.id}) #set dictionary key
i=i + 1
#return full list of links
for listing in range(1,i):
queryb = listing
trackid = temp.get(queryb) #retrieve key
track = client.get('/tracks/{0}'.format(trackid))
#tempart = "Artist: {0}\nDuration (in secs): {1}".format(track.user.get(u'username'), (track.duration/1000))
temptitle= track.title.encode('utf-8')
stream_url = client.get(track.stream_url, allow_redirects=False)
# ec is giving us 403's atm
if "ec-media" in stream_url.location:
print "{0}¬{1} ".format(temptitle,stream_url.location)
# "Track Loading complete"
except:
print "STREAM-DOWN! Unexpected Soundcloud error:", sys.exc_info()[0],"¬./fail.wav"
an example call
PHP Code:
static void playmplayer(GtkWidget *widget, gpointer data) {
char holder[1024] = "killall -9 mplayer & ./mplayer -softvol -softvol-max 200 -af volume=5 ";
char *formatted = data;
strcat(holder, formatted);
system(holder);
// g_print("debug=%s", holder);
}
(and yes I should check the strlen and free the space, this is an example)