Based on the info in this thread I've put together a simple script. I don't use the YouTube app that often, so I'm not 100% this works perfectly. It also appends the urls with the r00---sn-xxxxxx.googlevideos.com pattern, which are not in the hackertarget list.
Place it somewhere convenient, add execute permissions (chmod +x filter-youtube-domains.sh
) and add it to your cron jobs.
Edit:
I have noticed some ads still (although less than I used to). I'm not sure yet if the domains provided by hackertarget are incomplete or that I need to run my cron job more often (now it runs every 24h). I did find a longer list on Wolfram Alpha (click on subdomains) but they don't seem to have an easy way to get those in plain text.