How to batch download music using a linux terminal
Another day, another tutorial, on the menu today is the linux tool, spotdl, found here: https://github.com/spotDL/spotify-downloader
The setup and usage of this tool is very easy, I will be using it on windows 11 through windows subsystem for linux (WSL).
set up WSL#
WSL setup is also very easy, just hit the windows button on your keyboard and type powershell, hit enter and you will open a terminal.
type, or copy paste the below text.
wsl --install
This will run the installer, the linux distribution installed by default is ubuntu 24.04. You will be asked to input a username, and a password, after it is done you will be prompted to restart your pc.
There are a couple of different ways to access your WSL distros, you can type their name in the start menu if you have multiple, or you can type wsl, again in the start menu, or a windows terminal. Note that doing it in the latter way through the terminal will not send you to the distributions file system, but rather the windows file system.
Now with WSL open, you will first want to update and upgrade the distribution. This is easily done with these commands.
sudo apt update && sudo apt upgrade -y && clear
Notice that the usage of “&&” to seclude separate commands to be run left to right, the modifier “-y” is used to pre-emptively confirm that you do in fact want to install these updates and “clear”, which will clear the terminal, for cleanliness sake.
fish shell, optional#
An optional step here which I would highly recommend you do is install fish shell, found here: https://fishshell.com/
This shell has the great feature of adaptive and historical command prediction.
Here is an example of the historical prediction at work.
!
To install fish, and set it as the default shell that is run at startup.
sudo apt install fish && chsh $(which fish)
Note that when copying these specific commands the “-y” modifier is not used and you will get a (y/n) yes/no prompt to confirm install, I did not include it here to portray the difference.
In the future, any time you start WSL fish will automatically start, for now however, type fish and hit enter, to enable the fish shell for this session.
spotdl setup#
In order to install spotdl, you will have to download the pip package manager, there are a number of different versions available, personally I use pipx, installation goes as such.
sudo apt install pipx -y && pipx ensurepath
The above commands install, and then add pipx to the path, this is required to run the command globally.
Next you can finally install spotdl, as such.
sudo pipx install spotdl && pipx ensurepath
After installation of spotdl you will either have to restart WSL or source .bashrc or fish.config, depending on if you followed the earlier fish install step.
without fish
source .bashrc
within fish
source ~/.config/fish/config.fish
running spotdl#
You can now use spotdl.
spotdl will download in the directory that the terminal is pointing to. you will want to point to, or make and point to your music storage location.
My specific download location is a network attached storage, using the samba protocol, mounting network drives in wsl/ubuntu is another can of worms that I will keep for a later date.
Below I will give an example, using the drive letter M for music, this will be different for you, for a fresh music library, where you have to make all the folders.
Note that the below directory structure is kind of neurotic, in that it makes a folder, artists, where multiple artist folders can then be neatly made in, and then in the artist folder, there being an albums folder where individual album releases can then be categorized
cd /mnt/m/ && mkdir -p /music/artists/artist/albums/album &&
cd /music/artists/artist/albums/album
The above commands do the following, cd (change directory) to go the drive you want to store the music on, mkdir (make directory) makes new folders, the “-p” argument being required to create multiple folders down a non existent tree, to then go to the newly made directories.
It is now finally time to get to downloading, which is done by copying the spotify link, then typing such.
spotdl "SPOTIFYLINK"
FYI, this does not download from spotify but from youtube.
AGAIN, this is a tutorial, I am not responsible for what you do with the downloaded music, I personally happily pay for spotify premium.#
My reason for doing this is firstly, platforms can and will take anything they desire down.#
Secondly, if my internet goes out I still have access to music.#
Thirdly, if the zombie infection starts, or WW3 the third turns the world into fallout, I can entertain the raiders, and hopefully not be turned into a chewtoy, or sell access to this music for supplies.#
I got gifs working I hope you are proud crapples~!