mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 01:03:53 +00:00
* Made cache_path and username optional * Update readme and example * Lint * Lint * Feedback / add warning
16 lines
480 B
Python
16 lines
480 B
Python
# Shows the top tracks for a user
|
|
|
|
import spotipy
|
|
from spotipy.oauth2 import SpotifyOAuth
|
|
|
|
scope = 'user-top-read'
|
|
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))
|
|
|
|
ranges = ['short_term', 'medium_term', 'long_term']
|
|
|
|
for sp_range in ranges:
|
|
print("range:", sp_range)
|
|
results = sp.current_user_top_tracks(time_range=sp_range, limit=50)
|
|
for i, item in enumerate(results['items']):
|
|
print(i, item['name'], '//', item['artists'][0]['name'])
|
|
print() |