Here is the printed dic
:
{'album': {'album_type': 'single',
'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/6BrvowZBreEkXzJQMpL174'},
'href': 'https://api.spotify.com/v1/artists/6BrvowZBreEkXzJQMpL174',
'id': '6BrvowZBreEkXzJQMpL174',
'name': 'Hardwell',
'type': 'artist',
'uri': 'spotify:artist:6BrvowZBreEkXzJQMpL174'}],
'available_markets': ['AD',
'AE',
'AL',
'AR',
'AT',
'AU',
'BA',
'BE',
'BG',
'BH',
'BO',
'BR',
'BY',
'CA',
'CH',
'CL',
'CO',
'CR',
'CY',
'CZ',
'DE',
'DK',
'DO',
'DZ',
'EC',
'EE',
'EG',
'ES',
'FI',
'FR',
'GB',
'GR',
'GT',
'HK',
'HN',
'HR',
'HU',
'ID',
'IE',
'IL',
'IN',
'IS',
'JO',
'JP',
'KW',
'KZ',
'LB',
'LI',
'LT',
'LU',
'LV',
'MA',
'MC',
'MD',
'ME',
'MK',
'MT',
'MX',
'MY',
'NI',
'NL',
'NO',
'NZ',
'OM',
'PA',
'PE',
'PH',
'PL',
'PS',
'PT',
'PY',
'QA',
'RO',
'RS',
'RU',
'SA',
'SE',
'SG',
'SI',
'SK',
'SV',
'TN',
'TR',
'TW',
'UA',
'US',
'UY',
'VN',
'XK',
'ZA'],
'external_urls': {'spotify': 'https://open.spotify.com/album/14SHciJYQ4DnKzprcUzE1z'},
'href': 'https://api.spotify.com/v1/albums/14SHciJYQ4DnKzprcUzE1z',
'id': '14SHciJYQ4DnKzprcUzE1z',
'images': [{'height': 640,
'url': 'https://i.scdn.co/image/ab67616d0000b27397e4c7870cffac76662a92fd',
'width': 640},
{'height': 300,
'url': 'https://i.scdn.co/image/ab67616d00001e0297e4c7870cffac76662a92fd',
'width': 300},
{'height': 64,
'url': 'https://i.scdn.co/image/ab67616d0000485197e4c7870cffac76662a92fd',
'width': 64}],
'name': 'Spaceman',
'release_date': '2012-02-06',
'release_date_precision': 'day',
'total_tracks': 1,
'type': 'album',
'uri': 'spotify:album:14SHciJYQ4DnKzprcUzE1z'},
'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/6BrvowZBreEkXzJQMpL174'},
'href': 'https://api.spotify.com/v1/artists/6BrvowZBreEkXzJQMpL174',
'id': '6BrvowZBreEkXzJQMpL174',
'name': 'Hardwell',
'type': 'artist',
'uri': 'spotify:artist:6BrvowZBreEkXzJQMpL174'}],
'available_markets': [],
'disc_number': 1,
'duration_ms': 379260,
'explicit': False,
'external_ids': {'isrc': 'NLCY31100367'},
'external_urls': {'spotify': 'https://open.spotify.com/track/1Ca2ELRlvACAeI7xz9c9jR'},
'href': 'https://api.spotify.com/v1/tracks/1Ca2ELRlvACAeI7xz9c9jR',
'id': '1Ca2ELRlvACAeI7xz9c9jR',
'is_local': False,
'is_playable': True,
'name': 'Spaceman',
'popularity': 53,
'preview_url': 'https://p.scdn.co/mp3-preview/3e53578aa98127b4157b154a9714049d778393c5?cid=1d342fbcf9fd42a1b65ba5e7e369b991',
'track_number': 1,
'type': 'track',
'uri': 'spotify:track:1Ca2ELRlvACAeI7xz9c9jR'}
I need to pull this:
'images': [{'height': 640,
'url': 'https://i.scdn.co/image/ab67616d0000b27397e4c7870cffac76662a92fd',
'width': 640},
{'height': 300,
'url': 'https://i.scdn.co/image/ab67616d00001e0297e4c7870cffac76662a92fd',
'width': 300},
{'height': 64,
'url': 'https://i.scdn.co/image/ab67616d0000485197e4c7870cffac76662a92fd',
'width': 64}]
This seems easy enough but when I output dic.keys()
I get this:
dict_keys(['album', 'artists', 'available_markets', 'disc_number', 'duration_ms', 'explicit', 'external_ids', 'external_urls', 'href', 'id', 'is_local', 'is_playable', 'name', 'popularity', 'preview_url', 'track_number', 'type', 'uri'])
Is this an issue with Spotipy? Any help would be much appreciated.
There is nothing with Spotify API, 'images' key is in 'album'.
Try this:
images = dic['album']['images']