]>
Raphaƫl G. Git Repositories - youtubedl/blob - devscripts/check-porn.py
   4 This script employs a VERY basic heuristic ('porn' in webpage.lower()) to check 
   5 if we are not 'age_limit' tagging some porn site 
   8 # Allow direct execution 
  11 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
)))) 
  13 from test
.helper 
import get_testcases
 
  14 from youtube_dl
.utils 
import compat_urllib_request
 
  16 for test 
in get_testcases(): 
  18         webpage 
= compat_urllib_request
.urlopen(test
['url'], timeout
=10).read() 
  20         print('\nFail: {0}'.format(test
['name'])) 
  23     webpage 
= webpage
.decode('utf8', 'replace') 
  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'])) 
  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']))