]> jfr.im git - yt-dlp.git/commitdiff
[downloader/fragment] Ignore `FileNotFoundError` when downloading livestreams
authorLesmiscore <redacted>
Sat, 26 Feb 2022 03:34:36 +0000 (12:34 +0900)
committerLesmiscore <redacted>
Sat, 26 Feb 2022 03:34:36 +0000 (12:34 +0900)
when `--live-from-start` is used for YouTube and the live ends, request for the last segment prematurely ends (or 404, 403).
this is causing lack of the file and `FileNotFoundError`
lacking segment doesn't have any data, so it's safe to ignore

yt_dlp/downloader/fragment.py

index 7b213cd5f8f403f065c43a0d7b32fc888efef308..24f4ec959ee2d236bfe9ea83ce6e34e164ba34ad 100644 (file)
@@ -137,7 +137,12 @@ def _download_fragment(self, ctx, frag_url, info_dict, headers=None, request_dat
         if fragment_info_dict.get('filetime'):
             ctx['fragment_filetime'] = fragment_info_dict.get('filetime')
         ctx['fragment_filename_sanitized'] = fragment_filename
-        return True, self._read_fragment(ctx)
+        try:
+            return True, self._read_fragment(ctx)
+        except FileNotFoundError:
+            if not info_dict.get('is_live'):
+                raise
+            return False, None
 
     def _read_fragment(self, ctx):
         down, frag_sanitized = self.sanitize_open(ctx['fragment_filename_sanitized'], 'rb')