marcopeocchi / yt-dlp-web-ui

A terrible web ui for yt-dlp. Designed to be self-hosted.
Mozilla Public License 2.0
657 stars 67 forks source link

Fixed human-readable file size representation #137

Closed 0x6d61726b closed 3 months ago

0x6d61726b commented 3 months ago

I have changed the calculation of the human-readable file size representation that follows units of IEC 60027-2 A.2 (depicted from the chosen unit (see https://en.wikipedia.org/wiki/Binary_prefix). I also have extended the calculation to represent K/M/G/T/... dynamically based on the file size, because I had a value of something like 12345 GiB free space displayed.

I have also compared this to what different operation systems do, so Windows 10/11 and Debian/Ubuntu command line output uses the binary representation:

root@ytldp /srv # ls -all /srv/test
-rwxr-xr-x 1 ytdlp ytdlp 19648957 Mar  2 23:59 yt-dlp-webui
root@ytldp /srv # ls -all -h /srv/test
-rwxr-xr-x 1 ytdlp ytdlp 19M Mar  2 23:59 yt-dlp-webui
Windows 10/11:
2024-03-02  23:59        19.648.957 yt-dlp-webui
--> is shown in GUI as: 19.189 KB

However Windows and Debian/Ubuntu (shell) displays units following JEDEC writing and not IEC writing.

marcopeocchi commented 3 months ago

Awesome, thank you 😎👍