aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/downloader/ism.py
diff options
context:
space:
mode:
Diffstat (limited to 'yt_dlp/downloader/ism.py')
-rw-r--r--yt_dlp/downloader/ism.py27
1 files changed, 13 insertions, 14 deletions
diff --git a/yt_dlp/downloader/ism.py b/yt_dlp/downloader/ism.py
index 8a0071ab3..a157a8ad9 100644
--- a/yt_dlp/downloader/ism.py
+++ b/yt_dlp/downloader/ism.py
@@ -5,6 +5,7 @@ import time
import urllib.error
from .fragment import FragmentFD
+from ..utils import RetryManager
u8 = struct.Struct('>B')
u88 = struct.Struct('>Bx')
@@ -137,6 +138,8 @@ def write_piff_header(stream, params):
if fourcc == 'AACL':
sample_entry_box = box(b'mp4a', sample_entry_payload)
+ if fourcc == 'EC-3':
+ sample_entry_box = box(b'ec-3', sample_entry_payload)
elif stream_type == 'video':
sample_entry_payload += u16.pack(0) # pre defined
sample_entry_payload += u16.pack(0) # reserved
@@ -245,7 +248,6 @@ class IsmFD(FragmentFD):
'ism_track_written': False,
})
- fragment_retries = self.params.get('fragment_retries', 0)
skip_unavailable_fragments = self.params.get('skip_unavailable_fragments', True)
frag_index = 0
@@ -253,8 +255,10 @@ class IsmFD(FragmentFD):
frag_index += 1
if frag_index <= ctx['fragment_index']:
continue
- count = 0
- while count <= fragment_retries:
+
+ retry_manager = RetryManager(self.params.get('fragment_retries'), self.report_retry,
+ frag_index=frag_index, fatal=not skip_unavailable_fragments)
+ for retry in retry_manager:
try:
success = self._download_fragment(ctx, segment['url'], info_dict)
if not success:
@@ -267,18 +271,13 @@ class IsmFD(FragmentFD):
write_piff_header(ctx['dest_stream'], info_dict['_download_params'])
extra_state['ism_track_written'] = True
self._append_fragment(ctx, frag_content)
- break
except urllib.error.HTTPError as err:
- count += 1
- if count <= fragment_retries:
- self.report_retry_fragment(err, frag_index, count, fragment_retries)
- if count > fragment_retries:
- if skip_unavailable_fragments:
- self.report_skip_fragment(frag_index)
+ retry.error = err
continue
- self.report_error('giving up after %s fragment retries' % fragment_retries)
- return False
- self._finish_frag_download(ctx, info_dict)
+ if retry_manager.error:
+ if not skip_unavailable_fragments:
+ return False
+ self.report_skip_fragment(frag_index)
- return True
+ return self._finish_frag_download(ctx, info_dict)