какие-то изменения

main
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

@ -2,7 +2,7 @@
julia_version = "1.10.0"
manifest_format = "2.0"
project_hash = "f48a77939f961f20258ec2aa52454832f00fcb7d"
project_hash = "ea476216083c98aa4899baeb17324f82d092a2e7"
[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
@ -64,17 +64,6 @@ version = "1.6.0"
[[deps.FileWatching]]
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
[[deps.HTTP]]
deps = ["Base64", "Dates", "IniFile", "Logging", "MbedTLS", "NetworkOptions", "Sockets", "URIs"]
git-tree-sha1 = "0fa77022fe4b511826b39c894c90daf5fce3334a"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "0.9.17"
[[deps.IniFile]]
git-tree-sha1 = "f550e6e32074c939295eb5ea6de31849ac2c9625"
uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f"
version = "0.5.1"
[[deps.InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
@ -161,23 +150,11 @@ version = "3.1.12+0"
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
[[deps.MbedTLS]]
deps = ["Dates", "MbedTLS_jll", "MozillaCACerts_jll", "NetworkOptions", "Random", "Sockets"]
git-tree-sha1 = "c067a280ddc25f196b5e7df3877c6b226d390aaf"
uuid = "739be429-bea8-5141-9913-cc70e7f3736d"
version = "1.1.9"
[[deps.MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
version = "2.28.2+1"
[[deps.Merly]]
deps = ["HTTP", "MbedTLS", "Sockets"]
git-tree-sha1 = "ea3b47cbeb887d6c05b70c057c75f50ff57e7a59"
uuid = "5b70daea-9db9-5a46-aedf-2142e553ecc5"
version = "1.0.2"
[[deps.MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
version = "2023.1.10"
@ -298,11 +275,6 @@ deps = ["ArgTools", "SHA"]
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
version = "1.10.0"
[[deps.URIs]]
git-tree-sha1 = "67db6cc7b3821e19ebe75791a9dd19c9b1188f2b"
uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
version = "1.5.1"
[[deps.UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

@ -1,3 +1,2 @@
[deps]
Merly = "5b70daea-9db9-5a46-aedf-2142e553ecc5"
MySQL = "39abe10b-433b-5dbd-92d4-e302a9df00cd"

@ -2,6 +2,13 @@
Сканирует видео-файлы для получения мета информации
Создать как модуль не получилось
Использовал простую конструкцию:
include("Humanize.jl")
--------------------
## Особенности
Использует ffprobe для получения информации в виде json файла.

2169
meta.sql

File diff suppressed because it is too large Load Diff

@ -8,71 +8,16 @@ using CRC32c
using JSON
using Base.Threads
using MySQL
# using DBInterface
using Printf, Dates# using DBInterface
# debuglogger = ConsoleLogger(stderr, Logging.Debug)
# global_logger(debuglogger)
# правильный перевод!
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
# include( "./Humanize.jl")
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
# import humanbytes
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 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
include("Humanize.jl")
function valid_file(filename)
valids = [".avi", ".mkv", ".mp4", ".webm", ".mpeg"]
@ -80,9 +25,6 @@ function valid_file(filename)
return ext in valids
end
function humandate(d)
return Dates.format(Dates.unix2datetime(d), "dd.mm.yyyy")
end
# file_info function returns information from file
function file_info(filename)
@ -161,7 +103,7 @@ function check_file(filename)
end
function main(host_id::Integer)
dir = "d:\\vids\\ero\\2"
dir = "D:\\vids\\weed"
@info "Обработка каталога: $dir"
files = readdir(dir, join=true)
@ -173,7 +115,13 @@ function main(host_id::Integer)
# @sync begin
for file in filter(valid_file, files)
# Threads.@spawn begin
meta = check_file(file)
meta = nothing
try
@elapsed meta = check_file(file)
catch e
@error "Ошибка обработки файла $file: $e"
continue
end
meta["host_id"] = host_id
# println(meta)
save_db(conn, meta)
@ -200,7 +148,7 @@ function save_db(conn, m)
if exist(conn, m["crc"])
@info "уже имеется: $filename"
else
println("сохраняю: $filename")
# println("сохраняю: $filename")
host_id = m["host_id"]
filename = replace(m["filename"], "\\" => "\\\\")
newname = m["newname"]
Loading…
Cancel
Save