mirror of
https://github.com/hmjz100/LinkSwift.git
synced 2026-09-20 10:53:34 +08:00
修复:Aria2 POST 推送类型、ABDM 推送请求头格式化
This commit is contained in:
@@ -875,14 +875,15 @@
|
|||||||
id: new Date().getTime(),
|
id: new Date().getTime(),
|
||||||
jsonrpc: "2.0",
|
jsonrpc: "2.0",
|
||||||
method: "aria2.addUri",
|
method: "aria2.addUri",
|
||||||
params: [`token:${rpc.token}`, [link], {
|
params: [[link], {
|
||||||
dir,
|
dir,
|
||||||
out: filename,
|
out: filename,
|
||||||
header: headers
|
header: headers
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
if (rpc.token) data.params.unshift(`token:${rpc.token}`);
|
||||||
try {
|
try {
|
||||||
const res = await base.post(url, data, {}, "", false);
|
const res = await base.post(url, data, { "Accept": "application/json", "Content-Type": "application/json;charset=UTF-8" }, "json", false);
|
||||||
if (res.result) return "success";
|
if (res.result) return "success";
|
||||||
return "fail";
|
return "fail";
|
||||||
} catch {
|
} catch {
|
||||||
@@ -955,11 +956,7 @@
|
|||||||
async sendLinkToABDM(link, filename, headers) {
|
async sendLinkToABDM(link, filename, headers) {
|
||||||
if (!this.sendLinkToABDM.lock) this.sendLinkToABDM.lock = Promise.resolve();
|
if (!this.sendLinkToABDM.lock) this.sendLinkToABDM.lock = Promise.resolve();
|
||||||
return this.sendLinkToABDM.lock = this.sendLinkToABDM.lock.then(async () => {
|
return this.sendLinkToABDM.lock = this.sendLinkToABDM.lock.then(async () => {
|
||||||
const newHeaders = {};
|
headers = this.standHeaders(headers);
|
||||||
for (const key in headers) {
|
|
||||||
newHeaders[key.toLowerCase().split("-").map(word => word.charAt(0).toUpperCase() + word.slice(1)).join("-")] = headers[key];
|
|
||||||
}
|
|
||||||
headers = { "User-Agent": navigator.userAgent, "Origin": location.origin, "Referer": `${location.origin}/`, "DNT": "1", ...newHeaders };
|
|
||||||
const list = base.getValue("setting_abdm_rpc");
|
const list = base.getValue("setting_abdm_rpc");
|
||||||
const selected = list.find(i => i.default);
|
const selected = list.find(i => i.default);
|
||||||
const rpc = {
|
const rpc = {
|
||||||
@@ -973,11 +970,11 @@
|
|||||||
"name": filename,
|
"name": filename,
|
||||||
"description": "LinkSwift",
|
"description": "LinkSwift",
|
||||||
"link": link,
|
"link": link,
|
||||||
"headers": headers,
|
"headers": headers
|
||||||
"downloadPage": headers["Referer"]
|
|
||||||
},
|
},
|
||||||
"name": filename
|
"name": filename
|
||||||
}
|
}
|
||||||
|
if (headers["Referer"]) data["downloadSource"]["downloadPage"] = headers["Referer"];
|
||||||
if (rpc.dir) data.folder = rpc.dir;
|
if (rpc.dir) data.folder = rpc.dir;
|
||||||
try {
|
try {
|
||||||
const res = await base.post(url, data, { "Content-Type": "text/plain;charset=UTF-8" }, "text", false);
|
const res = await base.post(url, data, { "Content-Type": "text/plain;charset=UTF-8" }, "text", false);
|
||||||
|
|||||||
Reference in New Issue
Block a user