I am creating an app that will need to access a very large dataset. The dataset will need to have data about music, films, locations, etc.
I have started with populating my database with music data and I found the spotipy API. Does anyone know if the spotipy API would be a good method for populating my dataset with music? I have experimented with it and found that the search method has a limit of 50 results, so that does not help my situation.
I found in the examples in their documentation you can do this to retrieve all albums of a specific artist:
birdy_uri = 'spotify:artist:2WX2uTcsvV5OnS0inACecP'
spotify = spotipy.Spotify(client_credentials_manager=CLIENT_ID)
results = sp.artist_albums(birdy_uri, album_type='album')
albums = results['items']
while results['next']:
results = spotify.next(results)
albums.extend(results['items'])
for album in albums:
print(album['name'])
I got this working and it prints this:
Young Heart
Beautiful Lies
Beautiful Lies
Beautiful Lies (Deluxe)
Beautiful Lies (Deluxe)
Fire Within
Fire Within
Fire Within (Deluxe)
Fire Within (Deluxe)
Fire Within (Deluxe)
Live in London
Birdy
Birdy
Birdy
Birdy
Birdy (Deluxe Version)
But when I try the same thing with a different artist, for example led zeppelin like this:
ledZep_uri = "spotify:artist:36QJpDe2go2KgaRleHCDTp"
spotify = spotipy.Spotify(client_credentials_manager=CLIENT_ID)
results = sp.artist_albums(ledZep_uri , album_type='album')
albums = results['items']
while results['next']:
results = spotify.next(results)
albums.extend(results['items'])
for album in albums:
print(album['name'])
I get a traceback error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-14-451d92017532> in <module>
6
7 while results['next']:
----> 8 results = spotify.next(results)
9 albums.extend(results['items'])
10
3 frames
/usr/local/lib/python3.9/dist-packages/spotipy/client.py in _auth_headers(self)
234 return {}
235 try:
--> 236 token = self.auth_manager.get_access_token(as_dict=False)
237 except TypeError:
238 token = self.auth_manager.get_access_token()
AttributeError: 'str' object has no attribute 'get_access_token'
I understand it has a problem with my access token but I don't understand why it didn't throw error with the original birdy example. I would imagine if there's a problem with my access token, I wouldn't have been able to do either.
Anyways, I am curious if spotipy would work for populating my database? If anyone has experience with spotipy, or knows a different method of populating my database (maybe web scraping?) I would really appreciate some insight here.
Thanks