Submit your "listens" with Spotify (nerds only!)

spotify
nodejs
Tags: #<Tag:0x00007f23c5a23c90> #<Tag:0x00007f23c5a23858>

#1

So I’m back again with another crude script. This time the pre-requisites are heavier because we have to run a fake last.fm server with nodejs that intercepts scrobbles from Spotify and submits them to Listenbrainz instead.

Also, you need to edit your hosts file - details are contained in the readme…

https://github.com/19379/node-spotify-listenbrainz

It will report submission status in the command window. Any failed listens should be cached and retried again later with the exception of one type of error which I honestly don’t think we’ll see. If this does happen, the console will notify you.

You can get node here…

https://nodejs.org/en/


Web scrobbler for browser listening?
#2

Thanks for this script, it’s working great for me!

I have however noticed that a listen from two days ago has showed up on my LB profile: https://listenbrainz.org/user/Leo%20Verto
This definitely wasn’t there earlier today but it’s definitely possible that I listened to this song two days ago.
Now I’m wondering if Spotify perhaps cached that listen until it had a working connection (though I’m not sure why that particular song, I had listened to quite a few others in the meantime).


#3

It’s quite possible the cache had multiple items but the script is only designed to handle the first entry. And because the script blindly reports success to the spotify regardless of what happened with the LB submission, spotify will have then cleared its own cache which probably accounts for any missing tracks between that 2 day old submission and now.

I think I could rewrite the script to handle the spotify cache properly. Watch this space. :stuck_out_tongue:


#4

I’ve got a Wireshark capture of how Spotify sends it’s cache after regaining connection, interested?

Essentially just repeats the fields a[n], t[n], etc. with an increasing n for each song.


#5

Thanks but I’ve already got to the root of my problem. I just needed to ditch the internal node querystring function with this 3rd party package I found on github. It does exactly what I need with minimal effort.

edit: and it works… 3 tracks from the spotify cache getting submitted in one go…


#6

The script is now on github. Check the first post link/readme for full instructions as it’s changed slightly from the original version.

The only real change in functionality is the proper submission of the Spotify cache. I still need to work on handling connectivity issues/errors from Listenbrainz itself.


#7

Ah great, I was wondering when you’d move from Gist to full repo, seeing as that seems to be the normal workflow for scripts. :stuck_out_tongue:


#8

I thought I could maintain a single file because I wasn’t expecting to require any external dependencies. As it turns out, I was mistaken. :slight_smile:


#9

You can have multiple files in a gist. Gists are git repositories just like pretty much everything else on GitHub, so you could have copied the git history from the gist over to the “full” GH repository too…


#10

I’ve updated this to handle errors but it will be obsolete in the next day or 2 as the Listenbrainz server will soon be updated to handle Spotify submissions!!


#11

LB now supports submission from Spotify: https://listenbrainz.org/lastfm-proxy.