youtube-dl

Another place where youtube-dl lives on
git clone git://git.oshgnacknak.de/youtube-dl.git
Log | Files | Refs | README | LICENSE

commit 0eee52f34bfa55ba9d4ebfc4b4ba508c989f05b0
parent d3f0687cf7b049b976420056e02c26b5d96adeed
Author: Sergey M․ <dstftw@gmail.com>
Date:   Mon, 24 Apr 2017 03:09:08 +0700

Introduce --keep-fragments

Diffstat:
Myoutube_dl/__init__.py | 1+
Myoutube_dl/downloader/fragment.py | 5++++-
Myoutube_dl/options.py | 4++++
3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py @@ -343,6 +343,7 @@ def _real_main(argv=None): 'retries': opts.retries, 'fragment_retries': opts.fragment_retries, 'skip_unavailable_fragments': opts.skip_unavailable_fragments, + 'keep_fragments': opts.keep_fragments, 'buffersize': opts.buffersize, 'noresizebuffer': opts.noresizebuffer, 'continuedl': opts.continue_dl, diff --git a/youtube_dl/downloader/fragment.py b/youtube_dl/downloader/fragment.py @@ -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): diff --git a/youtube_dl/options.py b/youtube_dl/options.py @@ -469,6 +469,10 @@ def parseOpts(overrideArguments=None): action='store_false', dest='skip_unavailable_fragments', help='Abort downloading when some fragment is not available') downloader.add_option( + '--keep-fragments', + action='store_true', dest='keep_fragments', default=False, + help='Keep downloaded fragments on disk after downloading is finished; fragments are erased by default') + downloader.add_option( '--buffer-size', dest='buffersize', metavar='SIZE', default='1024', help='Size of download buffer (e.g. 1024 or 16K) (default is %default)')