sosb0ii / Spotify-Mute-Ads

0 stars 0 forks source link

Spotify Ad Muter (Desktop)

This program will mute unskippable ads (or commercials) on Spotify. It is intended for the peace of mind of Spotify Free users who can use the Desktop app.

Installation Guide

This script uses AutoHotkey v1.1, and as such requires the AutoHotkey software, which can be installed from their website. The most updated release can be downloaded directly by clicking here. A version for AutoHotkey v2 may or may not be added as a separate branch in the future. It works only on the Spotify desktop app (which can be installed here), not on the website. When these are installed, the Spotify Ad Muter.ahk file above can be run from any directory while Spotify is open to mute the Ads.

Functionality

This script will first check to see if Spotify is running or not. If not, it will wait one minute before checking again. If Spotify is running, it will retrieve the title of the Spotify window. If the current title is different from the last title (initially set to a blank string, and subsequently reset for new songs) and also not the Spotify Free title which occurs when it is paused, then a new audio is playing.
When a new audio begins playing, the script checks if the - string (present in the Artist - Song format when a song is playing) or the | character (present in many podcast titles) is in the name of the window. If neither is present, an advertisement is playing, and the system sound is muted. If one or both strings are present, then a song or podcase is playing, and the sound is unmuted.
In this way, the script will always and only perform an action when a new audio starts.

Optimization

In order to minimize processing power, when Spotify is not open, the script waits 30 seconds before checking again if it's open. This way, the script can be running when Spotify is not, without continuously looping and checking things. As long as you don't get an ad within 30 seconds of opening the app, it will work fine.
If you wish to further minimize processing power (for whatever reason) you can extend this delay (in line 22) by altering the time (in milliseconds) of the delay. Of course you can also add a delay anywhere you want, but you might compromise the effectiveness of the script.
If you have no concern for minimizing processing power and want to ensure absolute effectiveness of the script, you can comment out (put a semicolon in front of) line 22 or remove it entirely.

Customization

In the near future, a feature will be added for podcast users to help the script identify podcast episodes. To keep a list of episode titles, uncomment lines 12 and 17. Those mistakenly detected as ads will be in a file called Ads.txt and the others will be in a file called SongsPods.txt, all in the same directory.

Issues and Potential Fixes

[!NOTE] The below information is out of date. It will be updated soon.