From 992fc9d6e124b910ff3d720e252ef9aad99b2a8b Mon Sep 17 00:00:00 2001 From: Yen Chi Hsuan Date: Sun, 29 Nov 2015 12:58:29 +0800 Subject: [PATCH] [utils] Refactor handle_youtubedl_headers for future extension --- youtube_dl/utils.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index c43e9e3a1..d0606b4bc 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -664,12 +664,13 @@ def _create_http_connection(ydl_handler, http_class, is_https, *args, **kwargs): def handle_youtubedl_headers(headers): - if 'Youtubedl-no-compression' in headers: - filtered_headers = dict((k, v) for k, v in headers.items() if k.lower() != 'accept-encoding') - del filtered_headers['Youtubedl-no-compression'] - return filtered_headers + filtered_headers = headers - return headers + if 'Youtubedl-no-compression' in filtered_headers: + filtered_headers = dict((k, v) for k, v in filtered_headers.items() if k.lower() != 'accept-encoding') + del filtered_headers['Youtubedl-no-compression'] + + return filtered_headers class YoutubeDLHandler(compat_urllib_request.HTTPHandler):