def results(self, query): param_string = '' params = {} params['filter']="streamable" params['q'] = '"'+query['artist']+' '+query['track']+'"'; param_string = urllib.urlencode(params) url = 'http://soundcloud.com/api/tracks.json?'+param_string c=urllib2.urlopen(url) contents = c.read() print url print contents try: data = json.read(contents) except ValueError: return [] if len(data) < 1: return [] i =0 song = {}; #song['artist'] = #song['album'] = songObject['album']['title'] song['track'] = data[i]['title'] song['source'] = 'Sound Cloud' song['score'] = 1.00; song['url'] = data[i]['stream_url'] song['duration']= data[i]['duration'] #song['download_url'] = data[i]['download_url'] return [song];
def results(self, query): param_string = '' params = {} params['filter'] = "streamable" params['q'] = '"' + query['artist'] + ' ' + query['track'] + '"' param_string = urllib.urlencode(params) url = 'http://soundcloud.com/api/tracks.json?' + param_string c = urllib2.urlopen(url) contents = c.read() print url print contents try: data = json.read(contents) except ValueError: return [] if len(data) < 1: return [] i = 0 song = {} #song['artist'] = #song['album'] = songObject['album']['title'] song['track'] = data[i]['title'] song['source'] = 'Sound Cloud' song['score'] = 1.00 song['url'] = data[i]['stream_url'] song['duration'] = data[i]['duration'] #song['download_url'] = data[i]['download_url'] return [song]
def loadUserData(self, fileName): #ファイルを開いて、データを読み込んで変換する #データ形式は(user,password) #try file = open(fileName,'r') a = simplejson.read(file.read()) file.close() return a
def __doRequest(self, service, method, params=None): param_string = "" if params != None: param_string = urllib.urlencode(params) url = self.gateway_url + service + "/" + method + ".json?" + param_string c = urllib2.urlopen(url) contents = c.read() return json.read(contents)
def __doRequest(self, service, method, params=None): param_string = '' if params != None: param_string = urllib.urlencode(params) url = self.gateway_url + service + '/' + method + '.json?' + param_string c = urllib2.urlopen(url) contents = c.read() return json.read(contents)
def loadUserData(fileName): #ファイルを開いて、データを読み込んで変換する file = open(fileName,'r') a = json.read(file.read()) file.close() return a