webwidget

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: 9 Imported by: 0

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 Blur

type Blur struct {
	Initial *int64 `json:"initial"`
}

type Client

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

Client provides Web-widget operations.

func NewClient

func NewClient(client *core.Client) Client

NewClient binds the webwidget module to a shared client.

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 Opacity

type Opacity struct {
	Wrap    string   `json:"wrap"`
	Initial *float64 `json:"initial"`
}

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

type RegionCount map[string]uint64

RegionCount maps Bilibili region identifiers to today's upload counts.

type Resource

type Resource struct {
	Source string `json:"src"`
	ID     int64  `json:"id"`
}

Resource is one asset used by a header layer.

type Rotate

type Rotate struct {
	Offset *int64 `json:"offset"`
}

type Scale

type Scale struct {
	Initial *float64 `json:"initial"`
}

type SplitLayer

type SplitLayer struct {
	Version string  `json:"version"`
	Layers  []Layer `json:"layers"`
}

SplitLayer is the parsed, versioned header-layer definition.

type Translate

type Translate struct {
	Offset  []int64 `json:"offset"`
	Initial []int64 `json:"initial"`
}

Jump to

Keyboard shortcuts

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