5 import youtube_dl.extractor
6 from youtube_dl import YoutubeDL, YoutubeDLHandler
7 from youtube_dl.utils import (
12 # General configuration (from __init__, not very elegant...)
13 jar = compat_cookiejar.CookieJar()
14 cookie_processor = compat_urllib_request.HTTPCookieProcessor(jar)
15 proxy_handler = compat_urllib_request.ProxyHandler()
16 opener = compat_urllib_request.build_opener(proxy_handler, cookie_processor, YoutubeDLHandler())
17 compat_urllib_request.install_opener(opener)
19 PARAMETERS_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "parameters.json")
20 with io.open(PARAMETERS_FILE, encoding='utf-8') as pf:
21 parameters = json.load(pf)
23 class FakeYDL(YoutubeDL):
26 # Different instances of the downloader can't share the same dictionary
27 # some test set the "sublang" parameter, which would break the md5 checks.
28 self.params = dict(parameters)
29 def to_screen(self, s):
31 def trouble(self, s, tb=None):
33 def download(self, x):
37 for ie in youtube_dl.extractor.gen_extractors():
38 t = getattr(ie, '_TEST', None)
40 t['name'] = type(ie).__name__[:-len('IE')]
42 for t in getattr(ie, '_TESTS', []):
43 t['name'] = type(ie).__name__[:-len('IE')]