danmaku

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

Documentation

Overview

Package danmaku contains validated parameters for Bilibili danmaku JSON, XML, and protobuf endpoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdvState

type AdvState struct {
	Coins   uint8 `json:"coins"`
	Confirm uint8 `json:"confirm"`
	Accept  bool  `json:"accept"`
	HasBuy  bool  `json:"hasBuy"`
}

type AdvStateParams

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

func NewAdvStateParams

func NewAdvStateParams(cid ids.CID) AdvStateParams

func (AdvStateParams) EncodeQuery

func (p AdvStateParams) EncodeQuery() (url.Values, error)

type Client

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

Client provides danmaku-domain operations.

func NewClient

func NewClient(client *core.Client) Client

NewClient binds the danmaku module to a shared client.

func (Client) AdvState

func (d Client) AdvState(ctx context.Context, params AdvStateParams) (AdvState, error)

func (Client) HistoryDates

func (d Client) HistoryDates(ctx context.Context, params HistoryDatesParams) ([]string, error)

func (Client) HistoryXMLBytes

func (d Client) HistoryXMLBytes(ctx context.Context, params HistoryBytesParams) ([]byte, error)

func (Client) MobileSegment

func (d Client) MobileSegment(ctx context.Context, params SegmentParams) ([]byte, error)

func (Client) Snapshot

func (d Client) Snapshot(ctx context.Context, params SnapshotParams) ([]string, error)

func (Client) ThumbupStats

func (d Client) ThumbupStats(ctx context.Context, params ThumbupStatsParams) (ThumbupStats, error)

func (Client) WebHistorySegment

func (d Client) WebHistorySegment(ctx context.Context, params HistoryBytesParams) ([]byte, error)

func (Client) WebSegment

func (d Client) WebSegment(ctx context.Context, params SegmentParams) ([]byte, error)

WebSegment gets one raw protobuf danmaku segment. It intentionally does not attempt JSON envelope decoding; callers may decode it with the official DmSegMobileReply protobuf schema.

func (Client) WebSegmentWBI

func (d Client) WebSegmentWBI(ctx context.Context, params SegmentParams) ([]byte, error)

func (Client) WebView

func (d Client) WebView(ctx context.Context, params WebViewParams) ([]byte, error)

func (Client) XMLList

func (d Client) XMLList(ctx context.Context, params XMLListParams) (XML, error)

func (Client) XMLListSO

func (d Client) XMLListSO(ctx context.Context, params XMLListParams) (XML, error)

type Comment

type Comment struct {
	Parameters string       `xml:"p,attr"`
	Content    string       `xml:",chardata"`
	Meta       *CommentMeta `xml:"-"`
}

type CommentMeta

type CommentMeta struct {
	Time       float32
	Mode       int32
	FontSize   int32
	Color      int32
	SentAt     int64
	Pool       int32
	UserHash   string
	ID         int64
	BlockLevel int32
}

type HistoryBytesParams

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

func NewHistoryBytesParams

func NewHistoryBytesParams(typeID uint8, oid uint64, date string) (HistoryBytesParams, error)

func (HistoryBytesParams) EncodeQuery

func (p HistoryBytesParams) EncodeQuery() (url.Values, error)

type HistoryDatesParams

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

func NewHistoryDatesParams

func NewHistoryDatesParams(oid ids.CID, month string) (HistoryDatesParams, error)

func (HistoryDatesParams) EncodeQuery

func (p HistoryDatesParams) EncodeQuery() (url.Values, error)

func (HistoryDatesParams) WithType

func (p HistoryDatesParams) WithType(typeID uint8) (HistoryDatesParams, error)

type SegmentParams

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

SegmentParams configures a real-time protobuf danmaku segment request.

func NewSegmentParams

func NewSegmentParams(typeID uint8, oid uint64, segmentIndex uint32) (SegmentParams, error)

NewSegmentParams creates parameters with non-zero type, object ID, and segment index.

func (SegmentParams) EncodeQuery

func (p SegmentParams) EncodeQuery() (url.Values, error)

EncodeQuery returns a new URL query containing the request parameters.

func (SegmentParams) WithAID

func (p SegmentParams) WithAID(aid ids.AID) (SegmentParams, error)

WithAID returns a copy with the owning archive ID.

func (SegmentParams) WithPullMode

func (p SegmentParams) WithPullMode(mode uint32) SegmentParams

WithPullMode returns a copy with an API pull-mode value.

func (SegmentParams) WithRange

func (p SegmentParams) WithRange(start, end uint32) (SegmentParams, error)

WithRange returns a copy with an inclusive millisecond content range.

type SnapshotParams

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

func NewSnapshotByAID

func NewSnapshotByAID(aid ids.AID) SnapshotParams

func NewSnapshotByBVID

func NewSnapshotByBVID(bvid ids.BVID) SnapshotParams

func (SnapshotParams) EncodeQuery

func (p SnapshotParams) EncodeQuery() (url.Values, error)

type ThumbupStat

type ThumbupStat struct {
	Likes    int64  `json:"likes"`
	UserLike int32  `json:"user_like"`
	ID       string `json:"id_str"`
}

type ThumbupStats

type ThumbupStats map[string]ThumbupStat

type ThumbupStatsParams

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

func NewThumbupStatsParams

func NewThumbupStatsParams(oid ids.CID, danmakuIDs ...uint64) (ThumbupStatsParams, error)

func (ThumbupStatsParams) EncodeQuery

func (p ThumbupStatsParams) EncodeQuery() (url.Values, error)

type WebViewParams

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

func NewWebViewParams

func NewWebViewParams(typeID uint8, oid uint64) (WebViewParams, error)

func (WebViewParams) EncodeQuery

func (p WebViewParams) EncodeQuery() (url.Values, error)

func (WebViewParams) WithAID

func (p WebViewParams) WithAID(aid ids.AID) WebViewParams

type XML

type XML struct {
	XMLName    xml.Name  `xml:"i"`
	ChatServer string    `xml:"chatserver"`
	ChatID     string    `xml:"chatid"`
	Mission    int32     `xml:"mission"`
	MaxLimit   int32     `xml:"maxlimit"`
	State      int32     `xml:"state"`
	RealName   int32     `xml:"real_name"`
	Source     string    `xml:"source"`
	Comments   []Comment `xml:"d"`
}

func ParseDeflateXML

func ParseDeflateXML(body []byte) (XML, error)

ParseDeflateXML decodes a raw-deflate danmaku response and parses each comment's compact p attribute into typed metadata.

type XMLListParams

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

func NewXMLListParams

func NewXMLListParams(cid ids.CID) XMLListParams

func (XMLListParams) CommentURL

func (p XMLListParams) CommentURL() (string, error)

func (XMLListParams) EncodeQuery

func (p XMLListParams) EncodeQuery() (url.Values, error)

Jump to

Keyboard shortcuts

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