|
|
@@ -260,176 +260,176 @@ async function signBiliBili() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 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();
|
|
|
-// }
|
|
|
-// }).catch(err => {
|
|
|
-// const msg = `获取AuthCode异常\n${JSON.stringify(err)}`;
|
|
|
-// magicJS.logger.error(msg);
|
|
|
-// reject(msg);
|
|
|
-// });
|
|
|
-// });
|
|
|
-// }
|
|
|
+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();
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ const msg = `获取AuthCode异常\n${JSON.stringify(err)}`;
|
|
|
+ magicJS.logger.error(msg);
|
|
|
+ reject(msg);
|
|
|
+ });
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
-// 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();
|
|
|
-// }
|
|
|
-// }).catch(err => {
|
|
|
-// const msg = `确认登录异常\n${JSON.stringify(err)}`;
|
|
|
-// magicJS.logger.error(msg);
|
|
|
-// reject(msg);
|
|
|
-// });
|
|
|
-// });
|
|
|
-// }
|
|
|
+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();
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ const msg = `确认登录异常\n${JSON.stringify(err)}`;
|
|
|
+ magicJS.logger.error(msg);
|
|
|
+ reject(msg);
|
|
|
+ });
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
-// 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();
|
|
|
-// }
|
|
|
-// }).catch(err => {
|
|
|
-// const msg = `获取AccessKey异常\n${JSON.stringify(err)}`;
|
|
|
-// magicJS.logger.error(msg);
|
|
|
-// reject(msg);
|
|
|
-// });
|
|
|
-// });
|
|
|
-// }
|
|
|
+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();
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ const msg = `获取AccessKey异常\n${JSON.stringify(err)}`;
|
|
|
+ magicJS.logger.error(msg);
|
|
|
+ reject(msg);
|
|
|
+ });
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
-// async function watch(aid, bvid, cid) {
|
|
|
-// return new Promise((resolve, reject) => {
|
|
|
-// magicJS.logger.info("1️⃣ 观看(登录)任务");
|
|
|
-// if (check("watch")) {
|
|
|
-// magicJS.logger.info(`- 正在观看(登录)(${bvid})`);
|
|
|
-// const body = {
|
|
|
-// aid,
|
|
|
-// cid,
|
|
|
-// bvid,
|
|
|
-// mid: config.user.mid,
|
|
|
-// csrf: config.cookie.bili_jct,
|
|
|
-// played_time : 1,
|
|
|
-// real_played_time: 1,
|
|
|
-// realtime: 1,
|
|
|
-// start_ts: getTimestamp(),
|
|
|
-// type: 3,
|
|
|
-// dt: 2,
|
|
|
-// play_type: 0,
|
|
|
-// from_spmid: 0,
|
|
|
-// spmid: 0,
|
|
|
-// auto_continued_play: 0,
|
|
|
-// refer_url: "https%3A%2F%2Ft.bilibili.com%2F",
|
|
|
-// bsource: ""
|
|
|
-// };
|
|
|
-// const myRequest = {
|
|
|
-// url: 'https://api.bilibili.com/x/click-interface/web/heartbeat',
|
|
|
-// headers: {
|
|
|
-// "cookie": config.cookieStr,
|
|
|
-// "referrer": `https://www.bilibili.com/video/${bvid}`
|
|
|
-// },
|
|
|
-// body: magicJS.objToQueryStr(body),
|
|
|
-// };
|
|
|
-// magicJS.http.post(myRequest).then(response => {
|
|
|
-// const body = response.body;
|
|
|
-// if (body?.code === 0) {
|
|
|
-// magicJS.logger.info(`- 累计观看(登录)次数 ${(config.watch.num || 0) + 1}`);
|
|
|
-// config.user.num = (config.user.num || 0) + 1;
|
|
|
-// config.watch.num = (config.watch.num || 0) + 1;
|
|
|
-// magicJS.data.write("bilibili_daily_bonus", magicJS.toStr(config));
|
|
|
-// } else {
|
|
|
-// magicJS.logger.info("- 观看失败, 失败原因: " + body?.message);
|
|
|
-// }
|
|
|
-// resolve(body);
|
|
|
-// }).catch(err => {
|
|
|
-// const msg = `观看异常\n${JSON.stringify(err)}`;
|
|
|
-// magicJS.logger.error(msg);
|
|
|
-// reject();
|
|
|
-// });
|
|
|
-// } else {
|
|
|
-// magicJS.logger.info(`- 今日已经观看 ${config.watch.time}`);
|
|
|
-// resolve();
|
|
|
-// }
|
|
|
-// });
|
|
|
-// }
|
|
|
+async function watch(aid, bvid, cid) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ magicJS.logger.info("1️⃣ 观看(登录)任务");
|
|
|
+ if (check("watch")) {
|
|
|
+ magicJS.logger.info(`- 正在观看(登录)(${bvid})`);
|
|
|
+ const body = {
|
|
|
+ aid,
|
|
|
+ cid,
|
|
|
+ bvid,
|
|
|
+ mid: config.user.mid,
|
|
|
+ csrf: config.cookie.bili_jct,
|
|
|
+ played_time : 1,
|
|
|
+ real_played_time: 1,
|
|
|
+ realtime: 1,
|
|
|
+ start_ts: getTimestamp(),
|
|
|
+ type: 3,
|
|
|
+ dt: 2,
|
|
|
+ play_type: 0,
|
|
|
+ from_spmid: 0,
|
|
|
+ spmid: 0,
|
|
|
+ auto_continued_play: 0,
|
|
|
+ refer_url: "https%3A%2F%2Ft.bilibili.com%2F",
|
|
|
+ bsource: ""
|
|
|
+ };
|
|
|
+ const myRequest = {
|
|
|
+ url: 'https://api.bilibili.com/x/click-interface/web/heartbeat',
|
|
|
+ headers: {
|
|
|
+ "cookie": config.cookieStr,
|
|
|
+ "referrer": `https://www.bilibili.com/video/${bvid}`
|
|
|
+ },
|
|
|
+ body: magicJS.objToQueryStr(body),
|
|
|
+ };
|
|
|
+ magicJS.http.post(myRequest).then(response => {
|
|
|
+ const body = response.body;
|
|
|
+ if (body?.code === 0) {
|
|
|
+ magicJS.logger.info(`- 累计观看(登录)次数 ${(config.watch.num || 0) + 1}`);
|
|
|
+ config.user.num = (config.user.num || 0) + 1;
|
|
|
+ config.watch.num = (config.watch.num || 0) + 1;
|
|
|
+ magicJS.data.write("bilibili_daily_bonus", magicJS.toStr(config));
|
|
|
+ } else {
|
|
|
+ magicJS.logger.info("- 观看失败, 失败原因: " + body?.message);
|
|
|
+ }
|
|
|
+ resolve(body);
|
|
|
+ }).catch(err => {
|
|
|
+ const msg = `观看异常\n${JSON.stringify(err)}`;
|
|
|
+ magicJS.logger.error(msg);
|
|
|
+ reject();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ magicJS.logger.info(`- 今日已经观看 ${config.watch.time}`);
|
|
|
+ resolve();
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
async function share(aid, cid, short_link) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
@@ -490,71 +490,71 @@ async function share(aid, cid, short_link) {
|
|
|
}
|
|
|
|
|
|
async function coin() {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
+ return new Promise(async (resolve, reject) => {
|
|
|
if (config.coins.num >= 50) {
|
|
|
magicJS.logger.info(`- 今日已完成 ${config.coins.time}`);
|
|
|
resolve();
|
|
|
return;
|
|
|
}
|
|
|
let like_uid_list = await getFavUid();
|
|
|
- // if (like_uid_list && like_uid_list.length > 0) {
|
|
|
- // // let aid = await getFavAid(like_uid_list)
|
|
|
- // // //magicJS.logger.info("即将投币的视频aid: " + aid)
|
|
|
- // // if (aid !== 0) {
|
|
|
- // // const body = {
|
|
|
- // // aid,
|
|
|
- // // multiply: 1,
|
|
|
- // // select_like: 0,
|
|
|
- // // cross_domain: true,
|
|
|
- // // csrf: config.cookie.bili_jct
|
|
|
- // // }
|
|
|
- // // const myRequest = {
|
|
|
- // // url: "https://api.bilibili.com/x/web-interface/coin/add",
|
|
|
- // // headers: {
|
|
|
- // // 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36',
|
|
|
- // // 'accept': 'application/json, text/plain, */*',
|
|
|
- // // 'content-type': 'application/x-www-form-urlencoded',
|
|
|
- // // 'origin': 'https://www.bilibili.com',
|
|
|
- // // 'referer': 'https://www.bilibili.com/video/BV1MT411G7fG?vd_source=1970993e2eff4af7be029aefcfa468b8',
|
|
|
- // // 'cookie': config.cookieStr + ';buvid3=fuckchenruilovelaoliu'
|
|
|
- // // },
|
|
|
- // // body: magicJS.objToQueryStr(body)
|
|
|
- // // }
|
|
|
- // // magicJS.http.post(myRequest).then(async response => {
|
|
|
- // // try {
|
|
|
- // // const body = response.body;
|
|
|
- // // if (body?.code === 0 && body?.message === "0") {
|
|
|
- // // magicJS.logger.info("- 投币成功");
|
|
|
- // // config.user.money -= 1;
|
|
|
- // // config.coins.num += 10;
|
|
|
- // // magicJS.data.write("bilibili_daily_bonus", magicJS.toStr(config));
|
|
|
- // // } else {
|
|
|
- // // magicJS.logger.info("- 投币失败,失败原因 " + body.message);
|
|
|
- // // config.coins.failures = (config.coins.failures === 0 || typeof config.coins.failures === 'undefined' ? 1 : config.coins.failures + 1);
|
|
|
- // // magicJS.data.write("bilibili_daily_bonus", magicJS.toStr(config));
|
|
|
- // // if (config.coins.failures < 11) {
|
|
|
- // // magicJS.logger.info("- 正在重试...重试次数 " + (config.coins.failures - 1) + "(超过十次不再重试)");
|
|
|
- // // await coin();
|
|
|
- // // }
|
|
|
- // // }
|
|
|
- // // } catch (e) {
|
|
|
- // // magicJS.logger.error(e);
|
|
|
- // // } finally {
|
|
|
- // // resolve();
|
|
|
- // // }
|
|
|
- // // }).catch(err => {
|
|
|
- // // const msg = `投币异常\n${JSON.stringify(err)}`;
|
|
|
- // // magicJS.logger.error(msg);
|
|
|
- // // reject();
|
|
|
- // // });
|
|
|
- // // } else {
|
|
|
- // // magicJS.logger.info("获取随机投币视频失败");
|
|
|
- // // resolve();
|
|
|
- // // }
|
|
|
- // } else {
|
|
|
- // magicJS.logger.info("获取随机关注用户列表失败");
|
|
|
- // resolve();
|
|
|
- // }
|
|
|
+ if (like_uid_list && like_uid_list.length > 0) {
|
|
|
+ let aid = await getFavAid(like_uid_list)
|
|
|
+ //magicJS.logger.info("即将投币的视频aid: " + aid)
|
|
|
+ if (aid !== 0) {
|
|
|
+ const body = {
|
|
|
+ aid,
|
|
|
+ multiply: 1,
|
|
|
+ select_like: 0,
|
|
|
+ cross_domain: true,
|
|
|
+ csrf: config.cookie.bili_jct
|
|
|
+ }
|
|
|
+ const myRequest = {
|
|
|
+ url: "https://api.bilibili.com/x/web-interface/coin/add",
|
|
|
+ headers: {
|
|
|
+ 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36',
|
|
|
+ 'accept': 'application/json, text/plain, */*',
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded',
|
|
|
+ 'origin': 'https://www.bilibili.com',
|
|
|
+ 'referer': 'https://www.bilibili.com/video/BV1MT411G7fG?vd_source=1970993e2eff4af7be029aefcfa468b8',
|
|
|
+ 'cookie': config.cookieStr + ';buvid3=fuckchenruilovelaoliu'
|
|
|
+ },
|
|
|
+ body: magicJS.objToQueryStr(body)
|
|
|
+ }
|
|
|
+ magicJS.http.post(myRequest).then(async response => {
|
|
|
+ try {
|
|
|
+ const body = response.body;
|
|
|
+ if (body?.code === 0 && body?.message === "0") {
|
|
|
+ magicJS.logger.info("- 投币成功");
|
|
|
+ config.user.money -= 1;
|
|
|
+ config.coins.num += 10;
|
|
|
+ magicJS.data.write("bilibili_daily_bonus", magicJS.toStr(config));
|
|
|
+ } else {
|
|
|
+ magicJS.logger.info("- 投币失败,失败原因 " + body.message);
|
|
|
+ config.coins.failures = (config.coins.failures === 0 || typeof config.coins.failures === 'undefined' ? 1 : config.coins.failures + 1);
|
|
|
+ magicJS.data.write("bilibili_daily_bonus", magicJS.toStr(config));
|
|
|
+ if (config.coins.failures < 11) {
|
|
|
+ magicJS.logger.info("- 正在重试...重试次数 " + (config.coins.failures - 1) + "(超过十次不再重试)");
|
|
|
+ await coin();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ magicJS.logger.error(e);
|
|
|
+ } finally {
|
|
|
+ resolve();
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ const msg = `投币异常\n${JSON.stringify(err)}`;
|
|
|
+ magicJS.logger.error(msg);
|
|
|
+ reject();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ magicJS.logger.info("获取随机投币视频失败");
|
|
|
+ resolve();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ magicJS.logger.info("获取随机关注用户列表失败");
|
|
|
+ resolve();
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|