Youtube Ads Blocker 3.0 for Pihole 5.0

The brand new version of Pihole 5.0 has deleted the following files:

gravity.list,black.list,whitelist.txt

And has created for all these data a new SQLite3 database:

/etc/pihole/gravity.db

With this change, all the previous versions to 3.0 of the script that I made to block the YouTube Advertisement, has stopped working. So I have created a new version in order to handle that new SQLite database.

To install this new version you should follow the following steps:

  • Unistall the version previous to 3.0, executing:
./ytadsblocker.sh uninstall
  • Download the new version from my Github and install:
git clone https://github.com/deividgdt/ytadsblocker.git
cd ytadsblocker
chmod a+x ytadsblocker.sh
./ytadsblocker.sh install

I highly recommend you to take a look into the documentation of this new version here since there are a lot of new changes.

VERSION 3.0 YTADSBLOCKER

Now the script will generate a group called: YTADSBLOCKER. This name must not be deleted, since it could lead the script to fail. You can check this in ‘Group Management -> Groups’

In ‘Group Management -> Domains’ you can check the new subdomains added by the script:

Finally, in ‘Group Management -> Clients’ you should assign the group YTDASBLOCKER to the clients that we want to block the access to these subdomains. By example:

That’s all, folks!


If I have helped you, you could support me inviting me to a coffee! that’s the best way to support me.

16 comentarios sobre “Youtube Ads Blocker 3.0 for Pihole 5.0

  1. Buenas Deivid, lo primero gracias por el script, perdona que te abrí una incidencia por GitHub por el tema de que no se me añadían los dominios, y es que como yo les veía en el log ya, no sabía que tenía que activar la opción de ajustes de activar logs, que será el que lee tu script.
    Otra cosilla, lo de que el servicio busque nuevos dominios cada X tiempo, se configura en la variable SLEEPTIME del script? Va en segundos no?
    Y otra preguntilla, si queremos ejecutarlo manualmente que busque nuevos dominios, ejecutando de nuevo el script.

    Cuando puedas.

    Muchas gracias por tu tiempo.

    Un saludo

    1. Buenas Alberto,

      No te preocupes. No hay problema.

      -Otra cosilla, lo de que el servicio busque nuevos dominios cada X tiempo, se configura en la variable SLEEPTIME del script? Va en segundos no?
      Correcto, se configura en esta variable y va en segundos.

      -si queremos ejecutarlo manualmente que busque nuevos dominios, ejecutando de nuevo el script.
      Entiendo que quieres ejecutar manualmente el script y busque los dominios, omitiendo el proceso automático de cada X segundos. Si es así, puedes ejecutar:
      systemctl stop ytadsblocker -> detienes el servicio
      systemctl start ytadsblocker -> lo vuelves a ejecutar cuando tu quieras y lo vuelves a detener a tu gusto.

      Un saludo,

  2. Hi, thanks for sharing that, great job.
    I have a question. The scrip will update automatically the domain’s list to block? If yes, that meaning that the YTADSBLOCKER will “learn” and add the domains to block by itself? If not, so what I should do?
    I’ve just installed it and the first try on youtube it didn’t work, but I think is for my concerns above or it’s not? Thank you so much for your time.
    Best,
    Giulio

    1. Hi there Giulio,

      Of course, once the script is running, its reading the pihole logs and searching for Googlevideo subdomains. If a Googlevideo subdomain appear, it is forwarded straight away to the SQLite database, so it basically mean that the subdomains are being blocked.

      Anyway, take into account, that you must start the script executing: systemctl start ytadsblocker
      If you’re running the script on a Docker container, you must execute as follow: ./ytadsblocker.sh start &

      You can use: systemctl -l status ytadsblocker in order to check if the script is working properly. Or you can check the file /var/log/ytadsblocker.log.

      You must see some output like this:

      ┌─[root@raspberrypi]─[/var/log]
      └──╼ #tail -f /var/log/ytadsblocker.log
      [2020-11-19 20:16:32] Adding the subdomain: r4.sn-h5qzen76.googlevideo.com
      [2020-11-19 20:16:32] Adding the subdomain: r4.sn-h5qzen7d.googlevideo.com
      [2020-11-19 20:16:32] Adding the subdomain: r4.sn-h5qzen7l.googlevideo.com
      [2020-11-19 20:16:32] Adding the subdomain: r5.sn-h5q7dned.googlevideo.com
      [2020-11-19 20:16:32] Adding the subdomain: r5.sn-h5q7kne6.googlevideo.com
      [2020-11-19 20:16:32] Adding the subdomain: r5.sn-h5q7kned.googlevideo.com
      [2020-11-19 20:16:32] Adding the subdomain: r5.sn-h5q7knes.googlevideo.com
      [2020-11-19 20:16:32] Adding the subdomain: r5.sn-h5q7knez.googlevideo.com
      [2020-11-19 20:16:32] Adding the subdomain: r5.sn-h5qzen76.googlevideo.com
      [2020-11-19 20:16:32] Adding the subdomain: r5.sn-h5qzen7l.googlevideo.com

      Kind regards,

  3. Hello,

    How do I install this on Mac for the pi-hole running on docker?

    Forgive my ignorance as I am not familiar with scripting and coding. I followed the steps but it doesn’t work. It doesn’t create YTADSBLOCKER, for example.

    Thanks.

    1. Hi James, there’s already a version for Docker, did you use the latest version from my GitHub?

      In the Docker version you can’t use systemctl since this is not available by default, so you must install and execute as follows:
      ./ytadsblocker.sh install
      ./ytadsblocker.sh start

      1. Thank you for the prompt response. Below is the steps I’ve followed and the output.

        The /etc/pihole/, for example, doesn’t exist in my system. The ytadsblocker.log on the other than says the following:

        Error: unable to open database “/etc/pihole/gravity.db”: unable to open database file

        Terminal:

        root@301f0cbe3c0a ~ # git clone https://github.com/deividgdt/ytadsblocker.git
        Cloning into ‘ytadsblocker’…
        remote: Enumerating objects: 39, done.
        remote: Counting objects: 100% (39/39), done.
        remote: Compressing objects: 100% (39/39), done.
        remote: Total 148 (delta 20), reused 0 (delta 0), pack-reused 109
        Receiving objects: 100% (148/148), 58.50 KiB | 739.00 KiB/s, done.
        Resolving deltas: 100% (75/75), done.
        root@301f0cbe3c0a ~ # cd ytadsblocker
        root@301f0cbe3c0a ytadsblocker # chmod a+x ytadsblocker.sh
        root@301f0cbe3c0a ytadsblocker # ./ytadsblocker.sh install
        whereis: illegal option — b
        usage: whereis program […]
        \e[31m__ ______ __ __________ ______ ______ ___ ____ _____
        \ \/ / __ \/ / / /_ __/ / / / __ )/ ____/ / | / __ \/ ___/
        \ / / / / / / / / / / / / / __ / __/ / /| | / / / /\__ \
        / / /_/ / /_/ / / / / /_/ / /_/ / /___ / ___ |/ /_/ /___/ /
        /_/\____/\____/ ____ \______________________ |_/_____//____/
        / __ )/ / / __ \/ ____/ //_// ____/ __ \
        / __ / / / / / / / / ,< / __/ / /_/ /
        / /_/ / /___/ /_/ / /___/ /| |/ /___/ _, _/
        /_____/_____/\____/\____/_/ |_/_____/_/ |_| v3.4\e[0m by @deividgdt

        [i] Youtube Ads Blocker: INSTALLING…
        [i] You can check the logs in: /var/log/ytadsblocker.log
        [i] All the subdomains will be added to the database: /etc/pihole/gravity.db
        [i] Every 240s it reads: /var/log/pihole.log

        [\e[32m✓\e[0m] root is a valid user.
        [i] If you move the script to a different place, please run it again with the option 'install'
        [i] Installing the service…./ytadsblocker.sh: line 74: cd: /lib/systemd/system: No such file or directory
        OK. Service installed.
        [i] Configuring the database: /etc/pihole/gravity.db …
        root@301f0cbe3c0a ytadsblocker # ./ytadsblocker.sh start
        whereis: illegal option — b
        usage: whereis program […]
        [\e[32m✓\e[0m] root is a valid user.
        Youtube Ads Blocker Started
        Check the /var/log/ytadsblocker.log file to get further information.

        Thank you.

      2. After I installed the Docker Desktop, I used the following commands (via https://www.imore.com/how-run-pi-hole-your-mac):

        docker pull pihole/pihole

        then I edited and the used the following:

        docker run -d –name pihole -e ServerIP=your_IP_here -e TZ=time_zone_here -e WEBPASSWORD=Password -e DNS1=1.1.1.1 -e DNS2=1.0.0.1 -p 80:80 -p 53:53/tcp -p 53:53/udp -p 443:443 -v ~/pihole/:/etc/pihole/ –dns=127.0.0.1 –dns=1.1.1.1 –cap-add=NET_ADMIN –restart=unless-stopped pihole/pihole:latest

        I then directed the Mac’s DNS to 127.0.0.1 and it started working. It seems that in my case database and pihole folder is under ~ so I do have a pihole folder under ~/pihole/.

    2. I think I’ve found my mistake. I was directly using the Mac’s terminal to install, which explains why it couldn’t find the pihole.

      I launched the CLI on Docker Desktop for pihole and followed the same steps. I can see the new group and subdomains being added to the blacklist.

      After typing ./ytadsblocker.sh start, can I just close the terminal? I assume the script keeps working until I tell it to stop and it keeps updating the database so I don’t have to update gravity manually from the dashboard.

      1. Hi James,
        You must use an ampersand at the end of the command in order to let the script running on background.
        Something like this:
        ./ytadsblockers.sh start &
        With that will be enough.

    1. Buenas Arry650,

      Es la misma, si. Simplemente traduje la entrada al inglés para que la pueda encontrar el público de habla inglesa.

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión /  Cambiar )

Google photo

Estás comentando usando tu cuenta de Google. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s