Pi Hole Youtube
🛑 ALL INFORMATION CLICK HERE 👈🏻👈🏻👈🏻
Pi Hole Youtube
ErikFontanel / filter-youtube-domains.sh
Embed
Embed this gist in your website.
Share
Copy sharable link for this gist.
Clone via
HTTPS
Clone with Git or checkout with SVN using the repository’s web address.
Sign up for free
to join this conversation on GitHub .
Already have an account?
Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
Instantly share code, notes, and snippets.
Guys, I have a problem here.
My drive only has 20 gb storage...., the youtube.hosts file eats up all space.
The other day I had to do a trick to find the source of the problem
which was youtube.hosts
What is the solution for that problem? At the pihole forum other people claim they have this situation to.
But the pihole group responds logically 'Sorry, youtube.hosts is not our department...'
Besides that, all respect for this interesting script. Nowadays, I still find youtube adds.
Is there new development to handle 2019?
Hey @leeuwtjex ,
I had the same problem and fixed it by deleting the old youtube.hosts and editing the sed line to this:
sed -i $FILE -re 's/(^r[[:digit:]]+)(\.)(sn)/\1---\3-/'
I hope that helps you!
Also had to edit the regex at the wolfram grep since it didn't return anything (according to the website https://regexr.com/ your grep should work though). For me grep -Eo "r\d+---sn-.+.googlevideo.com" didn't find e.g. r1---sn-oguelned.googlevideo.com so I edited the grep to grep -Eo "r.+---sn-.+googlevideo.com" which works.
Thanks for sharing the script, it is working perfectly fine for over a year now.
Thanks Kapujino, I found this mod exactly like you said in another post to in a reddit post somewhere.
It works! I still have 19 gb free now!.
My I ask what does that wolfram API call do? I'm trying to make this happen without registering at wolfram. Thanks.
You need the $APPID$ for Wolfram to work
@ericknorr , Thanks mate, I appreciate. But that was not what I'm asking, I know how to use APIs. My questions was, rather, what is wolfram alpha is doing here. You know, the first API call gets the googlevideo subdomains from hackertarget , then with some awk and sed magic it transforms them to these ---sn like format but then, what is the purpose of call to wolfram services?
@Pouya-moh WA is able to retrieve more domains than hackertarget . But don't bother anymore, as this script is deprecated because YT changed how they serve ads. More info in this thread
This is a long going thread, however the solution (script) works well.
I applied some changes:
#!/bin/sh
# More info here: https:#discourse.pi-hole.net/t/how-do-i-block-ads-on-youtube/253/136
# File to store the YT ad domains
FILE=/etc/pihole/youtube.hosts
# Fetch the list of domains, remove the ip's and save them
curl 'https:#api.hackertarget.com/hostsearch/?q=googlevideo.com' \
| awk -F, 'NR>1{print $1}' \
| grep -vE "redirector|manifest" > $FILE
# Replace r*.sn*.googlevideo.com URLs to r*---sn-*.googlevideo.com
# and add those to the list too
sed -i $FILE -re 's/(^r[[:digit:]]+)(\.)(sn)/\1---\3-/'
# Scan log file for previously accessed domains
grep '^r.*googlevideo\.com' /var/log/pihole*.log \
| awk '{print $8}' \
| grep -vE "redirector|manifest" \
| sort | uniq >> $FILE
I added the list to the list group using the URL: file:///etc/pihole/youtube.hosts
I then edit my cron jobs
sudo crontab -e
adding
*/10 * * * * /etc/pihole/youtube-adblock.sh
This executes the script every 10 minutes, replacing the file (youtube.hosts) with the latest domains.
Works well - I only get Ad's one time, after this they are blocked.
@dev-2-4-h would you mind doing a step by step guide for those who are not particularly familiar with bash scripting? I already have my pi hole in place but I still see the same youtube ads as usual.
I get this error when I try to run the CURL
curl: (6) Could not resolve host: https
@dev-2-4-h would you mind doing a step by step guide for those who are not particularly familiar with bash scripting? I already have my pi hole in place but I still see the same youtube ads as usual.
I get this error when I try to run the CURL
curl: (6) Could not resolve host: https
I just changed "curl 'https:#api.hackertarget.com/hostsearch/?q=googlevideo.com' " to "curl ' https://api.hackertarget.com/hostsearch/?q=googlevideo.com ' "
Im running pih-hole v5.2.2 and I seem to be missing something as the AdList is not updating with the YouTube hosts (domains).
I have the script in my /etc/pihole folder as per above revised by @dev-2-4-h last post here
It Successfully creates a youtube.hosts file in the /etc/pihole folder
It Successfull call pihole -g and the update appears to run with success into GravityDB, but no new domains are added.
Looking at the script above I see no obvious way the youtube.hosts file is added to Pi-Hole automatically. Also checked the gravity.sh script Pi-Hole uses when executes the pihole -g command and that doesnt appear to look for .hosts files on updating GravityDB.
Therefore what am I missing, how does pihole -g suppose to add the contents of the auto-generated youtube.hosts file to Pi-Hole?
Cleaned up the script a little bit by replacing the curl/awk/grep/sed sequence with just curl and sed .
maybe this is neccesary to append the youtube domains list to the other already validated, works for me .
bash -c 'cat youtube.hosts >> list.1.raw.githubusercontent.com.domains'
i believe this would be a solution.
`
FILE=/etc/pihole/youtube.hosts
curl ' https://api.hackertarget.com/hostsearch/?q=googlevideo.com '
| awk -F, 'NR>1{print $1}'
| grep -vE "redirector|manifest" > $FILE
sed -i $FILE -re 's/(^r[[:digit:]]+)(.)(sn)/\1---\3-/'
grep '^r. googlevideo.com' /var/log/pihole .log
| awk '{print $8}'
| grep -vE "redirector|manifest"
| sort | uniq >> $FILE
bash -c 'cat /etc/pihole/youtube.hosts >> list.1.raw.githubusercontent.com.domains'
An alternative may be to add the following regex on the blacklist:
Seems to work for me locally. The ad segments still appear but it's just a spinner for 5 seconds then 'Skip Ads' appear.
Thanks for the idea, I just tried it cause I didn't understand it. After adding the regex ^r.+.googlevideo.com$
all youtube movies are blocked....not one runs.
How local did you mean?
Yea, I removed it last night as it looks like about half the videos are blocked if not more. Bad idea. So I wonder if there is a different pattern that might work instead.
# This script will fetch the Googlevideo ad domains and append them to the Pi-hole block list.
# Run this script daily with a cron job (don't forget to chmod +x)
# More info here: https://discourse.pi-hole.net/t/how-do-i-block-ads-on-youtube/253/136
# Fetch the list of domains, remove the ip's and save them
curl ' https://api.hackertarget.com/hostsearch/?q=googlevideo.com ' \
| grep -vE " redirector|manifest " > $FILE
# Replace r*.sn*.googlevideo.com URLs to r*---sn-*.googlevideo.com
cat $FILE | sed -r ' s/(^r[[:digit:]]+)(\.)(sn)/\1---\3-/ ' >> $FILE
# Scan log file for previously accessed domains
grep ' ^r.*googlevideo\.com ' /var/log/pihole * .log \
| grep -vE " redirector|manifest " \
# Add to Pi-hole adlists if it's not there already
if ! grep $FILE < /etc/pihole/adlists.list ; then echo " file:// $FILE " >> /etc/pihole/adlists.list ; fi ;
telekrmor
2016-05-16
Updates
0
$ USD $ AUD $ CAD € EUR ₹ INR ¥ JPY £ GBP
We are fast approaching the limitations of using bash to control Pi-hole, so we are going to try to re-code the project in Python. As we have been discussing how to implement new features and fixes, we keep coming back to the need to revamp the code. If it works, switching to Python will provide better maintainability and scalability. It will also allow us to release new features and bug fixes much faster.
It’s probably going to be slow going (we’ve never been very fast to begin with!) as everyone on the Pi-hole/Py-hole dev team are all volunteers and part-timers. If you like what we do, you can support us in a few different ways .
Also, to address the disparate documentation on Pi-hole (it became difficult to keep updated as Pi-hole began developing so quickly), I will slowly be releasing some videos to better explain how to install and configure your Pi-hole. I need to clean up some of the old, outdated FAQs, too.
The first video on our channel is a simple one minute tutorial on how to install Pi-hole (don’t forget to block YouTube ads ????). There have been many users who have made their own how-to videos, but I figured we should probably have an “official” one.
The next video will be a more detailed one on how to set up a headless Pi-hole from scratch. I’ll also make some videos for things like white/black-listing, customizing, among other things.
https://www.youtube.com/watch?v=TzFLJqUeirA
Unfortunately, your browser is unsupported . Please switch to a supported browser to view rich content, log in and reply.
[Should Block Youtube Ads and more, everything set up according to documentation and official guides (also checked manually if clients point to pihole as dns, which they are)]
[No blocking of YT ads (not sure about others ads but pretty sure there is also a lot of ads not being blocked, using default adblockers in browsers so hard to determine)]
AFAIK Youtube serves his ads differently, Pihole won't work (and any others url/DNS based blocker won't work (or not enough) btw)
For Youtube, just install ublock (free open-source software alternative to adblock)
to check if your pihole is working
From your client you can check with
nslookup domain.com
It's should show your pihole IP.
After try a domain that you sure you blocked like Google analytics for instance : analytics.google.com
do as follow :
ping -4 analytics.google.com
is should also show you pihole IP
(or that : )
ah ok then maybe it is just youtube, I installed pihole to block youtube ads on firetv and mobile devices, my other clients already use adblockers. Then I guess it works.
That is not the expected behavior. YouTube serves ads from the same domains as the content. Long running thread here.
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
Powered by Discourse , best viewed with JavaScript enabled
Hard Heels
Zara Heels
Abba Heels