mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-16 06:15:46 +00:00
Support header-related params in test cases
Header-related params are parsed into `std_headers` rather than the `params` dict, but this wasn't respected for test cases.
This commit is contained in:
parent
051e014e56
commit
0c8f7a5f12
1 changed files with 12 additions and 0 deletions
|
@ -34,6 +34,7 @@ from youtube_dl.utils import (
|
||||||
DownloadError,
|
DownloadError,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
format_bytes,
|
format_bytes,
|
||||||
|
std_headers,
|
||||||
UnavailableVideoError,
|
UnavailableVideoError,
|
||||||
)
|
)
|
||||||
from youtube_dl.extractor import get_info_extractor
|
from youtube_dl.extractor import get_info_extractor
|
||||||
|
@ -125,6 +126,17 @@ def generator(test_case, tname):
|
||||||
params.setdefault('extract_flat', 'in_playlist')
|
params.setdefault('extract_flat', 'in_playlist')
|
||||||
params.setdefault('skip_download', True)
|
params.setdefault('skip_download', True)
|
||||||
|
|
||||||
|
if 'user_agent' in params:
|
||||||
|
std_headers['User-Agent'] = params['user_agent']
|
||||||
|
|
||||||
|
if 'referer' in params:
|
||||||
|
std_headers['Referer'] = params['referer']
|
||||||
|
|
||||||
|
for h in params.get('headers', []):
|
||||||
|
h = h.split(':', 1)
|
||||||
|
if len(h) > 1:
|
||||||
|
std_headers[h[0]] = h[1]
|
||||||
|
|
||||||
ydl = YoutubeDL(params, auto_init=False)
|
ydl = YoutubeDL(params, auto_init=False)
|
||||||
ydl.add_default_info_extractors()
|
ydl.add_default_info_extractors()
|
||||||
finished_hook_called = set()
|
finished_hook_called = set()
|
||||||
|
|
Loading…
Reference in a new issue