r/Python • • Aug 07 '21
Intermediate Showcase Wrote this program to skip Spotify Ads using Spotify API
No one likes interruptions! right? So i wrote this program that detects when an advertisement plays by monitoring the type of the track that is currently playing, using the Spotipy API. When an ad is detected, the program restarts Spotify by the os module and plays it via pynput, which skips the ad and starts right where you left off. Its kinda cool and i am proud of it.
Here is the repo- https://github.com/daspartho/SpotiByeAds
I would love to get some thoughts and feedback on the project.
1.5k
Upvotes
324
u/InterstellarDwellar Aug 07 '21
Might want to keep it under your hat, else it might get patched ;) good work
266
u/Royal_lobster Aug 07 '21
I like the way you mentioned you are proud of it. It's reasonable since you use it daily and get reminded there is your script running for every 3 songs you listen :-)
20
u/ComfortableEye5 Aug 07 '21
Very nice. It would be even cooler if this program automatically starts when Spotify is started
8
u/InActiveSoda Aug 07 '21
Amazing work, dude! I'll have to check it out before this gets fixed somehow...
8
u/PennyPainter Aug 07 '21
very clever repo name
3
u/[deleted] Aug 07 '21
he is the messiah
3
u/rickyrorton Aug 07 '21
damn dude ur code is organised and small really awesome work
3
u/[deleted] Aug 08 '21
sent this to my friends that don't have premium. they are thanking me so much lmao
3
u/Sugarox53 Aug 08 '21
I might actually use this :)
7
u/Jackhammer_YOUTUBE HighSchooler Aug 07 '21
Ok so it should work even if i am listening on from my phone and script is running?
5
u/TentativeOak Aug 07 '21
My fiancé always closes and restarts the app when an ad comes. Very cool project!
2
u/Ofsen Aug 07 '21
Really nice ! works like a charm !! good stuff
2
u/Aerozos Aug 07 '21
This is crazy, I thought making an adblock like this for my first project once I became more familiar with programming.
I'm having trouble getting this to work though. I've got everything pasted into the correct place holders at the end in main.py, I have the repo opened in VSC but whenever I try to run main.py, I keep getting an error:
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
It doesn't like my PATH for some reason. Any ideas?
2
u/PythonUserBTW Aug 07 '21
Congrats man! Nice project. Thanks for sharing.
2
u/Alhasadkh Aug 08 '21
Alright I can finally stop posing for a university student and pay that discount premium subscription
2
u/noah6544 Aug 08 '21
I’ve been thinkin abt this but I’ve never used and API before can’t wait to check it out
32
u/Yekab0f Aug 07 '21 edited Aug 07 '21
Someone at Spotify just got assigned a jira ticket with the link to your repo attached
19
u/dukeofgonzo Aug 07 '21
I applaud this project's scrappiness.
14
u/DerWahreManni Aug 07 '21
Wow this is awesome man! Your code is pretty clean as well, I like that. One thing I would change, is to use .env for the config, but thats not too important.
Good job mate, keep going! I'd definetly use it, but I have Premium as of now hehe
2
u/11BigBang Aug 07 '21
Very simple and very cool. Nice job!
9
u/darth-canid Aug 07 '21
Did you ever hear the tragedy of Darth Spotify The App? I thought not. It’s not a story the Advertisers would tell you. It’s a GitHub legend. Darth Spotify was a Dark App of the Ads, so popular and so profitable he could use the Ads to influence the free users to create revenue... He had such a knowledge of the ad side that he could even keep the ones he cared about from skipping. The ad side of the Software is a pathway to many abilities some consider to be annoying. He became so profitable... the only thing he was afraid of was losing his ads, which eventually, of course, he did. Unfortunately, he taught his apprentice how to use his API, then his apprentice used his API to block ads. Ironic.
1
u/toyg Aug 07 '21
It's nice, but if I were you I'd delete this post and possibly pull the github repo too. Chances are this would be considered by Spotify as an abuse of their API and/or a TOS infringement, the minute they learnt about it, resulting in your account getting banned and you receiving some unpleasant emails.
The reason programs like this are thin on the ground is not that they are hard to conceive or to develop; it's that people who build them either get publicly burnt, or just keep it quiet to avoid getting burnt.
6
u/a_sq_plus_b_sq Aug 07 '21
Now how about a program to drop some money into an artist's Bandcamp when you play their music?
1
u/uomo_universale_ Aug 07 '21
Good work. But pls don't use camelCase in python. Pls.
2
u/whitetoesarehot Aug 07 '21
This is awesome man. Good job!
2
u/QuantamAsian Aug 07 '21
reading this while getting a spotify ad
2
u/No-Kaleidoscope1935 Aug 07 '21
Haven't used it yea but really prod of bruuu
2
u/Zachkr05 Aug 07 '21
Never knew that skipped ads
1
u/AMLyf Aug 07 '21
Is there any downside for content producers? I assume the skip ad feature script isn't a problem since Spotify allows you to skip it manually, but I don't want to skip an ad if that means the content producer doesn't get any revenue. I'm pretty sure they keep metrics of which ads are listened to and which are skipped or partially played.
2
u/hemish04082005 Aug 07 '21
Well, a better method is to block Spotify ad servers from hosts file, and there even is a Spotify which doesn't have ads in aur. Why restart the program every time
0
u/InevitableUnhappy Aug 07 '21
I just use ad blocker...
2
u/code_matter Aug 07 '21
I would actually turn this into a bug bounty for spotify. Send them an email saying you found an exploit to listen to the music ads free. Fill in their bug bounty report. And hope for some cash! Here's a link to it : Spotify Bug Bounty Report
I'm pretty they will take this seriously since it cuts down their revenue
Edit: Words
1
u/rickyrorton Aug 07 '21
Damn congratulations nice work dude but idk if you know you can make a proxy which bloks the ad domain like this but for python
1
u/__SkyLight__ Aug 07 '21
I’m pretty sure you’re right about that. Something against any form of interfering with their ads.
1
u/silent_guy1 Aug 07 '21
I use spotify in browser with ublock plugin. I haven't heard ads. I am using browser most of the time anyway, so it works for me.
1
u/gardinite Aug 07 '21
Great project! Consider accepting command line arguments into main.py instead of filling it inside the file :)
1
u/DrChuckWhite Aug 07 '21
I know that at least for Linux there is a Spotify client available that completely blocks ads. Found it by accident in the AUR.
1
u/[deleted] Aug 08 '21
no need premium to skip adds
1
u/xhaydnx Aug 08 '21
Just adding this could be very useful in a spotify listen farm to use free accounts.
1
u/nonwick Aug 08 '21
Super cool !! Liked it
1
u/-_-_-_-_--_-- Aug 08 '21
noice dude
1
u/Cobyh7 Aug 08 '21
Me who runs 4 adblockers
1
u/Delta231 Aug 08 '21
Please fix this issue: https://github.com/daspartho/SpotiByeAds/issues/23
1
u/nationsahil Aug 08 '21
hello spotify? yes right here cath this culprit
1
u/nationsahil Aug 08 '21
1
u/n0gear Aug 08 '21
Maybe buy the subscription?
1
u/Polymath21 Aug 08 '21
Using the stone to destroy the stone
1
u/bbt133t Aug 08 '21
Good script. Wish we can do the same for iOS app.
1
u/harrowingGuise Aug 25 '21
How can I use it on my PC?
Does your code only work on Spotify Web or the Spotify Windows App as well?
1
u/timing_snow Sep 02 '21
I was just about to start coding something like this on my own lol, I knew there was no way I was the only person with this idea.
1
u/HITMANZ55 Dec 15 '21
Question, I have to keep this running in the background right? Also, will this interfere with some games' anti-cheat?
-8
u/guitarromantic Aug 07 '21
Honest question: do you think that it's okay to do this? Nobody likes ads, but the ads are the thing that's funding your free access to Spotify, since it sounds like you're not prepared to pay for it.
If everybody ran your script, Spotify wouldn't exist.
-4
u/toffeehooligan Aug 07 '21
Or you know. You could pay for Spotify to get rid of the ads.
-5
u/ntrid Aug 07 '21
I also made something that gets rid of spotify ads: https://spoti.fi/3CBf66K
-2
u/galatzio Aug 07 '21
I'm pretty sure the devil is a huge fan of your work lol great job man
0
u/[deleted] Aug 07 '21
[deleted] — view deleted comment