aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2023-06-22 01:37:55 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2023-06-22 01:37:55 +0530
commit0dff8e4d1e6e9fb938f4256ea9af7d81f42fd54f (patch)
tree9b9742fcb249d17c85a60e47d38788b078202e98
parent1e75d97db21152acc764b30a688e516f04b8a142 (diff)
downloadhypervideo-pre-0dff8e4d1e6e9fb938f4256ea9af7d81f42fd54f.tar.lz
hypervideo-pre-0dff8e4d1e6e9fb938f4256ea9af7d81f42fd54f.tar.xz
hypervideo-pre-0dff8e4d1e6e9fb938f4256ea9af7d81f42fd54f.zip
Indicate `filesize` approximated from `tbr` better
-rw-r--r--yt_dlp/YoutubeDL.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index bc5c1b95e..79b7d47b0 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -2666,7 +2666,8 @@ class YoutubeDL:
format['dynamic_range'] = 'SDR'
if format.get('aspect_ratio') is None:
format['aspect_ratio'] = try_call(lambda: round(format['width'] / format['height'], 2))
- if (info_dict.get('duration') and format.get('tbr')
+ if (not format.get('manifest_url') # For fragmented formats, "tbr" is often max bitrate and not average
+ and info_dict.get('duration') and format.get('tbr')
and not format.get('filesize') and not format.get('filesize_approx')):
format['filesize_approx'] = int(info_dict['duration'] * format['tbr'] * (1024 / 8))
format['http_headers'] = self._calc_headers(collections.ChainMap(format, info_dict))
@@ -3707,8 +3708,11 @@ class YoutubeDL:
format_field(f, 'fps', '\t%d', func=round),
format_field(f, 'dynamic_range', '%s', ignore=(None, 'SDR')).replace('HDR', ''),
format_field(f, 'audio_channels', '\t%s'),
- delim,
- format_field(f, 'filesize', ' \t%s', func=format_bytes) + format_field(f, 'filesize_approx', '~\t%s', func=format_bytes),
+ delim, (
+ format_field(f, 'filesize', ' \t%s', func=format_bytes)
+ or format_field(f, 'filesize_approx', '≈\t%s', func=format_bytes)
+ or format_field(try_call(lambda: format_bytes(int(info_dict['duration'] * f['tbr'] * (1024 / 8)))),
+ None, self._format_out('~\t%s', self.Styles.SUPPRESS))),
format_field(f, 'tbr', '\t%dk', func=round),
shorten_protocol_name(f.get('protocol', '')),
delim,