Пример #1
0
def get_similar_artists(method, dict ):
    last_request = LastFM()
    artist_names=[]
    #somehow the returned similar artists for this doesn't contain mbid.
    #artist_mbid=[]
    #find the key          
    args = {
        "method":	method,
        "limit":	20
    }
    
    for key in dict.keys():
      args[key] = dict[key]
    
    
    response_data = defaultdict(lambda:None,last_request.send_request( args ))


    #print "~~~~~~~~~~~~~~" + str( args["method"] ) + "~~~~~~~~~~~~~~"
    #print response_data
    #print "------------------"
    #Get the first artist from the JSON response and print their name
    if response_data["similarartists"]:
        for art in response_data["similarartists"]["artist"]:
            #print art["name"]
            artist_names.append(art["name"])
    else:
        print "key error on response data: no similar artist for ", dict['artist']

    #artist_mbid.append(art["mbid"])
    return artist_names
Пример #2
0
def get_frds(method, dict ):
    last_request = LastFM()
    friends=[]
    #find the key          
    args = {
        "method":	method,
    }
    for key in dict.keys():
      args[key] = dict[key]
    response_data = last_request.send_request( args )
    for user in response_data["friends"]["user"]:
        #print user["name"]
        friends.append(user['name'])
    return friends
Пример #3
0
def get_user_top_artists(method, dict ):
    last_request = LastFM()
    artist_names=[]
    artist_mbid=[]
    #find the key          
    args = {
        "method":	method,
        #"limit":	10
    }
    for key in dict.keys():
      args[key] = dict[key]

    response_data = last_request.send_request( args )


    #print "~~~~~~~~~~~~~~" + str( args["method"] ) + "~~~~~~~~~~~~~~"
    #print response_data
    #print "------------------"
    #Get the first artist from the JSON response and print their name
    for art in response_data["topartists"]["artist"]:
        artist_names.append(art["name"])
        artist_mbid.append(art["mbid"])
    return artist_names,artist_mbid