()
| 263 | } |
| 264 | |
| 265 | async function getAuthCode() { |
| 266 | const body = { |
| 267 | appkey: "27eb53fc9058f8c3", |
| 268 | local_id: 0, |
| 269 | ts: $.getTimestamp() |
| 270 | } |
| 271 | const sortedBody = $.queryStr(Object.fromEntries(new Map(Array.from(Object.entries(body)).sort()))) |
| 272 | const sign = md5(sortedBody + 'c2ed53a74eeefe3cf99fbd01d8c9c375') |
| 273 | body['sign'] = sign |
| 274 | const myRequest = { |
| 275 | url: "https://passport.bilibili.com/x/passport-tv-login/qrcode/auth_code", |
| 276 | headers: { |
| 277 | "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" |
| 278 | }, |
| 279 | body: $.queryStr(body) |
| 280 | } |
| 281 | return await $.fetch(myRequest).then(response => { |
| 282 | try { |
| 283 | const body = $.toObj(response.body) |
| 284 | if (body.code === 0 && body.message === "0") { |
| 285 | $.log("- 获取auth_code成功") |
| 286 | return body.data.auth_code |
| 287 | } else { |
| 288 | $.log("- 获取auth_code失败") |
| 289 | return "0" |
| 290 | } |
| 291 | } catch (e) { |
| 292 | $.logErr(e, response) |
| 293 | } |
| 294 | }) |
| 295 | } |
| 296 | |
| 297 | async function loginConfirm(auth_code) { |
| 298 | const body = { |
no test coverage detected