krateng / maloja

Self-hosted music scrobble database to create personal listening statistics and charts

Home Page:https://maloja.krateng.ch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature request/proposal] Now playing

duckfromdiscord opened this issue · comments

commented

I think it would be cool to have a "now playing" feature. I am willing to implement this myself if needed. It would be a fun undertaking and a great way for me to contribute to one of my favorite open source projects.

I think the best way to do this in the API would be to add a new endpoint that takes the same parameters as a scrobble, minus the timestamp. In terms of duration, we could do it in this order, highest priority first: the duration included with the request, the duration from any existing scrobbles for the same track already in the database, potentially checking MusicBrainz for a known duration, and a default duration of 3 min 20 seconds. The "now playing" track could be displayed on the home page on the right-hand side, or alongside the maloja logo on the footer of every page. The old and new AudioScrobbler APIs already have a feature for this so we can redirect those as well.

I'm not exactly sure of the absolute best way to implement this, but I have some ideas. Perhaps we could add a new table to the database that would hold the track data, and the beginning and end timestamps. There would be a row in that table that held the data for the now playing track, and when the end timestamp is hit, it has to be removed somehow. A new request would automatically clear that table and enter a new row.