Implement Subsonic getNowPlaying API endpoint #632
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a proof of concept implementation of the getNowPlaying API endpoint (see #510 ). The response NowPlayingEntry only provides the minimal fields required by the OpenSubsonic spec, plus "artist" and "album". The IsDir and and PlayerId fields are hardcoded to false / 0.
I implemented this so I could use Homepage's Navidrome widget (which is just a generic Subsonic widget that hits the getNowPlaying endpoint and looks for Username, Title, Album, and Artist) as discussed in #533 .
Originally I had created a now_playing table in the database and would insert a row during ServeStream, but that seemed too heavy and invasive, so instead this code relies on an in-memory cache that simply stores the latest track streamed by each user.
Caveats:
Questions / Clarifications
Full disclosure, I never used Go before this week and this is mostly Copilot code, but I have reviewed it, and I'm running this version of the code on my personal network right now.