]>
Raphaƫl G. Git Repositories - youtubedl/blob - test/test_age_restriction.py
3 # Allow direct execution
7 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
9 from test
.helper
import global_setup
, try_rm
13 from youtube_dl
import YoutubeDL
16 def _download_restricted(url
, filename
, age
):
17 """ Returns true iff the file has been downloaded """
21 'skip_download': True,
22 'writeinfojson': True,
23 "outtmpl": "%(id)s.%(ext)s",
25 ydl
= YoutubeDL(params
)
26 ydl
.add_default_info_extractors()
27 json_filename
= filename
+ '.info.json'
30 res
= os
.path
.exists(json_filename
)
35 class TestAgeRestriction(unittest
.TestCase
):
36 def _assert_restricted(self
, url
, filename
, age
, old_age
=None):
37 self
.assertTrue(_download_restricted(url
, filename
, old_age
))
38 self
.assertFalse(_download_restricted(url
, filename
, age
))
40 def test_youtube(self
):
41 self
._assert
_restricted
('07FYdnEawAQ', '07FYdnEawAQ.mp4', 10)
43 def test_youporn(self
):
44 self
._assert
_restricted
(
45 'http://www.youporn.com/watch/505835/sex-ed-is-it-safe-to-masturbate-daily/',
46 '505835.mp4', 2, old_age
=25)
48 def test_pornotube(self
):
49 self
._assert
_restricted
(
50 'http://pornotube.com/c/173/m/1689755/Marilyn-Monroe-Bathing',
54 if __name__
== '__main__':