Skip to content

Replaced spotipy with a non-api library#2626

Open
TzurSoffer wants to merge 9 commits intospotDL:masterfrom
TzurSoffer:master
Open

Replaced spotipy with a non-api library#2626
TzurSoffer wants to merge 9 commits intospotDL:masterfrom
TzurSoffer:master

Conversation

@TzurSoffer
Copy link
Copy Markdown

@TzurSoffer TzurSoffer commented Mar 15, 2026

Title

Due to recent changes in Spotify, the api is no longer useful to non-premium users, therfore I have replaced it.

Description

I have made a wrapper to spotAPI, which functions as a drag-n-drop replacement to spotipy, it not perfect, but it has fixed spotdl.
To install working verison run pip install git+https://github.com/TzurSoffer/spotify-downloader
If this helped you a star to my fork and bump would be appreciated to help promote this fix.

Related Issue

#2621
#2617

Motivation and Context

It solves the problem of the app not working without Spotify Premium.

How Has This Been Tested?

I have tested both playlists and individual songs.

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the CONTRIBUTING document
  • I have added tests to cover my changes
  • All new and existing tests passed

@TzurSoffer
Copy link
Copy Markdown
Author

I currently have a hardcoded variable in the Spotify.py file, but this should be a config option. I tried to make it a config option, but I am unfamiliar with this code and couldn't.

@TzurSoffer
Copy link
Copy Markdown
Author

Hey, is there any progress towards merging this PR?

@DylanBPY
Copy link
Copy Markdown

This branch works on my system

@DylanBPY
Copy link
Copy Markdown

@TzurSoffer Have you seen this?

@TzurSoffer
Copy link
Copy Markdown
Author

if you see that error, you didnt install my fork as it does not use api.spotify.com...
if you do spotdl --version does it print 4.4.5 or 4.4.3?

@gripfastistech
Copy link
Copy Markdown

if you see that error, you didnt install my fork as it does not use api.spotify.com... if you do spotdl --version does it print 4.4.5 or 4.4.3?

4.4.5

I had too many pre-existing versions hanging around, was pointing back to the previous .local install.

After removing everything spotdl related, reinstalled again from the fork, and its processing, without the error so far.

Thanks!

@sidelkins
Copy link
Copy Markdown

Works on my system! Thanks!

@m111k333
Copy link
Copy Markdown

works very well,thank you!

@ciangottinim
Copy link
Copy Markdown

ciangottinim commented Mar 26, 2026

I tried it with the "artist" option and it doesn't work, I don't know if I'm doing something wrong or not; I run the command on a linux headless server, I attached the command and the error here:

Command: spotdl download artist:X --headless --output {artist}/{album}/{title}.{output-ext} --format m4a
Error: error.txt

@TzurSoffer
Copy link
Copy Markdown
Author

Artists are not yet supported, download a playlist with all his songs instead for now

@taco-mustard
Copy link
Copy Markdown

taco-mustard commented Mar 27, 2026

Thanks, it works pretty well! Just running into a couple errors at the moment (running this on mac):

  1. Trying to download spotify playlist from youtube playlist of same length via spotdl "{youtube playlist url}|{spotify playlist url}" results in AttributeError: 'Downloader' object has no attribute 'download_url'
  2. Downloading spotify playlists of over about 30 songs (after using command ulimit -n 10000) results in AudioProviderError: YT-DLP download error

@TzurSoffer
Copy link
Copy Markdown
Author

@taco-mustard Please provide the commands as well as the output from the terminal so I can fix replicate it

@taco-mustard
Copy link
Copy Markdown

taco-mustard commented Mar 27, 2026

This was the code that led to the AttributeError
spotdl "https://www.youtube.com/playlist?list=PL7fDRdzfbWcwVwup1gMdeO46S7-lMwFG2|https://open.spotify.com/playlist/2G42OAnMtsPSeUDmsC9TBt?si=UIpV6CXnRA-yrDnkf0bfhA"

This was the output

Found 121 songs in dl_songs (Playlist)                                                                                                                                                                                 
AttributeError: 'Downloader' object has no attribute 'download_url' ```

@TzurSoffer
Copy link
Copy Markdown
Author

TzurSoffer commented Mar 27, 2026

@taco-mustard It possible that youtube is bugged, I dont have time to fix it rn. for now, you can do
spotdl "https://open.spotify.com/playlist/2G42OAnMtsPSeUDmsC9TBt"
if you have trouble with yt-dlp, update it pip install -U yt-dlp

@taco-mustard
Copy link
Copy Markdown

changing candidate_urls = [self.download_url] to candidate_urls = [song.download_url] in line 716 of spotdl/download/downloader.py appears to fix the issue for me

@TzurSoffer
Copy link
Copy Markdown
Author

changing candidate_urls = [self.download_url] to candidate_urls = [song.download_url] in line 716 of spotdl/download/downloader.py appears to fix the issue for me

You are %100 right, fixed it and gave you credit. Thanks a lot!

@EvanBelcher
Copy link
Copy Markdown

I am trying to use this programmatically as follows:

spotdl = Spotdl(client_id=config['SPOTIFY_CLIENT_ID'], client_secret=config['SPOTIFY_CLIENT_SECRET'], downloader_settings={**config_file_options, 'output': os.path.join(config['SPOTIFY_DOWNLOAD_LOCATION'], '{artists} - {title}.{output-ext}')})

This code was working for me before Spotify changed its API and I downloaded your fork. Now I'm getting the below error:

  File "/home/evan/compose/spotcron/spotify.py", line 202, in <module>
    main(args)
    ~~~~^^^^^^
  File "/home/evan/compose/spotcron/spotify.py", line 40, in main
    process_tracks(config, tracks)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/home/evan/compose/spotcron/spotify.py", line 47, in process_tracks
    downloaded_tracks = download_tracks(config, tracks)
  File "/home/evan/compose/spotcron/spotify.py", line 65, in download_tracks
    spotdl = get_spotdl(config)
  File "/home/evan/compose/spotcron/spotify.py", line 89, in get_spotdl
    return Spotdl(client_id=config['SPOTIFY_CLIENT_ID'], client_secret=config['SPOTIFY_CLIENT_SECRET'], downloader_settings={**config_file_options,
'output': os.path.join(config['SPOTIFY_DOWNLOAD_LOCATION'], '{artists} - {title}.{output-ext}')})
  File "/home/evan/compose/spotcron/venv/lib/python3.13/site-packages/spotdl/__init__.py", line 83, in __init__
    self.downloader = Downloader(
                      ~~~~~~~~~~^
        settings=downloader_settings,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        loop=loop,
        ^^^^^^^^^^
    )
    ^
  File "/home/evan/compose/spotcron/venv/lib/python3.13/site-packages/spotdl/download/downloader.py", line 174, in __init__
    found_files = gather_known_songs(self.settings["output"], scan_format)
  File "/home/evan/compose/spotcron/venv/lib/python3.13/site-packages/spotdl/utils/search.py", line 616, in gather_known_songs
    search_results = get_search_results(path.stem)
  File "/home/evan/compose/spotcron/venv/lib/python3.13/site-packages/spotdl/utils/search.py", line 76, in get_search_results
    return Song.list_from_search_term(search_term)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/home/evan/compose/spotcron/venv/lib/python3.13/site-packages/spotdl/types/song.py", line 193, in list_from_search_term
    raw_search_results = Song.search(search_term)
  File "/home/evan/compose/spotcron/venv/lib/python3.13/site-packages/spotdl/types/song.py", line 152, in search
    raw_search_results = spotify_client.search(search_term)
  File "/home/evan/compose/spotcron/venv/lib/python3.13/site-packages/SpotipyFree/Spotify.py", line 221, in search
    results = spotapi.Search().search(query)["data"]
              ^^^^^^^^^^^^^^
AttributeError: module 'spotapi' has no attribute 'Search'

@TzurSoffer
Copy link
Copy Markdown
Author

I am trying to use this programmatically as follows:

spotdl = Spotdl(client_id=config['SPOTIFY_CLIENT_ID'], client_secret=config['SPOTIFY_CLIENT_SECRET'], downloader_settings={**config_file_options, 'output': os.path.join(config['SPOTIFY_DOWNLOAD_LOCATION'], '{artists} - {title}.{output-ext}')})

Searching is broken, you have to use the url or id for now

@EvanBelcher
Copy link
Copy Markdown

Searching is broken, you have to use the url or id for now

Ah gotcha, thanks for the help. Based on this, I had to make these changes to get it working

  1. I had to set scan-for-songs to false in my config.json. This is what was actually triggering the above error when initializing spotdl
  2. I originally was getting songs like this:
songs = spotdl.search(track_urls)
results = spotdl.download_songs(songs)

I had to change it to this:

songs = [Song.from_url(url) for url in track_urls]
results = spotdl.download_songs(songs)

I suppose I should have been doing this from the beginning given that I already had the track URLs, but I incorrectly assumed searching with the urls would just do this under the hood.

@TzurSoffer
Copy link
Copy Markdown
Author

Searching should now work. If it doesn't, please update SpotipyFree
pip install -U spotipyFree

Copy link
Copy Markdown

@Gr3gory Gr3gory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works!
(macOS brewed-python installation)

@adocampo
Copy link
Copy Markdown

adocampo commented Apr 1, 2026

hopefully this will be merged soon

@yonka2019
Copy link
Copy Markdown

how do i run this version? the uv run build actually crashes

@TzurSoffer
Copy link
Copy Markdown
Author

pip install git+https://github.com/TzurSoffer/spotify-downloader

@yonka2019
Copy link
Copy Markdown

it do installs the packages but nothing run

@TzurSoffer
Copy link
Copy Markdown
Author

Do python -m spotdl url

@yonka2019
Copy link
Copy Markdown

oh got it.
The version works perfectly, you're god
Thanks!

@JonneSaloranta
Copy link
Copy Markdown

Seems to work well with spotify playlist links.
First had an issue with songs not downloading but I updated yt-dlp package as suggested and now it works.

@taco-mustard It possible that youtube is bugged, I dont have time to fix it rn. for now, you can do spotdl "https://open.spotify.com/playlist/2G42OAnMtsPSeUDmsC9TBt" if you have trouble with yt-dlp, update it pip install -U yt-dlp

@mborn1
Copy link
Copy Markdown

mborn1 commented Apr 2, 2026

It did not work using pip install for me, however, cloning the forked repo and building with uv did work for me (also after upgrading yt-dlp version).
Starred the fork, hope it gets merged soon.

My configuration

Command (with uv environment active)

  • python -m spotdl [playlist url]

Spotify environment

  • Created dev app (today)
  • Set both http://127.0.0.1:9900 and http://127.0.0.1:9900/ as the redirect URIs
  • Added my premium account to the permitted users
  • Altered ~/.config/spotdl/config.json to include my client_id, clent_secret, and port = 9900

System specs

  • Ubuntu 24.04 LTS - kernel 6.17.0-19-generic
  • Python 3.12.3
  • uv 0.11.1 (a6042f67f 2026-03-24 x86_64-unknown-linux-gnu)

@elktonsgay2025
Copy link
Copy Markdown

When attempting to install your version I am now getting this;
ERROR: Error [Errno 2] No such file or directory: 'git' while executing command git version
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?

@TzurSoffer
Copy link
Copy Markdown
Author

Either install git or download the repo as zip, unzip it, and run pip install . in the folder

@elktonsgay2025
Copy link
Copy Markdown

My apologies for so many comments, still learning this. When I install your thread and run python -m spotdl I get this right afterwards, no downloads;

Traceback (most recent call last):
File "", line 189, in _run_module_as_main
File "", line 148, in _get_module_details
File "", line 112, in _get_module_details
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/spotdl/init.py", line 13, in
from spotdl.console import console_entry_point
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/spotdl/console/init.py", line 5, in
from spotdl.console.entry_point import console_entry_point
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/spotdl/console/entry_point.py", line 12, in
from spotdl.console.download import download
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/spotdl/console/download.py", line 7, in
from spotdl.download.downloader import Downloader
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/spotdl/download/downloader.py", line 20, in
from spotdl.download.progress_handler import ProgressHandler
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/spotdl/download/progress_handler.py", line 23, in
from spotdl.types.song import Song
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/spotdl/types/song.py", line 11, in
from spotdl.utils.spotify import SpotifyClient
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/spotdl/utils/spotify.py", line 217, in
from SpotipyFree import Spotify as SpotifyClient # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/SpotipyFree/init.py", line 3, in
from .Spotify import Spotify
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/SpotipyFree/Spotify.py", line 3, in
import spotapi
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/spotapi/init.py", line 1, in
from spotapi.artist import *
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/spotapi/artist.py", line 4, in
from spotapi.types.annotations import enforce
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/spotapi/types/init.py", line 1, in
from spotapi.types.data import *
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/spotapi/types/data.py", line 4, in
from spotapi.http.request import TLSClient
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/spotapi/http/init.py", line 1, in
from spotapi.http.request import *
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/spotapi/http/request.py", line 4, in
from tls_client.settings import ClientIdentifiers
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/tls_client/init.py", line 15, in
from .sessions import Session
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/tls_client/sessions.py", line 1, in
from .cffi import request, freeMemory, destroySession
File "/data/data/com.termux/files/usr/lib/python3.13/site-packages/tls_client/cffi.py", line 20, in
library = ctypes.cdll.LoadLibrary(f'{root_dir}/dependencies/tls-client{file_ext}')
File "/data/data/com.termux/files/usr/lib/python3.13/ctypes/init.py", line 480, in LoadLibrary
return self._dlltype(name)
~~~~~~~~~~~~~^^^^^^
File "/data/data/com.termux/files/usr/lib/python3.13/ctypes/init.py", line 361, in init
self._handle = self._load_library(name, mode, handle, winmode)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/data/com.termux/files/usr/lib/python3.13/ctypes/init.py", line 401, in _load_library
return _dlopen(name, mode)
OSError: dlopen failed: library "libpthread.so.0" not found: needed by /data/data/com.termux/files/usr/lib/python3.13/site-packages/tls_client/dependencies/tls-client-arm64.so in namespace (default)

@TzurSoffer
Copy link
Copy Markdown
Author

You probably need to install libpthread.so.0

@elktonsgay2025
Copy link
Copy Markdown

Is this not doable on android with termux since the phone isn't rooted?

@TzurSoffer
Copy link
Copy Markdown
Author

Idk, never tested it

@elktonsgay2025
Copy link
Copy Markdown

It seems like this is only working on computers and will not work on termux for android. If anyone has any fixes for that I'm all ears please

@watrd
Copy link
Copy Markdown

watrd commented Apr 3, 2026

Is there anyway to get the lyrics attached into the mp3 file like the way original spotdl does it?
btw good work, it's working fine for me

@TzurSoffer
Copy link
Copy Markdown
Author

TzurSoffer commented Apr 3, 2026

Is there anyway to get the lyrics attached into the mp3 file like the way original spotdl does it? btw good work, it's working fine for me

I am not aware of my app changing anything about the lyrics.
Do you get any errors? What command are you using

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.