diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-06-13 01:32:19 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-06-13 03:45:53 +0530 |
commit | 8326b00aabc332cad3edec246fe5353bea069cb0 (patch) | |
tree | 286e543dd7b6b447b797ceae8bd8655999f97970 /yt_dlp/postprocessor/common.py | |
parent | b0249bcaf0f2ac1fafecbf5d44f7403c6f0d5850 (diff) |
Allow `images` formats
Necessary for #343.
* They are identified by `vcodec=acodec='none'`
* These formats show as the worst in `-F`
* Any postprocessor that expects audio/video will be skipped
* `b*` and all related selectors will skip such formats
* This commit also does not add any selector for downloading such formats. They have to be explicitly requested by the `format_id`. Implementation of a selector is left for when #389 is resolved
Diffstat (limited to 'yt_dlp/postprocessor/common.py')
-rw-r--r-- | yt_dlp/postprocessor/common.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/yt_dlp/postprocessor/common.py b/yt_dlp/postprocessor/common.py index b6d06f33f..9bd025ff6 100644 --- a/yt_dlp/postprocessor/common.py +++ b/yt_dlp/postprocessor/common.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals +import functools import os from ..compat import compat_str @@ -67,6 +68,25 @@ class PostProcessor(object): """Sets the downloader for this PP.""" self._downloader = downloader + @staticmethod + def _restrict_to(*, video=True, audio=True, images=True): + allowed = {'video': video, 'audio': audio, 'images': images} + + def decorator(func): + @functools.wraps(func) + def wrapper(self, info): + format_type = ( + 'video' if info['vcodec'] != 'none' + else 'audio' if info['acodec'] != 'none' + else 'images') + if allowed[format_type]: + func(self, info) + else: + self.to_screen('Skipping %s' % format_type) + return [], info + return wrapper + return decorator + def run(self, information): """Run the PostProcessor. |