aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2021-11-23 20:38:30 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2021-11-23 20:42:20 +0530
commitff51ed588fa75256b98ead67bdef7edda08b66f0 (patch)
tree00822839af5065ad90fede54a7fd4ed8604cea98
parent57dbe8077f8d00e0fffac53669f40cd7d584474f (diff)
downloadhypervideo-pre-ff51ed588fa75256b98ead67bdef7edda08b66f0.tar.lz
hypervideo-pre-ff51ed588fa75256b98ead67bdef7edda08b66f0.tar.xz
hypervideo-pre-ff51ed588fa75256b98ead67bdef7edda08b66f0.zip
Clarify video/audio-only formats in -F
Related: #1759
-rw-r--r--yt_dlp/YoutubeDL.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index 5c2d64598..b983b1775 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -847,6 +847,7 @@ class YoutubeDL(object):
DELIM = 'blue'
ERROR = 'red'
WARNING = 'yellow'
+ SUPPRESS = 'light black'
def __format_text(self, out, text, f, fallback=None, *, test_encoding=False):
assert out in ('screen', 'err')
@@ -3149,22 +3150,17 @@ class YoutubeDL(object):
@staticmethod
def format_resolution(format, default='unknown'):
- is_images = format.get('vcodec') == 'none' and format.get('acodec') == 'none'
if format.get('vcodec') == 'none' and format.get('acodec') != 'none':
return 'audio only'
if format.get('resolution') is not None:
return format['resolution']
if format.get('width') and format.get('height'):
- res = '%dx%d' % (format['width'], format['height'])
+ return '%dx%d' % (format['width'], format['height'])
elif format.get('height'):
- res = '%sp' % format['height']
+ return '%sp' % format['height']
elif format.get('width'):
- res = '%dx?' % format['width']
- elif is_images:
- return 'images'
- else:
- return default
- return f'img {res}' if is_images else res
+ return '%dx?' % format['width']
+ return default
def _format_note(self, fdict):
res = ''
@@ -3236,7 +3232,7 @@ class YoutubeDL(object):
[
self._format_screen(format_field(f, 'format_id'), self.Styles.ID),
format_field(f, 'ext'),
- self.format_resolution(f),
+ format_field(f, func=self.format_resolution, ignore=('audio only', 'images')),
format_field(f, 'fps', '\t%d'),
format_field(f, 'dynamic_range', '%s', ignore=(None, 'SDR')).replace('HDR', ''),
delim,
@@ -3244,9 +3240,15 @@ class YoutubeDL(object):
format_field(f, 'tbr', '\t%dk'),
shorten_protocol_name(f.get('protocol', '').replace('native', 'n')),
delim,
- format_field(f, 'vcodec', default='unknown').replace('none', ''),
+ format_field(f, 'vcodec', default='unknown').replace(
+ 'none',
+ 'images' if f.get('acodec') == 'none'
+ else self._format_screen('audio only', self.Styles.SUPPRESS)),
format_field(f, 'vbr', '\t%dk'),
- format_field(f, 'acodec', default='unknown').replace('none', ''),
+ format_field(f, 'acodec', default='unknown').replace(
+ 'none',
+ '' if f.get('vcodec') == 'none'
+ else self._format_screen('video only', self.Styles.SUPPRESS)),
format_field(f, 'abr', '\t%dk'),
format_field(f, 'asr', '\t%dHz'),
join_nonempty(