예제 #1
0
        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];
예제 #2
0
    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]
예제 #3
0
	def loadUserData(self, fileName):
		#ファイルを開いて、データを読み込んで変換する
		#データ形式は(user,password)
		#try
		file = open(fileName,'r')
		a = simplejson.read(file.read())
		file.close()
		return a
예제 #4
0
파일: amieapi.py 프로젝트: RJ/playdar-core
    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)
예제 #5
0
    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)
예제 #6
0
def loadUserData(fileName):
    #ファイルを開いて、データを読み込んで変換する
    file = open(fileName,'r')
    a = json.read(file.read())
    file.close()
    return a