Exemplo n.º 1
0
for song_id in song_ids:
    SpotifyClient.get_audio_features(sp, song_id, danceability, energy,
                                     valence, tempo)
print("Obtained audio features of your songs successfully.")

# next, to do the data analysis with DataFrames, we need to convert our separate lists into a list of lists:
audio_features = []
audio_features.append(danceability)
audio_features.append(energy)
audio_features.append(valence)
audio_features.append(tempo)
audio_features.append(song_ids)
audio_features.append(dates_added)

# convert the audio_features list into a csv file
df = DataAnalysis.dataframe_conversion(pd, audio_features)
print("Created file 'audio_features.csv' successfully.")

# look at user's 50 most recently played songs
SpotifyClient.recently_played(sp, song_ids, in_liked_songs,
                              recently_played_songs)
print("Obtained your 50 most recently played songs successfully.")

# now lets get the audio features for our recently played songs:
for recent_song in recently_played_songs:
    SpotifyClient.get_audio_features(sp, recent_song, danceability_recent,
                                     energy_recent, valence_recent,
                                     tempo_recent)
print(
    "Obtained the audio features of your recently played songs successfully.")