├── .gitignore ├── LICENSE ├── README.md ├── pyproject.toml ├── setup.cfg └── yt_dlp_plugins ├── extractor ├── sample.py └── sample_override.py └── postprocessor └── sample.py /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | *.egg-info/ 3 | *.pyc 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This repository contains a sample plugin package for [yt-dlp](https://github.com/yt-dlp/yt-dlp#readme). 2 | 3 | See [yt-dlp plugins](https://github.com/yt-dlp/yt-dlp#plugins) for more details. 4 | 5 | 6 | ## Installation 7 | 8 | Requires yt-dlp `2023.01.02` or above. 9 | 10 | You can install this package with pip: 11 | ``` 12 | python3 -m pip install -U https://github.com/yt-dlp/yt-dlp-sample-plugins/archive/master.zip 13 | ``` 14 | 15 | See [installing yt-dlp plugins](https://github.com/yt-dlp/yt-dlp#installing-plugins) for the other methods this plugin package can be installed. 16 | 17 | 18 | ## Development 19 | 20 | See the [Plugin Development](https://github.com/yt-dlp/yt-dlp/wiki/Plugin-Development) section of the yt-dlp wiki. 21 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [tool.distutils.bdist_wheel] 6 | universal = true 7 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = yt-dlp-sample-plugins 3 | version = 2023.01.01 4 | 5 | [options] 6 | packages = find_namespace: 7 | -------------------------------------------------------------------------------- /yt_dlp_plugins/extractor/sample.py: -------------------------------------------------------------------------------- 1 | # ⚠ Don't use relative imports 2 | from yt_dlp.extractor.common import InfoExtractor 3 | 4 | # ℹ️ If you need to import from another plugin 5 | # from yt_dlp_plugins.extractor.example import ExamplePluginIE 6 | 7 | # ℹ️ Instructions on making extractors can be found at: 8 | # 🔗 https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#adding-support-for-a-new-site 9 | 10 | 11 | # ⚠ The class name must end in "IE" 12 | class SamplePluginIE(InfoExtractor): 13 | _WORKING = False 14 | _VALID_URL = r'^sampleplugin:' 15 | 16 | def _real_extract(self, url): 17 | self.to_screen('URL "%s" successfully captured' % url) 18 | -------------------------------------------------------------------------------- /yt_dlp_plugins/extractor/sample_override.py: -------------------------------------------------------------------------------- 1 | from yt_dlp.extractor.youtube import YoutubeIE 2 | 3 | # ⚠ Other plugins cannot be overridden using this method 4 | # ⚠ The extractor internals may change without warning, breaking the plugin 5 | 6 | 7 | 8 | class _SampleOverridePluginIE(YoutubeIE, plugin_name='sample'): 9 | def _real_extract(self, url): 10 | self.to_screen('Passing through SampleOverridePluginIE') 11 | return super()._real_extract(url) 12 | -------------------------------------------------------------------------------- /yt_dlp_plugins/postprocessor/sample.py: -------------------------------------------------------------------------------- 1 | # ⚠ Don't use relative imports 2 | from yt_dlp.postprocessor.common import PostProcessor 3 | 4 | # ℹ️ See the docstring of yt_dlp.postprocessor.common.PostProcessor 5 | 6 | # ⚠ The class name must end in "PP" 7 | 8 | 9 | class SamplePluginPP(PostProcessor): 10 | def __init__(self, downloader=None, **kwargs): 11 | # ⚠ Only kwargs can be passed from the CLI, and all argument values will be string 12 | # Also, "downloader", "when" and "key" are reserved names 13 | super().__init__(downloader) 14 | self._kwargs = kwargs 15 | 16 | # ℹ️ See docstring of yt_dlp.postprocessor.common.PostProcessor.run 17 | def run(self, info): 18 | filepath = info.get('filepath') 19 | if filepath: # PP was called after download (default) 20 | self.to_screen(f'Post-processed {filepath!r} with {self._kwargs}') 21 | else: # PP was called before actual download 22 | filepath = info.get('_filename') 23 | self.to_screen(f'Pre-processed {filepath!r} with {self._kwargs}') 24 | return [], info # return list_of_files_to_delete, info_dict 25 | --------------------------------------------------------------------------------