From 65e5c021e7c5f23ecbc6a982b72a02ac6cd6900d Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Fri, 17 Feb 2023 05:08:45 +0200 Subject: [utils] Don't use Content-length with encoding (#6176) Authored by: felixonmars Closes #3772, #6178 --- yt_dlp/downloader/http.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'yt_dlp/downloader/http.py') diff --git a/yt_dlp/downloader/http.py b/yt_dlp/downloader/http.py index 95c870ee8..fa72d5722 100644 --- a/yt_dlp/downloader/http.py +++ b/yt_dlp/downloader/http.py @@ -211,7 +211,12 @@ class HttpFD(FileDownloader): ctx.stream = None def download(): - data_len = ctx.data.info().get('Content-length', None) + data_len = ctx.data.info().get('Content-length') + + if ctx.data.info().get('Content-encoding'): + # Content-encoding is present, Content-length is not reliable anymore as we are + # doing auto decompression. (See: https://github.com/yt-dlp/yt-dlp/pull/6176) + data_len = None # Range HTTP header may be ignored/unsupported by a webserver # (e.g. extractor/scivee.py, extractor/bambuser.py). -- cgit v1.2.3