Skip to content

Add HTTP API for managing TIDAL favorites#243

Closed
prietus wants to merge 1 commit into
EbbLabs:mainfrom
prietus:feat/favorites-http-api
Closed

Add HTTP API for managing TIDAL favorites#243
prietus wants to merge 1 commit into
EbbLabs:mainfrom
prietus:feat/favorites-http-api

Conversation

@prietus

@prietus prietus commented May 11, 2026

Copy link
Copy Markdown

Summary

Implements the favorites HTTP API discussed in #241 (option A — endpoints in
the existing HTTP frontend).

  • Registers a Mopidy http:app so the routes mount at /tidal/ alongside
    the rest of the Mopidy HTTP frontend.
  • POST /tidal/favorites/<kind>s with body { "id": "<id>" } adds a
    favorite. Returns 204.
  • DELETE /tidal/favorites/<kind>s/<id> removes a favorite. Returns 204.
  • GET /tidal/favorites/<kind>s lists current favorites as
    [{ id, name, artist? }, ...].
  • <kind> is one of album, track, artist, playlist.
  • Authentication is implicit: the handlers reach the TidalBackend actor
    via pykka.ActorRegistry and reuse the tidalapi.Session it already
    holds, so clients don't re-implement OAuth.
  • Returns 503 if the backend isn't logged in yet, 400 for invalid/empty body
    on POST.

Closes #241.

Test plan

  • uv run pytest tests/test_web.py tests/test_extension.py — 31 passing
  • uv run ruff format --check — clean
  • uv run ruff check — clean
  • Smoke-tested against a live Mopidy + mopidy-tidal: POST adds the album
    to the TIDAL library, GET lists it back, DELETE removes it, and the
    changes show up on the official client / web app on next refresh.

Comment thread mopidy_tidal/web.py
raise RuntimeError(
"TidalBackend actor not running; cannot register HTTP routes"
)
backend = refs[0].proxy()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this proxy object? a pykka proxy, right?

@2e0byo

2e0byo commented May 15, 2026

Copy link
Copy Markdown
Contributor

(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.

The 503 (Service Unavailable) status code indicates that the server is currently unable to handle the request due to a temporary overload or scheduled maintenance, which will likely be alleviated after some delay. [RFC9110]

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.

@prietus

prietus commented May 17, 2026

Copy link
Copy Markdown
Author

Thanks for the review! Based on the feedback (and given the
workflow-approval issue) I'm going to keep this living in a companion package (github.com/prietus/mopidy-tidal-goodies)
rather than push for upstream inclusion — that lets me iterate at my own cadence and keeps mopidy-tidal's scope tighter.

Applied the 503→403 distinction you suggested there (with an actionable error message pointing at the lazy-login flow).
Closing this and deleting the branch.

Thanks again for the time.

@prietus prietus closed this May 17, 2026
@prietus prietus deleted the feat/favorites-http-api branch May 17, 2026 16:57
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.

Add Tidal favorites support (add/remove/list albums, tracks, artists)

2 participants