From 0c8f7a5f124500c618e75a6ce0cf1c27eaa2e546 Mon Sep 17 00:00:00 2001 From: df Date: Sat, 11 Sep 2021 11:58:05 +0100 Subject: [PATCH] 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. --- test/test_download.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/test_download.py b/test/test_download.py index 329f569c2..c4e6c8697 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -34,6 +34,7 @@ from youtube_dl.utils import ( DownloadError, ExtractorError, format_bytes, + std_headers, UnavailableVideoError, ) 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('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()