#NEWLINE# def query_artist( self , artist ) : #NEWLINE# #INDENT# 'Query for artist data.' #NEWLINE# result = self . _request_json ( 'http://developer.echonest.com/api/v4/artist/search' , [ ( 'api_key' , 'ZS0LNJH7V6ML8AHW3' ) , ( 'format' , 'json' ) , ( 'results' , 1 ) , ( 'bucket' , 'terms' ) , ( 'bucket' , 'genre' ) , ( 'name' , artist ) ] ) #NEWLINE# if ( not result [ 'response' ] [ 'artists' ] ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# result = result [ 'response' ] [ 'artists' ] [ 0 ] #NEWLINE# terms = { tag [ 'name' ] : ( float ( ( tag [ 'weight' ] + tag [ 'frequency' ] ) ) * 0.5 ) for tag in result [ 'terms' ] } #NEWLINE# genres = { tag [ 'name' ] : 0 for tag in result [ 'genres' ] } #NEWLINE# return [ { #NEWLINE# #INDENT# 'tags' : ( terms or genres ) , #NEWLINE# #UNINDENT# } ]