diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-09-30 02:23:33 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-09-30 03:32:46 +0530 |
commit | 3ae5e7977439193519c0ea62eba3aa3111c5571b (patch) | |
tree | b0ddc209e5baec86908fec6d6bddcbc6e385a062 /ytdlp_plugins/postprocessor/sample.py | |
parent | 8e3fd7e034cdd54972d13394821cd9e55e1c3735 (diff) | |
download | hypervideo-pre-3ae5e7977439193519c0ea62eba3aa3111c5571b.tar.lz hypervideo-pre-3ae5e7977439193519c0ea62eba3aa3111c5571b.tar.xz hypervideo-pre-3ae5e7977439193519c0ea62eba3aa3111c5571b.zip |
[postprocessor] Add plugin support
Adds option `--use-postprocessor` to enable them
Diffstat (limited to 'ytdlp_plugins/postprocessor/sample.py')
-rw-r--r-- | ytdlp_plugins/postprocessor/sample.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/ytdlp_plugins/postprocessor/sample.py b/ytdlp_plugins/postprocessor/sample.py new file mode 100644 index 000000000..6891280d5 --- /dev/null +++ b/ytdlp_plugins/postprocessor/sample.py @@ -0,0 +1,23 @@ +# coding: utf-8 + +# ⚠ Don't use relative imports +from yt_dlp.postprocessor.common import PostProcessor + + +# ℹ️ See the docstring of yt_dlp.postprocessor.common.PostProcessor +class SamplePluginPP(PostProcessor): + def __init__(self, downloader=None, **kwargs): + # ⚠ Only kwargs can be passed from the CLI, and all argument values will be string + # Also, "downloader", "when" and "key" are reserved names + super().__init__(downloader) + self._kwargs = kwargs + + # ℹ️ See docstring of yt_dlp.postprocessor.common.PostProcessor.run + def run(self, info): + filepath = info.get('filepath') + if filepath: # PP was called after download (default) + self.to_screen(f'Post-processed {filepath!r} with {self._kwargs}') + else: # PP was called before actual download + filepath = info.get('_filename') + self.to_screen(f'Pre-processed {filepath!r} with {self._kwargs}') + return [], info # return list_of_files_to_delete, info_dict |