sentriz / gonic

music streaming server / free-software subsonic server API implementation
ircs://irc.libera.chat/#gonic
GNU General Public License v3.0
1.62k stars 115 forks source link

feat: Add the ability to share scrobbles with other users #515

Open Laevos opened 5 months ago

Laevos commented 5 months ago

What

This change adds a "ListenWith" feature to Subsonic, allowing a user to indicate that they are "listening along" with a friend, and have that friend's Scrobbles tracked on their LastFM/ListenBrainz accounts.

This is achieved via a listenwith package which creates an in-memory map of a user (the one submitting the scrobbles) to a set of listeners (those who are "listening along" with the user). An in-memory data structure was chosen to avoid making changes to the database schema, and because this kind of activity is inherently transient, so the cost of storing it persistently seemed unwarranted.

A user can start/stop listening with someone by using the appropriate API call. These are currently exposed through a UI on the web interface:

Why

This is probably mostly useful if you're of the "Scrobble everything" mentality, as I am. Too often I've found myself riding in the car or otherwise hanging out with another user on my Gonic instance who is playing the music, only to feel a pang of regret that my LastFM/ListenBrainz statistics won't reflect that I've been happily listening along with them. This is my totally selfish attempt to fix that issue.

I'm currently running a forked version of Gonic which adds the code below, so I figured I'd offer to upstream it to the community.

Here's a picture of the resulting UI:

image

And when listening along to another user:

image

Limitations

Currently no subsonic clients support this functionality, so the UX is perhaps not as great as it could be; it currently requires logging in to the web UI and using the dropdown that I added). I have doubts whether this would have any luck getting added as a feature in any existing clients, as they generally aim for features specifically laid out in the subsonic spec.

Laevos commented 5 months ago

Going to re-factor this a bit to get rid of the use of global variables.