We didn't find reliable method based on DNS request (Pi-hole). For the moment, the only way is to have a web browser that can detect ads from html/url/javascrit.
So you will be able to remove ads if you can install this type of application on the Fire TV, otherwise no.
If you have web browser on the FireTV (I haven't it, I don't know), maybe this post can help you.
After I configured Pi-Hole, for a week, I saw ads that are un-skippable 15-seconds only. I did not see 5-seconds skip ads for a whole week. And the ads were more frequent. Its like, Google knows you are trying to block and it was like a punishment.
Now, the ads are high in number, but still skippable sometimes.
On a laptop browser, I don't care, as AbBlock is handling well enough. Only issue is with mobile devices like phones and iPads which we are a bit more frequent.
BTW, I noticed, I see less ads on my Samsung 43 and 65 Smart TV YouTube app.
I see ads on Apple TV -YouTube app on my Samsung 65".
#!/bin/sh
# 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
# File to store the YT ad domains
FILE=/etc/temp/temp.txt
# Wolfram Alfa AppID
APPID="Register at https://www.wolframalpha.com/ put your id here"
# 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
curl "http://api.wolframalpha.com/v2/query?input=googlevideo.com&appid=${APPID}&format=plaintext&podstate=WebSiteStatisticsPod:InternetData__Subdomains&podstate=WebSiteStatisticsPod:InternetData__Subdomains_More" \
| grep -Po "r\d+---sn-.+.googlevideo.com" >> $FILE
# Scan log file for previously accessed domains
grep r*.googlevideo.com /var/log/pihole.log \
| awk '{print $6}' \
| grep -v '^googlevideo.com\|redirector\|manifest' \
| sort | uniq >> $FILE
# Replace r*.sn*.googlevideo.com URLs to r*---sn-*.googlevideo.com
# and add those to the list too
cat $FILE | sed -i $FILE -re 's/(^r[[:digit:]]+)(\.)(sn)/\1---\3-/' >> $FILE
#delete duplicates
perl -i -ne 'print if ! $x{$_}++' /etc/temp/temp.txt
#demonstrative
cat $FILE >> /var/www/html/temp.txt
2º script /etc/pihole/youtube-ads.sh
echo off
#copy file to blacklist
cat /etc/temp/temp.txt >> /var/www/html/youtube.txt
#delete duplicates
perl -i -ne 'print if ! $x{$_}++' /var/www/html/youtube.txt
#removes the temporary file on the raspberry pi
rm /var/www/html/temp.txt
#updates pihole blacklist/whitelist
pihole -g
I noticed that block file created will have format like this:
...---sn--...
and in my log all request made are for domains in this format
...---sn-...
so line:
cat $FILE | sed -i $FILE -re 's/(^r[[:digit:]]+)(.)(sn)/\1---\3-/' >> $FILE
I changed to ->:
cat $FILE | sed -i $FILE -re 's/(^r[[:digit:]]+)(.)/\1---/' >> $FILE
In these type of url’s “sn-uxa0n” always there & other contents change every time.
If youtube urls are city location based. Then with unbound I think they come from central youtube server, so this method can help everyone who using unbound as upstream DNS
Is some body help me how this method is implement for this type of url. thanks
Please some expert help me, in my home internet connection or from my telephone internet data when I play anything on you tube. In my pihole log something like
Each time this type of url shown in pi log. In all these address “uxa0n” is always common. But when i run queries like this there is not any address with “uxa0n” in this data . so I am confusing this method not working for me as the domain name with this equation not matching with our filter address. What the expert advice me in this situation
I have Youtube Premium, but my Son who is 12 wants to watch Youtube on his AndroidTV. He can't with his Google-Account cause in Europe, Google denies the Use of Youtube for Children under 13 or 16(not clear).
Soooo I set up a new dummy Google-Account but that isn't in the family plan. (Plan is fully used by family members)
So I am a paying Youtube user that has to block youtube ads.
Alternatively you can just change his birthday on his Google account that is already in your family plan and avoid all of that. If you are worried about the content, you can make sure safe search is enabled, which I think is the default anyway.
Yeah, I think you have to enter something like 16, then confirm you entered the wrong date previously and they give you all kinds of warnings, but in the end it should work. I don't think they require a birth certificate or something like that. In any case, you can also create a new Google account, transfer all the data, then add it to Family Link if you really want to control it via Family Link. Alternatively you can just use 18+ and be logged into his account and check what he does via myactivity.google.com
back on topic, I have tried both scripts and although it worked for a couple of days, I started to get black loading screen issues.
The script has started to blacklist some servers that are essential to the streaming.
I was also getting sometimes 2 x 40 seconds ads for a single videos, as some said earlier, a Google punishment.
I think there really is no way to block those ads permanently with the pihole...
Just registered to say this, as it can be helpfull:
I was looking for a pihole solution, but if chrome/firefox plugin/extension is enough for you, there is "Enhancer for YouTube", which I having been using many months now and has always blocked the ads ( amount other usefull features ).
I got the script as posted by Marcio_Xavier to work after modifying the timeout in the wolfram URL thanks to instructions from Nurffe and most videos load just fine. What I've noticed is that any videos with music identified by content ID don't load now. Any other videos play fine, but even switching to another video and switching back which has helped when other videos don't load can't help this. Videos with copyrighted music just don't load. If anyone has any hint for this please let me know.