Swiftpack.co - Package - simonmeusel/MuteSpotifyAds

MuteSpotifyAds

size download size macOS version support

This is a native and efficient macOS application automatically silencing ads on the Spotify desktop app.

This application is very CPU and power efficient, since it only checks for an ad when a new song gets played.

You can also enable a endless private Spotify session, see below.

Usage

Instead of running Spotify directly, start this application. It will automatically run Spotify. Furthermore it will mute any ads it sees. When you close Spotify this program will also terminate, and thus it no longer has any effect on your battery or CPU.

Installation

  1. Download this application from the releases page
  2. Move it to your Applications folder
  3. Run it using Right Click -> Open. You need to do this because I don't pay Apple $99 every year.
  4. If you like the app, leave a star!

This application is tested on macOS High Sierra (10.13.5) with Spotify 1.0.85.257.g0f8531bd.

To uninstall the application, you can simply trash MuteSpotifyAds.app.

How is it so efficient?

⚠️ Because of a Spotify bug, pausing and playing a ad every 4 seconds is implemented. This requires polling, but only when ads actually play. This will be resolved when the Spotify bug gets fixed. See #4.

Whenever the track changes, the following file will get modified by Spotify:

# When a song plays next
~/Library/Application Support/Spotify/Users/($SPOTIFY_USER_NAME)-user/recently_played.bnk
# When a ad plays next
~/Library/Application Support/Spotify/Users/($SPOTIFY_USER_NAME)-user/ad-state-storage.bnk

This application simply watches for a change at those files and then runs the following apple script, to detect ads:

tell application "Spotify" to (get spotify url of current track)

If the Spotify URL starts with spotify:ad, the volume will be set to 0. Once a normal track plays, your initial volume will be restored (if you haven't already enabled sound man).

To set and get the volume, the following apple script is used:

tell application "Spotify" to (get sound volume)
tell application "Spotify" to set sound volume to ($VOLUME)

Using those techniques, it uses only 0.4% CPU when the track changes (rate: 5 seconds), and 0% in idle. It has a energy impact of less than one tenth of Spotify when the track changes, and a energy impact of 0.0 - 0.1 in idle.

This application does not use any hacks, its simply accesses Spotify's apple script API and look for file changes.

Endless private Spotify session

You can also use this application to enforce a endless private session. This requires administrative privileges. To enable them, go to System PreferencesSecurity & PrivacyPrivacy tab → Accessibility → Click the check mark next to this application.

To enable/disable the endless private session, click the ☀︎ in the status bar of your mac, and then click ∞ Private session. This will ensure that the Spotify private session is enabled whenever the current song changes.

The state of the endless private session will be saved and restored on program restart.

This application enables the private session using the following apple script:

tell application "System Events" to tell process "Spotify"
    tell menu bar item 2 of menu bar 1 -- AppleScript indexes are 1-based
        tell menu item "Private Session" of menu 1
            set isChecked to value of attribute "AXMenuItemMarkChar" is "✓"
            if not isChecked then click it
        end tell
    end tell
end tell

Contributing

If you want to contribute, feel free to do so. If you need help, just open a issue.

You can also contribute by adding support for another language. To do so, clone the repo, and then follow the instruction from this image. Then add the translations and open a pull request.

Currently supported languages are:

  • English
  • German

Alternatives

Linux

I you want this functionality on Linux, I have found but not tested! the following program: https://github.com/SecUpwN/Spotify-AdKiller

Windows

I you want this functionality on Windows, I have found but not tested! the following program: https://github.com/Xeroday/Spotify-Ad-Blocker/

macOS

This application is a alternative to Spotifree. Spotifree uses constant polling every 0.3 seconds. This results in a CPU constant drain of around 4% and a energy usage of about one fourth of the one from Spotify.

Although I created this application and had the idea to use apple script and file watching on my own, looking at the Spotifree source code gave me the idea of using the Spotify url instead of the songs popularity (because the popularity is always 0 for ads).

Thanks

Thanks to Artem Gordinsky and the other contributors of Spotifree! Thanks to vadian for the help!

License

GNU General Public License v3.0

Copyright (C) 2018 Simon Meusel

Github

link
Stars: 7
Help us keep the lights on

Dependencies

Used By

Total:

Releases

v1.4.1 - Aug 14, 2018

ℹ️ Installation guide

  • Support for macOS 10.12 #6

v1.4.0 - Aug 13, 2018

Installation guide

  • Localization #5

v1.3.1 - Aug 13, 2018

Add hotfix for spotify bug #3 #4

v1.3 - Jun 30, 2018

v1.2 - Jun 28, 2018

Add endless private session feature