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

Add playlist and recommendation API endpoints #9

Open
ssssam opened this issue Dec 27, 2021 · 6 comments · May be fixed by #10
Open

Add playlist and recommendation API endpoints #9

ssssam opened this issue Dec 27, 2021 · 6 comments · May be fixed by #10

Comments

@ssssam
Copy link

ssssam commented Dec 27, 2021

Hello,
Listenbrainz has a playlist API, and recently generated 2021 retrospective recommendations for everyone.

These are my initial thoughts on adding support for those to pylistenbrainz. I haven't thought about how the Python API would look.

Stage 1 - read only access

Endpoints to wrap:

* GET `user/<username>/playlists`: fetch <username>'s playlists (metadata only)
* GET `playlist/<id>`: fetch a specific playlist (content included)

Is this something you'd be interested in having in pylistenbrainz API?

Stage 2 - write access

After that's done, write access would involve:

* POST `create`, `edit`, `item/add,move,delete`, `delete`

I noticed this in the docs for create:

If a created_for field is found and the user is not an approved playlist bot, then a 403 forbidden will be raised.

It sounds like write access is not open to everyone right now, so maybe it's not worth adding to pylistenbrainz yet.

@paramsingh
Copy link
Contributor

Is this something you'd be interested in having in pylistenbrainz API?

@ssssam Yes, I'm definitely interested in keeping up with the ListenBrainz API. Is this something you want to write or a feature request for me? I can try to find some time to write this feature this weekend.

It sounds like write access is not open to everyone right now, so maybe it's not worth adding to pylistenbrainz yet.

I think what that means is that you cannot create playlists for other users, I'll dig into it, but if the endpoint can be used in any way by normal users, we should probably support it in pylistenbrainz.

@ssssam
Copy link
Author

ssssam commented Dec 29, 2021

Is this something you want to write or a feature request for me? I can try to find some time to write this feature this weekend.

Consider it a low priority feature request :) If you could at least come up with an API design then one of us can implement when we get the chance.

I think what that means is that you cannot create playlists for other users

Ah... that makes more sense.

@paramsingh
Copy link
Contributor

Coming up with a design shouldn't be much work. My high-level thoughts (at least for stage 1) are as follows:

get user playlists

def get_user_playlists(self, username, count=None, offset=None) -> PlaylistMetadata:
    pass

PlaylistMetadata is a class wrapping the output of the endpoint.

We can also add a parameter to this method to allow calls to the other 2 playlist retrieval endpoints: https://listenbrainz.readthedocs.io/en/production/dev/api/#get--1-user-(playlist_user_name)-playlists-collaborator and https://listenbrainz.readthedocs.io/en/production/dev/api/#get--1-user-(playlist_user_name)-playlists-createdfor

get playlist data

def get_playlist(self, playlist_id) -> Playlist:
   pass

Playlist is a class wrapping playlists (maybe with to_jspf methods etc)

What do you think?

@ssssam
Copy link
Author

ssssam commented Dec 31, 2021

We can also add a parameter to this method to allow calls to the other 2 playlist retrieval endpoints

Sounds good, so... created_for and collaborator flags? Would collaborator return the union of playlists/ and playlists/collaborator/ (seems more intuitive) or only playlists/collaborator/ (maps closer to the real API?).

Playlist is a class wrapping playlists (maybe with to_jspf methods etc)

Presumably this would be able to return a PlaylistMetadata object somehow too, since GET /playlist/ includes the metadata?

Being able to output straight to JSPF would be cool, in fact, for my use case that's probably the only thing required.

@paramsingh
Copy link
Contributor

Sounds good, so... created_for and collaborator flags? Would collaborator return the union of playlists/ and playlists/collaborator/ (seems more intuitive) or only playlists/collaborator/ (maps closer to the real API?).

That's what I was thinking, I'll think it over a bit more when I write it.

Presumably this would be able to return a PlaylistMetadata object somehow too, since GET /playlist/ includes the metadata?

Yeah, I think we can just have a metadata prop in the Playlist object which is a PlaylistMetadata.

Being able to output straight to JSPF would be cool, in fact, for my use case that's probably the only thing required.

Makes sense! I'll make sure to include that.

Thanks for your help here!

ssssam added a commit to ssssam/pylistenbrainz that referenced this issue Jan 31, 2022
Fixes metabrainz#9

Still to do:

  * Document all new API and check that generated output is correct
  * Add tests for new functions and ensure coverage is OK
@ssssam ssssam linked a pull request Jan 31, 2022 that will close this issue
ssssam added a commit to ssssam/pylistenbrainz that referenced this issue Jan 31, 2022
Fixes metabrainz#9

Still to do:

  * Add tests for new functions and ensure coverage is OK
ssssam added a commit to ssssam/pylistenbrainz that referenced this issue Jan 31, 2022
Fixes metabrainz#9

Still to do:

  * Add tests for new functions and ensure coverage is OK
@ssssam
Copy link
Author

ssssam commented Jan 31, 2022

I made a start on this - let me know what you think :) #10

ssssam added a commit to ssssam/pylistenbrainz that referenced this issue Feb 1, 2022
Fixes metabrainz#9

Still to do:

  * Add tests for new functions and ensure coverage is OK
ssssam added a commit to ssssam/pylistenbrainz that referenced this issue Feb 13, 2022
Fixes metabrainz#9

Still to do:

  * Add tests for new functions and ensure coverage is OK
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 a pull request may close this issue.

2 participants