audio

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 audio contains validated parameters and stable response models for Bilibili audio 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 audio-domain operations.

func NewClient

func NewClient(client *core.Client) Client

NewClient binds the audio module to a shared client.

func (Client) CoinCount

func (a Client) CoinCount(ctx context.Context, params SongParams) (int32, error)

func (Client) CollectionInfo

func (a Client) CollectionInfo(ctx context.Context, params CollectionInfoParams) (*Collection, error)

func (Client) CollectionStatus

func (a Client) CollectionStatus(ctx context.Context, params SongParams) (bool, error)

func (Client) CollectionsList

func (a Client) CollectionsList(ctx context.Context, params PageParams) (Page[Collection], error)

func (Client) HotMenu

func (a Client) HotMenu(ctx context.Context, params PageParams) (Page[HotMenu], error)

func (Client) Info

func (a Client) Info(ctx context.Context, params SongParams) (Info, error)

func (Client) Lyric

func (a Client) Lyric(ctx context.Context, params SongParams) (string, error)

func (Client) Members

func (a Client) Members(ctx context.Context, params SongParams) ([]MemberGroup, error)

func (Client) RankDetail

func (a Client) RankDetail(ctx context.Context, params RankListParams) (RankDetail, error)

func (Client) RankMenu

func (a Client) RankMenu(ctx context.Context, params PageParams) (Page[RankMenu], error)

func (Client) RankMusicList

func (a Client) RankMusicList(ctx context.Context, params RankListParams) (RankMusicList, error)

func (Client) RankPeriod

func (a Client) RankPeriod(ctx context.Context, params RankPeriodParams) (RankPeriods, error)

func (Client) StatusNumber

func (a Client) StatusNumber(ctx context.Context, params SongParams) (StatusNumber, error)

func (Client) StreamURL

func (a Client) StreamURL(ctx context.Context, params StreamURLParams) (StreamURL, error)

func (Client) StreamURLWeb

func (a Client) StreamURLWeb(ctx context.Context, params StreamURLWebParams) (StreamURLWeb, error)

func (Client) Tags

func (a Client) Tags(ctx context.Context, params SongParams) ([]Tag, error)

type Collection

type Collection struct {
	ID          int64               `json:"id"`
	UID         int64               `json:"uid"`
	UserName    string              `json:"uname"`
	Title       string              `json:"title"`
	Type        int32               `json:"type"`
	Published   int32               `json:"published"`
	Cover       string              `json:"cover"`
	CreatedAt   int64               `json:"ctime"`
	SongCount   int32               `json:"song"`
	Description string              `json:"desc"`
	SIDs        []int64             `json:"sids"`
	MenuID      int64               `json:"menuId"`
	Statistic   CollectionStatistic `json:"statistic"`
}

type CollectionInfoParams

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

func NewCollectionInfoParams

func NewCollectionInfoParams(id uint64) (CollectionInfoParams, error)

func (CollectionInfoParams) EncodeQuery

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

type CollectionStatistic

type CollectionStatistic struct {
	SID     int64  `json:"sid"`
	Play    int64  `json:"play"`
	Collect int64  `json:"collect"`
	Comment *int64 `json:"comment"`
	Share   int64  `json:"share"`
}

type HotMenu

type HotMenu struct {
	MenuID       int64         `json:"menuId"`
	UID          int64         `json:"uid"`
	UserName     string        `json:"uname"`
	Title        string        `json:"title"`
	Cover        string        `json:"cover"`
	Intro        string        `json:"intro"`
	Type         int32         `json:"type"`
	Off          int32         `json:"off"`
	CreatedAt    int64         `json:"ctime"`
	CurrentTime  int64         `json:"curtime"`
	Statistic    MenuStatistic `json:"statistic"`
	SongCount    int32         `json:"snum"`
	Attribute    int32         `json:"attr"`
	IsDefault    int32         `json:"isDefault"`
	CollectionID int64         `json:"collectionId"`
}

type Info

type Info struct {
	ID               ids.AudioID      `json:"id"`
	UID              ids.MID          `json:"uid"`
	UserName         string           `json:"uname"`
	Author           string           `json:"author"`
	Title            string           `json:"title"`
	Cover            string           `json:"cover"`
	Intro            string           `json:"intro"`
	LyricURL         string           `json:"lyric"`
	CRType           int32            `json:"crtype"`
	Duration         int64            `json:"duration"`
	PassTime         int64            `json:"passtime"`
	CurrentTime      int64            `json:"curtime"`
	AID              int64            `json:"aid"`
	BVID             string           `json:"bvid"`
	CID              int64            `json:"cid"`
	MSID             int64            `json:"msid"`
	Attribute        int64            `json:"attr"`
	Limit            int64            `json:"limit"`
	ActivityID       int64            `json:"activityId"`
	LimitDescription string           `json:"limitdesc"`
	CreatedAt        *json.RawMessage `json:"ctime"`
	Statistic        Statistic        `json:"statistic"`
	VIP              VIPInfo          `json:"vipInfo"`
	CollectIDs       []int64          `json:"collectIds"`
	CoinCount        int64            `json:"coin_num"`
}

type Member

type Member struct {
	MID      int64  `json:"mid"`
	Name     string `json:"name"`
	MemberID int64  `json:"member_id"`
}

type MemberGroup

type MemberGroup struct {
	List []Member `json:"list"`
	Type int32    `json:"type"`
}
type MenuStatistic struct {
	SID     int64 `json:"sid"`
	Play    int64 `json:"play"`
	Collect int64 `json:"collect"`
	Comment int64 `json:"comment"`
	Share   int64 `json:"share"`
}

type Page

type Page[T any] struct {
	CurrentPage int32 `json:"curPage"`
	PageCount   int32 `json:"pageCount"`
	TotalSize   int32 `json:"totalSize"`
	PageSize    int32 `json:"pageSize"`
	Data        []T   `json:"data"`
}

type PageParams

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

func NewPageParams

func NewPageParams(page, size uint32) (PageParams, error)

func (PageParams) EncodeQuery

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

type Quality

type Quality uint32
const (
	QualitySmooth Quality = iota
	QualityStandard
	QualityHigh
	QualityLossless
)

type QualityInfo

type QualityInfo struct {
	Type               uint32 `json:"type"`
	Description        string `json:"desc"`
	Size               uint64 `json:"size"`
	BPS                string `json:"bps"`
	Tag                string `json:"tag"`
	Require            uint32 `json:"require"`
	RequireDescription string `json:"requiredesc"`
}

type RankDetail

type RankDetail struct {
	ListenFID   uint64 `json:"listen_fid"`
	AllFID      uint64 `json:"all_fid"`
	FavoriteMID uint64 `json:"fav_mid"`
	CoverURL    string `json:"cover_url"`
	IsSubscribe bool   `json:"is_subscribe"`
	ListenCount uint64 `json:"listen_count"`
}

type RankItem

type RankItem struct {
	ID       ids.AudioID `json:"id"`
	Title    string      `json:"title"`
	Duration int64       `json:"duration"`
}

type RankListParams

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

func NewRankListParams

func NewRankListParams(id uint64) (RankListParams, error)

func (RankListParams) EncodeQuery

func (p RankListParams) EncodeQuery(csrf string) (url.Values, error)

type RankListType

type RankListType uint32
const (
	RankHot      RankListType = 1
	RankOriginal RankListType = 2
)

func NewCustomRankListType

func NewCustomRankListType(value uint32) (RankListType, error)

type RankMenu

type RankMenu struct {
	MenuID       int64         `json:"menuId"`
	UID          int64         `json:"uid"`
	UserName     string        `json:"uname"`
	Title        string        `json:"title"`
	Cover        string        `json:"cover"`
	Intro        string        `json:"intro"`
	Type         int32         `json:"type"`
	Off          int32         `json:"off"`
	CreatedAt    int64         `json:"ctime"`
	CurrentTime  int64         `json:"curtime"`
	Statistic    MenuStatistic `json:"statistic"`
	SongCount    int32         `json:"snum"`
	Attribute    int32         `json:"attr"`
	IsDefault    int32         `json:"isDefault"`
	CollectionID int64         `json:"collectionId"`
	Audios       []RankItem    `json:"audios"`
}

type RankMusic

type RankMusic struct {
	MusicID          string   `json:"music_id"`
	MusicTitle       string   `json:"music_title"`
	Singer           string   `json:"singer"`
	Album            string   `json:"album"`
	MVAID            uint64   `json:"mv_aid"`
	MVBVID           string   `json:"mv_bvid"`
	MVCover          string   `json:"mv_cover"`
	Heat             uint64   `json:"heat"`
	Rank             uint64   `json:"rank"`
	CanListen        bool     `json:"can_listen"`
	Recommendation   string   `json:"recommendation"`
	CreationAID      uint64   `json:"creation_aid"`
	CreationBVID     string   `json:"creation_bvid"`
	CreationCover    string   `json:"creation_cover"`
	CreationTitle    string   `json:"creation_title"`
	CreationUP       uint64   `json:"creation_up"`
	CreationNickname string   `json:"creation_nickname"`
	CreationDuration uint64   `json:"creation_duration"`
	CreationPlay     uint64   `json:"creation_play"`
	CreationReason   string   `json:"creation_reason"`
	Achievements     []string `json:"achievements"`
	MaterialID       uint64   `json:"material_id"`
	MaterialUseCount uint64   `json:"material_use_num"`
	MaterialDuration uint64   `json:"material_duration"`
	MaterialShow     uint64   `json:"material_show"`
	SongType         uint64   `json:"song_type"`
}

type RankMusicList

type RankMusicList struct {
	List []RankMusic `json:"list"`
}

type RankPeriod

type RankPeriod struct {
	ID          uint64 `json:"ID"`
	Period      uint64 `json:"priod"`
	PublishTime uint64 `json:"publish_time"`
}

type RankPeriodParams

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

func NewRankPeriodParams

func NewRankPeriodParams(listType RankListType) RankPeriodParams

func (RankPeriodParams) EncodeQuery

func (p RankPeriodParams) EncodeQuery(csrf string) (url.Values, error)

type RankPeriods

type RankPeriods struct {
	List map[string][]RankPeriod `json:"list"`
}

type SongParams

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

func NewSongParams

func NewSongParams(sid ids.AudioID) SongParams

func (SongParams) EncodeQuery

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

type Statistic

type Statistic struct {
	SID     ids.AudioID `json:"sid"`
	Play    int64       `json:"play"`
	Collect int64       `json:"collect"`
	Comment int64       `json:"comment"`
	Share   int64       `json:"share"`
}

type StatusNumber

type StatusNumber struct {
	SID     ids.AudioID `json:"sid"`
	Play    int64       `json:"play"`
	Collect int64       `json:"collect"`
	Comment int64       `json:"comment"`
	Share   int64       `json:"share"`
}

type StreamURL

type StreamURL struct {
	SID       ids.AudioID   `json:"sid"`
	Type      uint32        `json:"type"`
	Info      string        `json:"info"`
	Timeout   uint64        `json:"timeout"`
	Size      uint64        `json:"size"`
	CDNs      []string      `json:"cdns"`
	Qualities []QualityInfo `json:"qualities"`
	Title     string        `json:"title"`
	Cover     string        `json:"cover"`
}

type StreamURLParams

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

func NewStreamURLParams

func NewStreamURLParams(sid ids.AudioID, quality Quality) StreamURLParams

func (StreamURLParams) EncodeQuery

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

func (StreamURLParams) WithMID

func (p StreamURLParams) WithMID(mid uint64) (StreamURLParams, error)

func (StreamURLParams) WithPlatform

func (p StreamURLParams) WithPlatform(platform string) (StreamURLParams, error)

func (StreamURLParams) WithPrivilege

func (p StreamURLParams) WithPrivilege(privilege uint32) (StreamURLParams, error)

type StreamURLWeb

type StreamURLWeb struct {
	SID       ids.AudioID      `json:"sid"`
	Type      uint32           `json:"type"`
	Info      string           `json:"info"`
	Timeout   uint64           `json:"timeout"`
	Size      uint64           `json:"size"`
	CDNs      []string         `json:"cdns"`
	Qualities *json.RawMessage `json:"qualities"`
	Title     string           `json:"title"`
	Cover     string           `json:"cover"`
}

type StreamURLWebParams

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

func NewStreamURLWebParams

func NewStreamURLWebParams(sid ids.AudioID) StreamURLWebParams

func (StreamURLWebParams) EncodeQuery

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

func (StreamURLWebParams) WithPrivilege

func (p StreamURLWebParams) WithPrivilege(privilege uint32) (StreamURLWebParams, error)

func (StreamURLWebParams) WithQuality

func (p StreamURLWebParams) WithQuality(quality Quality) StreamURLWebParams

type Tag

type Tag struct {
	Type    string `json:"type"`
	Subtype int32  `json:"subtype"`
	Key     int32  `json:"key"`
	Info    string `json:"info"`
}

type VIPInfo

type VIPInfo struct {
	Type    int32 `json:"type"`
	Status  int32 `json:"status"`
	DueDate int64 `json:"due_date"`
	PayType int32 `json:"vip_pay_type"`
}

Jump to

Keyboard shortcuts

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