From d4553567d2f38809df2adaaf3a2257bc01d518f4 Mon Sep 17 00:00:00 2001 From: Felix S Date: Fri, 23 Apr 2021 09:13:33 +0200 Subject: [PATCH] [downloader/ism] Prevent writing the header again when resuming an interrupted download --- yt_dlp/downloader/ism.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/yt_dlp/downloader/ism.py b/yt_dlp/downloader/ism.py index 1ca666b4a1..b3e22793b3 100644 --- a/yt_dlp/downloader/ism.py +++ b/yt_dlp/downloader/ism.py @@ -221,10 +221,13 @@ class IsmFD(FragmentFD): self._prepare_and_start_frag_download(ctx) + extra_state = ctx.setdefault('extra_state', { + 'ism_track_written': False, + }) + fragment_retries = self.params.get('fragment_retries', 0) skip_unavailable_fragments = self.params.get('skip_unavailable_fragments', True) - track_written = False frag_index = 0 for i, segment in enumerate(segments): frag_index += 1 @@ -236,11 +239,11 @@ class IsmFD(FragmentFD): success, frag_content = self._download_fragment(ctx, segment['url'], info_dict) if not success: return False - if not track_written: + if not extra_state['ism_track_written']: tfhd_data = extract_box_data(frag_content, [b'moof', b'traf', b'tfhd']) info_dict['_download_params']['track_id'] = u32.unpack(tfhd_data[4:8])[0] write_piff_header(ctx['dest_stream'], info_dict['_download_params']) - track_written = True + extra_state['ism_track_written'] = True self._append_fragment(ctx, frag_content) break except compat_urllib_error.HTTPError as err: