diff options
author | dirkf <fieldhouse@gmx.net> | 2023-03-11 12:17:00 +0000 |
---|---|---|
committer | dirkf <fieldhouse@gmx.net> | 2023-03-14 16:23:20 +0000 |
commit | baa6c5e95cb307e7d716645780ff8aef22de6aca (patch) | |
tree | 419f4f2cd94ac6f2b3fa8fb60483b8bb933a658c /youtube_dl/downloader/http.py | |
parent | 5c985d4f81a43ada75dafb23233e7fe39913907a (diff) | |
download | youtube-dl-baa6c5e95cb307e7d716645780ff8aef22de6aca.tar.xz |
[FragmentFD] Respect `--no-continue`
* discard partial fragment on `--no-continue`
* continue with correct progress display otherwise
Resolves #21467
Diffstat (limited to 'youtube_dl/downloader/http.py')
-rw-r--r-- | youtube_dl/downloader/http.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/youtube_dl/downloader/http.py b/youtube_dl/downloader/http.py index d8ac41dcc..440471aa0 100644 --- a/youtube_dl/downloader/http.py +++ b/youtube_dl/downloader/http.py @@ -58,9 +58,9 @@ class HttpFD(FileDownloader): if self.params.get('continuedl', True): # Establish possible resume length - if os.path.isfile(encodeFilename(ctx.tmpfilename)): - ctx.resume_len = os.path.getsize( - encodeFilename(ctx.tmpfilename)) + ctx.resume_len = info_dict.get('frag_resume_len') + if ctx.resume_len is None: + ctx.resume_len = self.filesize_or_none(ctx.tmpfilename) or 0 ctx.is_resume = ctx.resume_len > 0 @@ -115,9 +115,9 @@ class HttpFD(FileDownloader): raise RetryDownload(err) raise err # When trying to resume, Content-Range HTTP header of response has to be checked - # to match the value of requested Range HTTP header. This is due to a webservers + # to match the value of requested Range HTTP header. This is due to webservers # that don't support resuming and serve a whole file with no Content-Range - # set in response despite of requested Range (see + # set in response despite requested Range (see # https://github.com/ytdl-org/youtube-dl/issues/6057#issuecomment-126129799) if has_range: content_range = ctx.data.headers.get('Content-Range') @@ -293,10 +293,7 @@ class HttpFD(FileDownloader): # Progress message speed = self.calc_speed(start, now, byte_counter - ctx.resume_len) - if ctx.data_len is None: - eta = None - else: - eta = self.calc_eta(start, time.time(), ctx.data_len - ctx.resume_len, byte_counter - ctx.resume_len) + eta = self.calc_eta(speed, ctx.data_len and (ctx.data_len - ctx.resume_len)) self._hook_progress({ 'status': 'downloading', |