MusicBox + Raspberry Pi + magnetic swipe card jukebox
This repo contains what I'm using to make a Musicbox+Raspberry Pi+Spotify jukebox for my kids work with magnetic swipe cards. There is a very small Bash script that waits for input from a card reader, a list of Spotify URIs (see below for why), and I'll try to explain the steps in this readme.
mpc add spotify:track:7GhIk7Il098yCjg4BQjzvb && mpc play
jukebox.sh
to point to the songs.txt
in your own repo.https://raw.githubusercontent.com/helen/swipe-jukebox/master/jukebox.sh > jukebox.sh
(substitute in your own username if you’ve forked the repo above).root
to auto-login on boot and /root/jukebox.sh
to run after login so the setup can live headlessly going forward. These instructions work well, noting that the user for MusicBox is root
, not pi
.bash jukebox.sh
; this will download the song list referenced in the script as songs.txt
. Enter a number like 1
at the prompt that says Swipe:
to ensure the script is working as expected. If you want to quit the script, hit ctrl-c
.songs.txt
to your liking. I have found the easiest way to do this is to create a Spotify playlist and then select-all, right click, go to the Share menu item, select Copy Spotify URIs, and paste the result into the file.songs.txt
file (and your playlist, if using one).http://musicbox.local
).There are a lot of projects I've looked at in the course of planning this that I will link as I continue to flesh out this readme! They helped me understand a lot of things and I would probably not have figured this out entirely on my own. That said, the scripts I found use Python, which is fine, but I wanted something super streamlined that didn't depend on installing other things. Also I barely understand Python and since I'm using magnetic swipe cards instead of RFID chips (mostly due to shipping constraints), I'd have to make modifications anyway.
tl;dr: case sensitivity but it started out as a workaround for a wonky card reader.
I don't live in a country where I can reasonably ship things from Amazon to myself and the USB card reader somebody just brought back from the US for me only seems to read tracks 2 and 3 on cards, confirmed by testing it with real live working cards. Tracks 2 and 3 can only contain numbers, so I figured a list of songs referenced by line number would be the path of least resistance. If I get more time before I just go ahead and acquire another card reader, I'll work on supporting comments so you can identify each line or maybe make it a full-on CSV. Right now I'm doing an annoying but cheap thing where I have a Spotify playlist and select-all, right-click, copy Spotify URIs, and paste that into the songs.txt
file. I may expand this into something where I can create labels more easily, but still working on that part.
As I was trying to figure out where to acquire another card reader, I realized that the cards can only be encoded in all-caps, and Spotify URIs are case-sensitive, so this wonky card reader actually sent me in the right direction anyway! Also, an advantage of the list of URIs is that I can update the song list on the fly without rewriting the cards, like if a URL breaks, or the kids decide they want to change a song.