Documentation
¶
Overview ¶
Package webwidget contains validated parameters and response models for Bilibili's public Web-widget endpoints.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides Web-widget operations.
func (Client) HeaderPage ¶
func (w Client) HeaderPage(ctx context.Context, params HeaderPageParams) (HeaderData, error)
HeaderPage gets the public home-page header and parses its embedded layer definition during response decoding.
func (Client) Online ¶
func (w Client) Online(ctx context.Context) (OnlineData, error)
Online gets today's upload counts grouped by video region.
func (Client) RegionBanner ¶
func (w Client) RegionBanner(ctx context.Context, params RegionBannerParams) (RegionBannerData, error)
RegionBanner gets the public carousel for a video region.
type HeaderData ¶
type HeaderData struct {
Name string `json:"name"`
Picture string `json:"pic"`
LitPicture string `json:"litpic"`
URL string `json:"url"`
IsSplitLayer uint32 `json:"is_split_layer"`
SplitLayerJSON string `json:"split_layer"`
ParsedSplitLayer *SplitLayer `json:"-"`
}
HeaderData is the public home-page header payload. SplitLayerJSON preserves the wire representation while SplitLayer exposes its parsed structure.
func (*HeaderData) UnmarshalJSON ¶
func (h *HeaderData) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the JSON object embedded in the split_layer string so callers do not need a second parsing step.
type HeaderPageParams ¶
type HeaderPageParams struct {
// contains filtered or unexported fields
}
HeaderPageParams configures web_widget.header_page. Its zero value selects Bilibili's default Web header resource 142.
func NewHeaderPageParams ¶
func NewHeaderPageParams() HeaderPageParams
NewHeaderPageParams returns parameters for the default header resource.
func (HeaderPageParams) EncodeQuery ¶
func (p HeaderPageParams) EncodeQuery() (url.Values, error)
EncodeQuery returns a new URL query with the effective resource ID.
func (HeaderPageParams) WithResourceID ¶
func (p HeaderPageParams) WithResourceID(resourceID uint32) (HeaderPageParams, error)
WithResourceID returns a copy configured for a non-zero resource ID.
type Layer ¶
type Layer struct {
Resources []Resource `json:"resources"`
Scale Scale `json:"scale"`
Rotate Rotate `json:"rotate"`
Translate Translate `json:"translate"`
Blur Blur `json:"blur"`
Opacity Opacity `json:"opacity"`
ID int64 `json:"id"`
Name string `json:"name"`
}
Layer is one independently transformed header asset layer.
type OnlineData ¶
type OnlineData struct {
RegionCount RegionCount `json:"region_count"`
}
OnlineData is the public per-region online-upload payload.
type RegionBanner ¶
type RegionBanner struct {
Image string `json:"image"`
Title string `json:"title"`
Subtitle string `json:"sub_title"`
URL string `json:"url"`
RegionID int64 `json:"rid"`
}
RegionBanner is one public regional carousel item.
type RegionBannerData ¶
type RegionBannerData struct {
Items []RegionBanner `json:"region_banner_list"`
}
RegionBannerData is the regional carousel payload.
type RegionBannerParams ¶
type RegionBannerParams struct {
// contains filtered or unexported fields
}
RegionBannerParams configures web_widget.region_banner.
func NewRegionBannerParams ¶
func NewRegionBannerParams(regionID uint32) (RegionBannerParams, error)
NewRegionBannerParams creates parameters for a non-zero video-region ID.
func (RegionBannerParams) EncodeQuery ¶
func (p RegionBannerParams) EncodeQuery() (url.Values, error)
EncodeQuery returns a new URL query for the configured video region.
type RegionCount ¶
RegionCount maps Bilibili region identifiers to today's upload counts.
type SplitLayer ¶
SplitLayer is the parsed, versioned header-layer definition.