diff --git a/app/run.py b/app/run.py index ae22fe1..f36dbce 100644 --- a/app/run.py +++ b/app/run.py @@ -348,6 +348,26 @@ def init(): write_json(data) +def filter_files(files, filterwords): + if not filterwords: + return files + filterwords_list = [word.strip() for word in filterwords.split(',')] + return [file for file in files if not any(word in file['file_name'] for word in filterwords_list)] + + +@app.route("/get_filtered_files") +def get_filtered_files(): + if not is_login(): + return jsonify({"error": "未登录"}) + data = read_json() + filterwords = request.args.get("filterwords", "") + account = Quark(data["cookie"][0], 0) + fid = request.args.get("fid", 0) + files = account.ls_dir(fid) + filtered_files = filter_files(files, filterwords) + return jsonify(filtered_files) + + if __name__ == "__main__": init() reload_tasks() diff --git a/app/templates/index.html b/app/templates/index.html index 30b4a7e..1cf73de 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -274,6 +274,19 @@ + +
+ +
+
+
+ 过滤词汇 +
+ +
+
+
+
@@ -421,6 +434,7 @@ enddate: "", addition: {}, ignore_extension: false, + filterwords: "", runweek: [1, 2, 3, 4, 5, 6, 7] }, run_log: "", diff --git a/quark_auto_save.py b/quark_auto_save.py index 4ae26ca..be5f508 100644 --- a/quark_auto_save.py +++ b/quark_auto_save.py @@ -645,6 +645,12 @@ class Quark: pwd_id, stoken, share_file_list[0]["fid"] )["list"] + # 应用过滤词过滤文件 + if task.get("filterwords"): + filterwords_list = [word.strip() for word in task["filterwords"].split(',')] + share_file_list = [file for file in share_file_list if not any(word in file['file_name'] for word in filterwords_list)] + print(f"📑 应用过滤词:{task['filterwords']},剩余{len(share_file_list)}个文件") + # 获取目标目录文件列表 savepath = re.sub(r"/{2,}", "/", f"/{task['savepath']}{subdir_path}") if not self.savepath_fid.get(savepath):