Browse Source

[utils] Refactor handle_youtubedl_headers for future extension

master
Yen Chi Hsuan 9 years ago
parent
commit
992fc9d6e1
1 changed files with 5 additions and 4 deletions
  1. 9
      youtube_dl/utils.py

9
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): 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')
filtered_headers = 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'] del filtered_headers['Youtubedl-no-compression']
return filtered_headers
return headers
return filtered_headers
class YoutubeDLHandler(compat_urllib_request.HTTPHandler): class YoutubeDLHandler(compat_urllib_request.HTTPHandler):

Loading…
Cancel
Save