mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-13 07:40:45 +08:00
新增手动刷新 Plex 媒体库和 AList 目录功能
This commit is contained in:
parent
df9ed8e76b
commit
0d2e942eae
58
app/run.py
58
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():
|
||||
|
||||
9
app/static/Plex.svg
Normal file
9
app/static/Plex.svg
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="plex-logo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 28.3 41.4" style="enable-background:new 0 0 28.3 41.4;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#EBAF00;}
|
||||
</style>
|
||||
<polygon class="st0" points="14.4,41.1 0.2,41.1 14,20.8 0.2,0.4 14.4,0.4 28.1,20.8 "/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 503 B |
@ -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;
|
||||
}
|
||||
|
||||
@ -484,8 +484,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button type="button" class="btn btn-outline-plex" v-if="formData.plugins && formData.plugins.plex && formData.plugins.plex.url && formData.plugins.plex.token && formData.plugins.plex.quark_root_path" @click="refreshPlexLibrary(index)" title="刷新Plex媒体库"><img src="./static/Plex.svg" class="plex-icon"></button>
|
||||
<button type="button" class="btn btn-outline-alist" v-if="formData.plugins && formData.plugins.alist && formData.plugins.alist.url && formData.plugins.alist.token && formData.plugins.alist.storage_id" @click="refreshAlistDirectory(index)" title="刷新AList目录"><img src="https://cdn.jsdelivr.net/gh/alist-org/logo@main/logo.svg" class="alist-icon"></button>
|
||||
<button class="btn btn-warning" v-if="task.shareurl_ban" :title="formatShareUrlBanMessage(task.shareurl_ban)" disabled><i class="bi bi-exclamation-circle"></i></button>
|
||||
<button type="button" class="btn btn-outline-primary" @click="runScriptNow(index)" title="运行此任务" v-else><i class="bi bi-caret-right"></i></button>
|
||||
<button type="button" class="btn btn-outline-primary" @click="runScriptNow(index)" title="运行此任务" v-if="!task.shareurl_ban"><i class="bi bi-caret-right"></i></button>
|
||||
<button type="button" class="btn btn-outline-danger" @click="removeTask(index)" title="删除此任务"><i class="bi bi-trash3"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
@ -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 || "未知错误"));
|
||||
});
|
||||
},
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user