login

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package login contains parameters and response models for Bilibili login and authenticated-session state.

Index

Constants

View Source
const (
	QRSuccess            int32 = 0
	QRExpired            int32 = 86038
	QRScannedUnconfirmed int32 = 86090
	QRWaiting            int32 = 86101
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountInfo

type AccountInfo struct {
	MID       ids.MID `json:"mid"`
	Username  string  `json:"uname"`
	UserID    string  `json:"userid"`
	Signature string  `json:"sign"`
	Birthday  string  `json:"birthday"`
	Sex       string  `json:"sex"`
	NickFree  bool    `json:"nick_free"`
	Rank      string  `json:"rank"`
}

type Captcha

type Captcha struct {
	Token     string
	GT        string
	Challenge string
}

type CaptchaPayload

type CaptchaPayload struct {
	Type    string  `json:"type"`
	Token   string  `json:"token"`
	Geetest Geetest `json:"geetest"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides login and authenticated-session operations.

func NewClient

func NewClient(client *core.Client) Client

NewClient binds the login module to a shared client.

func (Client) AccountInfo

func (l Client) AccountInfo(ctx context.Context) (AccountInfo, error)

func (Client) Coin

func (l Client) Coin(ctx context.Context) (CoinBalance, error)

func (Client) DailyReward

func (l Client) DailyReward(ctx context.Context) (DailyReward, error)

func (Client) GenerateCaptcha

func (l Client) GenerateCaptcha(ctx context.Context) (Captcha, error)

func (Client) GenerateQR

func (l Client) GenerateQR(ctx context.Context) (QRGenerate, error)

func (Client) Log

func (l Client) Log(ctx context.Context, params LogParams) (Log, error)

func (Client) Nav

func (l Client) Nav(ctx context.Context) (Nav, error)

Nav gets the current session's navigation/login state. Anonymous sessions normally return an API error for which RequiresLogin reports true.

func (Client) Notice

func (l Client) Notice(ctx context.Context, params NoticeParams) (Notice, error)

func (Client) PollQR

func (l Client) PollQR(ctx context.Context, params QRPollParams) (QRStatus, error)

func (Client) QRFlow

func (l Client) QRFlow(ctx context.Context) (QRFlow, error)

QRFlow generates a QR login challenge and immediately performs one poll. Callers can continue polling with PollQR and the returned Generate.Key.

func (Client) Stat

func (l Client) Stat(ctx context.Context) (Stats, error)

func (Client) TodayCoinExp

func (l Client) TodayCoinExp(ctx context.Context) (TodayCoinExp, error)

func (Client) VIPInfo

func (l Client) VIPInfo(ctx context.Context) (VIPInfo, error)

type CoinBalance

type CoinBalance struct {
	Money float64 `json:"money"`
}

type DailyReward

type DailyReward struct {
	Login        bool   `json:"login"`
	Watch        bool   `json:"watch"`
	Coins        uint32 `json:"coins"`
	Share        bool   `json:"share"`
	Email        bool   `json:"email"`
	Telephone    bool   `json:"tel"`
	SafeQuestion bool   `json:"safe_question"`
	IdentityCard bool   `json:"identify_card"`
}

type Geetest

type Geetest struct {
	Challenge string `json:"challenge"`
	GT        string `json:"gt"`
}

type Log

type Log struct {
	Count uint32     `json:"count"`
	List  []LogEntry `json:"list"`
}

type LogEntry

type LogEntry struct {
	IP        string `json:"ip"`
	Time      uint64 `json:"time"`
	TimeText  string `json:"time_at"`
	Succeeded bool   `json:"status"`
	Type      uint8  `json:"type"`
	Location  string `json:"geo"`
}

type LogParams

type LogParams struct {
	// contains filtered or unexported fields
}

func NewLogParams

func NewLogParams() LogParams

func (LogParams) EncodeQuery

func (p LogParams) EncodeQuery() (url.Values, error)

func (LogParams) WithJSONP

func (p LogParams) WithJSONP(jsonp string) (LogParams, error)

func (LogParams) WithWebLocation

func (p LogParams) WithWebLocation(location string) (LogParams, error)
type Nav struct {
	IsLogin  bool     `json:"isLogin"`
	MID      *ids.MID `json:"mid,omitempty"`
	Username *string  `json:"uname,omitempty"`
	Face     *string  `json:"face,omitempty"`
	WBIImage WBIImage `json:"wbi_img"`
}

Nav is the stable login/navigation state returned by login.nav.

func (n *Nav) UnmarshalJSON(data []byte) error

UnmarshalJSON normalizes guest zero/blank identity fields to nil while retaining strict validation for non-zero member IDs.

type Notice

type Notice struct {
	MID        ids.MID `json:"mid"`
	DeviceName string  `json:"device_name"`
	LoginType  string  `json:"login_type"`
	LoginTime  string  `json:"login_time"`
	Location   string  `json:"location"`
	IP         string  `json:"ip"`
}

type NoticeParams

type NoticeParams struct {
	// contains filtered or unexported fields
}

func NewNoticeParams

func NewNoticeParams(mid ids.MID) NoticeParams

func (NoticeParams) EncodeQuery

func (p NoticeParams) EncodeQuery() (url.Values, error)

func (NoticeParams) WithBuvid

func (p NoticeParams) WithBuvid(buvid string) (NoticeParams, error)

type QRFlow

type QRFlow struct {
	Generate QRGenerate
	Poll     QRStatus
}

type QRGenerate

type QRGenerate struct {
	URL string `json:"url"`
	Key string `json:"qrcode_key"`
}

type QRPollParams

type QRPollParams struct {
	// contains filtered or unexported fields
}

func NewQRPollParams

func NewQRPollParams(key string) (QRPollParams, error)

func (QRPollParams) EncodeQuery

func (p QRPollParams) EncodeQuery() (url.Values, error)

type QRStatus

type QRStatus struct {
	URL          string            `json:"url"`
	RefreshToken string            `json:"refresh_token"`
	Timestamp    uint64            `json:"timestamp"`
	Code         int32             `json:"code"`
	Message      string            `json:"message"`
	Cookies      map[string]string `json:"-"`
}

func (QRStatus) Authenticated

func (s QRStatus) Authenticated() bool

type Stats

type Stats struct {
	Following    uint64 `json:"following"`
	Followers    uint64 `json:"follower"`
	DynamicCount uint64 `json:"dynamic_count"`
}

type TodayCoinExp

type TodayCoinExp uint32

type VIPInfo

type VIPInfo struct {
	MID       ids.MID `json:"mid"`
	Type      uint8   `json:"vip_type"`
	Status    uint8   `json:"vip_status"`
	ExpiresAt uint64  `json:"vip_due_date"`
	PayType   uint8   `json:"vip_pay_type"`
	ThemeType uint8   `json:"theme_type"`
}

func (VIPInfo) Active

func (v VIPInfo) Active() bool

type WBIImage

type WBIImage struct {
	ImageURL string `json:"img_url"`
	SubURL   string `json:"sub_url"`
}

WBIImage contains the current image-key URLs used for WBI signing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL