]>
Commit | Line | Data |
---|---|---|
3ae5e797 | 1 | # ⚠ Don't use relative imports |
2 | from yt_dlp.postprocessor.common import PostProcessor | |
3 | ||
4 | ||
5 | # ℹ️ See the docstring of yt_dlp.postprocessor.common.PostProcessor | |
6 | class SamplePluginPP(PostProcessor): | |
7 | def __init__(self, downloader=None, **kwargs): | |
8 | # ⚠ Only kwargs can be passed from the CLI, and all argument values will be string | |
9 | # Also, "downloader", "when" and "key" are reserved names | |
10 | super().__init__(downloader) | |
11 | self._kwargs = kwargs | |
12 | ||
13 | # ℹ️ See docstring of yt_dlp.postprocessor.common.PostProcessor.run | |
14 | def run(self, info): | |
ebed8b37 | 15 | if info.get('_type', 'video') != 'video': # PP was called for playlist |
16 | self.to_screen(f'Post-processing playlist {info.get("id")!r} with {self._kwargs}') | |
17 | elif info.get('filepath'): # PP was called after download (default) | |
18 | filepath = info.get('filepath') | |
3ae5e797 | 19 | self.to_screen(f'Post-processed {filepath!r} with {self._kwargs}') |
f46e2f9d | 20 | elif info.get('requested_downloads'): # PP was called after_video |
21 | filepaths = [f.get('filepath') for f in info.get('requested_downloads')] | |
22 | self.to_screen(f'Post-processed {filepaths!r} with {self._kwargs}') | |
3ae5e797 | 23 | else: # PP was called before actual download |
24 | filepath = info.get('_filename') | |
25 | self.to_screen(f'Pre-processed {filepath!r} with {self._kwargs}') | |
26 | return [], info # return list_of_files_to_delete, info_dict |