Thread: SoundKloud
View Single Post
Old 01-01-2013, 10:07 AM   #157
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
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[0in arg
            
fullsearch fullsearch " " arg  
    tracks 
client.get('/tracks'fullsearchlimit=15,filter="streamable")
    
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=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))
        
temptitletrack.title.encode('utf-8')
        
stream_url client.get(track.stream_urlallow_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 *widgetgpointer data) {
    
char holder[1024] = "killall -9 mplayer & ./mplayer  -softvol -softvol-max 200 -af volume=5 ";
    
char *formatted data;
    
strcat(holderformatted);
    
system(holder);
//    g_print("debug=%s", holder);

(and yes I should check the strlen and free the space, this is an example)

Last edited by twobob; 01-01-2013 at 11:21 PM. Reason: fixed spaces issue
twobob is offline   Reply With Quote