A feature-rich command-line audio/video downloader
Add new option `--progress-delta` (#9082)
Simon Sawicki9590cc6b4768
diff --git a/README.md b/README.mdindex fde5453f82..bc4eba6606 100644--- a/README.md+++ b/README.md@@ -758,6 +758,7 @@ If you fork the project on GitHub, you can run your fork's [build workflow](.gitaccessible under "progress" key. E.g.--console-title --progress-template"download-title:%(info.id)s-%(progress.eta)s"+ --progress-delta SECONDS Time between progress output (default: 0)-v, --verbose Print various debugging information--dump-pages Print downloaded pages encoded using base64to debug problems (very verbose)diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.pyindex 291fc8d00c..35aba968fb 100644--- a/yt_dlp/YoutubeDL.py+++ b/yt_dlp/YoutubeDL.py@@ -481,7 +481,7 @@ class YoutubeDL:nopart, updatetime, buffersize, ratelimit, throttledratelimit, min_filesize,max_filesize, test, noresizebuffer, retries, file_access_retries, fragment_retries,continuedl, xattr_set_filesize, hls_use_mpegts, http_chunk_size,- external_downloader_args, concurrent_fragment_downloads.+ external_downloader_args, concurrent_fragment_downloads, progress_delta.The following options are used by the post processors:ffmpeg_location: Location of the ffmpeg/avconv binary; either the pathdiff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.pyindex 940594fafb..3d606bcba2 100644--- a/yt_dlp/__init__.py+++ b/yt_dlp/__init__.py@@ -836,6 +836,7 @@ def parse_options(argv=None):'noprogress': opts.quiet if opts.noprogress is None else opts.noprogress,'progress_with_newline': opts.progress_with_newline,'progress_template': opts.progress_template,+ 'progress_delta': opts.progress_delta,'playliststart': opts.playliststart,'playlistend': opts.playlistend,'playlistreverse': opts.playlist_reverse,diff --git a/yt_dlp/downloader/common.py b/yt_dlp/downloader/common.pyindex b71d7ee8f2..65a0d6f234 100644--- a/yt_dlp/downloader/common.py+++ b/yt_dlp/downloader/common.py@@ -4,6 +4,7 @@ import functoolsimport osimport randomimport re+import threadingimport timefrom ..minicurses import (@@ -63,6 +64,7 @@ class FileDownloader:min_filesize: Skip files smaller than this sizemax_filesize: Skip files larger than this sizexattr_set_filesize: Set ytdl.filesize user xattribute with expected size.+ progress_delta: The minimum time between progress output, in secondsexternal_downloader_args: A dictionary of downloader keys (in lower case)and a list of additional command-line arguments for theexecutable. Use 'default' as the name for arguments to be@@ -88,6 +90,9 @@ class FileDownloader:self.params = paramsself._prepare_multiline_status()self.add_progress_hook(self.report_progress)+ if self.params.get('progress_delta'):+ self._progress_delta_lock = threading.Lock()+ self._progress_delta_time = time.monotonic()def _set_ydl(self, ydl):self.ydl = ydl@@ -366,6 +371,12 @@ class FileDownloader:if s['status'] != 'downloading':return+ if update_delta := self.params.get('progress_delta'):+ with self._progress_delta_lock:+ if time.monotonic() < self._progress_delta_time:+ return+ self._progress_delta_time += update_delta+s.update({'_eta_str': self.format_eta(s.get('eta')).strip(),'_speed_str': self.format_speed(s.get('speed')),diff --git a/yt_dlp/options.py b/yt_dlp/options.pyindex 43d71ef070..faa1ee5634 100644--- a/yt_dlp/options.py+++ b/yt_dlp/options.py@@ -1258,6 +1258,10 @@ def create_parser():'the progress attributes are accessible under "progress" key. E.g. '# TODO: Document the fields inside "progress"'--console-title --progress-template "download-title:%(info.id)s-%(progress.eta)s"'))+ verbosity.add_option(+ '--progress-delta',+ metavar='SECONDS', action='store', dest='progress_delta', type=float, default=0,+ help='Time between progress output (default: 0)')verbosity.add_option('-v', '--verbose',action='store_true', dest='verbose', default=False,