From 000ee7ef3440349cd714f8bdfab4214648881805 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Sat, 8 May 2021 23:42:25 +0530 Subject: [PATCH] [fragment] Make sure first segment is not skipped --- yt_dlp/downloader/dash.py | 5 +++-- yt_dlp/downloader/hls.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/yt_dlp/downloader/dash.py b/yt_dlp/downloader/dash.py index 4ccf53e23..b3ebfb057 100644 --- a/yt_dlp/downloader/dash.py +++ b/yt_dlp/downloader/dash.py @@ -120,6 +120,7 @@ def download_fragment(fragment): return frag_content, frag_index def append_fragment(frag_content, frag_index): + fatal = frag_index == 1 or not skip_unavailable_fragments if frag_content: fragment_filename = '%s-Frag%d' % (ctx['tmpfilename'], frag_index) try: @@ -132,7 +133,7 @@ def append_fragment(frag_content, frag_index): if ose.errno != errno.ENOENT: raise # FileNotFoundError - if skip_unavailable_fragments: + if not fatal: self.report_skip_fragment(frag_index) return True else: @@ -141,7 +142,7 @@ def append_fragment(frag_content, frag_index): 'fragment %s not found, unable to continue' % frag_index) return False else: - if skip_unavailable_fragments: + if not fatal: self.report_skip_fragment(frag_index) return True else: diff --git a/yt_dlp/downloader/hls.py b/yt_dlp/downloader/hls.py index 8a99171f8..c66902cdf 100644 --- a/yt_dlp/downloader/hls.py +++ b/yt_dlp/downloader/hls.py @@ -387,6 +387,7 @@ def pack_fragment(frag_content, frag_index): return output.getvalue().encode('utf-8') def append_fragment(frag_content, frag_index): + fatal = frag_index == 1 or not skip_unavailable_fragments if frag_content: fragment_filename = '%s-Frag%d' % (ctx['tmpfilename'], frag_index) try: @@ -400,7 +401,7 @@ def append_fragment(frag_content, frag_index): if ose.errno != errno.ENOENT: raise # FileNotFoundError - if skip_unavailable_fragments: + if not fatal: self.report_skip_fragment(frag_index) return True else: @@ -409,7 +410,7 @@ def append_fragment(frag_content, frag_index): 'fragment %s not found, unable to continue' % frag_index) return False else: - if skip_unavailable_fragments: + if not fatal: self.report_skip_fragment(frag_index) return True else: