sentriz / gonic

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

Last.fm scrobbling not working #162

Closed TheLastZombie closed 2 years ago

TheLastZombie commented 2 years ago

I set up and linked Last.fm to my Gonic (0.14.0) instance, but scrobbling doesn't seem to be working.

image

I tested this with Ultrasonic, which updates the now playing status but doesn't send any scrobbles, and Subtracks, which does neither. I enabled the respective scrobble settings in both apps.

The log doesn't contain any errors either:

Oct 12 18:09:06 raspberrypi gonic[640]: 2021/10/12 18:09:06 serving raw `01. Enter Sandman.mp3`
Oct 12 18:09:07 raspberrypi gonic[640]: 2021/10/12 18:09:07 response  200  for `/rest/scrobble?u=roesch&t=[...]&s=[...]&v=1.15.0&c=subtracks&id=tr-9529`

I also double-checked the API key/secret and my account connection. Curiously enough, Listenbrainz scrobbling does work.

sentriz commented 2 years ago

interesting, could you confirm that your user account has lastfm session?

$ sqlite3 path/to/gonic.db "select last_fm_session from users where name='admin'"
abc1234jdjdjdsdf

or whatever your username is

TheLastZombie commented 2 years ago
$ sqlite3 /var/lib/gonic/gonic.db "select last_fm_session from users where name='roesch'"
ql5XXXXXXXXXXXXXXXXXXXXXXXXXXLnG
sentriz commented 2 years ago

the 200 response may be misleading. since I don't think the subsonic spec defines HTTP responses codes for subsonic errors. Since Ultrasonic isn't logging any errors while submitting - I just added some logging to the console.

Could you try go.senan.xyz/gonic/cmd/gonic@latest (or however you are installing) and check the logs again when scrobbling?

Thanks!

TheLastZombie commented 2 years ago

I re-ran the go install command and tried again, but still no logs :/

I also manually sent one of the /scrobble HTTP requests (i. e. curl http://127.0.0.1:4747/rest/scrobble/[...]) to see if I could get anything out of that, but that just gave me a simple:

<subsonic-response status="ok" version="1.15.0" xmlns="http://subsonic.org/restapi" type="gonic"></subsonic-response>

Oh, I might as well put my environment here, on the off chance it helps:

sentriz commented 2 years ago

interesting would you mind trying the go install again with @issue-162 at the end? I just created that branch and it should log some more stuff including the raw response from lastfm

TheLastZombie commented 2 years ago

Ah, now I'm getting something:

2021/10/13 06:28:58 new scrobble request
2021/10/13 06:28:58 scrobbling with 0
2021/10/13 06:28:58 scrobbling with lastfm 17. Perfect Sound Whatever.mp3
2021/10/13 06:28:58 lastfm response:
2021/10/13 06:28:58 HTTP/2.0 200 OK
Content-Length: 451
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 86400
Alt-Svc: clear
Content-Type: text/xml; charset=UTF-8
Date: Wed, 13 Oct 2021 04:28:58 GMT
Server: openresty/1.13.6.2
Via: 1.1 google
<?xml version="1.0" encoding="UTF-8"?>
<lfm status="ok">
  <scrobbles ignored="1" accepted="0">
    <scrobble>
      <track corrected="0">Perfect Sound Whatever</track>
      <artist corrected="0">Jeff Rosenstock</artist>
      <album corrected="0">WORRY.</album>
      <albumArtist corrected="0">Jeff Rosenstock</albumArtist>
      <timestamp>2011765</timestamp>
      <ignoredMessage code="1"></ignoredMessage>
    </scrobble>
  </scrobbles>
</lfm>
2021/10/13 06:28:58 scrobbling with 1

The ignoredMessage sticks out to me. According to Last.fm's API documentation, a code of 1 means "filtered artist", but in the provided example, the field isn't empty (plus I've successfully scrobbled this artist before).

I also noticed the timestamps vary greatly (2011765 above, 1288728940 in the example). I wonder if it has something to do with that, but the ignoredMessage code for "timestamp too far in the past" is 3.

sentriz commented 2 years ago

yeah that is a funny looking timestamp. what is the ?time= param that ultrasonic sends to the /rest/scrobble endpoint? if any

I also updated the issue-162 branch to improve the time parsing. maybe that could fix it?

TheLastZombie commented 2 years ago

There is no time parameter, but:

I also updated the issue-162 branch to improve the time parsing. maybe that could fix it?

That did the trick! The timestamp looks normal now, and both the now playing statuses and scrobbles don't get rejected anymore.

Thanks for your quick response (and for Gonic in general) :)