imdb

package module
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: Apache-2.0 Imports: 10 Imported by: 21 modules, 18 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

IMDb Go API

Build Status Godoc

go get github.com/StalkR/imdb

Bugs, comments, questions: create a new issue.

Also, IMDb has alternative interfaces.

Documentation

Overview

Package imdb implements IMDb web API.

All operations require an http client such as:

client := http.DefaultClient

To search a title:

results, err := imdb.SearchTitle(client, "matrix")
...

results is a slice of imdb.Title results with basic information (Name, URL, Year).

To get detailed information on a title:

title, err := imdb.NewTitle(client, "tt0133093")
...

Actors, Rating, Description and other fields are available.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidID = errors.New("imdb: invalid ID")
)

Generic errors.

Functions

This section is empty.

Types

type Episode added in v1.0.16

type Episode struct {
	SeasonNumber, EpisodeNumber int
	ImageURL, ID, Name          string
}

Episode represents a single episode from a TV series.

type ErrParse

type ErrParse struct {
	// contains filtered or unexported fields
}

An ErrParse represents a parsing error. It implements error interface.

func NewErrParse

func NewErrParse(details string) ErrParse

NewErrParse creates a parsing error with details.

func (ErrParse) Error

func (e ErrParse) Error() string

Error formats a parsing error.

type Media

type Media struct {
	ID         string `json:",omitempty"`
	TitleID    string `json:",omitempty"`
	URL        string `json:",omitempty"`
	ContentURL string `json:",omitempty"`
}

A Media represents an IMDb media (poster, photos, etc.). It references to a Title by its ID.

func NewMedia

func NewMedia(c *http.Client, id, titleid string) (*Media, error)

NewMedia gets, parses and returns a Media by its ID and Title ID.

func (*Media) Parse

func (m *Media) Parse(page []byte) error

Parse parses a Media from its page.

func (*Media) String

func (m *Media) String() string

String formats a Media.

type Name

type Name struct {
	ID       string `json:",omitempty"`
	URL      string `json:",omitempty"`
	FullName string `json:",omitempty"`
}

A Name represents an IMDb name (actor, director, writer, etc.).

func NewName

func NewName(c *http.Client, id string) (*Name, error)

NewName gets, parses and returns a Name by its ID.

func (*Name) Parse

func (n *Name) Parse(page []byte) error

Parse parses a Name from its page.

func (*Name) String

func (n *Name) String() string

String formats a Name.

type SearchQueryResponse added in v1.0.16

type SearchQueryResponse struct {
	Matches []struct {
		Image struct {
			Height   int    `json:"height"`
			ImageURL string `json:"imageUrl"`
			Width    int    `json:"width"`
		} `json:"i"`
		ID               string `json:"id"`
		Title            string `json:"l"`
		MainActors       string `json:"s"`
		Q                string `json:"q,omitempty"`
		Type             string `json:"qid,omitempty"`
		Rank             int    `json:"rank,omitempty"`
		Year             int    `json:"y,omitempty"`
		YearInProduction string `json:"yr,omitempty"`
	} `json:"d"`
	Query string `json:"q"`
	V     int    `json:"v"`
}

SearchQueryResponse represents the JSON struct returned by a query on searchURL

type Season added in v1.0.16

type Season struct {
	ID           string    `json:",omitempty"`
	SeasonNumber int       `json:",omitempty"`
	Episodes     []Episode `json:",omitempty"`
}

Season represents a season from a TV Series, with a list of episodes.

func NewSeason added in v1.0.16

func NewSeason(c *http.Client, id string, season int) (*Season, error)

NewSeason gets, parses and returns a Season by its ID and season number.

func (*Season) Parse added in v1.0.16

func (s *Season) Parse(c *http.Client, page []byte) error

Parse parses a Season from its page.

type Title

type Title struct {
	ID            string   `json:",omitempty"`
	URL           string   `json:",omitempty"`
	Name          string   `json:",omitempty"`
	Type          string   `json:",omitempty"`
	Year          int      `json:",omitempty"`
	Rating        string   `json:",omitempty"`
	RatingCount   int      `json:",omitempty"`
	Duration      string   `json:",omitempty"`
	Directors     []Name   `json:",omitempty"`
	Writers       []Name   `json:",omitempty"`
	Actors        []Name   `json:",omitempty"`
	Genres        []string `json:",omitempty"`
	Languages     []string `json:",omitempty"`
	Nationalities []string `json:",omitempty"`
	Description   string   `json:",omitempty"`
	Poster        Media    `json:",omitempty"`
	SeasonCount   int      `json:",omitempty"`
	Season        int      `json:",omitempty"`
	Episode       int      `json:",omitempty"`
}

A Title represents an IMDb title (movie, series, etc.).

func NewTitle

func NewTitle(c *http.Client, id string) (*Title, error)

NewTitle gets, parses and returns a Title by its ID.

func SearchTitle

func SearchTitle(c *http.Client, name string) ([]Title, error)

SearchTitle searches for titles matching name and returns partial Titles. A partial Title has only ID, URL, Name and Year set. A full Title can be obtained with NewTitle, at the cost of extra requests.

func (*Title) Parse

func (t *Title) Parse(page []byte) error

Parse parses a Title from its page.

func (*Title) String

func (t *Title) String() string

String formats a Title on one line.

Directories

Path Synopsis
appengine
app module
Binary imdb is a simple command-line tool to demonstrate imdb package.
Binary imdb is a simple command-line tool to demonstrate imdb package.

Jump to

Keyboard shortcuts

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