Add HTTP API for managing TIDAL favorites#243
Conversation
| raise RuntimeError( | ||
| "TidalBackend actor not running; cannot register HTTP routes" | ||
| ) | ||
| backend = refs[0].proxy() |
There was a problem hiding this comment.
what is this proxy object? a pykka proxy, right?
|
(I can't approve the workflow.) From a quick glance the code looks good. I'd question the choice of 503, although it is defensible.
Neither of these is true here: it's just that mopidy-tidal is using lazy login and we need you to login. I think you should definitely make sure the error text says something like "please ensure that you can play music from tidal using mopidy-tidal and then retry", and consider raising 403 instead, although the re-auth flow is a bit weird ("go and play a track"). Thanks for the code, this is definitely something it'd be good to have. |
|
Thanks for the review! Based on the feedback (and given the Applied the 503→403 distinction you suggested there (with an actionable error message pointing at the lazy-login flow). Thanks again for the time. |
Summary
Implements the favorites HTTP API discussed in #241 (option A — endpoints in
the existing HTTP frontend).
http:appso the routes mount at/tidal/alongsidethe rest of the Mopidy HTTP frontend.
POST /tidal/favorites/<kind>swith body{ "id": "<id>" }adds afavorite. Returns 204.
DELETE /tidal/favorites/<kind>s/<id>removes a favorite. Returns 204.GET /tidal/favorites/<kind>slists current favorites as[{ id, name, artist? }, ...].<kind>is one ofalbum,track,artist,playlist.TidalBackendactorvia
pykka.ActorRegistryand reuse thetidalapi.Sessionit alreadyholds, so clients don't re-implement OAuth.
on POST.
Closes #241.
Test plan
uv run pytest tests/test_web.py tests/test_extension.py— 31 passinguv run ruff format --check— cleanuv run ruff check— cleanto the TIDAL library, GET lists it back, DELETE removes it, and the
changes show up on the official client / web app on next refresh.