Skip to content

Commit

Permalink
Support header-related params in test cases
Browse files Browse the repository at this point in the history
Header-related params are parsed into `std_headers` rather than
the `params` dict, but this wasn't respected for test cases.
  • Loading branch information
dirkf committed Sep 11, 2021
1 parent 051e014 commit 0c8f7a5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
DownloadError,
ExtractorError,
format_bytes,
std_headers,
UnavailableVideoError,
)
from youtube_dl.extractor import get_info_extractor
Expand Down Expand Up @@ -125,6 +126,17 @@ def print_skipping(reason):
params.setdefault('extract_flat', 'in_playlist')
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.add_default_info_extractors()
finished_hook_called = set()
Expand Down

0 comments on commit 0c8f7a5

Please sign in to comment.