Created
May 28, 2019 02:38
-
-
Save portothree/ca8c3c44bccd9b57fac8cb26ef88f61a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
import pprint | |
pp = pprint.PrettyPrinter(indent=4) | |
endpoint = 'https://api.spotify.com/v1/playlists/37i9dQZF1DZ06evO2zakRW/tracks?offset=0&limit=100' | |
headers = {'Authorization': 'Bearer '} | |
data = requests.get(endpoint, headers=headers) | |
binary = data.content | |
output = json.loads(binary) | |
trackInfo = output['items'] | |
fullPlaylist = [] | |
for track in trackInfo: | |
artistsNames = track['track']['artists'] | |
trackName = track['track']['name'] | |
artistss = [] | |
for artists in artistsNames: | |
artistss.append(artists['name']) | |
musicTitle = str(artistss) + ' ' +str(trackName) | |
fullPlaylist.append(musicTitle) | |
pp.pprint(fullPlaylist) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment