Documentation
¶
Overview ¶
Package tvmaze is the library behind the tvmaze command line: the HTTP client, request shaping, and the typed data models for the TVMaze show search and schedule endpoints.
The TVMaze public API at api.tvmaze.com requires no authentication. The Client sets a real User-Agent, paces requests at 200 ms intervals, and retries transient 429/5xx failures with exponential backoff.
Index ¶
- Constants
- type CastMember
- type Client
- func (c *Client) Cast(ctx context.Context, showID int) ([]CastMember, error)
- func (c *Client) Episodes(ctx context.Context, showID int) ([]Episode, error)
- func (c *Client) GetSchedule(ctx context.Context, country, date string, limit int) ([]ScheduleItem, error)
- func (c *Client) GetShow(ctx context.Context, id int) (*Show, error)
- func (c *Client) Search(ctx context.Context, query string, limit int) ([]Show, error)
- type Config
- type Domain
- type Episode
- type ScheduleItem
- type Show
Constants ¶
const Host = "api.tvmaze.com"
Host is the site this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CastMember ¶ added in v0.1.1
type CastMember struct {
PersonID int `kit:"id" json:"person_id"`
PersonName string `json:"person_name"`
Birthday string `json:"birthday,omitempty"`
Country string `json:"country,omitempty"`
Character string `json:"character"`
}
CastMember is one cast entry from the /shows/{id}/cast endpoint.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to TVMaze over HTTP.
func (*Client) Episodes ¶ added in v0.1.1
Episodes fetches all episodes for a show by its TVMaze ID.
func (*Client) GetSchedule ¶ added in v0.1.2
func (c *Client) GetSchedule(ctx context.Context, country, date string, limit int) ([]ScheduleItem, error)
GetSchedule fetches the TV schedule for the given country and date from /schedule. Country defaults to "US" if empty. Date should be YYYY-MM-DD; if empty, the date param is omitted. It returns at most limit results (pass 0 for all).
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable parameters for the Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
type Domain ¶
type Domain struct{}
Domain is the tvmaze driver.
func (Domain) Classify ¶
Classify turns an input into the canonical (type, id). Numeric inputs are treated as show IDs; otherwise treated as a search query.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.
type Episode ¶ added in v0.1.1
type Episode struct {
ID int `kit:"id" json:"id"`
Name string `json:"name"`
Season int `json:"season"`
Number int `json:"number"`
Airdate string `json:"airdate,omitempty"`
Runtime int `json:"runtime,omitempty"`
Rating float64 `json:"rating"`
Summary string `json:"summary,omitempty"`
}
Episode is one episode record from the /shows/{id}/episodes endpoint.
type ScheduleItem ¶ added in v0.1.2
type ScheduleItem struct {
ID int `kit:"id" json:"id"`
Name string `json:"name"`
Season int `json:"season"`
Number int `json:"number"`
Airdate string `json:"airdate"`
Airtime string `json:"airtime"`
ShowID int `json:"show_id"`
ShowName string `json:"show_name"`
Network string `json:"network"`
}
ScheduleItem is one entry from the /schedule endpoint.
type Show ¶
type Show struct {
ID int `kit:"id" json:"id"`
Name string `json:"name"`
Genres []string `json:"genres"`
Status string `json:"status"`
Rating float64 `json:"rating"`
Network string `json:"network"`
Premiered string `json:"premiered"`
Language string `json:"language"`
Type string `json:"type"`
Summary string `json:"summary"`
}
Show is the public output record for a TV show.