Top Related Projects
Protect your privacy by blocking all annoying Spotify ads & analytics in Linux, OSX and Windows with hosts file.
SpotX patcher used for patching the desktop version of Spotify
Video, audio & banner adblock/skip for Spotify
EZBlocker - A Spotify Ad Blocker for Windows
Quick Overview
Spotify-adblock is an open-source project that aims to block advertisements in the Spotify desktop application for Linux. It works by intercepting and modifying network requests made by the Spotify client, effectively preventing ads from being served to the user.
Pros
- Provides ad-free Spotify experience without a premium subscription
- Works with the official Spotify desktop client for Linux
- Lightweight and easy to install
- Regularly updated to maintain compatibility with Spotify updates
Cons
- Only available for Linux systems
- May violate Spotify's terms of service
- Potential for breakage if Spotify changes its ad-serving mechanism
- Doesn't work with the web player or mobile versions of Spotify
Getting Started
-
Clone the repository:
git clone https://github.com/abba23/spotify-adblock.git cd spotify-adblock
-
Build the project:
make
-
Install the adblock library:
sudo make install
-
Create a desktop entry to launch Spotify with the adblock:
cp spotify-adblock.desktop ~/.local/share/applications/
-
Launch Spotify using the new desktop entry, which will now block ads.
Note: Make sure to keep the project updated by periodically pulling the latest changes from the repository and rebuilding.
Competitor Comparisons
Protect your privacy by blocking all annoying Spotify ads & analytics in Linux, OSX and Windows with hosts file.
Pros of SpotifyAdBlock
- Supports multiple platforms (Windows, macOS, Linux)
- Provides a user-friendly GUI for easy configuration
- Regularly updated with new features and improvements
Cons of SpotifyAdBlock
- May require more system resources due to the GUI
- Installation process can be more complex for some users
- Potential for compatibility issues with certain Spotify versions
Code Comparison
spotify-adblock:
static int (*real_connect)(int sockfd, const struct sockaddr *addr, socklen_t addrlen) = NULL;
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) {
if (addr->sa_family == AF_INET) {
struct sockaddr_in *addr_in = (struct sockaddr_in *)addr;
char ip[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &(addr_in->sin_addr), ip, INET_ADDRSTRLEN);
if (is_blocked(ip)) {
errno = ECONNREFUSED;
return -1;
}
}
return real_connect(sockfd, addr, addrlen);
}
SpotifyAdBlock:
def block_ads(proxy_port):
def request_handler(req, req_body):
if is_ad_request(req.path):
return {'body': '', 'status': 200}
return None
proxy = ProxyServer(proxy_port)
proxy.set_request_handler(request_handler)
proxy.serve_forever()
if __name__ == '__main__':
block_ads(8080)
The code snippets show different approaches: spotify-adblock uses low-level C code to intercept network connections, while SpotifyAdBlock employs a Python-based proxy server to filter ad requests.
SpotX patcher used for patching the desktop version of Spotify
Pros of SpotX
- More comprehensive feature set, including additional customization options
- Regular updates and active community support
- Compatible with multiple Spotify versions and platforms
Cons of SpotX
- More complex installation process
- Potential for increased resource usage due to additional features
- May require more frequent updates to maintain compatibility
Code Comparison
SpotX:
$spotx = "https://raw.githubusercontent.com/SpotX-Official/SpotX/main/Install.ps1"
iwr -useb $spotx | iex
spotify-adblock:
make
sudo make install
LD_PRELOAD=/usr/local/lib/spotify-adblock.so spotify
Key Differences
- spotify-adblock focuses primarily on ad-blocking for the Linux version of Spotify
- SpotX offers a wider range of features, including ad-blocking, UI customization, and additional functionality
- spotify-adblock uses a simpler, more lightweight approach
- SpotX provides a more feature-rich experience but may require more setup and maintenance
Conclusion
Both projects aim to enhance the Spotify experience, with spotify-adblock offering a straightforward ad-blocking solution for Linux users, while SpotX provides a more comprehensive set of features and customization options across multiple platforms. The choice between the two depends on the user's specific needs, technical expertise, and desired level of customization.
Video, audio & banner adblock/skip for Spotify
Pros of BlockTheSpot
- Supports automatic updates, making it easier to maintain
- Includes a user-friendly installer for Windows
- Offers additional features like unlimited skips and app modification
Cons of BlockTheSpot
- Limited to Windows platform only
- Requires more frequent updates due to Spotify client changes
- May have compatibility issues with certain Spotify versions
Code Comparison
BlockTheSpot (C++):
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hModule);
CreateThread(NULL, 0, MainThread, NULL, 0, NULL);
}
return TRUE;
}
spotify-adblock (C):
static int (*real_connect)(int sockfd, const struct sockaddr *addr, socklen_t addrlen) = NULL;
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) {
if (addr->sa_family == AF_INET) {
struct sockaddr_in *addr_in = (struct sockaddr_in *)addr;
if (is_blocked(addr_in->sin_addr.s_addr)) {
errno = ECONNREFUSED;
return -1;
}
}
return real_connect(sockfd, addr, addrlen);
}
Both projects aim to block ads in Spotify, but they use different approaches. BlockTheSpot modifies the Spotify client directly, while spotify-adblock uses a shared library to intercept network connections. The code snippets show these different approaches, with BlockTheSpot using Windows-specific API calls and spotify-adblock focusing on network connection interception.
EZBlocker - A Spotify Ad Blocker for Windows
Pros of Spotify-Ad-Blocker
- User-friendly graphical interface for easy operation
- Supports automatic updates for the latest ad-blocking capabilities
- Cross-platform compatibility (Windows, macOS, Linux)
Cons of Spotify-Ad-Blocker
- Requires installation and setup of additional software
- May have a higher resource footprint due to the GUI
- Potential for detection by Spotify due to its more complex nature
Code Comparison
spotify-adblock:
static int (*real_connect)(int sockfd, const struct sockaddr *addr, socklen_t addrlen) = NULL;
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) {
if (addr->sa_family == AF_INET) {
struct sockaddr_in *addr_in = (struct sockaddr_in *)addr;
char ip[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &(addr_in->sin_addr), ip, INET_ADDRSTRLEN);
if (is_blocked(ip)) {
errno = ECONNREFUSED;
return -1;
}
}
return real_connect(sockfd, addr, addrlen);
}
Spotify-Ad-Blocker:
def block_ads():
hosts = get_hosts()
for host in hosts:
if is_ad_domain(host):
block_host(host)
def is_ad_domain(host):
return any(ad_domain in host for ad_domain in AD_DOMAINS)
block_ads()
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
spotify-adblock
Spotify adblocker for Linux (macOS untested) that works by wrapping getaddrinfo
and cef_urlrequest_create
. It blocks requests to domains that are not on the allowlist, as well as URLs that are on the denylist.
Notes
- This does not work with the snap Spotify package.
- This might not work with the Flatpak Spotify package, depending on your system's shared libraries' versions.
- On Debian-based distributions (e.g. Ubuntu), the Debian Spotify package can be installed by following the instructions at the bottom of this page. (recommended)
Build
Prerequisites:
- Git
- Make
- Rust
- Cargo
$ git clone https://github.com/abba23/spotify-adblock.git
$ cd spotify-adblock
$ make
Install
$ sudo make install
Flatpak
$ mkdir -p ~/.spotify-adblock && cp target/release/libspotifyadblock.so ~/.spotify-adblock/spotify-adblock.so
$ mkdir -p ~/.config/spotify-adblock && cp config.toml ~/.config/spotify-adblock
$ flatpak override --user --filesystem="~/.spotify-adblock/spotify-adblock.so" --filesystem="~/.config/spotify-adblock/config.toml" com.spotify.Client
Usage
Command-line
$ LD_PRELOAD=/usr/local/lib/spotify-adblock.so spotify
Flatpak
$ flatpak run --command=sh com.spotify.Client -c 'eval "$(sed s#LD_PRELOAD=#LD_PRELOAD=$HOME/.spotify-adblock/spotify-adblock.so:#g /app/bin/spotify)"'
Desktop file
You can integrate it with your desktop environment by creating a .desktop
file (e.g. spotify-adblock.desktop
) in ~/.local/share/applications
. This lets you easily run it from an application launcher without opening a terminal.
Examples:
Debian Package
[Desktop Entry]
Type=Application
Name=Spotify (adblock)
GenericName=Music Player
Icon=spotify-client
TryExec=spotify
Exec=env LD_PRELOAD=/usr/local/lib/spotify-adblock.so spotify %U
Terminal=false
MimeType=x-scheme-handler/spotify;
Categories=Audio;Music;Player;AudioVideo;
StartupWMClass=spotify
Flatpak
[Desktop Entry]
Type=Application
Name=Spotify (adblock)
GenericName=Music Player
Icon=com.spotify.Client
Exec=flatpak run --file-forwarding --command=sh com.spotify.Client -c 'eval "$(sed s#LD_PRELOAD=#LD_PRELOAD=$HOME/.spotify-adblock/spotify-adblock.so:#g /app/bin/spotify)"' @@u %U @@
Terminal=false
MimeType=x-scheme-handler/spotify;
Categories=Audio;Music;Player;AudioVideo;
StartupWMClass=spotify
Uninstall
$ sudo make uninstall
Flatpak
$ rm -r ~/.spotify-adblock ~/.config/spotify-adblock
$ flatpak override --user --reset com.spotify.Client
Configuration
The allowlist and denylist can be configured in a config file located at (in descending order of precedence):
config.toml
in the working directory$XDG_CONFIG_HOME/spotify-adblock/config.toml
~/.config/spotify-adblock/config.toml
/etc/spotify-adblock/config.toml
(default)
Top Related Projects
Protect your privacy by blocking all annoying Spotify ads & analytics in Linux, OSX and Windows with hosts file.
SpotX patcher used for patching the desktop version of Spotify
Video, audio & banner adblock/skip for Spotify
EZBlocker - A Spotify Ad Blocker for Windows
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