]> jfr.im git - yt-dlp.git/blob - ytdlp_plugins/postprocessor/sample.py
[update] Workaround #5632
[yt-dlp.git] / ytdlp_plugins / postprocessor / sample.py
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):
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')
19 self.to_screen(f'Post-processed {filepath!r} with {self._kwargs}')
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}')
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