Skip to content

Commit

Permalink
Fix error on empty spotify playlist artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
justin025 committed Nov 7, 2024
1 parent df425a8 commit 84709ad
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/onthespot/api/spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,9 @@ def spotify_get_playlist_items(token, playlist_id):
logger.info(f"Getting items in playlist: '{playlist_id}'")
items = []
offset = 0
limit = 50
limit = 100
url = f'https://api.spotify.com/v1/playlists/{playlist_id}/tracks?additional_types=track%2Cepisode'


while True:
headers = {'Authorization': f'Bearer {token}'}
params = {
Expand Down
23 changes: 13 additions & 10 deletions src/onthespot/parse_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,19 @@ def parsingworker():
items = spotify_get_playlist_items(token, current_id)
playlist_name, playlist_by = spotify_get_playlist_data(token, current_id)
for index, item in enumerate(items):
item_id = item['track']['id']
item_type = item['track']['type']
pending[item_id] = {
'item_service': 'spotify',
'item_type': item_type,
'item_id': item_id,
'parent_category': 'playlist',
'playlist_name': playlist_name,
'playlist_by': playlist_by
}
try:
item_id = item['track']['id']
item_type = item['track']['type']
pending[item_id] = {
'item_service': 'spotify',
'item_type': item_type,
'item_id': item_id,
'parent_category': 'playlist',
'playlist_name': playlist_name,
'playlist_by': playlist_by
}
except TypeError:
logger.error(f'TypeError for {item}')
continue

elif current_type == "artist":
Expand Down

0 comments on commit 84709ad

Please sign in to comment.