aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordirkf <fieldhouse@gmx.net>2025-11-26 01:16:35 +0000
committerdirkf <fieldhouse@gmx.net>2025-11-26 03:02:36 +0000
commitd5f561166b9decff97ad6657cc992c7b0fd1aba2 (patch)
treed5ead212f5ee711dde8c642ff6a5de0bfd2248a3
parentd0283f5385acd21dd51afa2102844c8cb2fe6b62 (diff)
[core] Re-work format_note display in format list with abbreviated codec name
-rwxr-xr-xyoutube_dl/YoutubeDL.py90
-rw-r--r--youtube_dl/extractor/youtube.py10
2 files changed, 47 insertions, 53 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py
index ec1d35c3a..4c762bf2c 100755
--- a/youtube_dl/YoutubeDL.py
+++ b/youtube_dl/YoutubeDL.py
@@ -2404,60 +2404,52 @@ class YoutubeDL(object):
return res
def _format_note(self, fdict):
- res = ''
- if fdict.get('ext') in ['f4f', 'f4m']:
- res += '(unsupported) '
- if fdict.get('language'):
- if res:
- res += ' '
- res += '[%s] ' % fdict['language']
- if fdict.get('format_note') is not None:
- res += fdict['format_note'] + ' '
- if fdict.get('tbr') is not None:
- res += '%4dk ' % fdict['tbr']
+
+ def simplified_codec(f, field):
+ assert field in ('acodec', 'vcodec')
+ codec = f.get(field)
+ return (
+ 'unknown' if not codec
+ else '.'.join(codec.split('.')[:4]) if codec != 'none'
+ else 'images' if field == 'vcodec' and f.get('acodec') == 'none'
+ else None if field == 'acodec' and f.get('vcodec') == 'none'
+ else 'audio only' if field == 'vcodec'
+ else 'video only')
+
+ res = join_nonempty(
+ fdict.get('ext') in ('f4f', 'f4m') and '(unsupported)',
+ fdict.get('language') and ('[%s]' % (fdict['language'],)),
+ fdict.get('format_note') is not None and fdict['format_note'],
+ fdict.get('tbr') is not None and ('%4dk' % fdict['tbr']),
+ delim=' ')
+ res = [res] if res else []
if fdict.get('container') is not None:
- if res:
- res += ', '
- res += '%s container' % fdict['container']
- if (fdict.get('vcodec') is not None
- and fdict.get('vcodec') != 'none'):
- if res:
- res += ', '
- res += fdict['vcodec']
- if fdict.get('vbr') is not None:
- res += '@'
+ res.append('%s container' % (fdict['container'],))
+ if fdict.get('vcodec') not in (None, 'none'):
+ codec = simplified_codec(fdict, 'vcodec')
+ if codec and fdict.get('vbr') is not None:
+ codec += '@'
elif fdict.get('vbr') is not None and fdict.get('abr') is not None:
- res += 'video@'
- if fdict.get('vbr') is not None:
- res += '%4dk' % fdict['vbr']
+ codec = 'video@'
+ else:
+ codec = None
+ codec = join_nonempty(codec, fdict.get('vbr') is not None and ('%4dk' % fdict['vbr']))
+ if codec:
+ res.append(codec)
if fdict.get('fps') is not None:
- if res:
- res += ', '
- res += '%sfps' % fdict['fps']
- if fdict.get('acodec') is not None:
- if res:
- res += ', '
- if fdict['acodec'] == 'none':
- res += 'video only'
- else:
- res += '%-5s' % fdict['acodec']
- elif fdict.get('abr') is not None:
- if res:
- res += ', '
- res += 'audio'
- if fdict.get('abr') is not None:
- res += '@%3dk' % fdict['abr']
- if fdict.get('asr') is not None:
- res += ' (%5dHz)' % fdict['asr']
+ res.append('%sfps' % (fdict['fps'],))
+ codec = (
+ simplified_codec(fdict, 'acodec') if fdict.get('acodec') is not None
+ else 'audio' if fdict.get('abr') is not None else None)
+ if codec:
+ res.append(join_nonempty(
+ '%-4s' % (codec + (('@%3dk' % fdict['abr']) if fdict.get('abr') else ''),),
+ fdict.get('asr') and '(%5dHz)' % fdict['asr'], delim=' '))
if fdict.get('filesize') is not None:
- if res:
- res += ', '
- res += format_bytes(fdict['filesize'])
+ res.append(format_bytes(fdict['filesize']))
elif fdict.get('filesize_approx') is not None:
- if res:
- res += ', '
- res += '~' + format_bytes(fdict['filesize_approx'])
- return res
+ res.append('~' + format_bytes(fdict['filesize_approx']))
+ return ', '.join(res)
def list_formats(self, info_dict):
formats = info_dict.get('formats', [info_dict])
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
index 7965fa08a..e5d218d17 100644
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -1669,10 +1669,12 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'_rtmp': {'protocol': 'rtmp'},
# av01 video only formats sometimes served with "unknown" codecs
- '394': {'acodec': 'none', 'vcodec': 'av01.0.05M.08'},
- '395': {'acodec': 'none', 'vcodec': 'av01.0.05M.08'},
- '396': {'acodec': 'none', 'vcodec': 'av01.0.05M.08'},
- '397': {'acodec': 'none', 'vcodec': 'av01.0.05M.08'},
+ '394': {'acodec': 'none', 'vcodec': 'av01.0.00M.08'},
+ '395': {'acodec': 'none', 'vcodec': 'av01.0.00M.08'},
+ '396': {'acodec': 'none', 'vcodec': 'av01.0.01M.08'},
+ '397': {'acodec': 'none', 'vcodec': 'av01.0.04M.08'},
+ '398': {'acodec': 'none', 'vcodec': 'av01.0.05M.08'},
+ '399': {'acodec': 'none', 'vcodec': 'av01.0.08M.08'},
}
_PLAYER_JS_VARIANT_MAP = (