Skip to content

Commit

Permalink
优化部分视频相关接口
Browse files Browse the repository at this point in the history
  • Loading branch information
CuteReimu committed Apr 3, 2024
1 parent 139de66 commit d98d921
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 248 deletions.
4 changes: 2 additions & 2 deletions article.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type Category struct {
Name string `json:"name"` // 分类名称
}

type Tag struct {
type ArticleTag struct {
Tid int `json:"tid"` // 标签id
Name string `json:"name"` // 标签名称
}
Expand Down Expand Up @@ -72,7 +72,7 @@ type Article struct {
PublishTime int `json:"publish_time"` // 发布时间戳。单位:秒
Ctime int `json:"ctime"` // 提交时间戳。单位:秒
Stats ArticleStats `json:"stats"` // 专栏文章数据统计
Tags []Tag `json:"tags"` // 标签
Tags []ArticleTag `json:"tags"` // 标签
Words int `json:"words"`
Dynamic string `json:"dynamic"` // 粉丝动态文案
OriginImageUrls []string `json:"origin_image_urls"`
Expand Down
24 changes: 23 additions & 1 deletion comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ type CommentReply struct {
Control CommentsControl `json:"control"` // 评论区输入属性
Page CommentsPage `json:"page"` // 页面信息
Replies []*Comment `json:"replies"` // 评论对话树列表。最大内容数为20
Root *Comment `json:"root"` // 根评论信息。[对象定义见表](readme.md#评论条目对象)
Root *Comment `json:"root"` // 根评论信息
ShowBvid bool `json:"show_bvid"` // 显示 bvid?
ShowText string `json:"show_text"` // (?)
ShowType int `json:"show_type"` // (?)
Expand All @@ -190,3 +190,25 @@ func (c *Client) GetCommentReply(param GetCommentReplyParam) (*CommentReply, err
)
return execute[*CommentReply](c, method, url, param)
}

type GetCommentsHotReplyParam struct {
Type int `json:"type"` // 评论区类型代码
Oid int `json:"oid"` // 目标评论区 id
Root int `json:"root"` // 根回复 rpid
Ps int `json:"ps,omitempty" request:"query,omitempty"` // 每页项数。默认为20。定义域:1-49
Pn int `json:"pn,omitempty" request:"query,omitempty"` // 页码。默认为1
}

type CommentsHotReply struct {
Page CommentsPage `json:"page"` // 页面信息
Replies []Comment `json:"replies"` // 热评列表
}

// GetCommentsHotReply 获取评论区热评
func (c *Client) GetCommentsHotReply(param GetCommentsHotReplyParam) (*CommentsHotReply, error) {
const (
method = resty.MethodGet
url = "https://api.bilibili.com/x/v2/reply/hot"
)
return execute[*CommentsHotReply](c, method, url, param)
}
5 changes: 5 additions & 0 deletions util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import (
"github.com/go-resty/resty/v2"
)

func TestVideo(t *testing.T) {
c := New()
t.Log(c.GetVideoRecommendList(GetVideoRecommendListParam{Bvid: "BV17x411w7KC"}))
}

func TestQuery(t *testing.T) {
type Test struct {
TestA string `request:"query"`
Expand Down
Loading

0 comments on commit d98d921

Please sign in to comment.