spotipy/examples/show_artist_tracks.py

17 lines
448 B
Python

# shows tracks for the given artist
# usage: python tracks.py [artist name]
from spotipy.oauth2 import SpotifyClientCredentials
import spotipy
import sys
auth_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(auth_manager=auth_manager)
if len(sys.argv) > 1:
artist_name = ' '.join(sys.argv[1:])
results = sp.search(q=artist_name, limit=20)
for i, t in enumerate(results['tracks']['items']):
print(' ', i, t['name'])