Introduce --keep-fragments
[youtube-dl] / youtube_dl / downloader / fragment.py
index 62de0a75bad4553ff963c7919f035975097af1f3..bcff94cbe918c1bf6a984b29c780c550cad430af 100644 (file)
@@ -29,6 +29,8 @@ class FragmentFD(FileDownloader):
                         and hlsnative only)
     skip_unavailable_fragments:
                         Skip unavailable fragments (DASH and hlsnative only)
+    keep_fragments:     Keep downloaded fragments on disk after downloading is
+                        finished
     """
 
     def report_retry_fragment(self, err, frag_index, count, retries):
@@ -81,7 +83,8 @@ class FragmentFD(FileDownloader):
         finally:
             if not (ctx.get('live') or ctx['tmpfilename'] == '-'):
                 self._write_ytdl_file(ctx)
-            os.remove(ctx['fragment_filename_sanitized'])
+            if not self.params.get('keep_fragments', False):
+                os.remove(ctx['fragment_filename_sanitized'])
             del ctx['fragment_filename_sanitized']
 
     def _prepare_frag_download(self, ctx):