Top Related Projects
Download your Spotify playlists and songs along with album art and metadata (from YouTube if a match is found).
Open Source Spotify client library
Adblocker for Spotify
Protect your privacy by blocking all annoying Spotify ads & analytics in Linux, OSX and Windows with hosts file.
Quick Overview
Spotify-Ad-Blocker is an open-source project that aims to block advertisements on the Spotify desktop application. It works by muting the Spotify client when it detects an advertisement playing, and unmutes it when the regular content resumes. This project is designed for users who want an ad-free Spotify experience without subscribing to Spotify Premium.
Pros
- Provides a free alternative to blocking ads on Spotify
- Easy to install and use
- Works on multiple operating systems (Windows, macOS, Linux)
- Regularly updated to maintain compatibility with Spotify updates
Cons
- May violate Spotify's terms of service
- Does not remove ads entirely, only mutes them
- Potential for false positives, muting regular content
- Requires the application to be running in the background
Code Examples
This project is not a code library, but rather a standalone application. Therefore, there are no code examples to provide.
Getting Started
To use Spotify-Ad-Blocker:
- Visit the GitHub repository
- Download the latest release for your operating system
- Extract the downloaded file
- Run the executable file (e.g.,
SpotifyAdBlocker.exe
on Windows) - Ensure the application is running while using Spotify
Note: Make sure to read the project's README and follow any additional instructions specific to your operating system.
Competitor Comparisons
Download your Spotify playlists and songs along with album art and metadata (from YouTube if a match is found).
Pros of spotify-downloader
- Allows downloading of Spotify tracks for offline listening
- Supports various audio formats and quality options
- Can download entire playlists or albums
Cons of spotify-downloader
- Requires more setup and dependencies
- May have legal implications depending on usage
- Doesn't block ads within the Spotify app itself
Code Comparison
Spotify-Ad-Blocker (C#):
private void BlockAds()
{
foreach (var host in adHosts)
{
hostsFile.AppendLine($"0.0.0.0 {host}");
}
}
spotify-downloader (Python):
def download_track(track_url):
track = spotify.track(track_url)
audio = youtube.search(f"{track['name']} {track['artists'][0]['name']}")
audio.download()
The code snippets show the core functionality of each project. Spotify-Ad-Blocker modifies the hosts file to block ad domains, while spotify-downloader searches for and downloads audio tracks from YouTube based on Spotify metadata.
Both projects serve different purposes: Spotify-Ad-Blocker focuses on improving the user experience within the Spotify app, while spotify-downloader provides a way to obtain offline copies of Spotify tracks. The choice between them depends on the user's specific needs and preferences.
Open Source Spotify client library
Pros of librespot
- Open-source Spotify client library, allowing for more customization and integration possibilities
- Supports multiple platforms (Linux, macOS, Windows, Android)
- Actively maintained with regular updates and improvements
Cons of librespot
- Requires more technical knowledge to set up and use
- May not provide a user-friendly interface out of the box
- Potential for breaking changes due to Spotify API updates
Code Comparison
Spotify-Ad-Blocker (PowerShell):
$spotifyProcesses = Get-Process -Name Spotify
foreach ($spotify in $spotifyProcesses) {
$spotify.CloseMainWindow()
}
librespot (Rust):
let session = Session::connect(config, credentials, None, handle).await?;
let (player, _) = Player::new(config, session, None, move |_| {});
player.load(track, true, 0);
The Spotify-Ad-Blocker code focuses on closing Spotify processes, while librespot provides a more comprehensive API for interacting with Spotify's services. librespot offers greater flexibility and control over the Spotify experience, but requires more complex implementation.
Adblocker for Spotify
Pros of spotify-adblock
- Written in Rust, potentially offering better performance and memory safety
- Uses a more targeted approach by intercepting Spotify API calls
- Actively maintained with recent updates
Cons of spotify-adblock
- Linux-only solution, limiting its user base
- Requires compilation from source, which may be challenging for some users
- More complex installation process compared to Spotify-Ad-Blocker
Code Comparison
spotify-adblock (Rust):
fn hook(func: *const (), hook: *const ()) {
unsafe {
let mut page_size = libc::sysconf(libc::_SC_PAGESIZE) as usize;
let mut addr = func as usize & !(page_size - 1);
libc::mprotect(addr as *mut _, page_size * 2, libc::PROT_READ | libc::PROT_WRITE | libc::PROT_EXEC);
std::ptr::write(func as *mut _, hook);
}
}
Spotify-Ad-Blocker (Python):
def block_ad():
global ad_blocker_on
if ad_blocker_on:
spotify.pause()
time.sleep(1)
spotify.next()
The code comparison shows the different approaches: spotify-adblock uses low-level system calls to intercept Spotify API functions, while Spotify-Ad-Blocker uses higher-level Python commands to control Spotify playback.
Protect your privacy by blocking all annoying Spotify ads & analytics in Linux, OSX and Windows with hosts file.
Pros of SpotifyAdBlock
- More recent updates and active development
- Supports multiple platforms (Windows, macOS, Linux)
- Utilizes a hosts file approach, potentially more effective for blocking
Cons of SpotifyAdBlock
- Requires more setup steps and system modifications
- May interfere with other applications using the same domains
- Less user-friendly for non-technical users
Code Comparison
SpotifyAdBlock:
def block_spotify_ads():
hosts_file = "/etc/hosts"
with open(hosts_file, "a") as f:
f.write("\n# Spotify Ad Blocking\n")
for domain in ad_domains:
f.write(f"0.0.0.0 {domain}\n")
Spotify-Ad-Blocker:
private void MuteAds()
{
if (IsAdPlaying())
{
SetVolume(0);
}
else
{
SetVolume(100);
}
}
The code comparison shows that SpotifyAdBlock modifies the system's hosts file to block ad domains, while Spotify-Ad-Blocker uses a muting approach to silence ads when they play. This difference in implementation reflects the pros and cons mentioned earlier, with SpotifyAdBlock offering potentially more effective blocking but requiring system modifications, and Spotify-Ad-Blocker providing a simpler, less intrusive solution at the cost of still allowing ads to play (albeit silently).
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
EZBlocker
EZBlocker is a Spotify Ad Blocker written in C# for Windows 7/8/10/11. The goal for EZBlocker is to be the most reliable ad blocker for Spotify.
When an advertisement is playing, EZBlocker will mute Spotify until it's over.
To download a pre-compiled binary of the latest version, click here. For more info, visit the EZBlocker project page.
Technical overview
The current version of EZBlocker hooks Spotify in three ways: window titles, audio sessions, and a reverse listener.
Window title
The window title is used to grab the name of the currently playing song/artist/advertisement. EZBlocker also uses the window title to grab the Spotify process handle.
Audio session
Using lower level COM interfaces, EZBlocker is able to both find and extract information from Spotify's audio session.
Firstly, if the Spotify window is hidden (in the tray), its window title cannot be used locate the correct Spotify process handle. In this case, EZBlocker falls back to searching through the audio sessions to find the correct process.
Secondly, the audio session is a somewhat reliable way to detect whether or not a song/advertisement is playing regardless of whether or not the Spotify window is hidden. It can be inaccurate at times, eg. when a song has a 3 second gap of no sound, but can automatically recover.
Reverse Listener
I've historically tried to avoid modifying the Spotify application, but since the shutdown of its unofficial local API (in mid July 2018), there was no reliable way to detect if an advertisement was playing.
Spotify is built with the Chromium Embedded Framework, which means many of its components are written in HTML/JS. EZBlocker patches one of them to attach a web worker that sends a signal to a local listener when an advertisement is playing.
More data could probably be extracted through the web worker, but I haven't had time to explore.
Changelog (Major releases only):
- V 1.8 (Oct 31, 2021):
- New muting logic, reduces false positives (podcasts no longer muted)
- Cleanup and bugfixes
- V 1.7 (July 22, 2018):
- Almost a complete re-write of the application (lighter, more performant, cleaner code)
- New Spotify ad detection and muting logic after Spotify's shutdown of its local API
- V 1.6 (March 10, 2016):
- Better handling of Spotify updates/restarts
- Fix bugs caused by newer Spotify local API
- Update dependencies
- Now requires .NET Framework 4.5
Translations
To better support non-English speakers, I've started an effort to translate EZBlocker. Please reach out if you are a native speaker of a non-English language.
The following are contributors to this goal:
-
Portuguese: RaÃ
Top Related Projects
Download your Spotify playlists and songs along with album art and metadata (from YouTube if a match is found).
Open Source Spotify client library
Adblocker for Spotify
Protect your privacy by blocking all annoying Spotify ads & analytics in Linux, OSX and Windows with hosts file.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot