]> jfr.im git - yt-dlp.git/blame - devscripts/check-porn.py
Add the missing age_limit tags; added a devscript to do a superficial check for porn...
[yt-dlp.git] / devscripts / check-porn.py
CommitLineData
750e9833
FV
1#!/usr/bin/env python
2
3"""
4This script employs a VERY basic heuristic ('porn' in webpage.lower()) to check
5if we are not 'age_limit' tagging some porn site
6"""
7
8# Allow direct execution
9import os
10import sys
11sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
12
13from test.helper import get_testcases
14from youtube_dl.utils import compat_urllib_request
15
16for test in get_testcases():
17 try:
18 webpage = compat_urllib_request.urlopen(test['url'], timeout=10).read()
19 except:
20 print('\nFail: {0}'.format(test['name']))
21 continue
22
23 webpage = webpage.decode('utf8', 'replace')
24
25 if 'porn' in webpage.lower() and ('info_dict' not in test
26 or 'age_limit' not in test['info_dict']
27 or test['info_dict']['age_limit'] != 18):
28 print('\nPotential missing age_limit check: {0}'.format(test['name']))
29
30 elif 'porn' not in webpage.lower() and ('info_dict' in test and
31 'age_limit' in test['info_dict'] and
32 test['info_dict']['age_limit'] == 18):
33 print('\nPotential false negative: {0}'.format(test['name']))
34
35 else:
36 sys.stdout.write('.')
37 sys.stdout.flush()
38
39print()