Home > database >  Block Youtube ads
Block Youtube ads

Time:03-29

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

CodePudding user response:

Using [\s]{2} in the pattern (which can be written as \s{2} matches 2 whitespace chars, but in the example data there is sn

The single meta characters in this case do not have to be placed between square brackets.

Looking at some documentation on this page \w \s and \d are not supported.

You might use

rr[[:digit:]]---sn-[[:alnum:]]{8}-[[:alnum:]]{4}\.googlevideo\.com

The pattern matches:

  • rr[[:digit:]] Match rr and a single digit
  • ---sn- Match literally
  • [[:alnum:]]{8} Match 8 alphanumerics
  • -[[:alnum:]]{4} Match - and 4 alphanumerics
  • \.googlevideo\.com Match .googlevideo.com

See a regex demo.

CodePudding user response:

This pattern matches all your samples but it may be too tight?

rr\d---sn-8xgn5uxa-quh\w.googlevideo.com

CodePudding user response:

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.

  • Related