biligo icon indicating copy to clipboard operation
biligo copied to clipboard

✨feat(client): login with qrcode

Open GoldenSheep402 opened this issue 2 years ago • 1 comments

add feat that login by scaning qrcode instead of set cookies manually.

Snipaste_2023-05-07_14-38-45

GoldenSheep402 avatar May 07 '23 06:05 GoldenSheep402

// NewBiliClientScanQrcode
//
// 通过扫描二维码获取Cookie无需手动设置Cookies
func NewBiliClientScanQrcode(setting *BiliSetting) (*BiliClient, error) {
	cookies := util.GetCookie()
	bili := &BiliClient{
		auth: &CookieAuth{
			DedeUserID:      cookies.DedeUserID,
			SESSDATA:        cookies.SESSDATA,
			BiliJCT:         cookies.Bili_jct,
			DedeUserIDCkMd5: cookies.DedeUserID__ckMd5,
		},
		baseClient: newBaseClient(&baseSetting{
			Client:    setting.Client,
			DebugMode: setting.DebugMode,
			UserAgent: setting.UserAgent,
			Prefix:    "BiliClient ",
		}),
	}

	account, err := bili.GetMe()
	if err != nil {
		return nil, err
	}

	bili.Me = account

	return bili, nil
}

GoldenSheep402 avatar May 07 '23 06:05 GoldenSheep402