bilibili

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubTypeUp      = "up"
	SubTypeBangumi = "bangumi"
	SubTypeLive    = "live"

	SubUserAll = "all"
)
View Source
const (
	SearchTypeBangumi  = "media_bangumi"
	SearchTypeFT       = "media_ft"
	SearchTypeUser     = "bili_user"
	DynamicTypeShare   = 1  // 转发
	DynamicTypePic     = 2  // 图片动态
	DynamicTypeText    = 4  // 文字动态
	DynamicTypeVideo   = 8  // 视频动态
	DynamicTypeRead    = 64 // 专栏动态
	LiveStatusClose    = 0  // 直播间关闭
	LiveStatusOpen     = 1  // 直播中
	LiveStatusCarousel = 2  // 直播间轮播中
)

一些预定义

Variables

This section is empty.

Functions

func AddSubscription

func AddSubscription(sub Subscription) error

AddSubscription 添加订阅

func DeleteSubscription

func DeleteSubscription(sub Subscription) error

DeleteSubscription 删除订阅,必须指定SubUsers(=SubUserAll则该订阅全部删除),另外至少需要SubType和BID,或单独指定ID

func DynamicTypePicMessage added in v0.2.4

func DynamicTypePicMessage(d DynamicInfo) (m []message.MessageSegment)

func DynamicTypeReadMessage added in v0.2.4

func DynamicTypeReadMessage(d DynamicInfo) (m []message.MessageSegment)

func DynamicTypeShareMessage added in v0.2.4

func DynamicTypeShareMessage(d DynamicInfo) (m []message.MessageSegment)

func DynamicTypeTextMessage added in v0.2.4

func DynamicTypeTextMessage(d DynamicInfo) (m []message.MessageSegment)

func GetAPI

func GetAPI(api string) (url string)

GetAPI 获取API地址

func SendSearchResult

func SendSearchResult(ctx *zero.Ctx, ms []messager)

func SetAPIDefault

func SetAPIDefault(api string, value string)

SetAPIDefault 设置默认API地址

func SetGlobalCookie added in v0.3.0

func SetGlobalCookie(cookie string)

SetGlobalCookie 设置全局cookie

func UpdateSubsStatus

func UpdateSubsStatus(sub Subscription) error

Types

type Bangumi

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

Bangumi Bilibili番剧相关

func NewBangumi

func NewBangumi() *Bangumi

func (*Bangumi) ByMDID

func (b *Bangumi) ByMDID(mediaID int64) (BangumiLatestInfo, error)

type BangumiEPInfo

type BangumiEPInfo struct {
	ID        int64  `json:"id"`
	Name      string `json:"index"`
	IndexShow string `json:"index_show"`
}

type BangumiInfo

type BangumiInfo struct {
	MediaID     int64  `json:"media_id"`
	SeasonID    int64  `json:"season_id"`
	Title       string `json:"title"`
	OrgTitle    string `json:"org_title"`
	Areas       string `json:"areas"`
	Description string `json:"desc"`
	Styles      string `json:"styles"`
	EPSize      int    `json:"ep_size"`
	CoverURL    string `json:"cover"`
	// 与哔哩哔哩回包不一致的字段:
	Score float64 `json:"score"`
}

func (BangumiInfo) GenMessage

func (b BangumiInfo) GenMessage(index int) message.Message

func (BangumiInfo) GenText

func (b BangumiInfo) GenText(index int) string

type BangumiLatestInfo

type BangumiLatestInfo struct {
	MediaID  int64         `json:"media_id"`
	SeasonID int64         `json:"season_id"`
	Title    string        `json:"title"`
	Areas    string        `json:"areas"`
	CoverURL string        `json:"cover"`
	NewEP    BangumiEPInfo `json:"new_ep"`
	URL      string        `json:"share_url"`
	// 与哔哩哔哩回包不一致的字段:
	Score float64 `json:"score"`
}

type Client

type Client struct {
	*client.HttpClient
}

Client bilibili客户端(请求器)

func NewClient

func NewClient() *Client

func (*Client) GetDefaultCookie added in v0.3.3

func (c *Client) GetDefaultCookie() error

func (*Client) NewBangumi added in v0.3.0

func (c *Client) NewBangumi() *Bangumi

func (*Client) NewLiveRoom added in v0.3.0

func (c *Client) NewLiveRoom(id int64) *LiveRoom

func (*Client) NewSearch added in v0.3.0

func (c *Client) NewSearch() *Search

func (*Client) NewUser added in v0.3.0

func (c *Client) NewUser(ID int64) *User

func (*Client) SetCookie added in v0.3.0

func (c *Client) SetCookie(cookie string)

type DynamicInfo

type DynamicInfo struct {
	ID   string    `json:"dynamic_id_str"`
	Type int       `json:"type"`
	Card string    `json:"card"`
	View int64     `json:"view"`
	Like int64     `json:"like"`
	Time time.Time `json:"timestamp"`
	// 与哔哩哔哩回包不一致的附加字段:
	Uname string `json:"uname"`
	BVID  string `json:"bvid"`
}

func (DynamicInfo) VideoCoverURL added in v0.3.0

func (d DynamicInfo) VideoCoverURL() string

func (DynamicInfo) VideoTitle

func (d DynamicInfo) VideoTitle() string

type LiveRoom

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

LiveRoom 直播相关

func NewLiveRoom

func NewLiveRoom(id int64) *LiveRoom

func (*LiveRoom) Info

func (l *LiveRoom) Info() (LiveRoomInfo, error)

type LiveRoomInfo

type LiveRoomInfo struct {
	ID       int64    `json:"room_id"`
	ShortID  int64    `json:"short_id"`
	Title    string   `json:"title"`
	Status   int      `json:"live_status"`
	CoverURL string   `json:"cover"`
	Anchor   UserInfo `json:"anchor_info"`
}

func (LiveRoomInfo) IsOpen

func (l LiveRoomInfo) IsOpen() bool
type Search struct {
	// contains filtered or unexported fields
}

Search Bilibili搜索相关

func NewSearch

func NewSearch() *Search

func (*Search) Bangumi

func (s *Search) Bangumi(keyword string) ([]BangumiInfo, error)

func (*Search) FT

func (s *Search) FT(keyword string) ([]BangumiInfo, error)

FT 搜索影视

func (*Search) Type

func (s *Search) Type(searchType string, keyword string, additionalKV ...string) (gjson.Result, error)

func (*Search) User

func (s *Search) User(keyword string) ([]UserInfo, error)

type Subscription

type Subscription struct {
	ID       int
	SubUsers string // 格式:若为私人,则直接是ID;若为群订阅,则为 群ID:发起用户ID;多个User用,分隔
	SubType  string `gorm:"uniqueIndex:idx_sub_item;size:64"`
	BID      int64  `gorm:"uniqueIndex:idx_sub_item"` // UP主ID、番剧ID、直播间ID
	// 状态相关:
	BangumiLastIndex string    // 番剧:最后一集Index
	DynamicLastTime  time.Time // UP动态:最后一条动态时间戳
	LiveStatus       bool      // 直播间:开播状态
}

func AllSubscription

func AllSubscription() []Subscription

AllSubscription 获取所有订阅

func GetSubForGroup

func GetSubForGroup(groupID int64) []Subscription

GetSubForGroup 获取群订阅列表

func GetSubForPrimary

func GetSubForPrimary(userID int64) []Subscription

GetSubForPrimary 获取私人订阅列表

func (Subscription) GenMessage

func (s Subscription) GenMessage(showUsers bool) message.Message

func (Subscription) GenUsersText

func (s Subscription) GenUsersText() string

func (Subscription) GetFriendsGroups

func (s Subscription) GetFriendsGroups() (friends, groups []int64)

func (*Subscription) TableName

func (s *Subscription) TableName() string

type User

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

User Bilibili用户(up主)相关

func NewUser

func NewUser(ID int64) *User

func (*User) Dynamics

func (u *User) Dynamics(offset int, hasTop bool) ([]DynamicInfo, string, error)

func (*User) Info

func (u *User) Info() (UserInfo, error)

type UserInfo

type UserInfo struct {
	MID      int64  `json:"mid"`
	Name     string `json:"name"`
	Sex      string `json:"sex"`
	FaceURL  string `json:"face"`
	Sign     string `json:"sign"`
	Level    int    `json:"level"`
	Birthday string `json:"birthday"`
	// 与哔哩哔哩回包不一致的字段:
	Silence    bool  `json:"silence"` // 是否被封禁
	Fans       int64 `json:"fans"`    // 粉丝数(仅在搜索结果中提供)
	LiveRoomID int64 `json:"live_room_id"`
}

func (UserInfo) GenMessage

func (u UserInfo) GenMessage(index int) message.Message

func (UserInfo) GenText

func (u UserInfo) GenText(index int) string

Jump to

Keyboard shortcuts

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