fm16191 / spotify-recorder

Recorder for Spotify. Not a YouTube downloader !!!
30 stars 6 forks source link
pulseaudio recorder spotify spotify-downloader spotify-recorder youtube-dl

Spotify-recorder

Spotify-recorder is, as it name suggest a Spotify recorder for Linux. Given a song name, or its share link, starts Spotify, plays and records the song at its best quality, then exits. As simple as that !

Works on both Pulseaudio and Pipewire. Please note that a Spotify client is required

Songs recorded at 320kbps bitrate by default.

FYI, Spotify has a much higher quality than its YouTube equivalent, so I highly recommend it when possible. Check the Why record from Spotify instead of downloading the song from YouTube ? section for more information.

This tool is (for now) Linux exclusive. As long as the dependencies are met, it should work fine.

This tool is in beta stage. Please don't mind if you you encounter a problem, and feel free to open an Issue for any suggestion or bug !

Features :

Features to be added in future :

Dependencies :

Python 3+ with python-dotenv, spotipy and mutagen modules.

packages : mp3splt, ffmpeg, pulseaudio-utils or pipewire-pulse

core-utils : grep, tr

Installation :

git clone https://github.com/fm16191/spotify-recorder.git

cd spotify-recorder

pip install -r requirements.txt

Set up :

Get your Spotify API credentials

  1. Go to Spotify's developper page and create an application.

  2. Go to "Edit Settings"

    • In the "Website" input, put http://localhost:8888
    • In the "Redirect URIs" input, put http://localhost:8888/callback
  3. Edit the .env file and replace YOUR_CLIENT_ID and YOUR_CLIENT_SECRET by your respectives CLIENT_ID and CLIENT_SECRET from the Spotify app just created

Usage :

python3 api.py <song name author> to search and record a song given an input

python3 api.py https://open.spotify.com/track/X to record a song from it's share link

python3 api.py https://open.spotify.com/playlist/X to record all songs from a playlist's share link

Unless given the share link, this will lookup for the query, and if multiple results, ask for one.

Once song identified, Spotify will start, play the song while being recorded, and then quit.

Recommended Spotify setup

Disable all music fading (improve song trimming) spotify_settings_0.png

Improve audio quality spotify_settings_1.png

Recommended pulseaudio setup

Known issues :

Please first refer to the "Recommended Spotify setup" and "Recommended pulseaudio setup" tabs.

Why record from Spotify instead of downloading the song from YouTube ?

  1. Spotify has much better sound quality than YouTube, and the recording hardly affects the quality from what I tested, as long as you follow the "Recommended configuration for Spotify" section.

    For your information, YouTube's audio quality is capped at 128kbps, while Spotify's audio quality defaults to 160kbps, up to 320kbps for premium accounts.

    In addition, YouTube normalizes the audio to further reduce storage, as soon as it is uploaded, an option that can be disabled on Spotify

    (But how much is it a difference ? Unless you don't care much about audio quality, the difference is pretty noticeable. I'll post some experiments I've done to illustrate the difference sometime.)

  2. Some music has an intro on YouTube, which would require post processing to remove it, which is not the case on Spotify
  3. Sometimes the music you're looking for is just not available on YouTube :)