Skip to content

Commit afea932

Browse files
committed
Patch in format_bytes_humanized for older mpvs
1 parent 2da8546 commit afea932

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/patched_osc.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,19 @@ if not msg.trace then
7070
msg.trace = function(...) return mp.log("trace", ...) end
7171
end
7272

73+
-- Patch in utils.format_bytes_humanized
74+
if not utils.format_bytes_humanized then
75+
utils.format_bytes_humanized = function(b)
76+
local d = {"Bytes", "KiB", "MiB", "GiB", "TiB", "PiB"}
77+
local i = 1
78+
while b >= 1024 do
79+
b = b / 1024
80+
i = i + 1
81+
end
82+
return string.format("%0.2f %s", b, d[i] and d[i] or "*1024^" .. (i-1))
83+
end
84+
end
85+
7386
Thumbnailer:register_client()
7487

7588
function get_thumbnail_y_offset(thumb_size, msy)

0 commit comments

Comments
 (0)