Hello! I'm using Spotipy to try to get some data on a specific artist. I'm following the instructions on this link (https://medium.com/@RareLoot/extracting-...8bc92a4330), but can't seem to get past getting the album names and URIs. Once I get to the part that says "Grab the songs from each album", I don't really understand why the errors occur. Fairly new to Python, so this might be a stupid mistake I'm making.
This is what I have so far:
This is what I have so far:
>>> import spotipy >>> from spotipy.oauth2 import SpotifyClientCredentials >>> >>> client_id = "......." >>> client_secret = "......" >>> >>> client_credentials_manager = SpotifyClientCredentials(client_id=client_id, client_secret=client_secret) >>> sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager) >>> >>> name = "National,The" >>> >>> result = sp.search(name) >>> result['tracks']['items'][0]['artists'] [{'external_urls': {'spotify': 'https://open.spotify.com/artist/2cCUtGK9sDU2EoElnk0GNB'}, 'href': 'https://api.spotify.com/v1/artists/2cCUtGK9sDU2EoElnk0GNB', 'id': '2cCUtGK9sDU2EoElnk0GNB', 'name': 'The National', 'type': 'artist', 'uri': 'spotify:artist:2cCUtGK9sDU2EoElnk0GNB'}] >>> >>> artist_uri = result['tracks']['items'][0]['artists'][0]['uri'] >>> sp_albums = sp.artist_albums(artist_uri, album_type='album') >>> >>> album_names = [] >>> album_uris = [] >>> for i in range(len(sp_albums['items'])): album_names.append(sp_albums['items'][i]['name']) album_uris.append(sp_albums['items'][i]['uri']) >>> album_names ['Boxer Live in Brussels', 'Sleep Well Beast', 'Trouble Will Find Me', 'High Violet (Expanded Edition)', 'High Violet', 'High Violet', 'High Violet', 'Boxer', 'Boxer', 'Alligator', 'Cherry Tree', 'Cherry Tree', 'Cherry Tree', 'Sad Songs for Dirty Lovers', 'Sad Songs for Dirty Lovers', 'Sad Songs for Dirty Lovers', 'The National', 'The National', 'The National'] >>> album_uris ['spotify:album:44QWVzSZGGPFyJkTsfjzWA', 'spotify:album:6zG9PHw8dlMLIyRE9TEGGk', 'spotify:album:2JhR4tjuc3MIKa8v2JaKze', 'spotify:album:36VJqCEgUg3nj0Eyxtc1av', 'spotify:album:59gXPxZ8CwFaeknPxtxXHZ', 'spotify:album:722zk0GySQPLbB0p2Rxxd6', 'spotify:album:6k54ZuG2Z49HQRbJdO65b5', 'spotify:album:3hvjTC9OSOrf6SFQmfqLNX', 'spotify:album:2pG7mDkQhia2OyGE6fbkmJ', 'spotify:album:4rwdrCccOqPlRjFZq0H1M1', 'spotify:album:2kDz8nWLPl3jmrO3xeFUXL', 'spotify:album:4ZjXzOFdtpcaCZdIxsLJky', 'spotify:album:12G4rtxl2ZFl1BVsKUomB9', 'spotify:album:0HIkf7pfkZ3IGmEYgcCXnO', 'spotify:album:7C1aHOdnNjVn6X09RRHgTa', 'spotify:album:5MXOch8nt9sOQ5mvUtCWB6', 'spotify:album:7lyQDI1JwwvqHZPfaYhOLA', 'spotify:album:4mr0nXLuoWv0AleieUrRkR', 'spotify:album:4Y9k8jM1INrE8iB6upO0Iq']