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

Function getAuthCode

Script/Task/BiliBili.js:265–295  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

263}
264
265async 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
297async function loginConfirm(auth_code) {
298 const body = {

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