Search code examples
regexpihole

Block Youtube ads


I'm trying to block the annoying youtube ads with pihole but unfortunately it doesn't work for me. The following is not viewed at all:

(rr[\d]{1}---[\s]{2}-[\s]{8}-[\w]{4})\.googlevideo\.com

Has anyone had similar experiences?

Examples look like this

rr1---sn-8xgn5uxa-quhl.googlevideo.com
rr1---sn-8xgn5uxa-quhl.googlevideo.com
rr3---sn-8xgn5uxa-quhz.googlevideo.com
rr6---sn-8xgn5uxa-quhl.googlevideo.com

Solution

  • Pi-Hole documentation does not mention the usual abbrevations for character classes (like \d, \s or \w you used).

    If you replace your character classes with the ones from the Pi-Hole documentation you end with

    (rr[:digit:]{1}---[:space:]{2}-[:space:]{8}-[A-Za-z0-9_]{4})\.googlevideo\.com
    

    Probably the \s is not what you originally wanted, as your examples contain letters there instead of spaces. And \w includes an underscore, that does not appear in your examples. Also a {1} can be skipped.

    So I would suggest this expression:

    (rr[:digit:]---[:alnum:]{2}-[:alnum:]{8}-[:alnum:]{4})\.googlevideo\.com
    

    If you don't need the hostname-part for further processing, you could remove the group marker () around it.