[FragmentFD] Respect --no-continue

* discard partial fragment on `--no-continue`
* continue with correct progress display otherwise

Resolves #21467
This commit is contained in:
dirkf
2023-03-11 12:17:00 +00:00
parent 5c985d4f81
commit baa6c5e95c
4 changed files with 58 additions and 37 deletions

View File

@@ -38,8 +38,7 @@ class DashSegmentsFD(FragmentFD):
# In DASH, the first segment contains necessary headers to
# generate a valid MP4 file, so always abort for the first segment
fatal = i == 0 or not skip_unavailable_fragments
count = 0
while count <= fragment_retries:
for count in range(fragment_retries + 1):
try:
fragment_url = fragment.get('url')
if not fragment_url:
@@ -57,9 +56,8 @@ class DashSegmentsFD(FragmentFD):
# is usually enough) thus allowing to download the whole file successfully.
# To be future-proof we will retry all fragments that fail with any
# HTTP error.
count += 1
if count <= fragment_retries:
self.report_retry_fragment(err, frag_index, count, fragment_retries)
if count < fragment_retries:
self.report_retry_fragment(err, frag_index, count + 1, fragment_retries)
except DownloadError:
# Don't retry fragment if error occurred during HTTP downloading
# itself since it has own retry settings
@@ -68,7 +66,7 @@ class DashSegmentsFD(FragmentFD):
break
raise
if count > fragment_retries:
if count >= fragment_retries:
if not fatal:
self.report_skip_fragment(frag_index)
continue