mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 09:13:53 +00:00
* Add python_requires to help pip * Update supported versions in tox.ini * Upgrade Python syntax with pyupgrade --py37-plus * Bump GitHub Actions * Add Python 3.11 and 3.12 to CI * Remove six dependency * Remove redundant dependencies * Remove redudant Python 3.5 code * Drop support for EOL Python 3.7 * Upgrade Python syntax with pyupgrade --py38-plus * Update CHANGELOG * More f-strings --------- Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
25 lines
740 B
Python
25 lines
740 B
Python
# shows related artists for the given seed artist
|
|
|
|
from spotipy.oauth2 import SpotifyClientCredentials
|
|
import spotipy
|
|
import sys
|
|
|
|
if len(sys.argv) > 1:
|
|
artist_name = sys.argv[1]
|
|
else:
|
|
artist_name = 'weezer'
|
|
|
|
client_credentials_manager = SpotifyClientCredentials()
|
|
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
|
result = sp.search(q='artist:' + artist_name, type='artist')
|
|
try:
|
|
name = result['artists']['items'][0]['name']
|
|
uri = result['artists']['items'][0]['uri']
|
|
|
|
related = sp.artist_related_artists(uri)
|
|
print('Related artists for', name)
|
|
for artist in related['artists']:
|
|
print(' ', artist['name'])
|
|
except BaseException:
|
|
print("usage show_related.py [artist-name]")
|