├── requirements.txt ├── docker-compose.yml ├── Dockerfile ├── start.sh ├── README.md └── app.py /requirements.txt: -------------------------------------------------------------------------------- 1 | nextdnsapi -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.5" 2 | 3 | services: 4 | nextdns: 5 | build: . 6 | environment: 7 | - NEXTDNS_USERNAME=youremail 8 | - NEXTDNS_PASSWORD=yourpassword 9 | - NEXTDNS_CONFID=yourconfigid 10 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3 2 | 3 | WORKDIR /usr/src/app 4 | 5 | COPY app.py requirements.txt start.sh blacklist_domains.txt ./ 6 | 7 | RUN pip install -r requirements.txt 8 | 9 | RUN chmod +x start.sh 10 | 11 | CMD ["/bin/bash", "start.sh"] 12 | -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | echo "Setting up container" 2 | 3 | if [ -z $NEXTDNS_USERNAME ] || [ -z $NEXTDNS_PASSWORD ] || [ -z $NEXTDNS_CONFID ] 4 | then 5 | echo "You must specify NEXTDNS_USERNAME & NEXTDNS_PASSWORD & NEXTDNS_CONFID" 6 | else 7 | echo "Setting up API Settings" 8 | sed -i 's#nextdns_username=".*"#nextdns_username="'$NEXTDNS_USERNAME'"#' app.py 9 | sed -i 's#nextdns_password=".*"#nextdns_password="'$NEXTDNS_PASSWORD'"#' app.py 10 | sed -i 's#nextdns_confid=".*"#nextdns_confid="'$NEXTDNS_CONFID'"#' app.py 11 | 12 | echo "Starting APP" 13 | python3 app.py 14 | fi 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NextDNS-BlockYoutubeAds 2 | 3 | ## Usage 4 | Container that automatically add Youtube ADS domains to your NextDNS blacklist 5 | 6 | ## How it work 7 | The container makes API calls to Next DNS and establishes a block list based on a REGEX 8 | 9 | ## How to use 10 | ``` 11 | $ docker run -e NEXTDNS_USERNAME=YOUR_EMAIL -e NEXTDNS_PASSWORD=YOUR_PASSWORD -e NEXTDNS_CONFID=YOUR CONFID aguyonnet/nextdns-youtube-block 12 | ``` 13 | ### Notes: 14 | You can find your ID in the URL of your Browser 15 | 16 | ### Env vars: 17 | 18 | NEXTDNS_USERNAME=YOUR_EMAIL
19 | NEXTDNS_PASSWORD=YOUR_PASSWORD
20 | NEXTDNS_CONFID=YOUR CONFID
21 | 22 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from nextdnsapi.api import * 2 | import sys, time 3 | 4 | #Configurations 5 | nextdns_username="" 6 | nextdns_password="" 7 | nextdns_confid="" 8 | 9 | #API Auth 10 | header = account.login(nextdns_username, nextdns_password) 11 | 12 | #Open Domains File 13 | blacklistfile = open('blacklist_domains.txt', 'r') 14 | domains = blacklistfile.readlines() 15 | 16 | #Use API to add domains on NEXTDNS 17 | count_domains = 0 18 | for domain in domains: 19 | count_domains += 1 20 | 21 | print(denylist.blockdomain(domain.strip(), nextdns_confid, header)) 22 | sys.stdout.flush() 23 | time.sleep(1) 24 | 25 | #Close file 26 | blacklistfile.close() 27 | 28 | print(count_domains, " Added to blacklist") 29 | print("Done, exiting app") --------------------------------------------------------------------------------