How do I block ads on YouTube?

blacklisting

#239

I dont mind an ad at the beginning but blocking just the ones random ones while playing would be nice.


#240

I’ve written a Python script that can be run as a cronjob or separately. It will search the logs for youtube advertisement queries and add them to the local blacklist automatically.
It also creates a file blocklist.txt for further use.
For now when I detect an ad I run the script manually over ssh. Otherwise it runs once a day.

You can find it here.

Hope this helps


#241

To clarify your terminology, you are adding these domains to your “blacklist” (a local file), not to blocklists (publicly accessible lists of domains).


#242

That’s correct. It also creates a local file with the domains.


#248

Thanks for the idea eLVee!

But how is that different than blocking those domains with a simple RegEx? Plus, you can’t know for sure that does are YouTube ads - you’ll be blocking pretty much every video…

Please correct me if I’m wrong, thanks!


#249

Not really different. Just experimenting! So far it still plays all video’s and block almost everything from my side. But ran into some errors with .sn-. domains.
Regex is a lot simpler than this, but still. Liked a challenge to see how far I would come.