Skip to content

Commit

Permalink
perf: 添加HD登录的日志打印
Browse files Browse the repository at this point in the history
  • Loading branch information
msojocs committed Nov 5, 2023
1 parent 0f4a99a commit cb8ccb7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
34 changes: 21 additions & 13 deletions extensions/area_unlimit/hook/biliapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,20 +336,28 @@ window.log = window.log ||{
formEl.resetFields()
},
startHDLogin: async function() {
log.info('HD Login')
const login = new BiliBiliApi()
const qr = await login.TV_getLoginQrCode()
this.hdLogin.qrCode = qr.data.url
let t = setInterval(async () => {
const ret = await login.TV_pollCheckLogin(qr.data.auth_code)
log.log('扫码结果:', ret)
if (ret.code === 0) {
this.hdLogin.qrCode = ''
ret.data.token_info.expires_at = parseInt(Date.now()/1000) + ret.data.token_info.expires_in
localStorage.setItem('bili_accessToken_hd', JSON.stringify(ret.data.token_info))
this.hdLogin.tokenInfo = ret.data.token_info
clearInterval(t)
}
}, 2000)
try {
log.info('获取登录二维码')
const qr = await login.HD_getLoginQrCode()
this.hdLogin.qrCode = qr.data.url
let t = setInterval(async () => {
log.info('获取扫码结果')
const ret = await login.HD_pollCheckLogin(qr.data.auth_code)
log.log('扫码结果:', ret)
if (ret.code === 0) {
this.hdLogin.qrCode = ''
ret.data.token_info.expires_at = parseInt(Date.now() / 1000) + ret.data.token_info.expires_in
localStorage.setItem('bili_accessToken_hd', JSON.stringify(ret.data.token_info))
this.hdLogin.tokenInfo = ret.data.token_info
clearInterval(t)
}
}, 2000)
}
catch (e) {
log.error('HD Login Error:', e)
}
},
deleteHDLogin: function() {
localStorage.removeItem('bili_accessToken_hd')
Expand Down
8 changes: 2 additions & 6 deletions extensions/area_unlimit/hook/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,8 @@ class BiliBiliApi {
})
}
pList = pList.sort((a, b) => a.key > b.key ? 1 : -1)
log.log(pList)

const str = pList.map(e => `${e.key}=${encodeURIComponent(e.value)}`).join('&')
log.log(str + this.appSecret)
const sign = hex_md5(str + this.appSecret)
return `${str}&sign=${sign}`
}
Expand Down Expand Up @@ -395,7 +393,7 @@ class BiliBiliApi {
* @return {Promise<any>}
* @constructor
*/
async TV_getLoginQrCode() {
async HD_getLoginQrCode() {
const url = 'https://passport.bilibili.com/x/passport-tv-login/qrcode/auth_code'
// const url = 'https://passport.snm0516.aisee.tv/x/passport-tv-login/qrcode/auth_code'
const deviceId = (await cookieStore.get('device_id')).value
Expand Down Expand Up @@ -426,13 +424,11 @@ class BiliBiliApi {
sys_ver: '29',
ts: (Date.now()/1000).toFixed(0)
}
log.log(this.genSignParam(param))
const _resp = await HTTP.post(url, this.genSignParam(param), {
'Content-Type': 'application/x-www-form-urlencoded',
'app-key': 'android_hd',
env: 'prod',
buvid: buvid,
'User-Agent': '',
})
const resp = JSON.parse(_resp.responseText)
if (resp.code === 0) {
Expand All @@ -449,7 +445,7 @@ class BiliBiliApi {
* @return {Promise<any>}
* @constructor
*/
async TV_pollCheckLogin(authCode) {
async HD_pollCheckLogin(authCode) {
const url = 'https://passport.bilibili.com/x/passport-tv-login/qrcode/poll'
const deviceId = (await cookieStore.get('device_id')).value
const fingerprint = (await cookieStore.get('fingerprint')).value
Expand Down

0 comments on commit cb8ccb7

Please sign in to comment.