какие-то изменения
parent
186e468bb0
commit
9374937e40
@ -0,0 +1,71 @@
|
||||
# module Humanize
|
||||
|
||||
using Printf, Dates
|
||||
|
||||
# export humanbytes, humanbitrate, humandate
|
||||
|
||||
function new_name(name)
|
||||
matches = Dict(
|
||||
"Сек" => r"(.+) Сек.*",
|
||||
"Сцен" => r"(.+) Сцен.*",
|
||||
"Голые" => r"(.+) Голые.*",
|
||||
"Откро" => r"(.+) Откро.*",
|
||||
"Посте" => r"(.+) Посте.*",
|
||||
"Изнас" => r"(.+) Изнас.*",
|
||||
"Инцес" => r"(.+) Инцес.*",
|
||||
"Лесб" => r"(.+) Лесб.*",
|
||||
"Эро" => r"(.+) Эро.*"
|
||||
)
|
||||
for (k, v) in matches
|
||||
if contains(name, k)
|
||||
base, ext = splitext(name)
|
||||
new_name = replace(base, v => s"\1")
|
||||
# @debug base, new_name
|
||||
return string(new_name, ext)
|
||||
end
|
||||
end
|
||||
return name
|
||||
end
|
||||
|
||||
|
||||
# правильный перевод!
|
||||
function humanbytes(B)
|
||||
"""Return the given bytes as a human friendly KB, MB, GB, or TB string."""
|
||||
B = float(B)
|
||||
KB = float(1024)
|
||||
MB = float(KB ^ 2) # 1,048,576
|
||||
GB = float(KB ^ 3) # 1,073,741,824
|
||||
TB = float(KB ^ 4) # 1,099,511,627,776
|
||||
|
||||
if B < KB
|
||||
return @sprintf("%.2f Bytes", B)
|
||||
elseif KB <= B && B < MB
|
||||
return @sprintf("%.2f KB", (B / KB))
|
||||
elseif MB <= B && B < GB
|
||||
return @sprintf("%.2f MB", (B / MB))
|
||||
elseif GB <= B && B < TB
|
||||
return @sprintf("%.2f GB", (B / GB))
|
||||
elseif TB <= B
|
||||
return @sprintf("%.2f TB", (B / KB))
|
||||
end
|
||||
end
|
||||
|
||||
function humanbitrate(s)
|
||||
"""
|
||||
# The function "humanbitrate" takes a string representing a bitrate in the format "a/b" and returns
|
||||
the bitrate as a float with one decimal place.
|
||||
|
||||
:param s: The parameter "s" is a string that represents a fraction in the format "a/b", where "a"
|
||||
and "b" are numbers
|
||||
:return: the bitrate as a string.
|
||||
"""
|
||||
items = split(s, "/")
|
||||
a = parse(Float64, items[1])
|
||||
b = parse(Float64, items[2])
|
||||
bitrate = @sprintf("%8.1f", (a / b))
|
||||
return strip(bitrate)
|
||||
end
|
||||
|
||||
function humandate(d)
|
||||
return Dates.format(Dates.unix2datetime(d), "dd.mm.yyyy")
|
||||
end
|
@ -1,3 +1,2 @@
|
||||
[deps]
|
||||
Merly = "5b70daea-9db9-5a46-aedf-2142e553ecc5"
|
||||
MySQL = "39abe10b-433b-5dbd-92d4-e302a9df00cd"
|
||||
|
Loading…
Reference in New Issue