mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-12-15 11:06:39 +01:00
[postprocessor] Add plugin support
Adds option `--use-postprocessor` to enable them
This commit is contained in:
parent
8e3fd7e034
commit
3ae5e79774
11 changed files with 95 additions and 49 deletions
23
ytdlp_plugins/postprocessor/sample.py
Normal file
23
ytdlp_plugins/postprocessor/sample.py
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue