From 1f631cca981b4fe38dc02e72412b36b07c27bddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9=20=D0=A2?= =?UTF-8?q?=D1=83=D1=85=D1=82=D0=B0=D1=80=D0=BE=D0=B2?= Date: Wed, 10 Jan 2024 15:41:14 +0500 Subject: [PATCH] julia --- Manifest.toml | 7 ++++++ test.jl | 66 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 Manifest.toml diff --git a/Manifest.toml b/Manifest.toml new file mode 100644 index 0000000..49def11 --- /dev/null +++ b/Manifest.toml @@ -0,0 +1,7 @@ +# This file is machine-generated - editing it directly is not advised + +julia_version = "1.10.0" +manifest_format = "2.0" +project_hash = "da39a3ee5e6b4b0d3255bfef95601890afd80709" + +[deps] diff --git a/test.jl b/test.jl index 94f3e45..bad2607 100644 --- a/test.jl +++ b/test.jl @@ -1,3 +1,63 @@ -io = open("meta.sql") -list = readlines(io) -println(list) \ No newline at end of file +# То же самое, но на julia + +using Logging +debuglogger = ConsoleLogger(stderr, Logging.Debug) +global_logger(debuglogger) + +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 valid_file(filename) + valids = [".mp4", ".webm", ".mpeg"] + _, ext = splitext(filename) + return ext in valids +end + +# file_info function returns information from file +function file_info(filename) + _, ext = splitext(filename) + info = stat(filename) + m = Dict( + "filename" => filename, + "size" => info.size, + "mtime" => info.mtime, + "ctime" => info.ctime, + "ext" => ext, + ) + return m +end + +function check_file(filename) + println(filename) + meta = file_info(filename) + println(meta) +end + +# -------- основная программа -------------- +dir = "d:\\vids\\ero" +@info "Обработка каталога: $dir" + +files = readdir(dir, join=true) +for file in filter(valid_file, files) + meta = check_file(file) +end