|
@@ -261,118 +261,106 @@ async function signBiliBili() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function getAuthCode() {
|
|
async function getAuthCode() {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
|
|
- const body = {
|
|
|
|
|
- appkey: "27eb53fc9058f8c3",
|
|
|
|
|
- local_id: 0,
|
|
|
|
|
- ts: getTimestamp()
|
|
|
|
|
- };
|
|
|
|
|
- const sortedBody = magicJS.objToQueryStr(Object.fromEntries(new Map(Array.from(Object.entries(body)).sort())));
|
|
|
|
|
- const sign = md5(sortedBody + 'c2ed53a74eeefe3cf99fbd01d8c9c375');
|
|
|
|
|
- body['sign'] = sign;
|
|
|
|
|
- const myRequest = {
|
|
|
|
|
- url: "https://passport.bilibili.com/x/passport-tv-login/qrcode/auth_code",
|
|
|
|
|
- headers: {
|
|
|
|
|
- "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
|
|
|
|
|
- },
|
|
|
|
|
- body: magicJS.objToQueryStr(body),
|
|
|
|
|
- }
|
|
|
|
|
- magicJS.http.post(myRequest).then(response => {
|
|
|
|
|
- try {
|
|
|
|
|
- const body = response.body;
|
|
|
|
|
- if (body.code === 0 && body.message === "0") {
|
|
|
|
|
- magicJS.logger.info("- 获取auth_code成功");
|
|
|
|
|
- resolve(body.data.auth_code);
|
|
|
|
|
- } else {
|
|
|
|
|
- magicJS.logger.info("- 获取auth_code失败");
|
|
|
|
|
- resolve("0");
|
|
|
|
|
- }
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- magicJS.logger.error(e);
|
|
|
|
|
- resolve();
|
|
|
|
|
|
|
+ const body = {
|
|
|
|
|
+ appkey: "27eb53fc9058f8c3",
|
|
|
|
|
+ local_id: 0,
|
|
|
|
|
+ ts: getTimestamp()
|
|
|
|
|
+ };
|
|
|
|
|
+ const sortedBody = magicJS.objToQueryStr(Object.fromEntries(new Map(Array.from(Object.entries(body)).sort())));
|
|
|
|
|
+ const sign = md5(sortedBody + 'c2ed53a74eeefe3cf99fbd01d8c9c375');
|
|
|
|
|
+ body['sign'] = sign;
|
|
|
|
|
+ const myRequest = {
|
|
|
|
|
+ url: "https://passport.bilibili.com/x/passport-tv-login/qrcode/auth_code",
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
|
|
|
|
|
+ },
|
|
|
|
|
+ body: magicJS.objToQueryStr(body),
|
|
|
|
|
+ }
|
|
|
|
|
+ await magicJS.http.post(myRequest).then(response => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const body = response.body;
|
|
|
|
|
+ if (body.code === 0 && body.message === "0") {
|
|
|
|
|
+ magicJS.logger.info("- 获取auth_code成功");
|
|
|
|
|
+ return body.data.auth_code;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ magicJS.logger.info("- 获取auth_code失败");
|
|
|
|
|
+ return "0";
|
|
|
}
|
|
}
|
|
|
- }).catch(err => {
|
|
|
|
|
- const msg = `获取AuthCode异常\n${JSON.stringify(err)}`;
|
|
|
|
|
- magicJS.logger.error(msg);
|
|
|
|
|
- reject(msg);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ magicJS.logger.error(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(err => {
|
|
|
|
|
+ const msg = `获取AuthCode异常\n${JSON.stringify(err)}`;
|
|
|
|
|
+ magicJS.logger.error(msg);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function loginConfirm(auth_code) {
|
|
async function loginConfirm(auth_code) {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
|
|
- const body = {
|
|
|
|
|
- auth_code,
|
|
|
|
|
- build: 7082000,
|
|
|
|
|
- csrf: config.cookie.bili_jct
|
|
|
|
|
- };
|
|
|
|
|
- const myRequest = {
|
|
|
|
|
- url: "https://passport.bilibili.com/x/passport-tv-login/h5/qrcode/confirm",
|
|
|
|
|
- headers: {
|
|
|
|
|
- "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
|
|
|
- 'cookie': `DedeUserID=${config.cookie.DedeUserID}; SESSDATA=${config.cookie.SESSDATA}`
|
|
|
|
|
- },
|
|
|
|
|
- body: magicJS.objToQueryStr(body),
|
|
|
|
|
- };
|
|
|
|
|
- magicJS.http.post(myRequest).then(response => {
|
|
|
|
|
- try {
|
|
|
|
|
- const body = response.body;
|
|
|
|
|
- if (body.code === 0 && body.message === "0") {
|
|
|
|
|
- magicJS.logger.info("- 确认登录成功")
|
|
|
|
|
- resolve(true);
|
|
|
|
|
- } else {
|
|
|
|
|
- magicJS.logger.info("- 确认登录失败")
|
|
|
|
|
- resolve(false);
|
|
|
|
|
- }
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- magicJS.logger.error(e);
|
|
|
|
|
- resolve();
|
|
|
|
|
|
|
+ const body = {
|
|
|
|
|
+ auth_code,
|
|
|
|
|
+ build: 7082000,
|
|
|
|
|
+ csrf: config.cookie.bili_jct
|
|
|
|
|
+ };
|
|
|
|
|
+ const myRequest = {
|
|
|
|
|
+ url: "https://passport.bilibili.com/x/passport-tv-login/h5/qrcode/confirm",
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
|
|
|
+ 'cookie': `DedeUserID=${config.cookie.DedeUserID}; SESSDATA=${config.cookie.SESSDATA}`
|
|
|
|
|
+ },
|
|
|
|
|
+ body: magicJS.objToQueryStr(body),
|
|
|
|
|
+ };
|
|
|
|
|
+ await magicJS.http.post(myRequest).then(response => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const body = response.body;
|
|
|
|
|
+ if (body.code === 0 && body.message === "0") {
|
|
|
|
|
+ magicJS.logger.info("- 确认登录成功")
|
|
|
|
|
+ return true;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ magicJS.logger.info("- 确认登录失败")
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
- }).catch(err => {
|
|
|
|
|
- const msg = `确认登录异常\n${JSON.stringify(err)}`;
|
|
|
|
|
- magicJS.logger.error(msg);
|
|
|
|
|
- reject(msg);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ magicJS.logger.error(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(err => {
|
|
|
|
|
+ const msg = `确认登录异常\n${JSON.stringify(err)}`;
|
|
|
|
|
+ magicJS.logger.error(msg);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function getAccessKey(auth_code) {
|
|
async function getAccessKey(auth_code) {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
|
|
- const body = {
|
|
|
|
|
- appkey: "27eb53fc9058f8c3",
|
|
|
|
|
- auth_code,
|
|
|
|
|
- local_id: 0,
|
|
|
|
|
- ts: getTimestamp()
|
|
|
|
|
- }
|
|
|
|
|
- const sortedBody = magicJS.objToQueryStr(Object.fromEntries(new Map(Array.from(Object.entries(body)).sort())));
|
|
|
|
|
- const sign = md5(sortedBody + 'c2ed53a74eeefe3cf99fbd01d8c9c375');
|
|
|
|
|
- body['sign'] = sign;
|
|
|
|
|
- const myRequest = {
|
|
|
|
|
- url: "https://passport.bilibili.com/x/passport-tv-login/qrcode/poll",
|
|
|
|
|
- headers: {
|
|
|
|
|
- "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
|
|
|
|
|
- },
|
|
|
|
|
- body: magicJS.objToQueryStr(body),
|
|
|
|
|
- };
|
|
|
|
|
- magicJS.http.post(myRequest).then(response => {
|
|
|
|
|
- try {
|
|
|
|
|
- const body = response.body;
|
|
|
|
|
- if (body.code === 0 && body.message === "0") {
|
|
|
|
|
- magicJS.logger.info("- 获取access_key成功");
|
|
|
|
|
- resolve(body.data.access_token);
|
|
|
|
|
- } else {
|
|
|
|
|
- magicJS.logger.info("- 获取access_key失败");
|
|
|
|
|
- resolve("0");
|
|
|
|
|
- }
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- magicJS.logger.error(e);
|
|
|
|
|
- resolve();
|
|
|
|
|
|
|
+ const body = {
|
|
|
|
|
+ appkey: "27eb53fc9058f8c3",
|
|
|
|
|
+ auth_code,
|
|
|
|
|
+ local_id: 0,
|
|
|
|
|
+ ts: getTimestamp()
|
|
|
|
|
+ }
|
|
|
|
|
+ const sortedBody = magicJS.objToQueryStr(Object.fromEntries(new Map(Array.from(Object.entries(body)).sort())));
|
|
|
|
|
+ const sign = md5(sortedBody + 'c2ed53a74eeefe3cf99fbd01d8c9c375');
|
|
|
|
|
+ body['sign'] = sign;
|
|
|
|
|
+ const myRequest = {
|
|
|
|
|
+ url: "https://passport.bilibili.com/x/passport-tv-login/qrcode/poll",
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
|
|
|
|
|
+ },
|
|
|
|
|
+ body: magicJS.objToQueryStr(body),
|
|
|
|
|
+ };
|
|
|
|
|
+ await magicJS.http.post(myRequest).then(response => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const body = response.body;
|
|
|
|
|
+ if (body.code === 0 && body.message === "0") {
|
|
|
|
|
+ magicJS.logger.info("- 获取access_key成功");
|
|
|
|
|
+ return body.data.access_token;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ magicJS.logger.info("- 获取access_key失败");
|
|
|
|
|
+ return "0";
|
|
|
}
|
|
}
|
|
|
- }).catch(err => {
|
|
|
|
|
- const msg = `获取AccessKey异常\n${JSON.stringify(err)}`;
|
|
|
|
|
- magicJS.logger.error(msg);
|
|
|
|
|
- reject(msg);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ magicJS.logger.error(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(err => {
|
|
|
|
|
+ const msg = `获取AccessKey异常\n${JSON.stringify(err)}`;
|
|
|
|
|
+ magicJS.logger.error(msg);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -645,7 +633,7 @@ async function silver2coin() {
|
|
|
},
|
|
},
|
|
|
body: magicJS.objToQueryStr(body)
|
|
body: magicJS.objToQueryStr(body)
|
|
|
};
|
|
};
|
|
|
- magicJS.http.get(myRequest).then(response => {
|
|
|
|
|
|
|
+ magicJS.http.post(myRequest).then(response => {
|
|
|
try {
|
|
try {
|
|
|
let result = response.body;
|
|
let result = response.body;
|
|
|
let title = `银瓜子转硬币`;
|
|
let title = `银瓜子转硬币`;
|