Skip to content

Fixed playlist fetching - #49

Open
cameron-h-price wants to merge 3 commits into
varunneal:mainfrom
cameron-h-price:main
Open

Fixed playlist fetching#49
cameron-h-price wants to merge 3 commits into
varunneal:mainfrom
cameron-h-price:main

Conversation

@cameron-h-price

Copy link
Copy Markdown

Hi! I've been using this package and ran into a few bugs which I've fixed in this PR. Happy to discuss any of the changes before merging.

Bugs Fixed

1. KeyError: 'tracks' on playlist search

When searching with qtype=playlist, the tool was crashing because parse_playlist tried to access playlist_item['tracks'] directly. Spotify's search results can return playlist items where tracks is None. Fixed by using .get('tracks') or {} and safely accessing nested keys.

2. Playlist pagination — only first 50 playlists returned

get_current_user_playlists was only fetching the first page of results. Fixed by following Spotify's next cursor to paginate through all playlists.

3. user_is_owner always returning False

Because get_current_user_playlists wasn't decorated with @ensure_username, self.username was None when parse_playlist ran the owner comparison. Fixed by adding the @utils.ensure_username decorator.

Thanks for the package!

updated parse_playlist to handle missing/None tracks field
modified get_current_user_playlist to allow pagination of results
added utils.ensure_username to get_current_user_playlists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant