]> jfr.im git - yt-dlp.git/blob - ytdlp_plugins/postprocessor/sample.py
[postprocessor] Add plugin support
[yt-dlp.git] / ytdlp_plugins / postprocessor / sample.py
1 # coding: utf-8
2
3 # ⚠ Don't use relative imports
4 from yt_dlp.postprocessor.common import PostProcessor
5
6
7 # ℹ️ See the docstring of yt_dlp.postprocessor.common.PostProcessor
8 class SamplePluginPP(PostProcessor):
9 def __init__(self, downloader=None, **kwargs):
10 # ⚠ Only kwargs can be passed from the CLI, and all argument values will be string
11 # Also, "downloader", "when" and "key" are reserved names
12 super().__init__(downloader)
13 self._kwargs = kwargs
14
15 # ℹ️ See docstring of yt_dlp.postprocessor.common.PostProcessor.run
16 def run(self, info):
17 filepath = info.get('filepath')
18 if filepath: # PP was called after download (default)
19 self.to_screen(f'Post-processed {filepath!r} with {self._kwargs}')
20 else: # PP was called before actual download
21 filepath = info.get('_filename')
22 self.to_screen(f'Pre-processed {filepath!r} with {self._kwargs}')
23 return [], info # return list_of_files_to_delete, info_dict