pihole-youtube-block
pihole-youtube-block copied to clipboard
Scan pihole logs and block YouTube ads domains
trafficstars
Warning: it might block YouTube completely.
Ads are served through the same domains as normal video clips. Until I find a better solution, please be mindful of this issue and consider this as experimental.
pihole-youtube-block
Scans logs generated by pihole and extracts domains used to serve ads on YouTube
- scans log files, including archived logs
- can process multiple files in parallel
- compiles a unique list with the extracted domains
- offers the option to add (blacklist) the extracted domains directly to
pihole - low memory footprint and extremely fast
- no dependencies
- you don't need to install anything (check
binfolder)
Getting started
$ git clone https://github.com/foae/pihole-youtube-block.git
$ cd pihole-youtube-block
How to run if you have go installed
$ go run main.go
How to run it without having go installed
For ARM (Raspberry Pi and alternatives)
$ cd bin
$ ./ytblock-rpi
For all others
$ cd bin
$ ./ytblock
All gathered domains will be written to compiled_domains.txt
You can easily tweak the configuration; it has sensible defaults.
File config.json
"PIHOLE_LOGS_DIR": "/var/log/",– path to your pihole logs"COMPILED_FILE_NAME": "./compiled_domains.txt",– name of the file used to collect all domains from logs"LOG_FILE_NAME_PREFIX": "pihole.log"– if your pihole log files bear a different name, change this with the common prefix of your log files that you want scanned"POP_CONFIRMATION_DIALOGUE": true– change tofalseto skip the confirmation dialogue and send the found domains directly to pihole without asking. Useful for scripting.
Example output
blana@raspberrypi:~/pihole-youtube-block/bin $ ./ytblock-rpi
>>> Waiting for all jobs to finish...
2018/11/30 19:19:14 Finished processing file (/var/log/pihole.log) in (1.964928163s).
2018/11/30 19:19:16 Finished processing file (/var/log/pihole.log.1) in (3.518280066s).
2018/11/30 19:19:18 Finished processing file (/var/log/pihole.log.2.gz) in (5.431282712s).
>>> Done: (125) unique extracted domains written to (./compiled_domains.txt) in (5.48431123s)
-----------
Would you like to stick those (125) collected domains into *your* pihole? (y/n)
-----------
n
2018/11/30 19:19:20 No is a no. Bye.
License
MIT License