bilibili

package module
v0.0.0-...-056b60d Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2022 License: GPL-3.0 Imports: 9 Imported by: 1

README

bilibili

解析bilibili动态,视频,专栏,直播信息的库

Documentation

Overview

Package bilibili b站动态解析库

Index

Constants

View Source
const (
	// ArticleInfoURL 查看专栏信息
	ArticleInfoURL = "https://api.bilibili.com/x/article/viewinfo?id=%v"
	// CURL b站专栏前缀
	CURL = "https://www.bilibili.com/read/cv"
)
View Source
const (
	// TURL bilibili动态前缀
	TURL = "https://t.bilibili.com/"
	// SpaceHistoryURL 历史动态信息,一共12个card
	SpaceHistoryURL = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?host_uid=%v&offset_dynamic_id=%v&need_top=0"
	// DynamicDetailURL 当前动态信息,一个card
	DynamicDetailURL = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail?dynamic_id=%v"
)
View Source
const (
	// LiveRoomInfoURL 查看直播间信息
	LiveRoomInfoURL = "https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom?room_id=%v"
	// UserLiveURL 查看直播用户信息
	UserLiveURL = "https://api.bilibili.com/x/space/acc/info?mid=%v"
	// LURL b站直播间前缀
	LURL = "https://live.bilibili.com/"
)
View Source
const (
	// VideoInfoURL 查看视频信息
	VideoInfoURL = "https://api.bilibili.com/x/web-interface/view?aid=%v&bvid=%v"
	// SearchVideoInfoURL 搜索视频信息
	SearchVideoInfoURL = "https://api.bilibili.com/x/web-interface/search/all/v2?%v"
	// VURL 视频网址前缀
	VURL = "https://www.bilibili.com/video/"
)
View Source
const (
	// MemberCardURL 个人信息
	MemberCardURL = "https://account.bilibili.com/api/member/getCardByMid?mid=%v"
)

Variables

This section is empty.

Functions

func ArticleCard2msg

func ArticleCard2msg(str string, defaultID string) (msg []message.MessageSegment, err error)

ArticleCard2msg 专栏转消息

func ArticleInfo

func ArticleInfo(id string) (msg []message.MessageSegment, err error)

ArticleInfo 用id查专栏信息

func DynamicCard2msg

func DynamicCard2msg(str string, cType int) (msg []message.MessageSegment, err error)

DynamicCard2msg cType=0时,处理DynCard字符串,cType=1, 2, 4, 8, 16, 64, 256, 2048, 4200, 4308时,处理Card字符串,cType为card类型

func DynamicDetail

func DynamicDetail(dynamicIDStr string) (msg []message.MessageSegment, err error)

DynamicDetail 用动态id查动态信息

func LiveCard2msg

func LiveCard2msg(str string) (msg []message.MessageSegment, err error)

LiveCard2msg 直播卡片转消息

func LiveRoomInfo

func LiveRoomInfo(roomID string) (msg []message.MessageSegment, err error)

LiveRoomInfo 用直播间id查直播间信息

func VideoCard2msg

func VideoCard2msg(str string) (msg []message.MessageSegment, err error)

VideoCard2msg 视频卡片转消息

func VideoInfo

func VideoInfo(id string) (msg []message.MessageSegment, err error)

VideoInfo 用av或bv查视频信息

Types

type Card

type Card struct {
	Item struct {
		Content     string `json:"content"`
		UploadTime  int    `json:"upload_time"`
		Description string `json:"description"`
		Pictures    []struct {
			ImgSrc string `json:"img_src"`
		} `json:"pictures"`
		Timestamp int `json:"timestamp"`
		Cover     struct {
			Default string `json:"default"`
		} `json:"cover"`
		OrigType int `json:"orig_type"`
	} `json:"item"`
	AID             interface{} `json:"aid"`
	BvID            interface{} `json:"bvid"`
	Dynamic         interface{} `json:"dynamic"`
	Pic             string      `json:"pic"`
	Title           string      `json:"title"`
	ID              int         `json:"id"`
	Summary         string      `json:"summary"`
	ImageUrls       []string    `json:"image_urls"`
	OriginImageUrls []string    `json:"origin_image_urls"`
	Sketch          struct {
		Title     string `json:"title"`
		DescText  string `json:"desc_text"`
		CoverURL  string `json:"cover_url"`
		TargetURL string `json:"target_url"`
	} `json:"sketch"`
	Stat struct {
		Aid      int `json:"aid"`
		View     int `json:"view"`
		Danmaku  int `json:"danmaku"`
		Reply    int `json:"reply"`
		Favorite int `json:"favorite"`
		Coin     int `json:"coin"`
		Share    int `json:"share"`
		Like     int `json:"like"`
	} `json:"stat"`
	Stats struct {
		Aid      int `json:"aid"`
		View     int `json:"view"`
		Danmaku  int `json:"danmaku"`
		Reply    int `json:"reply"`
		Favorite int `json:"favorite"`
		Coin     int `json:"coin"`
		Share    int `json:"share"`
		Like     int `json:"like"`
	} `json:"stats"`
	Owner struct {
		Name    string `json:"name"`
		Pubdate int    `json:"pubdate"`
		Mid     int    `json:"mid"`
	} `json:"owner"`
	Cover        string      `json:"cover"`
	ShortID      interface{} `json:"short_id"`
	LivePlayInfo struct {
		ParentAreaName string `json:"parent_area_name"`
		AreaName       string `json:"area_name"`
		Cover          string `json:"cover"`
		Link           string `json:"link"`
		Online         int    `json:"online"`
		RoomID         int    `json:"room_id"`
		LiveStatus     int    `json:"live_status"`
		WatchedShow    string `json:"watched_show"`
		Title          string `json:"title"`
	} `json:"live_play_info"`
	Intro      string      `json:"intro"`
	Schema     string      `json:"schema"`
	Author     interface{} `json:"author"`
	AuthorName string      `json:"author_name"`
	PlayCnt    int         `json:"play_cnt"`
	ReplyCnt   int         `json:"reply_cnt"`
	TypeInfo   string      `json:"type_info"`
	User       struct {
		Name  string `json:"name"`
		Uname string `json:"uname"`
	} `json:"user"`
	Desc          string `json:"desc"`
	ShareSubtitle string `json:"share_subtitle"`
	ShortLink     string `json:"short_link"`
	PublishTime   int    `json:"publish_time"`
	BannerURL     string `json:"banner_url"`
	Ctime         int    `json:"ctime"`
	Vest          struct {
		Content string `json:"content"`
	} `json:"vest"`
	Upper   string `json:"upper"`
	Origin  string `json:"origin"`
	Pubdate int    `json:"pubdate"`
	Rights  struct {
		IsCooperation int `json:"is_cooperation"`
	} `json:"rights"`
	Staff []struct {
		Title    string `json:"title"`
		Name     string `json:"name"`
		Follower int    `json:"follower"`
	} `json:"staff"`
}

Card 卡片结构体

type Desc

type Desc struct {
	Type         int    `json:"type"`
	DynamicIDStr string `json:"dynamic_id_str"`
	OrigType     int    `json:"orig_type"`
	Timestamp    int    `json:"timestamp"`
	Origin       struct {
		DynamicIDStr string `json:"dynamic_id_str"`
	} `json:"origin"`
	UserProfile struct {
		Info struct {
			Uname string `json:"uname"`
		} `json:"info"`
	} `json:"user_profile"`
}

Desc 描述结构体

type DynamicCard

type DynamicCard struct {
	Desc      Desc   `json:"desc"`
	Card      string `json:"card"`
	Extension struct {
		VoteCfg struct {
			VoteID  int    `json:"vote_id"`
			Desc    string `json:"desc"`
			JoinNum int    `json:"join_num"`
		} `json:"vote_cfg"`
		Vote string `json:"vote"`
	} `json:"extension"`
}

DynamicCard 总动态结构体,包括desc,card

type MemberCard

type MemberCard struct {
	Mid        string  `json:"mid"`
	Name       string  `json:"name"`
	Sex        string  `json:"sex"`
	Face       string  `json:"face"`
	Coins      float64 `json:"coins"`
	Regtime    int     `json:"regtime"`
	Birthday   string  `json:"birthday"`
	Sign       string  `json:"sign"`
	Attentions []int   `json:"attentions"`
	Fans       int     `json:"fans"`
	Friend     int     `json:"friend"`
	Attention  int     `json:"attention"`
	LevelInfo  struct {
		CurrentLevel int `json:"current_level"`
	} `json:"level_info"`
}

MemberCard 个人信息卡片

type RoomCard

type RoomCard struct {
	RoomInfo struct {
		RoomID         int    `json:"room_id"`
		ShortID        int    `json:"short_id"`
		Title          string `json:"title"`
		LiveStatus     int    `json:"live_status"`
		AreaName       string `json:"area_name"`
		ParentAreaName string `json:"parent_area_name"`
		Keyframe       string `json:"keyframe"`
		Online         int    `json:"online"`
	} `json:"room_info"`
	AnchorInfo struct {
		BaseInfo struct {
			Uname string `json:"uname"`
		} `json:"base_info"`
	} `json:"anchor_info"`
}

RoomCard 直播间卡片

type Vote

type Vote struct {
	ChoiceCnt int    `json:"choice_cnt"`
	Desc      string `json:"desc"`
	Endtime   int    `json:"endtime"`
	JoinNum   int    `json:"join_num"`
	Options   []struct {
		Idx    int    `json:"idx"`
		Desc   string `json:"desc"`
		ImgURL string `json:"img_url"`
	} `json:"options"`
}

Vote 投票结构体

Jump to

Keyboard shortcuts

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