Results 1 to 3 of 3
  1. #1
    le_37's Avatar
    Join Date
    Oct 2015
    Gender
    male
    Posts
    26
    Reputation
    10
    Thanks
    20

    [Python] Spotify Adblocker

    SPOTIFY AD BLOCKER
    My first release and I'm learning Python again after years.
    IT IS VERY SIMPLE

    Project is open source

    spotify_adblocker.py

    Code:
    from __future__ import print_function
    import platform
    from random import random
    import urllib.request
    import shutil
    from shutil import copyfileobj
    
    
    
    
    if "Windows" in platform.system():
        
        file = "C:\Windows\System32\drivers\etc\hosts";
        
        urllib.request.urlretrieve("https://gist.******userconten*****m/opus-x/3e673a9d5db2a214df05929a4eee6a57/raw?"+ str(random()), "hostfile.txt")
        
        #  shutil.copy(file, 'hosts.bak')
        #  ^ If this is emitted, please backup your hosts manually
        #  If you decide to go back, this is your original file content of hosts
        
        with open('C:\Windows\System32\drivers\etc\hosts', 'ab') as output, open('hostfile.txt', 'rb') as input:
            copyfileobj(input, output)
        
    else:
        print("Windows Only")
    Run this program with administrator privilege to avoid errors

    MAKE A BACKUP OF YOUR HOSTS FILE C:\Windows\System32\drivers\etc

    What this program does is retrieves data from a list on ****** which is updated daily of servers that contain Spotify advertisements. It then copies it to your hosts file to block them.

    You're better of using the browser application of Spotify and using Ad blocker there, but I just wanted to release something incase you wanted to see the method.
    Last edited by le_37; 05-08-2020 at 10:43 AM.

  2. #2
    sprremix's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    WI
    Posts
    35
    Reputation
    10
    Thanks
    5
    Fun project. But you can use Notepad to edit the hosts file. No need to use an entire programming language to do it for you.

  3. #3
    le_37's Avatar
    Join Date
    Oct 2015
    Gender
    male
    Posts
    26
    Reputation
    10
    Thanks
    20
    True however this retrieves a list which is updated daily, automatically so you don't have to do anything except run the program rather than navigating to your hosts file and finding a good list to paste on there

Similar Threads

  1. Spotify Free Account [Will thank +rep]
    By Greg in forum Spammers Corner
    Replies: 1
    Last Post: 11-11-2009, 12:46 PM
  2. Python
    By halosaveyer in forum General Hacking
    Replies: 0
    Last Post: 10-13-2008, 12:43 PM
  3. Python
    By thiag00 in forum Programming Tutorial Requests
    Replies: 0
    Last Post: 04-30-2008, 08:23 PM
  4. Monty Python and the Holy Grail
    By BluSpex in forum General
    Replies: 18
    Last Post: 08-16-2007, 07:49 PM
  5. to anyone who knows python
    By ace76543 in forum General
    Replies: 0
    Last Post: 12-09-2006, 11:53 AM