mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-13 15:50:45 +08:00
commit
df296236af
65
app/run.py
65
app/run.py
@ -259,6 +259,37 @@ def get_task_suggestions():
|
||||
return jsonify({"success": True, "message": f"error: {str(e)}"})
|
||||
|
||||
|
||||
# 添加函数,与主程序保持一致
|
||||
def is_date_format(number_str):
|
||||
"""
|
||||
判断一个纯数字字符串是否可能是日期格式
|
||||
支持的格式:YYYYMMDD, MMDD
|
||||
"""
|
||||
# 判断YYYYMMDD格式 (8位数字)
|
||||
if len(number_str) == 8 and number_str.startswith('20'):
|
||||
year = int(number_str[:4])
|
||||
month = int(number_str[4:6])
|
||||
day = int(number_str[6:8])
|
||||
|
||||
# 简单检查月份和日期是否有效
|
||||
if 1 <= month <= 12 and 1 <= day <= 31:
|
||||
# 可能是日期格式
|
||||
return True
|
||||
|
||||
# 判断MMDD格式 (4位数字)
|
||||
elif len(number_str) == 4:
|
||||
month = int(number_str[:2])
|
||||
day = int(number_str[2:4])
|
||||
|
||||
# 简单检查月份和日期是否有效
|
||||
if 1 <= month <= 12 and 1 <= day <= 31:
|
||||
# 可能是日期格式
|
||||
return True
|
||||
|
||||
# 其他长度的纯数字不视为日期格式
|
||||
return False
|
||||
|
||||
|
||||
@app.route("/get_share_detail", methods=["POST"])
|
||||
def get_share_detail():
|
||||
if not is_login():
|
||||
@ -285,7 +316,11 @@ def get_share_detail():
|
||||
current_sequence = 1
|
||||
|
||||
# 构建顺序命名的正则表达式
|
||||
regex_pattern = re.escape(sequence_pattern).replace('\\{\\}', '(\\d+)')
|
||||
if sequence_pattern == "{}":
|
||||
# 对于单独的{},使用特殊匹配
|
||||
regex_pattern = "(\\d+)"
|
||||
else:
|
||||
regex_pattern = re.escape(sequence_pattern).replace('\\{\\}', '(\\d+)')
|
||||
|
||||
# 实现高级排序算法
|
||||
def extract_sorting_value(file):
|
||||
@ -401,10 +436,24 @@ def get_share_detail():
|
||||
return 0
|
||||
|
||||
# 过滤出非目录文件,并且排除已经符合命名规则的文件
|
||||
files_to_process = [
|
||||
f for f in share_detail["list"]
|
||||
if not f["dir"] and not re.match(regex_pattern, f["file_name"])
|
||||
]
|
||||
files_to_process = []
|
||||
for f in share_detail["list"]:
|
||||
if f["dir"]:
|
||||
continue # 跳过文件夹
|
||||
|
||||
# 检查文件是否已符合命名规则
|
||||
if sequence_pattern == "{}":
|
||||
# 对于单独的{},检查文件名是否为纯数字
|
||||
file_name_without_ext = os.path.splitext(f["file_name"])[0]
|
||||
if file_name_without_ext.isdigit():
|
||||
# 增加判断:如果是日期格式的纯数字,不视为已命名
|
||||
if not is_date_format(file_name_without_ext):
|
||||
continue # 跳过已符合命名规则的文件
|
||||
elif re.match(regex_pattern, f["file_name"]):
|
||||
continue # 跳过已符合命名规则的文件
|
||||
|
||||
# 添加到待处理文件列表
|
||||
files_to_process.append(f)
|
||||
|
||||
# 根据提取的排序值进行排序
|
||||
sorted_files = sorted(files_to_process, key=extract_sorting_value)
|
||||
@ -426,7 +475,11 @@ def get_share_detail():
|
||||
# 获取文件扩展名
|
||||
file_ext = os.path.splitext(file["file_name"])[1]
|
||||
# 生成预览文件名
|
||||
file["file_name_re"] = sequence_pattern.replace("{}", f"{current_sequence:02d}") + file_ext
|
||||
if sequence_pattern == "{}":
|
||||
# 对于单独的{},直接使用数字序号作为文件名
|
||||
file["file_name_re"] = f"{current_sequence:02d}{file_ext}"
|
||||
else:
|
||||
file["file_name_re"] = sequence_pattern.replace("{}", f"{current_sequence:02d}") + file_ext
|
||||
current_sequence += 1
|
||||
|
||||
return share_detail
|
||||
|
||||
@ -636,6 +636,13 @@
|
||||
mounted() {
|
||||
this.fetchData();
|
||||
this.checkNewVersion();
|
||||
|
||||
// 从本地存储中恢复之前的标签页状态
|
||||
const savedTab = localStorage.getItem('quarkAutoSave_activeTab');
|
||||
if (savedTab) {
|
||||
this.activeTab = savedTab;
|
||||
}
|
||||
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
document.addEventListener('keydown', this.handleKeyDown);
|
||||
document.addEventListener('click', (e) => {
|
||||
@ -693,6 +700,8 @@
|
||||
methods: {
|
||||
changeTab(tab) {
|
||||
this.activeTab = tab;
|
||||
// 在本地存储中保存当前标签页状态
|
||||
localStorage.setItem('quarkAutoSave_activeTab', tab);
|
||||
if (window.innerWidth <= 768) {
|
||||
$('#sidebarMenu').collapse('toggle')
|
||||
}
|
||||
@ -1211,8 +1220,8 @@
|
||||
},
|
||||
detectNamingMode(task) {
|
||||
// 检测是否为顺序命名模式或剧集命名模式
|
||||
const sequencePatterns = ['E{}', 'EP{}', 'S\\d+E{}', '第{}集', '第{}话', '第{}期'];
|
||||
const episodePatterns = ['E[]', 'EP[]', 'S\\d+E[]', '第[]集', '第[]话', '第[]期', '[]'];
|
||||
const sequencePatterns = ['{}', 'E{}', 'EP{}', 'S\\d+E{}', '第{}集', '第{}话', '第{}期'];
|
||||
const episodePatterns = ['[]', 'E[]', 'EP[]', 'S\\d+E[]', '第[]集', '第[]话', '第[]期'];
|
||||
|
||||
let isSequenceNaming = false;
|
||||
let isEpisodeNaming = false;
|
||||
|
||||
1131
quark_auto_save.py
1131
quark_auto_save.py
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user