1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-09-03 08:35:32 +00:00

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
This commit is contained in:
pukkandan
2021-06-13 01:32:19 +05:30
parent b0249bcaf0
commit 8326b00aab
6 changed files with 44 additions and 7 deletions

View File

@ -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.