Spotify daemon recorder and downloader
A python 3.6+ script intended to be run as a daemon used to sap spotify songs into your local library, slowly freeing you from the proprietary hinges. The idea here is not to crack spotify protection algorithm or anything is just a daemon intended to be the most 'set it and forget it' possible, and will slowly sap all the songs you hear into your local disk, until one day, you won't need spotify anymore.
But if you don't wan't to be bothered with the moral aspect, don't have enough
local storage space, or don't care, you still can use the ad-skipping functionally
stand-alone with the -a
flag.
The song recording part it's a extremely simple proof of concept and assumes a lot of things about your sound setup, I intend to make it more seamless to more setups, but here is what you need to get it working:
pactl load-module module-jack-sink client_name=spotify connect=yes
Given such setup, the script should be able to create a jack output and automatically connect it to spotify's jack-pulseaudio sink.
The required dependency are all on requirements.txt you can use pip to install them all. So to sum it all up, this should get you up and running:
git clone https://github.com/samosaara/sapfy ~/.sapfy
pip install --user -r ~/.sapfy/Requirements.txt
mkdir -p ~/.local/bin/
ln -s $HOME/.sapfy/sapfyd ~/.local/bin/sapfy
There should be an executable symbolic link to named sapfy inside your ~/.local/bin
that you can use to execute the daemon. That folder might not be on your PATH
, you may move the executable, or see here.
If you want you can also setup a service in your init system to get the ultimate seamless sapping experience. I pretend on providing this on the future.
The way I structured the imports, you need to run the program as a python module if want to run it directly through python. Or you can just run the provided executable sapfyd
.
python3 -m sapfy
# Is the same as
./sapfyd
You can use --help to see the available command line options.
The --output flag receives a string, that will be formatted with the song's current metadata. It must not have the file extension, it will be added automatically. The output string can have the following place-holders that will be replaced based on the track metadata:
Property | Type | Description |
---|---|---|
title | String | The track's title |
artist | String List | An zero indexed array containing all the artists involved in the particular song. |
album | String | String with the name of the track's album. |
trackNumber | Integer | The number of this song on the current disc. |
albumArtist | String List | String with the name of the artist behind the track's album. |
autoRating | Float | Number from 0 to 5 indicating spotify's grade. |
discNumber | Integer | Which of the album's disc(s) is the track at. |
length | Integer | Number of seconds this track has. |
For an example, the default output string is
"{albumArtist[0]}/{album}/{trackNumber} {title}'"