Leon

Leon

Live to the point of tears.
tg_channel
twitter

Download Spotify songs using spotDL

Introduction#

spotify-downloader (hereinafter referred to as spotDL) is a command-line tool that can match and download corresponding songs from YouTube Music based on submitted Spotify links, and then assign the song metadata provided by Spotify to the downloaded files. The files downloaded through this method have clear and accurate album covers, complete information such as song name, artist, album, year, and genre, and in most cases, they even come with lyrics. If, like me, you don't have excessive requirements for the sound quality of your offline music library but still want to avoid seeing blank album covers or "unknown artist" in your music app, this tool is perfect for you.

Preparation#

It is worth noting that spotDL is a command-line tool, which means that all operations need to be done in the terminal. However, it is actually very simple to use, and even if you have no experience, it should not be difficult to follow the steps.

Requirements#

To use spotDL, you need to meet the following requirements:

  1. Have a Spotify account (you need to copy the Spotify share link);
  2. The network conditions allow you to use YouTube Music (friends in China need to use native IPs that support YTM regions, the easiest way is to directly open music.youtube.com to see if you can access it normally. If you can see the homepage, it means there is no problem. If you see "Coming Soon", it means that the region or network environment does not support it);
  3. Install the dependencies and add them to the PATH.

Installing Dependencies#

spotDL specifically requires two dependency programs: Python 3.6.1 (or above) and FFmpeg 4.2 (or above), both of which have been added to the PATH. The README in the official repository provides detailed instructions. Here, I will briefly explain the installation process on the Windows platform.

Python#

The process of installing Python is the same as installing any other application. First, go to the download page on the official Python website and click download.

The only thing to note is that when you first open the installation interface, there will be a checkbox at the bottom that says "Add Python X.X to PATH". By default, it should not be checked, but you need to check it and follow the prompts to complete the installation.

Since Python is already installed on my computer, I found a random image online that shows the checkbox is not checked. We need to check it.

Check the "Add to PATH" option at the bottom

Then click "Install Now" and follow the prompts to complete the installation.

If you have already installed Python before, just make sure that Python (not the launcher) is added to the PATH. If you choose a custom installation, remember to check the installation of pip as well.

FFmpeg#

Installing FFmpeg is very simple on macOS and Linux. As for the installation method on Windows, the official README also provides a detailed reference link. Here, I will briefly describe the installation process on Windows.

First, open the official download page of FFmpeg, then hover your mouse over the Windows icon on the webpage and click on the download link that appears below to go to a new page. Then, choose the version you want to download.

image

Here, I chose the "full" version. After downloading, you will get a compressed file. Save the folder obtained after decompression and remember the path to the folder. (You can put it in the directory where you usually install applications and do not delete it.)

Then, open Windows Search and search for "environment variables" to open "Edit the system environment variables".

image

In the window that appears, click on "Environment Variables" and in the new window that pops up, select "Path". Click on "Edit" and in the new window that appears, select "New". Then, enter the directory of the "bin" folder in the folder where you just extracted the compressed file in the edit box.

image

For example, if I just extracted the compressed file and renamed it to "ffmpeg" and placed it in the "D:\Applictions" directory, then I need to enter "D:\Applications\ffmpeg\bin".

Another simple method is to directly open the folder that was just extracted, select the "bin" folder, hold down the Shift key on the keyboard, right-click, and select "Copy as path" from the context menu. Then, paste it into the input box of the new Path. (Note: Delete the surrounding quotation marks)

image

After completing the steps, click "OK" all the way.

If you need to know the installation methods for other systems or more detailed step-by-step instructions, you can refer to this article by VideoProc:

Checking the Installation#

Now we have completed the installation of the two dependencies. Open a terminal and enter the following commands:

python --version
ffmpeg -version

If the version numbers are displayed normally and there are no errors, it means that the installation was successful.

image

Installing spotDL#

The next steps are relatively simple. Continue to operate in the terminal and enter the following command:

pip install spotdl

To upgrade spotDL in the future, simply enter any of the following commands:

pip install --upgrade spotdl
pip install -U spotdl

Using spotDL#

As mentioned earlier, all usage of spotDL occurs in the terminal, and different functions can be called using different commands (if you don't want to remember, just copy and paste).

File Saving Location#

By default, spotDL saves songs in the current working directory. You can use the pwd command in the terminal to check the current working directory. It is recommended to cd to the desired location before starting the download to avoid cluttering your user folder with a bunch of messy files.

If you don't understand what I just said, don't worry. Taking the Windows system as an example, you just need to create the folder where you want to save the downloaded songs, and then, inside that folder, hold down Shift and right-click, then select "Open PowerShell window here" or any other terminal option.

image

For example, in the image above, the downloaded files using spotDL will be saved in the directory D:\Download(D)\Music.

Downloading Songs, Albums, Artists, and Playlists#

Downloading individual songs, albums, artists, and playlists from Spotify is the simplest way to use spotDL. Just copy the share link from Spotify:

image

Then, in the terminal, use spotdl <url>. For example, if I want to download the song "QUEEN" by my little airport, the command would be:

spotdl https://open.spotify.com/track/5PimlePLQd8xdf7uKccHqS

Similarly, the format spotdl <url> can be used for album, artist, and playlist links. If you want to download the content of multiple URLs at once, just add a space between the URLs.

For example, here I am downloading two songs:

image

By default, spotDL uses 4 threads for downloading, so downloading albums, playlists, or multiple songs at once is more efficient than downloading one song at a time.

After the download is complete, you can see the songs in the current working directory. If the songs are fine, the generated cache files can be deleted.

Searching and Downloading by Song Name#

Another method is to download songs by searching for their names. Although this method is not recommended, for some songs that are not easily confused with others, it is convenient to occasionally use this method.

spotdl '[songQuery]'

Using the previous example, to download "QUEEN" by my little airport, you just need to enter:

spotdl 'my little airport - queen'

The download will be successful as well.

image

Downloading with Specified YouTube Videos and Spotify Metadata#

To deal with cases where spotDL fails to recognize a song (which rarely happens), but we can find the corresponding song on YouTube, we can manually let spotDL download the song from YouTube, convert it to an audio format, and write the metadata of the song from Spotify. The usage is as follows:

spotdl "<YouTube url>|<Spotify url>"

Using this method, the sound of the song comes from the specified YouTube video or music, and the metadata comes from the specified Spotify track.

There are many other usage methods, including specifying the download threads, audio format, resuming interrupted downloads, etc., which are also detailed in the project's README. I won't go into detail here.

Conclusion#

For various well-known reasons, sometimes our favorite artists suddenly become unavailable in China, so I have the habit of regularly saving offline files of frequently listened songs. Domestic music platforms have issues with censorship and incomplete copyright coverage, while foreign music platforms often do not include some popular Chinese music due to regional differences. After comprehensive use, the method of downloading music using spotDL is very suitable for me. However, I want to emphasize that the sound quality of the music files is indeed sufficient for someone like me who just wants to listen. There are definitely many other methods to download music files, but this is the one I have found so far that has the most complete music file information and is the most convenient once you become familiar with it.

Recently, I set up a directory on OneDrive and uploaded all the songs by my little airport. Here is the link to share: my-little-airport. Currently, mla has basically disappeared in mainland China. You can download the songs and upload them to the NetEase Cloud Music cloud drive as a temporary solution. However, if conditions permit, please support the artists we like by listening to their music on platforms like Spotify, YT Music, or Apple Music in other regions.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.