]> jfr.im git - yt-dlp.git/commitdiff
Clarify video/audio-only formats in -F
authorpukkandan <redacted>
Tue, 23 Nov 2021 15:08:30 +0000 (20:38 +0530)
committerpukkandan <redacted>
Tue, 23 Nov 2021 15:12:20 +0000 (20:42 +0530)
Related: #1759

yt_dlp/YoutubeDL.py

index 5c2d6459886831ca77711001c3332273d66fce27..b983b17752687031c6ab3c288f872c6a76f1a5d3 100644 (file)
@@ -847,6 +847,7 @@ class Styles(Enum):
         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 @@ def record_download_archive(self, info_dict):
 
     @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 @@ def list_formats(self, info_dict):
                 [
                     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 @@ def list_formats(self, info_dict):
                     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(