tvmaze

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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

View Source
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 NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) Cast added in v0.1.1

func (c *Client) Cast(ctx context.Context, showID int) ([]CastMember, error)

Cast fetches the cast for a show by its TVMaze ID.

func (*Client) Episodes added in v0.1.1

func (c *Client) Episodes(ctx context.Context, showID int) ([]Episode, error)

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).

func (*Client) GetShow added in v0.1.1

func (c *Client) GetShow(ctx context.Context, id int) (*Show, error)

GetShow fetches a single show by its TVMaze ID.

func (*Client) Search

func (c *Client) Search(ctx context.Context, query string, limit int) ([]Show, error)

Search fetches shows matching query from /search/shows. 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

func (Domain) Classify(input string) (uriType, id string, err error)

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.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate returns the live https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

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.

Jump to

Keyboard shortcuts

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