]> jfr.im git - yt-dlp.git/commitdiff
Approximate filesize from bitrate
authorpukkandan <redacted>
Sun, 24 Oct 2021 12:32:00 +0000 (18:02 +0530)
committerpukkandan <redacted>
Sun, 24 Oct 2021 12:32:00 +0000 (18:02 +0530)
Closes #1400

yt_dlp/YoutubeDL.py

index 071f2e943805acee7c236d7e5d8ae642332f228b..8c8cf7ecb600fa794fb5d1743b09e6fa8a78a007 100644 (file)
@@ -2330,6 +2330,10 @@ def is_wellformed(f):
                 format['resolution'] = self.format_resolution(format, default=None)
             if format.get('dynamic_range') is None and format.get('vcodec') != 'none':
                 format['dynamic_range'] = 'SDR'
+            if (info_dict.get('duration') and format.get('tbr')
+                    and not format.get('filesize') and not format.get('filesize_approx')):
+                format['filesize_approx'] = info_dict['duration'] * format['tbr'] * (1024 / 8)
+
             # Add HTTP headers, so that external programs can use them from the
             # json output
             full_format_info = info_dict.copy()