Documentation
¶
Overview ¶
Package imdb is the library behind the imdb command line: the HTTP client, request shaping, and the typed data models for IMDB.
IMDB embeds JSON-LD structured data (<script type="application/ld+json">) on every public page. This package parses that data for chart lists, search results, and individual title pages. No API key required.
Index ¶
Constants ¶
const DefaultUserAgent = "imdb/dev (+https://github.com/tamnd/imdb-cli)"
DefaultUserAgent identifies the client to IMDB.
const Host = "www.imdb.com"
Host is the canonical hostname this package targets.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound is returned when a title or resource is not found.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to IMDB over HTTP.
func (*Client) Chart ¶
Chart fetches a named chart and returns up to limit Title records. name must be one of "top", "toptv", or "popular".
func (*Client) TitleByID ¶
TitleByID fetches a title detail page by IMDB id or full URL. Accepts either "tt0111161" or "https://www.imdb.com/title/tt0111161/".
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Retries int
Timeout time.Duration
}
Config holds constructor parameters.
type Domain ¶ added in v0.1.1
type Domain struct{}
Domain is the IMDB driver. It carries no state; the per-run client is built by the factory Register hands to kit.
func (Domain) Classify ¶ added in v0.1.1
Classify turns any accepted input into the canonical (uriType, id).
func (Domain) Info ¶ added in v0.1.1
func (Domain) Info() kit.DomainInfo
Info returns the domain scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.
type Title ¶
type Title struct {
Rank int `json:"rank"`
ID string `json:"id" kit:"id"`
Name string `json:"name"`
Year string `json:"year"`
Rating string `json:"rating"`
Votes string `json:"votes"`
Genre string `json:"genre"`
Type string `json:"type"`
Description string `json:"description"`
URL string `json:"url" table:"url,url"`
}
Title is the primary record emitted by top, toptv, popular, and search.
type TitleDetail ¶
type TitleDetail struct {
ID string `json:"id" kit:"id"`
Name string `json:"name"`
Type string `json:"type"`
Year string `json:"year"`
Rating string `json:"rating"`
Votes string `json:"votes"`
Genre string `json:"genre"`
Description string `json:"description" kit:"body"`
Directors []string `json:"directors"`
Actors []string `json:"actors"`
Keywords []string `json:"keywords"`
Duration string `json:"duration"`
Language string `json:"language"`
Country string `json:"country"`
URL string `json:"url" table:"url,url"`
}
TitleDetail carries the richer fields available on a single title page.