mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-17 18:30:43 +08:00
Compare commits
5 Commits
cd3964a8f8
...
8e27444f0e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e27444f0e | ||
|
|
59e024fd40 | ||
|
|
ba9d3c7826 | ||
|
|
44b3920055 | ||
|
|
a939c233dc |
@ -358,10 +358,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row" title="需匹配到各级嵌套目录名才会更新,否则子目录在第一次转存后不会更新。注意:原理是逐级索引,深层嵌套目录的场景下效率非常低,慎用 .*">
|
<div class="form-group row" title="需匹配到各级嵌套目录名才会更新,否则子目录在第一次转存后不会更新。注意:递归模式原理是逐级索引,深层嵌套目录的场景下效率非常低,慎用 .*">
|
||||||
<label class="col-sm-2 col-form-label">更新目录</label>
|
<label class="col-sm-2 col-form-label">更新目录</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input type="text" name="update_subdir[]" class="form-control" v-model="task.update_subdir" placeholder="可选,匹配需更新子目录(含各级嵌套目录)的正则表达式,多项以|分割,如 4k|1080p">
|
<div class="input-group">
|
||||||
|
<input type="text" name="update_subdir[]" class="form-control" v-model="task.update_subdir" placeholder="可选,匹配需更新子目录(含各级嵌套目录)的正则表达式,多项以|分割,如 4k|1080p">
|
||||||
|
<div class="input-group-append" title="重存模式:删除该目录下所有文件,重新转存,大资源包时推荐使用
不勾选为递归模式:递归检查,逐级更新嵌套目录,效率低">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<input type="checkbox" v-model="task.update_subdir_resave_mode"> 重存模式
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
"alist",
|
"alist",
|
||||||
"alist_strm",
|
"alist_strm",
|
||||||
"alist_strm_gen",
|
"alist_strm_gen",
|
||||||
|
"alist_sync",
|
||||||
"aria2",
|
"aria2",
|
||||||
"emby",
|
"emby",
|
||||||
"plex"
|
"plex"
|
||||||
|
|||||||
@ -26,7 +26,7 @@ class Alist_sync:
|
|||||||
"enable": False, # 当前任务开关,
|
"enable": False, # 当前任务开关,
|
||||||
"save_path": "", # 需要同步目录,默认空时路径则会与夸克的保存路径一致,不开启完整路径模式时,默认根目录为保存驱动的根目录
|
"save_path": "", # 需要同步目录,默认空时路径则会与夸克的保存路径一致,不开启完整路径模式时,默认根目录为保存驱动的根目录
|
||||||
"verify_path": "", # 验证目录,主要用于影视库避免重复文件,一般配合alist的别名功能及full_path使用,用于多个网盘的源合并成一个目录
|
"verify_path": "", # 验证目录,主要用于影视库避免重复文件,一般配合alist的别名功能及full_path使用,用于多个网盘的源合并成一个目录
|
||||||
"full_path": False, # 完整路径模式
|
"full_path_mode": False, # 完整路径模式
|
||||||
# 完整路径模式开启后不再限制保存目录的存储驱动,将根据填入的路径进行保存,需要填写完整的alist目录
|
# 完整路径模式开启后不再限制保存目录的存储驱动,将根据填入的路径进行保存,需要填写完整的alist目录
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import importlib
|
|||||||
import traceback
|
import traceback
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from natsort import natsorted
|
||||||
|
|
||||||
# 兼容青龙
|
# 兼容青龙
|
||||||
try:
|
try:
|
||||||
@ -264,7 +265,8 @@ class MagicRename:
|
|||||||
def sort_file_list(self, file_list, dir_filename_dict={}):
|
def sort_file_list(self, file_list, dir_filename_dict={}):
|
||||||
"""文件列表统一排序,给{I+}赋值"""
|
"""文件列表统一排序,给{I+}赋值"""
|
||||||
filename_list = [
|
filename_list = [
|
||||||
f["file_name_re"]
|
# 强制加入`文件修改时间`字段供排序,效果:1无可排序字符时则按修改时间排序,2和目录已有文件重名时始终在其后
|
||||||
|
f"{f['file_name_re']}{f['updated_at']}"
|
||||||
for f in file_list
|
for f in file_list
|
||||||
if f.get("file_name_re") and not f["dir"]
|
if f.get("file_name_re") and not f["dir"]
|
||||||
]
|
]
|
||||||
@ -273,7 +275,7 @@ class MagicRename:
|
|||||||
# print(f"dir_filename_list: {dir_filename_list}")
|
# print(f"dir_filename_list: {dir_filename_list}")
|
||||||
# 合并目录文件列表
|
# 合并目录文件列表
|
||||||
filename_list = list(set(filename_list) | set(dir_filename_dict.values()))
|
filename_list = list(set(filename_list) | set(dir_filename_dict.values()))
|
||||||
filename_list.sort(key=self._custom_sort_key)
|
filename_list = natsorted(filename_list, key=self._custom_sort_key)
|
||||||
filename_index = {}
|
filename_index = {}
|
||||||
for name in filename_list:
|
for name in filename_list:
|
||||||
if name in dir_filename_dict.values():
|
if name in dir_filename_dict.values():
|
||||||
@ -286,7 +288,9 @@ class MagicRename:
|
|||||||
for file in file_list:
|
for file in file_list:
|
||||||
if file.get("file_name_re"):
|
if file.get("file_name_re"):
|
||||||
if match := re.search(r"\{I+\}", file["file_name_re"]):
|
if match := re.search(r"\{I+\}", file["file_name_re"]):
|
||||||
i = filename_index.get(file["file_name_re"], 0)
|
i = filename_index.get(
|
||||||
|
f"{file['file_name_re']}{file['updated_at']}", 0
|
||||||
|
)
|
||||||
file["file_name_re"] = re.sub(
|
file["file_name_re"] = re.sub(
|
||||||
match.group(),
|
match.group(),
|
||||||
str(i).zfill(match.group().count("I")),
|
str(i).zfill(match.group().count("I")),
|
||||||
@ -609,7 +613,7 @@ class Quark:
|
|||||||
"__t": datetime.now().timestamp(),
|
"__t": datetime.now().timestamp(),
|
||||||
}
|
}
|
||||||
response = self._send_request("GET", url, params=querystring).json()
|
response = self._send_request("GET", url, params=querystring).json()
|
||||||
if response["data"]["status"] != 0:
|
if response["data"]["status"] == 2:
|
||||||
if retry_index > 0:
|
if retry_index > 0:
|
||||||
print()
|
print()
|
||||||
break
|
break
|
||||||
@ -898,8 +902,35 @@ class Quark:
|
|||||||
need_save_list.append(share_file)
|
need_save_list.append(share_file)
|
||||||
elif share_file["dir"]:
|
elif share_file["dir"]:
|
||||||
# 存在并是一个目录,历遍子目录
|
# 存在并是一个目录,历遍子目录
|
||||||
if task.get("update_subdir", False):
|
if task.get("update_subdir", False) and re.search(
|
||||||
if re.search(task["update_subdir"], share_file["file_name"]):
|
task["update_subdir"], share_file["file_name"]
|
||||||
|
):
|
||||||
|
if task.get("update_subdir_resave_mode", False):
|
||||||
|
# 重存模式:删除该目录下所有文件,重新转存
|
||||||
|
print(f"重存子目录:{savepath}/{share_file['file_name']}")
|
||||||
|
# 删除子目录、回收站中彻底删除
|
||||||
|
subdir = next(
|
||||||
|
(
|
||||||
|
f
|
||||||
|
for f in dir_file_list
|
||||||
|
if f["file_name"] == share_file["file_name"]
|
||||||
|
),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
delete_return = self.delete([subdir["fid"]])
|
||||||
|
self.query_task(delete_return["data"]["task_id"])
|
||||||
|
recycle_list = self.recycle_list()
|
||||||
|
record_id_list = [
|
||||||
|
item["record_id"]
|
||||||
|
for item in recycle_list
|
||||||
|
if item["fid"] == subdir["fid"]
|
||||||
|
]
|
||||||
|
self.recycle_remove(record_id_list)
|
||||||
|
# 作为新文件添加到转存列表
|
||||||
|
share_file["file_name_re"] = share_file["file_name"]
|
||||||
|
need_save_list.append(share_file)
|
||||||
|
else:
|
||||||
|
# 递归模式
|
||||||
print(f"检查子目录:{savepath}/{share_file['file_name']}")
|
print(f"检查子目录:{savepath}/{share_file['file_name']}")
|
||||||
subdir_tree = self.dir_check_and_save(
|
subdir_tree = self.dir_check_and_save(
|
||||||
task,
|
task,
|
||||||
|
|||||||
@ -2,3 +2,4 @@ flask
|
|||||||
apscheduler
|
apscheduler
|
||||||
requests
|
requests
|
||||||
treelib
|
treelib
|
||||||
|
natsort
|
||||||
Loading…
Reference in New Issue
Block a user