imdb

package module
v0.0.0-...-1a43734 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

README

IMDb Go API

Build Status Godoc

go get gitlab.com/B4dM4n/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 AKA

type AKA struct {
	Country, Title string
}

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 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"`
	AKA           []AKA    `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) ParseRls

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

ParseRls parses a Title release info from its page.

func (*Title) String

func (t *Title) String() string

String formats a Title on one line.

Directories

Path Synopsis
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