Ejemplo n.º 1
0
def artist_tracks_info(artist):
    if artist not in artists:
        raise NotFound()

    artist__tracks_info_spotify = send_request(
        "http://127.0.0.1:5001/spotify/artist/" +
        artists[artist]['spotify_id'] + "/tracks",
        format=None)
    r = {'tracks': []}

    for track in artist__tracks_info_spotify['tracks']:
        track_audio_analysis_spotify = send_request(
            "http://127.0.0.1:5001/spotify/track/" + track['id'] +
            "/audio-analysis",
            format=None)
        artist__lyrics_info_musixmatch = send_request(
            "http://127.0.0.1:5002/musixmatch/lyric/" + artist + "/" +
            track['name'],
            format=None)
        lyrics = ''
        if (artist__lyrics_info_musixmatch['message']['header']['status_code']
                != 404):
            lyrics = artist__lyrics_info_musixmatch['message']['body'][
                'lyrics']['lyrics_body']
        if lyrics:
            r['tracks'].append({
                'name': track['name'],
                'lyrics': lyrics,
                'audio-analysis': track_audio_analysis_spotify
            })
    return jsonify(r)
Ejemplo n.º 2
0
def artist_info(artist):
    if artist not in artists:
        raise NotFound(
            'This artist does not exist ! You can check the available artists at address /artists/'
        )
    return send_request("http://127.0.0.1:5001/spotify/artist/" +
                        artists[artist]['spotify_id'])
Ejemplo n.º 3
0
 def generate_access_token(self):
     '''    
     Generate an access token after a client creditentails authentication   
     '''
     data = {'grant_type' : GRANT_TYPE}  
     response = send_request(SPOTIFY_TOKEN_URL, data=data, auth = (self.client_id, self.client_secret), type='post', format=None)           
     self.acces_token = response['access_token']
     self.headers = {'Authorization': 'Bearer ' + self.acces_token}
Ejemplo n.º 4
0
 def get_artist_info(self, id):
     return send_request(SPOTIFY_GET_ARTIST + id, headers = self.headers)
Ejemplo n.º 5
0
 def get_audio_analysis(self, id):
     return send_request(SPOTIFY_GET_AUDIO_ANALYSIS_TRACK + id, headers = self.headers)
Ejemplo n.º 6
0
 def get_artist_tracks_info(self, id):
     return send_request(SPOTIFY_GET_ARTIST_TOP_TRACKS.format(id), headers = self.headers)
Ejemplo n.º 7
0
 def get_lyrics(self, artist, track):
     params = { 'apikey' : self.api_key, 'q_track' : track, 'q_artist' : artist}       
     return send_request(MUSIXMATCH_SEARCH_TRACK_URL, params=params)