Showing
1 changed file
with
28 additions
and
0 deletions
spotify test.py
0 → 100644
| 1 | +#!/usr/bin/env python | ||
| 2 | +# coding: utf-8 | ||
| 3 | + | ||
| 4 | +# In[5]: | ||
| 5 | + | ||
| 6 | + | ||
| 7 | +from spotipy.oauth2 import SpotifyClientCredentials | ||
| 8 | +import spotipy | ||
| 9 | +import pprint | ||
| 10 | + | ||
| 11 | + | ||
| 12 | +client_id = "faf7865d62b5488da2f6bca05e63a075" | ||
| 13 | +client_secret = "b888f07e8986499aa70950b0235d81eb" | ||
| 14 | + | ||
| 15 | +lz_uri = 'spotify:artist:13ubrt8QOOCPljQ2FL1Kca' # ASAP Rocky | ||
| 16 | + | ||
| 17 | +client_credentials_manager = SpotifyClientCredentials(client_id=client_id, client_secret=client_secret) | ||
| 18 | +sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager) | ||
| 19 | + | ||
| 20 | +results = sp.artist_top_tracks(lz_uri) | ||
| 21 | + | ||
| 22 | +# get top 10 tracks | ||
| 23 | +for track in results['tracks'][:10]: | ||
| 24 | + print('track : ' + track['name']) | ||
| 25 | + print('audio : ' + track['preview_url']) | ||
| 26 | + print('cover art: ' + track['album']['images'][0]['url']) | ||
| 27 | + print() | ||
| 28 | + |
-
Please register or login to post a comment