epoupon / lms

Lightweight Music Server. Access your self-hosted music using a web interface.
http://lms-demo.poupon.dev
GNU General Public License v3.0
1.14k stars 62 forks source link

Issue when using MusicAssistant and server side Listenbrainz scrobbling #542

Closed Maxmystere closed 1 month ago

Maxmystere commented 1 month ago

Hello, I've started using MusicAssistant for my in home music streaming and i've noticed that despite MusicAssistant not having an "enable scrobbling" setting it "works", sadly it seems to be reporting duplicates and wrong timings in the listenbrainz page (Maybe caused by it caching the music file ?) image

I have not yet really looked if the issue came from the subsonic implementation of MusicAssistant or the server but i'd gladly take a look myself if you help me with the relevant API route

Thanks a lot for this project btw

epoupon commented 1 month ago

Hello!

LMS doesn't scrobble by itself using stream or download endpoints. I suggest you inspect LMS logs to extract what MusicAssistant actually asks to scrobble, see https://www.subsonic.org/pages/api.jsp#scrobble Then we can check if these requests are wrong or if there is something wrong on LMS side (which is possible, as LMS stores listens to scrobble, to retry later in case of failure, etc.)

Maxmystere commented 1 month ago

Seeing the MusicAssistant implementation, it is calling the api with a submission False then True after the end of the stream https://github.com/music-assistant/server/blob/113e51dbf356f7c2aec55d6b5f0908fa8d348c0c/music_assistant/server/providers/opensubsonic/sonic_provider.py#L807:L813

Seeing the logs, it seems to be doing 2 scrobble calls for each song playing which is matching whats visible in listenbrainz : 1 call for the current music and another one for the next music (or for the completion of the last one) I sadly don't have the details of the calls except

[2024-Oct-28 18:57:31.882] 1 - [info] "wthttp: 172.18.0.11 POST /rest/scrobble.view HTTP/1.1 200 109"

epoupon commented 1 month ago

Try to change log-level to "debug" in lms.conf, you will get more details

Maxmystere commented 1 month ago

When a song finishes and another start I seem to have the correct scrobbling submission but with wrong id, it's also missing the optional time param

[2024-Oct-28 19:30:06.032] 1 - [debug] - 140592878443320 [API_SUBSONIC] Handling request 84 '/scrobble.view', continuation = false, params = {c=Music Assistant}, {f=json}, {id=tr-1946}, {p=REDACTED}, {submission=True}, {u=Max}, {v=1.16.1}, [2024-Oct-28 19:30:08.283] 1 - [debug] - 140592878746424 [API_SUBSONIC] Handling request 87 '/scrobble.view', continuation = false, params = {c=Music Assistant}, {f=json}, {id=tr-9360}, {p=REDACTED}, {submission=False}, {u=Max}, {v=1.16.1}, [2024-Oct-28 19:33:47.450] 1 - [debug] - 140592878594872 [API_SUBSONIC] Handling request 121 '/scrobble.view', continuation = false, params = {c=Music Assistant}, {f=json}, {id=tr-6669}, {p=REDACTED}, {submission=True}, {u=Max}, {v=1.16.1}, [2024-Oct-28 19:33:50.479] 1 - [debug] - 140592878443320 [API_SUBSONIC] Handling request 124 '/scrobble.view', continuation = false, params = {c=Music Assistant}, {f=json}, {id=tr-6280}, {p=REDACTED}, {submission=False}, {u=Max}, {v=1.16.1},

Maxmystere commented 1 month ago

On a side note the the music assistant is also failing on several getAlbumInfo2 calls which are not implemented

epoupon commented 1 month ago

It is fine to not provide time, lms will then use the current time when reporting to LB. Submission set to false should trigger "playing_now" call to LB API in submit-listens Submission set to true should trigger "single" in the same endpoint. Could you check this in lms logs? In debug log level you see the calls done to the LB API.

Maxmystere commented 1 month ago

Sadly the debug doesn't seem to display the submit-listens params but it seems that the playing_now call is never sent because I do not see the "now playing" view on listenbrainz webpage using MusicAssistant image

With my phone player (Ultrasonic) it's working well

You can take a look at my listenbrainz if you want

epoupon commented 1 month ago

I checked again with manual commands on the LMS's subsonic API, I don't see any obvious problem. Could you please send me the LMS debug logs for a couple songs you listen to at tmp49-tmp49@yahoo.com?

epoupon commented 1 month ago

Ah never mind, it comes from "False" that is not matched, and then LMS fallbacks on the default value for this param, which is "true"

Maxmystere commented 1 month ago

The issue is from False != false ?

epoupon commented 1 month ago

Yes exactly!

Maxmystere commented 1 month ago

Ho yeah that's always happening ! Thanks for the fix