aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/YoutubeDL.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-12-15 01:26:18 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2014-12-15 01:26:20 +0100
commit71b640cc5b2f15a6913a720b589bdd3ed318c154 (patch)
tree2fae1a597334a878e0da92f7622d1e81351e3b10 /youtube_dl/YoutubeDL.py
parent4f026fafbc6cc4eac10a5f89b9375b44d64083c9 (diff)
[YoutubeDL] Add declarative version of progress hooks
Diffstat (limited to 'youtube_dl/YoutubeDL.py')
-rwxr-xr-xyoutube_dl/YoutubeDL.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py
index 6acfd8cf9..bea1ef83c 100755
--- a/youtube_dl/YoutubeDL.py
+++ b/youtube_dl/YoutubeDL.py
@@ -182,10 +182,27 @@ class YoutubeDL(object):
Pass in 'in_playlist' to only show this behavior for
playlist items.
postprocessors: A list of dictionaries, each with an entry
- key: The name of the postprocessor. See
- youtube_dl/postprocessor/__init__.py for a list.
+ * key: The name of the postprocessor. See
+ youtube_dl/postprocessor/__init__.py for a list.
as well as any further keyword arguments for the
postprocessor.
+ progress_hooks: A list of functions that get called on download
+ progress, with a dictionary with the entries
+ * filename: The final filename
+ * status: One of "downloading" and "finished"
+
+ The dict may also have some of the following entries:
+
+ * downloaded_bytes: Bytes on disk
+ * total_bytes: Size of the whole file, None if unknown
+ * tmpfilename: The filename we're currently writing to
+ * eta: The estimated time in seconds, None if unknown
+ * speed: The download speed in bytes/second, None if
+ unknown
+
+ Progress hooks are guaranteed to be called at least once
+ (with status "finished") if the download is successful.
+
The following parameters are not used by YoutubeDL itself, they are used by
the FileDownloader:
@@ -273,6 +290,9 @@ class YoutubeDL(object):
pp = pp_class(self, **compat_kwargs(pp_def))
self.add_post_processor(pp)
+ for ph in self.params.get('progress_hooks', []):
+ self.add_progress_hook(ph)
+
def warn_if_short_id(self, argv):
# short YouTube ID starting with dash?
idxs = [