This is a script that takes the now-playing song from a Spinitron station and scrobbles it to a Last.fm account. It was originally written by WKNC for their station's Last.fm account. I have since configured it at WBOR 91.1 FM (WBOR on Spinitron - Last.fm) with a few modifications.
In this fork, I Dockerized the original script and wrote a more streamlined setup process so that other station managers who may not be as technically inclined can hopefully implement it without much friction.
- A Last.fm account and API application. Create an API app here if you haven't already done so. Make sure to log in to Last.fm with the account you plan to scrobble to.
- Admin login to the Spinitron account corresponding to the station that plans to scrobble.
- Some kind of Linux server environment (WBOR is running it on a Virtual Private Server (VPS) at Digital Ocean using Ubuntu 22.04.3 at the time of this writing)
- Docker version 24.0.7 (at the time of this writing -- your mileage may vary on newer versions)
nano
or a similar command line text editor such asvim
. If you choose to use something other thannano
, you will need to modify the following commands accordingly.
After you've gone through the following setup process once, you theoretically shouldn't need to ever repeat it! Neat.
-
In terminal, navigate to the directory you want to set this up in, and then run:
git clone https://github.com/mdrxy/wbor-scrobbler.git && cd wbor-scrobbler && cd env && nano .env
- Clones the repository, navigates to its folder, and opens the .env needed for editing in step 2.
-
In .env, enter the following values after a
=
(without a space):-
LASTFM_API_KEY
: Found on your Last.fm API accounts page under "API Key" -
LASTFM_API_SECRET
: Found on your Last.fm API accounts page under "Shared Secret" -
SPINITRON_API_KEY
: Found on the Spinitron automation and API page under "API Key" -
The resulting
.env
file shoud look something like the following:LASTFM_API_KEY=7AtTWxDq3ho9AEwjiuMjAdYPkoyUHgFH LASTFM_API_SECRET=nwZvxiCbx28dAAwswQETeBjjyhMz6LFf SPINITRON_API_KEY=HjeZczCFkQ87RghvJXMHvGVn
-
Once entered, press ctrl + x and then enter y then enter to save and exit.
-
-
Set a scrobbling schedule. By default, it is set to scrobble 24/7, but you can choose a block of time to start/stop scrobbling. Run:
cd .. && cd scrobbler && nano schedule.json
- Navigates to the repo's assets folder and opens nano to modify the schdeule.
- NOTE: times are 24-hour UTC. Use a conversion tool to find your time zone in UTC.
- You are not locked in to this schedule and can change it at a later date if you choose.
- If you are content scrobbling 24 hours a day, press ctrl + x and move on to step #4.
- If you are defining a custom schedule, change the start and end hour, press ctrl + x and then enter y then enter to save and exit.
-
Build the docker image. Run:
cd .. && docker build --no-cache -t scrobbler .
- Navigates to the repo's root folder and creates a Docker image tagged/titled
scrobbler
.- You are free to give the image a tag/title other than
scrobbler
but note that you will need to adjust the code in the following steps accordingly.
- You are free to give the image a tag/title other than
- Navigates to the repo's root folder and creates a Docker image tagged/titled
-
Assuming the image was built successfully, you can now spin up a container to complete setup. Run:
docker run -v "$(pwd)"/env:/env -p 4000:80 -it --name scrobbler --restart unless-stopped scrobbler
- Creates and starts a container titled
scrobbler
in interactive terminal mode for the initial setup process. Same as above: you are free to give the container a title other thanscrobbler
but note that you will need to adjust the code in the following steps accordingly. - In the case of a server reboot or a script failure, the container
scrobbler
will immediately restart, and will continue to do so unless you explicitly stop the container (more below). - Maps to external port 4000 by default, however you can change this as needed depending on your installation environment.
- Creates and starts a container titled
-
Navigate to the Last.fm url presented to you (in some terminals you can cmd + click the URL) and authorize the application by pressing "allow access." Return to the terminal and enter y followed by enter.
-
Following setup, the container
scrobbler
will immediately begin running in the background, so no further action is required!
- To stop/start the script's container for any reason, run
docker stop scrobbler
anddocker start scrobbler
respectively.- NOTE: stopping the container may take 5-10 seconds.
- Like mentioned in part 5 of "Installation & Setup," in the case of a server reboot or a script failure, the container
scrobbler
will immediately restart without needing to run the setup process again.
-
Enter the currently running wbor-scrobbler container. Run:
docker exec -it scrobbler /bin/bash
- Opens the container's shell.
-
Edit
schedule.json
. Run:nano schedule.json
- Choose hours to START and STOP scrobbling. These should be in 24-hour UTC format. E.g. 1 PM EST should be entered as 15 for 15:00 UTC. No other integers other than 0-24 are permitted. Once done, press ctrl + x and then enter y then enter to save and exit.
- You can now run
exit
to escape the container's CLI. - Restart the container.
docker kill scrobbler
- stops the currently runningscrobbler
if there is onedocker rm scrobbler
- deletes the previously builtscrobbler
containerdocker rmi scrobbler
- deletes the previously builtscrobbler
iamge- Navigate to the location of the
scrobbler
source files (e.g. the folder with the Dockerfile, wherever you cloned this repo to) git stash
to save any local changesgit pull
to get the latest filesgit stash pop
to restore any changes you saved in step 4docker build --no-cache -t scrobbler .
to build the new scrobbler Docker imagedocker run -v "$(pwd)"/env:/env -d --name scrobbler --restart unless-stopped scrobbler
to create and run a new container in the background from the new image. Change-d
to-it
to start in interactive mode to see print statements/realtime logs, but remember, you will need to delete and recreate the container again in order to run the container in detached (background) mode.
-
If you accidentally removed the
scrobbler
docker container, create a new one by navigating to the location you cloned this repo to (important!) and running:docker run -v "$(pwd)"/env:/env -p 4000:80 -d --name scrobbler --restart unless-stopped scrobbler
- Runs the container in the background since it is assumed you've already gone through the initial setup process.