spotipy/examples/my_top_artists.py
2020-06-14 18:01:14 +01:00

18 lines
486 B
Python

# Shows the top artists for a user
import spotipy
from spotipy.oauth2 import SpotifyOAuth
scope = 'user-top-read'
ranges = ['short_term', 'medium_term', 'long_term']
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))
for sp_range in ['short_term', 'medium_term', 'long_term']:
print("range:", sp_range)
results = sp.current_user_top_artists(time_range=sp_range, limit=50)
for i, item in enumerate(results['items']):
print(i, item['name'])
print()