AnanthVivekanand / spotify-adblock

Blocking ads on desktop Spotify, crazy code ahead

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spotify mutes after some minutes.

mgoyanes opened this issue · comments

After some minutes, Spotify stops playing music. Whenever I press the play button, nothing happens.
Have to kill pm, kill Spotify, restart npm and Spotify.

image

Terminal does not output more than that.

MacOS version: 10.15.5

Weird.. I don't know why it would do that.. Can you give me a terminal output of every domain that's pinged? A pastebin link should suffice

I can't reproduce the issue on my side, but try whitelisting login5.spotify.com in whitelist.js and can you tell if anything changes? The reason login5 is blocked right now is because it triggers ads from spclient.wg.spotify.com.

Hello.

Yep. login5.spotify.com is the culprit. If I whitelist it ads are played. If I block it, at some point, I am unable to keep listening. Even If I close and restart Spotify, I still can't play anything.
Here is the terminal output. That space over there is when it stopped playing, that is, when it skipped to the next track, it then stopped playing.

I'm using Spotify version 1.1.36.734.g8731c306

Thanks.

> node index.js

Proxy server listening on port 8080
Blocking: login5.spotify.com
Proxying HTTPS request for: apresolve.spotify.com 443
Proxying HTTPS request for: gew1-accesspoint-b-1v3x.ap.spotify.com 4070
Blocking: s3.amazonaws.com
Proxying HTTPS request for: lineup-images.scdn.co 443
Proxying HTTPS request for: dailymix-images.scdn.co 443
Proxying HTTPS request for: dailymix-images.scdn.co 443
Proxying HTTPS request for: dailymix-images.scdn.co 443
Proxying HTTPS request for: dailymix-images.scdn.co 443
Proxying HTTPS request for: newjams-images.scdn.co 443
Proxying HTTPS request for: newjams-images.scdn.co 443
Proxying HTTPS request for: thisis-images.scdn.co 443
Proxying HTTPS request for: thisis-images.scdn.co 443
Proxying HTTPS request for: thisis-images.scdn.co 443
Proxying HTTPS request for: thisis-images.scdn.co 443
Proxying HTTPS request for: thisis-images.scdn.co 443
Proxying HTTPS request for: thisis-images.scdn.co 443
Proxying HTTPS request for: thisis-images.scdn.co 443
Proxying HTTPS request for: i.scdn.co 443
Proxying HTTPS request for: i.scdn.co 443
Proxying HTTPS request for: i.scdn.co 443
Proxying HTTPS request for: i.scdn.co 443
Proxying HTTPS request for: i.scdn.co 443
Blocking: www.googletagservices.com
Blocking: heads4-ak-spotify-com.akamaized.net
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Proxy HTTP request for: http://192.168.1.65:1960
Proxy HTTP request for: http://192.168.1.65:36866
Blocking: login5.spotify.com
Proxying HTTPS request for: apresolve.spotify.com 443
Proxy HTTP request for: http://192.168.1.65:1960
Proxy HTTP request for: http://192.168.1.65:36866
Proxying HTTPS request for: gew1-accesspoint-b-kcjp.ap.spotify.com 4070
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Proxy HTTP request for: http://192.168.1.65:1960
Proxy HTTP request for: http://192.168.1.65:36866
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Proxy HTTP request for: http://192.168.1.65:1960
Proxy HTTP request for: http://192.168.1.65:36866
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Proxy HTTP request for: http://192.168.1.65:1960
Proxy HTTP request for: http://192.168.1.65:36866
Blocking: login5.spotify.com






Blocking: login5.spotify.com
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Proxy HTTP request for: http://192.168.1.65:1960
Proxy HTTP request for: http://192.168.1.65:36866
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Proxy HTTP request for: http://192.168.1.65:1960
Proxy HTTP request for: http://192.168.1.65:36866
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Proxy HTTP request for: http://192.168.1.65:1960
Proxy HTTP request for: http://192.168.1.65:36866
Blocking: login5.spotify.com
Blocking: login5.spotify.com
Proxy HTTP request for: http://192.168.1.65:1960
Proxy HTTP request for: http://192.168.1.65:36866
Blocking: login5.spotify.com
^Z
[1]  + 90201 suspended  npm start

Hm, I don't know why this is happening. I wonder if Spotify is somehow detecting that we're blocking its ads. It might be your Spotify version - when I get back to my computer I'll check my version and upgrade/downgrade to see if I can replicate the issue

The issue with just domain filtering is that spclient.wg.spotify.com serves music, ads, and Spotify friends functionality. We can't just block it so instead I tried to block everything that triggers it from sending ads. But doing that breaks more functionality, and so on.

A workaround that I did was use SSL decryption on spclient.wg.spotify.com where I could actually read the full url of the requests sent there. All the ads from spclient are served from /ads so it was easy to just filter that path. Anyways, the code for the SSL decryption is on the mitm-proxy branch. If you could test that out, that'd be great. If you're up for testing it, you'll need to trust the root CA it creates, an easy command for that is in the readme on that branch.

Sorry you're having trouble, it's just the way Spotify ads work :( I'll keep looking into it though

I think that that branch solves the issue. Have you tried?

So wasn't able to upgrade my Spotify to 1.1.36 exactly, I upgraded to 1.1.37 from 1.1.28. For me, Spotify doesn't stop playing completely, it just can't play certain songs. Selecting a new song works and Spotify will play again. This was already happening on 1.1.28, so I can't seem to replicate your issue.

The reason I'm keeping the mitm-proxy branch separate from master is because the MITM proxy requires users to add the root CA to their machine and not all users might feel comfortable with that. So users can use the mitm proxy branch over master if desire.

And yes, I personally use the mitm-proxy branch everyday and it works perfectly.

Hello.

Updated the mitm-proxy branch to the latest commit and I'm getting this error:

node mitm2.js
internal/modules/cjs/loader.js:1083
  throw err;
  ^

Error: Cannot find module '/Users/miguelgoyanes/Desktop/spotify-adblock-macos/mitm2.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1080:15)
    at Function.Module._load (internal/modules/cjs/loader.js:923:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

In commit ce0a6eba8f5c671c50ba21472c37c7cfbc73ea94 that message does not appear.

If you look at the commit changes, you'll see that mitm2.js was renamed to mitm.js, so run node mitm.js.

Sorry. Missed that. Thanks