新增作品列表下删除作品

This commit is contained in:
lzyme.dev@gmail.com
2026-08-29 18:10:41 +08:00
parent 2383406ede
commit d99af94e74
3 changed files with 88 additions and 3 deletions
+43
View File
@@ -8082,6 +8082,48 @@ ${err.stack}` : "");
}
return fileId;
}
async deleteOfflineTasksByKeyword(keyword) {
try {
const singInfo = await (async () => {
const res = await gmHttp.get("https://115.com/?ct=offline&ac=space&_=" + (/* @__PURE__ */ new Date()).getTime());
return "object" == typeof res ? res : null;
})();
if (!singInfo) {
console.error("删除离线任务: 未登录115网盘");
return;
}
const {sign, time} = singInfo, uid = singInfo.uid || (() => {
const match = document.cookie.match(/UID=(\d+)_/);
return match ? match[1] : null;
})() || await this.getUserId();
const taskListRes = await gmHttp.postForm("https://115.com/web/lixian/?ct=lixian&ac=task_lists", {
page: 1,
uid,
sign,
time
});
const tasks = (null == taskListRes ? void 0 : taskListRes.tasks) || [];
const keyword2 = keyword.toLowerCase().replace("fc2-", "");
let deletedCount = 0;
for (const task of tasks) {
if (task.name && task.name.toLowerCase().includes(keyword2)) {
console.log(`删除离线任务: ${task.name} (hash: ${task.info_hash})`);
await gmHttp.postForm("https://115.com/web/lixian/?ct=lixian&ac=task_del", {
"hash[0]": task.info_hash,
flag: 1,
uid,
sign,
time
});
deletedCount++;
}
}
deletedCount > 0 && console.log(`共删除 ${deletedCount} 个离线任务`);
} catch (error) {
console.error("删除离线任务失败:", error);
}
}
}
class ScreenShotPlugin extends BasePlugin {
getName() {
@@ -10085,6 +10127,7 @@ ${err.stack}` : "");
const matchPlugin = this.getBean("WangPan115MatchPlugin");
const matchList = await matchPlugin.searchFiles(carNum2);
matchPlugin.updateMatchStatus($box2, carNum2, matchList);
this.getBean("WangPan115TaskPlugin").deleteOfflineTasksByKeyword(carNum2);
} else {
const errMsg = result && result.error_msg ? result.error_msg : "未知错误";
show.error(`删除失败: ${errMsg}`);
+3 -3
View File
@@ -150,9 +150,8 @@ class CoverButtonPlugin extends BasePlugin {
let loadObj = loading();
try {
// 使用旧版115删除API删除整个作品目录
// 注意:此处仅删除文件目录,不会删除离线下载任务记录
// 原因:旧版任务删除接口(task_del)已失效,新版接口需要安全验证(如验证码),脚本无法绕过
// 如需重新下载同一作品,请先在115离线下载页面手动删除对应的任务记录,否则会提示"任务已存在"
// 删除后也会尝试删除对应的离线下载任务记录,避免重新下载时提示"任务已存在"
// 注意:旧版任务删除接口(task_del)可能已失效,新版接口需要安全验证,若删除失败请手动清理
const result = await gmHttp.postForm("https://webapi.115.com/rb/delete", {
pid: 0,
"fid[0]": dirId
@@ -163,6 +162,7 @@ class CoverButtonPlugin extends BasePlugin {
const matchPlugin = this.getBean("WangPan115MatchPlugin");
const matchList = await matchPlugin.searchFiles(carNum2);
matchPlugin.updateMatchStatus($box2, carNum2, matchList);
// this.getBean("WangPan115TaskPlugin").deleteOfflineTasksByKeyword(carNum2);
} else {
const errMsg = result && result.error_msg ? result.error_msg : "未知错误";
show.error(`删除失败: ${errMsg}`);
+42
View File
@@ -145,6 +145,48 @@ class WangPan115TaskPlugin extends BasePlugin {
}
return fileId;
}
// async deleteOfflineTasksByKeyword(keyword) {
// try {
// const singInfo = await (async () => {
// const res = await gmHttp.get("https://115.com/?ct=offline&ac=space&_=" + (new Date).getTime());
// return "object" == typeof res ? res : null;
// })();
// if (!singInfo) {
// console.error("删除离线任务: 未登录115网盘");
// return;
// }
// const {sign: sign, time: time} = singInfo, uid = singInfo.uid || (() => {
// const match = document.cookie.match(/UID=(\d+)_/);
// return match ? match[1] : null;
// })() || await this.getUserId();
// const taskListRes = await gmHttp.postForm("https://115.com/web/lixian/?ct=lixian&ac=task_lists", {
// page: 1,
// uid: uid,
// sign: sign,
// time: time
// });
// const tasks = (null == taskListRes ? void 0 : taskListRes.tasks) || [];
// const keyword2 = keyword.toLowerCase().replace("fc2-", "");
// let deletedCount = 0;
// for (const task of tasks) {
// if (task.name && task.name.toLowerCase().includes(keyword2)) {
// console.log(`删除离线任务: ${task.name} (hash: ${task.info_hash})`);
// await gmHttp.postForm("https://115.com/web/lixian/?ct=lixian&ac=task_del", {
// "hash[0]": task.info_hash,
// flag: 1,
// uid: uid,
// sign: sign,
// time: time
// });
// deletedCount++;
// }
// }
// deletedCount > 0 && console.log(`共删除 ${deletedCount} 个离线任务`);
// } catch (error) {
// console.error("删除离线任务失败:", error);
// }
// }
}