Skip to content

Commit

Permalink
Handling more illegal tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
John42506176Linux committed Apr 9, 2021
1 parent e4765bf commit cb4d493
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions spotify_data/spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def get_all_songs_table_info(access_token,market_id):
resp =requests.get(req_endpoint, headers=auth_header)
resp.raise_for_status()
for track in resp.json()['items']:
if track: # For Illegal tracks
if track['track']: # For Illegal tracks
songs.add(track['track']['id'])
for artist in track['track']['artists']:
artists.add((artist['id'],artist['name']))
Expand All @@ -202,20 +202,21 @@ def get_all_songs_table_info(access_token,market_id):
try:
resp = get_recent_tracks(access_token)
for track in resp["items"]:
songs.add(track['track']['id'])
if track['track']['id'] not in songs_playlists:
for artist in track['track']['artists']:
artists.add((artist['id'],artist['name']))
if artist['id'] not in artist_songs:
artist_songs[artist['id']] = list()
artist_songs[artist['id']].append(track['track']['id'])
recently_played_songs.append(track['track']['id'])
extra_info[track['track']['id']] = {
'name' : track['track']['name'],
'is_explicit' : track['track']['explicit'],
'popularity' : track['track']['popularity'],
'release_date' : track['track']['album']['release_date']
}
if track['track']: # For Illegal tracks
songs.add(track['track']['id'])
if track['track']['id'] not in songs_playlists:
for artist in track['track']['artists']:
artists.add((artist['id'],artist['name']))
if artist['id'] not in artist_songs:
artist_songs[artist['id']] = list()
artist_songs[artist['id']].append(track['track']['id'])
recently_played_songs.append(track['track']['id'])
extra_info[track['track']['id']] = {
'name' : track['track']['name'],
'is_explicit' : track['track']['explicit'],
'popularity' : track['track']['popularity'],
'release_date' : track['track']['album']['release_date']
}
except requests.exceptions.HTTPError as err:
print("ERR:" + str(err))
songs_features = get_songs_audio_features(access_token,songs,extra_info)
Expand Down

0 comments on commit cb4d493

Please sign in to comment.