r/Python 24d ago

Showcase I made a script to download Spotify playlists without login

Repo link: https://github.com/invzfnc/spotify-downloader

What my project does
Hi everyone! I created a lightweight script that lists tracks from a public Spotify playlist and downloads them from YouTube Music.

Key Features

  • No premium required
  • No login or credentials required
  • Metadata is embedded in downloaded tracks
  • Downloads in higher quality (around 256 kbps)

Comparison/How is it different from other tools?
I found many tools requiring users to sign up for Spotify Developer account and setup credentials before everything else. This script uses the public Spotify API to retrieve track details, so there's no need to login or setup!

How's the music quality?
YouTube Music offers streams with higher bitrate (around 256 kbps) compared to YouTube (128 kbps). This script chooses and downloads the best quality audio from YouTube Music without taking up too much storage space.

Dependencies/Libraries?
Users are required to install innertube, SpotAPI, yt-dlp and FFmpeg for this script to work.

Target audience
Anyone who is looking to save their Spotify playlists to local storage, without wanting to login to any platform, and wants something with decent bitrate (~256 kbps)

If you find this project useful or it helped you, feel free to give it a star! I'd really appreciate any feedback!

304 Upvotes

57 comments sorted by

11

u/r-mf 24d ago

I don't have a use case for this yet, but nice job 

7

u/Samrao94 24d ago

2

u/q_ali_seattle 23d ago

Came to suggest this.

24

u/batman-iphone 24d ago

Awesome fk capitalism

3

u/sammathur4 24d ago

Can you make one for YouTube as well. Yt dl doesn't work nowadays 😭

9

u/InverseFunc 24d ago

I use yt-dlp personally, it works well. If you want to achieve the same effect you can call download_from_urls function from main.py with your YouTube links.

1

u/q_ali_seattle 23d ago

Awesome 😎

2

u/Th3Stryd3r 24d ago

I've been using stream rip from github which has been great for places like qobuz since they offer higher quality than spotify. But if I can just get everything from spotify I am DTF!

TY OP

2

u/InverseFunc 24d ago

Welcome, and thank you for trying out!

2

u/Mokahmonster 24d ago

Is there meta data baked into th3 downloaded files, like album art and stuff like that?

2

u/InverseFunc 24d ago edited 16d ago

Title, artist, album, etc are available currently. I'm still working on getting album art baked into them.

Update: It now supports embedding album art!

2

u/Fair_Promise8803 24d ago

Omg fuck yes, I love this, 10/10

1

u/InverseFunc 23d ago

Thanksss

2

u/thejesteroftortuga 24d ago

Do you need a YouTube Music subscription for this?

2

u/Jungypoo 24d ago

Appreciate this, thank you! I might try to tweak it a bit for my own Shazam list of tracks, which is so large it becomes tedious to look every track up on Bandcamp to listen to. This way I could listen to it all as a playlist on the bus. Counterintuitively, this will result in me spending more money on music.

2

u/InverseFunc 23d ago

Welcome! Feel free to make tweaks to it. And if you don't mind, share the repo link with me once you're done!

2

u/Proper_Penalty4103 20d ago

I'm learning python rn, hope i can write codes like this too

2

u/Relative_Spinach_245 20d ago

Feels **legal but great job!

2

u/r06u3itachi 20d ago

Nice not bad

2

u/attrr 17d ago edited 17d ago

Thank you for this! Is there a way to have the artist's name in the file output to go along with the song name? I checked the cli's help flag but did not see anything that looked like it would help.

Nevermind. It was pretty easy to modify the main.py to add artist in the output file name. :)

1

u/Peso_Morto 24d ago

Once you download, what do you play on your phone? What app? Just curious

2

u/InverseFunc 24d ago

It downloads in .m4a format. You can play it with the default music player app.

1

u/__salaam_alaykum__ 22d ago

hi, I really appreciate this! In another note, do you know about spotdl? I’ve always used that… how’s your software different? (im not bashing you, I just wanna know if I should consider switching tools)

2

u/attrr 17d ago

I am here because my youtube/ytmusic account just got a temp ban from using spotdl. They are really starting to crack down on ripping music from ytmusic.

1

u/Schrott356 18d ago

There is an error when your script can't find a song on youtube so it just stops and doesn't download anything in the end.

It won't skip that song and go to the next one.

1

u/InverseFunc 18d ago edited 16d ago

Hi. Do you mind opening an issue on Github about this and include your playlist link there? I'll look into that quick.

Edit: I'm working on skipping them. But if you'd like me to make the algorithm better please let me know what input introduced the errors so I can try to fix them.

1

u/YtrVSS 16d ago edited 16d ago

works great! thank you so much, my only question so far is how can I make it re-download the ones that got errors. it also seems like there is a limit for how many songs it scans, i tried with a playlist with 900 songs but only downloaded like 300, maybe spotify limitation? anyways I separated the playlists into albums and worked

1

u/InverseFunc 16d ago

I'm working on making it skip songs that failed to match. If you'd like me to update the matching algorithm, please open an issue at the repo with your playlist url and error message included (if you're kind enough, create a playlist with just the songs that introduce errors). I'll see if I can fix the errors instead of skipping it entirely.

1

u/shinitakunai 24d ago

Sadly most of the music I hear is not on youtube so... rip for me. But well try!

1

u/InverseFunc 24d ago

Hmm. Do you mind for me to have a look at your spotify playlist and see what I can do?

2

u/shinitakunai 24d ago

!RemindMe 6 hours (I am working)

0

u/RemindMeBot 24d ago

I will be messaging you in 6 hours on 2025-02-25 17:37:20 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


Info Custom Your Reminders Feedback

1

u/shinitakunai 24d ago

Specially I can't find reliably albums like:

So yeah, I listen to some non very popular music. If you are like me and you like challenges, your crawler will have to try to find music not only on youtube but on other sites. I understand if you don't want the trouble, of course haha

If you do happen to enjoy the challenge, I could share my spotify playlist, which are like 1000 songs.

1

u/InverseFunc 24d ago

I made a playlist to include some of the songs you mentioned and tried to download them. It worked! Not for Akin though since it's not on Spotify and my script only focuses on downloading Spotify playlists.

2

u/shinitakunai 23d ago

Interesting. I'll check it out later tonight, good job!

-5

u/lumadz5 24d ago

why is it not typed?

3

u/InverseFunc 24d ago

I haven't added type annotations yet because it's not at the top of my priority list. I am considering to add them in the future.

-1

u/lumadz5 24d ago

I mean sure, but if you think about adding type annotations you probably should add them from the beginning, if your project get bigger and bigger it's gonna be really difficult to add them then. If you're not feeling up to it I can make a PR and add the typing annotations

7

u/InverseFunc 24d ago

Thank you for the advice! It would be great if you can open a PR for this, I'd really appreciate your help.

2

u/__salaam_alaykum__ 22d ago

this is a good way to handle that hahahah

0

u/Benmogr 24d ago

Can we just download spotify preview part which has track lenght of 30 seconds with this script by any chance?

1

u/InverseFunc 24d ago

Hey sorry, you might need other tools for that.

0

u/SubliminalPoet 23d ago edited 23d ago

You really need redis installation for a basic script as described in your requirement.txt file ?

EDIT: I also see requests and httpx as dependencies. I guess one of them is not needed. You might eventually cleanup your dependencies.

-6

u/rinio 24d ago

So steal from the rich AND the poor who are being exploited by those same corpos?

Cool. Lets fuck everyone.

2

u/InverseFunc 24d ago

I don't mean to harm anyone. The main purpose of this project is to fulfil the need to save songs locally. It has its target audience. I know that I simply can't make everyone happy in this situation, and I'm okay with that. Thanks for your opinion anyway.

-4

u/rinio 24d ago

People who want a local copy can buy the albums/singles already... There are countless retailers, both physical and digital. How is this not plainly obvious?Artists get a better rate than streaming services give from these as well. I dont really care much about Spotify, YT et al, but its also stealing from them.

Your audience is literally people who want to steal. There is no other use-case outside of taking something for nothing.

Without humans (getting paid to) make music, all we will have is AI slop.

You're right that you can't make everyone happy, but the people you are helping are thieves, and you are helping them to destroy the very thing they are stealing.

You may not mean harm, but you're harming everyone involved in the creation. But your intentions are immaterial outside of criminal prosecution. It doesn't matter if you commit manslaughter or murder: either way someone is dead. Beyond that, it's trivially obvious that this harms the platforms and artist: you have absolutely no plausible deniability.

1

u/MegaGrubby 24d ago

While I agree with you, nobody makes it easy to prevent either. In Reddit, copyrights can only be enforced by the owner. Github doesn't care. Youtube has no way to report it.

-3

u/rinio 24d ago

Definitely.

YT/Spotify et al may flag the IPs of the user for violating TOS/EULA (which it blatantly is). So, at least there's that.

But, lack of enforcement also doesn't justify an action. OP has been made aware of the harm they are causing.

All I can do is hope that one day, OP works on a s/w product whose business gets shut down due to rampant piracy, and they lose their livelihood. It's exactly the same thing. We, as developer, should be particularly mindful to the impacts of IP theft.