Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added paginator to spotify client #506

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fcusson
Copy link

@fcusson fcusson commented Feb 8, 2025

Proposed Changes

Implementation of a page read that is able to go through limit and offset logic api endpoint to retrieve all or a set number of items from the API. This function will enable to centralize the logic of retrive whole list of items (playlists, album tracks, etc.) from the API without requiring to implement the same logic in multiple methods

This functionality is required for Spotcast to be able to move to spotifyaio

pytest has been validated to provide full coverage with current process.

@fcusson
Copy link
Author

fcusson commented Feb 11, 2025

Hi @joostlek,

just wanted to point out I made a PR for spotifyaio and also provide some details regarding the change.

Currently, this PR is purely foundation implementation for requirements that Spotcast has. We need to be able to pull an arbitrary number of items from the API that sometimes require more than the limit per single call. The _paginator method will help as a private method to be used by other functions to be able to manage the logic of limit and offset to pull the required amount of items.

The method can be called with the parameter max_items to any int, in this case, it will pull up to that amount of items and return them, or it can be called with None where the method will infer the total number of items from the result (which contains a total key) and pull everything.

This is refactored version of the _paginator Spotcast currently uses, but I do think it would be worth while for the underlying library to manage this part instead.

My goal after would be to refactor the different methods that have a limit and offset logic to use the _paginator instead.

If you have any questions on my change, please ask. Also, if there are any changes you would like to better fit in the structure and style of the library, please provide your comments.

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