Documentation
¶
Overview ¶
Package imdb is a simple imdb client.
Index ¶
- Constants
- Variables
- type Client
- func (cl *Client) Find(ctx context.Context, q string, params ...string) ([]Result, error)
- func (cl *Client) FindCompany(ctx context.Context, company string, params ...string) ([]Result, error)
- func (cl *Client) FindEpisode(ctx context.Context, episode string, params ...string) ([]Result, error)
- func (cl *Client) FindGame(ctx context.Context, game string, params ...string) ([]Result, error)
- func (cl *Client) FindKeyword(ctx context.Context, keyword string, params ...string) ([]Result, error)
- func (cl *Client) FindMovie(ctx context.Context, movie string, params ...string) ([]Result, error)
- func (cl *Client) FindName(ctx context.Context, name string, params ...string) ([]Result, error)
- func (cl *Client) FindSeries(ctx context.Context, series string, params ...string) ([]Result, error)
- func (cl *Client) FindTitle(ctx context.Context, title string, params ...string) ([]Result, error)
- func (cl *Client) FindTitleSubtype(ctx context.Context, subtype, title string, params ...string) ([]Result, error)
- func (cl *Client) FindType(ctx context.Context, typ, q string, params ...string) ([]Result, error)
- type Option
- type Result
- func Find(q string, opts ...Option) ([]Result, error)
- func FindCompany(company string, opts ...Option) ([]Result, error)
- func FindEpisode(episode string, opts ...Option) ([]Result, error)
- func FindGame(game string, opts ...Option) ([]Result, error)
- func FindKeyword(keyword string, opts ...Option) ([]Result, error)
- func FindMovie(movie string, opts ...Option) ([]Result, error)
- func FindName(name string, opts ...Option) ([]Result, error)
- func FindSeries(series string, opts ...Option) ([]Result, error)
- func FindTitle(title string, opts ...Option) ([]Result, error)
- func FindTitleSubtype(subtype, title string, opts ...Option) ([]Result, error)
- func FindType(typ, q string, opts ...Option) ([]Result, error)
Examples ¶
Constants ¶
const ( TypeAll = "al" TypeCompany = "co" TypeKeyword = "kw" TypeName = "nm" TypeTitle = "tt" )
Type values.
const ( SubtypeGame = "vg" SubtypeMovie = "ft" SubtypeSeries = "tv" SubtypeEpisode = "ep" )
Subtype values.
Variables ¶
var DefaultTransport = http.DefaultTransport
DefaultTransport is the default http transport.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Transport http.RoundTripper
UserAgent string
AppCacheDir string
// contains filtered or unexported fields
}
Client is a imdb client.
func New ¶
New creates a new imdb client.
Example (FindTitle) ¶
package main
import (
"context"
"fmt"
"github.com/kenshaw/imdb"
)
func main() {
cl := imdb.New()
res, err := cl.FindTitle(context.Background(), "luca")
if err != nil {
panic(err)
}
if len(res) == 0 {
panic("expected at least one result")
}
fmt.Printf("result: %s\n", res[0])
}
Output: result: tt12801262: "Luca" (2021) https://www.imdb.com/title/tt12801262/
func (*Client) FindCompany ¶
func (cl *Client) FindCompany(ctx context.Context, company string, params ...string) ([]Result, error)
FindCompany searches for a company.
func (*Client) FindEpisode ¶
func (cl *Client) FindEpisode(ctx context.Context, episode string, params ...string) ([]Result, error)
FindEpisode searches for a episode.
func (*Client) FindKeyword ¶
func (cl *Client) FindKeyword(ctx context.Context, keyword string, params ...string) ([]Result, error)
FindKeyword searches for a keyword.
func (*Client) FindSeries ¶
func (cl *Client) FindSeries(ctx context.Context, series string, params ...string) ([]Result, error)
FindSeries searches for a series.
type Option ¶
type Option func(*Client)
Option is a imdb client option.
func WithAppCacheDir ¶
WithAppCacheDir is a imdb client option to set the app cache dir.
func WithLogf ¶
WithLogf is a imdb client option to set a log handler for http requests and responses.
func WithTransport ¶
func WithTransport(transport http.RoundTripper) Option
WithTransport is a imdb client option to set the http transport.
type Result ¶
type Result struct {
URL string
ID string
Title string
Type string
Subtype string
S *goquery.Selection
}
Result is the result of a search.
func FindCompany ¶
FindCompany searches for a company.
func FindEpisode ¶
FindEpisode searches for a episode.
func FindKeyword ¶
FindKeyword searches for a keyword.
func FindSeries ¶
FindSeries searches for a series.
func FindTitleSubtype ¶ added in v0.1.9
FindTitleSubtype searches for subtype with title.