tvmaze

package
v0.1.1 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 = "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 {
	PersonName    string `json:"person_name"`
	CharacterName string `json:"character_name"`
	Birthday      string `json:"birthday,omitempty"`
}

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

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

Schedule fetches today's TV schedule for the given country from /schedule. Country defaults to "US" if empty. Shows are deduplicated by show ID. It returns at most limit results (pass 0 for all).

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

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    `json:"id"`
	Name    string `json:"name"`
	Season  int    `json:"season"`
	Number  int    `json:"number"`
	Airdate string `json:"airdate,omitempty"`
	Summary string `json:"summary,omitempty"`
	Runtime int    `json:"runtime,omitempty"`
}

Episode is one episode record from the /shows/{id}/episodes endpoint.

type Show

type Show struct {
	Rank      int      `json:"rank"`
	ID        int      `json:"id"`
	Name      string   `json:"name"`
	Type      string   `json:"type"` // "Scripted", "Animation", etc.
	Genres    []string `json:"genres"`
	Status    string   `json:"status"`    // "Running", "Ended", "In Development"
	Premiered string   `json:"premiered"` // YYYY-MM-DD
	Rating    float64  `json:"rating"`
	Network   string   `json:"network"`
	Summary   string   `json:"summary"` // HTML stripped
	URL       string   `json:"url"`     // tvmaze.com URL
}

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