aboutsummaryrefslogtreecommitdiffstats
path: root/ytdlp_plugins
diff options
context:
space:
mode:
Diffstat (limited to 'ytdlp_plugins')
-rw-r--r--ytdlp_plugins/extractor/__init__.py3
-rw-r--r--ytdlp_plugins/extractor/sample.py2
-rw-r--r--ytdlp_plugins/postprocessor/__init__.py4
-rw-r--r--ytdlp_plugins/postprocessor/sample.py23
4 files changed, 29 insertions, 3 deletions
diff --git a/ytdlp_plugins/extractor/__init__.py b/ytdlp_plugins/extractor/__init__.py
index 92f2bfd86..3045a590b 100644
--- a/ytdlp_plugins/extractor/__init__.py
+++ b/ytdlp_plugins/extractor/__init__.py
@@ -1,3 +1,4 @@
-# flake8: noqa
+# flake8: noqa: F401
+# ℹ️ The imported name must end in "IE"
from .sample import SamplePluginIE
diff --git a/ytdlp_plugins/extractor/sample.py b/ytdlp_plugins/extractor/sample.py
index 99a384140..986e5bb22 100644
--- a/ytdlp_plugins/extractor/sample.py
+++ b/ytdlp_plugins/extractor/sample.py
@@ -1,7 +1,5 @@
# coding: utf-8
-from __future__ import unicode_literals
-
# ⚠ Don't use relative imports
from yt_dlp.extractor.common import InfoExtractor
diff --git a/ytdlp_plugins/postprocessor/__init__.py b/ytdlp_plugins/postprocessor/__init__.py
new file mode 100644
index 000000000..61099abbc
--- /dev/null
+++ b/ytdlp_plugins/postprocessor/__init__.py
@@ -0,0 +1,4 @@
+# flake8: noqa: F401
+
+# ℹ️ The imported name must end in "PP" and is the name to be used in --use-postprocessor
+from .sample import SamplePluginPP
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