mirror of https://github.com/ytdl-org/youtube-dl
[DashSegmentsFD] Correctly detect errors when `fragment_retries` == 0
* use the success flag instead of the retry count * establish the fragment_url outside the retry loop * only report skipping a fragment once. * resolves #32033pull/32060/head
parent
2da3fa04a6
commit
26035bde46
|
@ -38,12 +38,13 @@ class DashSegmentsFD(FragmentFD):
|
||||||
# In DASH, the first segment contains necessary headers to
|
# In DASH, the first segment contains necessary headers to
|
||||||
# generate a valid MP4 file, so always abort for the first segment
|
# generate a valid MP4 file, so always abort for the first segment
|
||||||
fatal = frag_index == 1 or not skip_unavailable_fragments
|
fatal = frag_index == 1 or not skip_unavailable_fragments
|
||||||
|
fragment_url = fragment.get('url')
|
||||||
|
if not fragment_url:
|
||||||
|
assert fragment_base_url
|
||||||
|
fragment_url = urljoin(fragment_base_url, fragment['path'])
|
||||||
|
success = False
|
||||||
for count in itertools.count():
|
for count in itertools.count():
|
||||||
try:
|
try:
|
||||||
fragment_url = fragment.get('url')
|
|
||||||
if not fragment_url:
|
|
||||||
assert fragment_base_url
|
|
||||||
fragment_url = urljoin(fragment_base_url, fragment['path'])
|
|
||||||
success, frag_content = self._download_fragment(ctx, fragment_url, info_dict)
|
success, frag_content = self._download_fragment(ctx, fragment_url, info_dict)
|
||||||
if not success:
|
if not success:
|
||||||
return False
|
return False
|
||||||
|
@ -63,14 +64,13 @@ class DashSegmentsFD(FragmentFD):
|
||||||
# itself since it has its own retry settings
|
# itself since it has its own retry settings
|
||||||
if fatal:
|
if fatal:
|
||||||
raise
|
raise
|
||||||
self.report_skip_fragment(frag_index)
|
|
||||||
break
|
break
|
||||||
|
|
||||||
if count >= fragment_retries:
|
if not success:
|
||||||
if not fatal:
|
if not fatal:
|
||||||
self.report_skip_fragment(frag_index)
|
self.report_skip_fragment(frag_index)
|
||||||
continue
|
continue
|
||||||
self.report_error('giving up after %s fragment retries' % fragment_retries)
|
self.report_error('giving up after %s fragment retries' % count)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self._finish_frag_download(ctx)
|
self._finish_frag_download(ctx)
|
||||||
|
|
Loading…
Reference in New Issue