bangumi

package
v0.0.0-...-193b04c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2024 License: Unlicense Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResGroupSmall  = "small"
	ResGroupMedium = "medium"
	ResGroupLarge  = "large"
)
View Source
const (
	Host    = "bangumi.tv"
	ApiHost = "api.bgm.tv"

	SubjectURL = "https://bangumi.tv/subject"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Cli       *http.Client
	Token     string
	UserAgent string
}

func (*Client) Get

func (c *Client) Get(url string, dst any) error

func (*Client) GetSubjectDetail

func (c *Client) GetSubjectDetail(id int) (*SubjectDetail, error)

func (*Client) GetSubjectDetailWithContext

func (c *Client) GetSubjectDetailWithContext(ctx context.Context, id int) (*SubjectDetail, error)

func (*Client) GetWithContext

func (c *Client) GetWithContext(ctx context.Context, url string, dst any) error

func (*Client) Post

func (c *Client) Post(url string, dst any) error

func (*Client) PostWithContext

func (c *Client) PostWithContext(ctx context.Context, url string, dst any) error

func (*Client) Search

func (c *Client) Search(query string, options SearchOption) (*SearchResp, error)

func (*Client) SearchWithContext

func (c *Client) SearchWithContext(ctx context.Context, query string, options SearchOption) (*SearchResp, error)

type SearchItem

type SearchItem struct {
	ID         int    `json:"id"`
	URL        string `json:"url"`
	Type       int    `json:"type"`
	Name       string `json:"name"`
	NameCn     string `json:"name_cn"`
	Summary    string `json:"summary"`
	AirDate    string `json:"air_date"`
	AirWeekday int    `json:"air_weekday"`
	Rating     struct {
		Total int         `json:"total"`
		Count map[int]int `json:"count"`
		Score float64     `json:"score"`
	} `json:"rating"`
	Rank   int `json:"rank"`
	Images struct {
		Large  string `json:"large"`
		Common string `json:"common"`
		Medium string `json:"medium"`
		Small  string `json:"small"`
		Grid   string `json:"grid"`
	} `json:"images"`
	Collection struct {
		Wish    int `json:"wish"`
		Collect int `json:"collect"`
		Doing   int `json:"doing"`
		OnHold  int `json:"on_hold"`
		Dropped int `json:"dropped"`
	} `json:"collection"`
}

type SearchOption

type SearchOption struct {
	Start         int
	MaxResult     int
	Type          int
	ResponseGroup string
}

type SearchResp

type SearchResp struct {
	Results int          `json:"results"`
	List    []SearchItem `json:"list"`
}

type SubjectDetail

type SubjectDetail struct {
	ID       int    `json:"id"`
	Type     int    `json:"type"`
	Name     string `json:"name"`
	NameCn   string `json:"name_cn"`
	Summary  string `json:"summary"`
	Nsfw     bool   `json:"nsfw"`
	Locked   bool   `json:"locked"`
	Date     string `json:"date"`
	Platform string `json:"platform"`
	Images   struct {
		Large  string `json:"large"`
		Common string `json:"common"`
		Medium string `json:"medium"`
		Small  string `json:"small"`
		Grid   string `json:"grid"`
	} `json:"images"`
	Infobox []struct {
		Key   string          `json:"key"`
		Value json.RawMessage `json:"value"`
	} `json:"infobox"`
	Volumes       int `json:"volumes"`
	Eps           int `json:"eps"`
	TotalEpisodes int `json:"total_episodes"`
	Rating        struct {
		Rank  int         `json:"rank"`
		Total int         `json:"total"`
		Count map[int]int `json:"count"`
		Score float32     `json:"score"`
	} `json:"rating"`
	Collection struct {
		Wish    int `json:"wish"`
		Collect int `json:"collect"`
		Doing   int `json:"doing"`
		OnHold  int `json:"on_hold"`
		Dropped int `json:"dropped"`
	} `json:"collection"`
	Tags []struct {
		Name  string `json:"name"`
		Count int    `json:"count"`
	} `json:"tags"`
}

type SubjectType

type SubjectType int

https://bangumi.github.io/api/#model-Legacy_SubjectType subject_type 1 = book 2 = anime 3 = music 4 = game 6 = real

const (
	SubjectTypeBook  SubjectType = 1
	SubjectTypeAnime SubjectType = 2
	SubjectTypeMusic SubjectType = 3
	SubjectTypeGame  SubjectType = 4
	SubjectTypeReal  SubjectType = 6
)

Jump to

Keyboard shortcuts

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