DOsinga / deep_learning_cookbook

Deep Learning Cookbox
Apache License 2.0
689 stars 338 forks source link

15.3 Finding Playlists - StopIteration Exception raised 404 Not Found #86

Open jlousada315 opened 3 years ago

jlousada315 commented 3 years ago

Running the following code to fetch list of playlists:

while len(playlists) < 100000:
    for word, _ in word_counts.most_common():
        if not word in words_seen:
            words_seen.add(word)
            print('word>', word)
            for playlist in find_playlists(session, word):
                if playlist['id'] in playlists:
                    dupes += 1
                elif playlist['name'] and playlist['owner']:
                    playlists[playlist['id']] = {
                      'owner': playlist['owner']['id'],
                      'name': playlist['name'],
                      'id': playlist['id'],
                    }
                    count += 1
                    for token in tokenize(playlist['name'], lowercase=True):
                        word_counts[token] += 1
            break

After a while, I get the following error:

HTTP Error for GET to https://api.spotify.com/v1/search?query=a&type=playlist&market=PT&offset=1000&limit=50 returned 404 due to Not found.

Shouldn't the code skip that request whenever this happens ?