MCPcopy Create free account
hub / github.com/ClydeTime/Surge / getAccessKey

Function getAccessKey

Script/Task/BiliBili.js:327–358  ·  view source on GitHub ↗
(auth_code)

Source from the content-addressed store, hash-verified

325}
326
327async 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
360async function watch(aid, bvid, cid) {
361 $.log("1️⃣ 观看(登录)任务")

Callers 1

persistentStoreFunction · 0.85

Calls 8

md5Function · 0.70
getTimestampMethod · 0.45
queryStrMethod · 0.45
fromMethod · 0.45
fetchMethod · 0.45
toObjMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected