(auth_code)
| 325 | } |
| 326 | |
| 327 | async function getAccessKey(auth_code) { |
| 328 | const body = { |
| 329 | appkey: "27eb53fc9058f8c3", |
| 330 | auth_code, |
| 331 | local_id: 0, |
| 332 | ts: $.getTimestamp() |
| 333 | } |
| 334 | const sortedBody = $.queryStr(Object.fromEntries(new Map(Array.from(Object.entries(body)).sort()))) |
| 335 | const sign = md5(sortedBody + 'c2ed53a74eeefe3cf99fbd01d8c9c375') |
| 336 | body['sign'] = sign |
| 337 | const myRequest = { |
| 338 | url: "https://passport.bilibili.com/x/passport-tv-login/qrcode/poll", |
| 339 | headers: { |
| 340 | "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" |
| 341 | }, |
| 342 | body: $.queryStr(body) |
| 343 | } |
| 344 | return await $.fetch(myRequest).then(response => { |
| 345 | try { |
| 346 | const body = $.toObj(response.body) |
| 347 | if (body.code === 0 && body.message === "0") { |
| 348 | $.log("- 获取access_key成功") |
| 349 | return body.data.access_token |
| 350 | } else { |
| 351 | $.log("- 获取access_key失败") |
| 352 | return "0" |
| 353 | } |
| 354 | } catch (e) { |
| 355 | $.logErr(e, response) |
| 356 | } |
| 357 | }) |
| 358 | } |
| 359 | |
| 360 | async function watch(aid, bvid, cid) { |
| 361 | $.log("1️⃣ 观看(登录)任务") |
no test coverage detected