diff --git a/app/run.py b/app/run.py index 851f311..02d2214 100644 --- a/app/run.py +++ b/app/run.py @@ -319,6 +319,64 @@ def run_script_now(): ) +# 刷新Plex媒体库 +@app.route("/refresh_plex_library", methods=["POST"]) +def refresh_plex_library(): + if not is_login(): + return jsonify({"success": False, "message": "未登录"}) + + task_index = request.json.get("task_index") + if task_index is None: + return jsonify({"success": False, "message": "缺少任务索引"}) + + # 获取任务信息 + task = config_data["tasklist"][task_index] + if not task.get("savepath"): + return jsonify({"success": False, "message": "任务没有保存路径"}) + + # 导入Plex插件 + from plugins.plex import Plex + + # 初始化Plex插件 + plex = Plex(**config_data["plugins"]["plex"]) + if not plex.is_active: + return jsonify({"success": False, "message": "Plex 插件未正确配置"}) + + # 执行刷新 + plex.run(task) + + return jsonify({"success": True, "message": "成功刷新 Plex 媒体库"}) + + +# 刷新AList目录 +@app.route("/refresh_alist_directory", methods=["POST"]) +def refresh_alist_directory(): + if not is_login(): + return jsonify({"success": False, "message": "未登录"}) + + task_index = request.json.get("task_index") + if task_index is None: + return jsonify({"success": False, "message": "缺少任务索引"}) + + # 获取任务信息 + task = config_data["tasklist"][task_index] + if not task.get("savepath"): + return jsonify({"success": False, "message": "任务没有保存路径"}) + + # 导入AList插件 + from plugins.alist import Alist + + # 初始化AList插件 + alist = Alist(**config_data["plugins"]["alist"]) + if not alist.is_active: + return jsonify({"success": False, "message": "AList 插件未正确配置"}) + + # 执行刷新 + alist.run(task) + + return jsonify({"success": True, "message": "成功刷新 AList 目录"}) + + @app.route("/task_suggestions") def get_task_suggestions(): if not is_login(): diff --git a/app/static/Plex.svg b/app/static/Plex.svg new file mode 100644 index 0000000..7bd25d1 --- /dev/null +++ b/app/static/Plex.svg @@ -0,0 +1,9 @@ + + + diff --git a/app/static/css/main.css b/app/static/css/main.css index 1c1d86c..2f582c2 100644 --- a/app/static/css/main.css +++ b/app/static/css/main.css @@ -2311,6 +2311,8 @@ main .table th { .task .btn-outline-primary, .task .btn-outline-danger, .task .btn-warning, +.task .btn-outline-plex, +.task .btn-outline-alist, .row .btn-outline-primary { width: 32px; height: 32px; @@ -2318,6 +2320,7 @@ main .table th { display: flex; align-items: center; justify-content: center; + border-radius: 6px !important; } /* 播放按钮样式 */ @@ -3921,3 +3924,51 @@ table.selectable-records .expand-button:hover { #fileSelectModal .table tr.selected-file:hover { background-color: var(--button-gray-background-color); } + +/* Plex按钮样式 */ +.btn-outline-plex { + border-color: #EBAF00; + color: #EBAF00; +} + +.btn-outline-plex:hover { + background-color: #EBAF00; + border-color: #EBAF00; + color: #fff; +} + +.btn-outline-plex:hover .plex-icon { + filter: brightness(0) invert(1); +} + +/* AList按钮样式 */ +.btn-outline-alist { + border-color: #70C6BE; + color: #70C6BE; +} + +.btn-outline-alist:hover { + background-color: #70C6BE; + border-color: #70C6BE; + color: #fff; +} + +.btn-outline-alist:hover .alist-icon { + filter: brightness(0) invert(1); +} + +/* Plex图标样式 */ +.plex-icon { + width: 11px; + height: auto; + object-fit: contain; +} + +/* AList图标样式 */ +.alist-icon { + width: 17.8px; + height: auto; + object-fit: contain; + position: relative; + top: -0.5px; +} diff --git a/app/templates/index.html b/app/templates/index.html index eb0e9bd..494aa74 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -484,8 +484,10 @@
+ + - +
@@ -3584,6 +3586,32 @@ }); } }, + refreshPlexLibrary(index) { + axios.post('/refresh_plex_library', { task_index: index }) + .then(response => { + if (response.data.success) { + this.showToast(response.data.message); + } else { + alert(response.data.message); + } + }) + .catch(error => { + alert("刷新 Plex 媒体库失败: " + (error.response?.data?.message || error.message || "未知错误")); + }); + }, + refreshAlistDirectory(index) { + axios.post('/refresh_alist_directory', { task_index: index }) + .then(response => { + if (response.data.success) { + this.showToast(response.data.message); + } else { + alert(response.data.message); + } + }) + .catch(error => { + alert("刷新 AList 目录失败: " + (error.response?.data?.message || error.message || "未知错误")); + }); + }, } });