Skip to content

Instantly share code, notes, and snippets.

@portothree
Created May 28, 2019 02:38
Show Gist options
  • Save portothree/ca8c3c44bccd9b57fac8cb26ef88f61a to your computer and use it in GitHub Desktop.
Save portothree/ca8c3c44bccd9b57fac8cb26ef88f61a to your computer and use it in GitHub Desktop.
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