goIMDB

package module
v0.0.0-...-e122b04 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: MIT Imports: 18 Imported by: 0

README

goIMDB

A simple and effective library to query the IMDB database using the unofficial mobile app API.

Description

A frontend to access the unofficial mobile API of IMDB, the famous movie database. The package allows among others to:

  • Search for Titles
  • Search for People
  • Get Title information, including additional details on cast, genre, versions etc.
  • Get People information, including image, jobs, etc.

The implemented calls are only a subset of all available api calls, and in the future, upon need, I will add the remaining calls.

This package was inspired by the python package imdb-pie and the unofficial api calls are copied from that package.

This package handles three parts of the vast IMDB information:

  • Title - represent a movie/tv title and has a code similar to tt123435
  • Name - represent a person (actor, director etc.) and has a code similar to nm88888
  • Search - search results return very basic information on a list of possible matches - and is ordered by their internal, very good, search algo.

Installation

This package can be installed with the go get command:

go get github.com/sraz001/goIMDB

API Reference

API documentation can be found here.

Sample Usage

Below is an example to search for a title, pick the first result (note that the search results are sorted per IMDB sorting algo) and get more details about the results (like plot and cast), then print some details on the first actor.

package main

import (
  "fmt"
  "github.com/sraz001/goIMDB"
  "log"
)

func main() {
  m := goIMDB.InitIMDBPie()
  // search for The Matrix title:
  result, e := m.SearchTitle("The Matrix", 1999)
  if e != nil {
    log.Fatal(e)
  }
  // print the first result
  fmt.Printf("Got %d Search Results, the first one is %s - %s (%d)\n", len(result), result[0].ID, result[0].Title, result[0].Year)
  // Got 8 Search Results, the first one is tt0133093 - The Matrix (1999)

  // get Basic title information
  title, e := m.GetTitle(result[0].ID)
  if e != nil {
    log.Fatal(e)
  }
  fmt.Printf("Plot of %s is [ %s ]\n", title.ID, title.PlotOutline)
  // Plot of tt0133093 is [ When a beautiful stranger leads computer hacker Neo to a forbidding underworld, he discovers the shocking truth--the life he knows is the elaborate deception of an evil cyber-intelligence. ]

  // get the cast of the title
  credits, _ := title.GetTitleCredits() // skip error check for readability
  actor := credits["cast"][0]           // get first actor
  fmt.Printf("Actor %s is %s with Image url: %s", actor.ID, actor.Name, actor.Image.Url)
  // Actor nm0000206 is Keanu Reeves with Image url: https://m.media-amazon.com/images/M/MV5BNGJmMWEzOGQtMWZkNS00MGNiLTk5NGEtYzg1YzAyZTgzZTZmXkEyXkFqcGdeQXVyMTE1MTYxNDAw._V1_.jpg

}
Features & Future Development

Below is a short table of the implemented api at this stage.

Example Description
m := goIMDB.InitIMDBPie() return a client to access the Title,Name and Search functions
t := m.GetTitle(imdbCode) return a Title Struct that holds the title information
nm := m.GetName(imdbCode) return a Name Struct that holds the title information
t.GetTitleEpisodes() return all episodes for a tv series
t.GetTitleGenres() return all genres for a title
t.GetTitleImages() return all images for a title
t.GetTitleCredits() return all credits for a title (large amount of data!)
m.SearchTitle(Searchterm,year) lookup Titles with optional year (set to zero to ignore)
m.SearchName(Searchterm,) lookup Names with optional year (set to zero to ignore)

The entire code is documented and all the available api calls are included (although most are not used).

Todo:
  • add disk caching to the program, as the api calls are rather slow. Caching might be done on a url basis (before encryption)
  • implement additional api calls on Name and Title
  • add tests & examples
  • add better error messages and handling
License

MIT: http://mattn.mit-license.org/2018

all contributions are welcome.

Documentation

Index

Constants

View Source
const (
	BaseUri       = "https://api.imdbws.com"
	SearchBaseUri = `https://v2.sg.media-imdb.com`
	UserAgent     = `IMDb/8.3.1 (iPhone9,4; iOS 11.2.1)`
	AppKey        = `76a6cc20-6073-4290-8a2c-951b4580ae4a`
	SoonExpire    = time.Minute * 5
	ServiceName   = "imdbapi"
	ServiceRegion = "us-east-1"
)

holds various constants used in the program

Variables

View Source
var ERROR_NO_EPISODES_FOR_TITLE = errors.New("title is not a tvSeries so can't get episodes")
View Source
var ERROR_NO_NAME_DATA = errors.New("name has no api data, please call getName prior to calling its methods")
View Source
var ERROR_NO_TITLE_DATA = errors.New("title has no api data, please call get title prior to calling its methods")

error messages

View Source
var RegexImdbExtract = regexp.MustCompile(`((?:tt|nm)\d{5,8})(?:$|\D)`)
View Source
var RegexImdbID = regexp.MustCompile(`^(tt|nm)\d{5,8}$`)
View Source
var RegexImdbName = regexp.MustCompile(`^nm\d{5,8}$`)
View Source
var RegexImdbTitle = regexp.MustCompile(`^tt\d{5,8}$`)

Functions

This section is empty.

Types

type Episode

type Episode struct {
	Imdb_id string
	Title   string
	Season  int
	Episode int
	Year    int
}

type ErrBadDateFormat

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

func (ErrBadDateFormat) Error

func (e ErrBadDateFormat) Error() string

type ErrEpisodeTitle

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

func (ErrEpisodeTitle) Error

func (e ErrEpisodeTitle) Error() string

type ErrInvalidImdbCode

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

ErrInvalidImdbCode - bad imdb code (must be tt....)

func (ErrInvalidImdbCode) Error

func (e ErrInvalidImdbCode) Error() string

type ErrInvalidQuery

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

func (ErrInvalidQuery) Error

func (e ErrInvalidQuery) Error() string

type ErrRedirect

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

func (ErrRedirect) Error

func (e ErrRedirect) Error() string

type ErrTitleNotFound

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

func (ErrTitleNotFound) Error

func (e ErrTitleNotFound) Error() string

type FilmingLocation

type FilmingLocation struct {
	Attributes []string `json:"attributes,omitempty"` // where (i.e. inside, outside)
	Comment    string   `json:"comment,omitempty"`    // additional info
	Location   string   `json:"location,omitempty"`   // location mame
}

FilmingLocation a single Film Location

type IMDBPie

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

IMDBPie - contain information about the parameters of the package. No exposed fields

func InitIMDBPie

func InitIMDBPie() *IMDBPie

InitIMDBPie - create the api structure that allows the searchs.

func (*IMDBPie) ExcludeEpisodes

func (m *IMDBPie) ExcludeEpisodes(s bool)

ExcludeEpisodes - set a flag to exclude the episodes from the result sets (use if you don't need such details)

func (*IMDBPie) GetName

func (m *IMDBPie) GetName(imdbid string) (nmD NameDetailed, err error)

GetName - Get Info on a Name by its ID.

func (*IMDBPie) GetTitle

func (m *IMDBPie) GetTitle(imdbid string) (Title, error)

GetTitle - Get Basic Info on a title (and film locations, soundtracks) using a single api call the call also check for a valid ttxxxxxx id code and that this id is not redirected to a new one

func (*IMDBPie) SearchName

func (m *IMDBPie) SearchName(tName string) ([]SingleSearchNameResult, error)

SerachName - search IMDB for a name result. Only name results will be returned.

func (*IMDBPie) SearchTitle

func (m *IMDBPie) SearchTitle(tName string, tYear int) ([]SingleSearchTitleResult, error)

SearchTitle - search IMDB for the title with an optional year (which is just added as a string to the search). note, non title results will not be returned. (use Name search to search for people)

func (*IMDBPie) SetRegion

func (m *IMDBPie) SetRegion(r string)

SetRegion - set the region, default is 'en_US'

type Image

type Image struct {
	Url    string
	Width  int
	Height int
}

type ImageBasic

type ImageBasic struct {
	Url  string `json:"url,omitempty"`
	Size `json:"size"`
}

ImageBasic Basic image data - contain the URL and the size

type ImageDetail

type ImageDetail struct {
	ImageBasic  `json:"imageBasic"`
	Caption     string    `json:"caption,omitempty"`
	CreatedOn   time.Time `json:"createdOn"`
	Copyright   string    `json:"copyright,omitempty"`
	Attribution string    `json:"attribution,omitempty"`
	Source      string    `json:"source,omitempty"`
	Type        string    `json:"type,omitempty"`
}

ImageDetail Image with more details (as getting it from the image api)

type NameBasic

type NameBasic struct {
	ID         string     `json:"ID,omitempty"`
	Akas       []string   `json:"akas,omitempty"`
	Image      ImageBasic `json:"image"`
	Name       string     `json:"name,omitempty"`
	LegacyName string     `json:"legacyName,omitempty"`
}

NameBasic Basic Name / person information

type NameDetailed

type NameDetailed struct {
	NameBasic
	BirthDate         string  `json:"birthDate"`
	BirthPlace        string  `json:"birthPlace"`
	Gender            string  `json:"gender"`
	HeightCentimeters float64 `json:"heightCentimeters"`
	MiniBios          []struct {
		Author string `json:"author"`
		//ID       string `json:"id"`
		Language string `json:"language"`
		Text     string `json:"text"`
	} `json:"miniBios"`
	Nicknames []string `json:"nicknames"`
	RealName  string   `json:"realName"`
	Spouses   []struct {
		Attributes string `json:"attributes"`
		FromDate   string `json:"fromDate"`
		Name       string `json:"name"`
		ToDate     string `json:"toDate"`
	} `json:"spouses"`
	Jobs []string `json:"jobs"`
	// contains filtered or unexported fields
}

NameDetailed detailed name (I excluded known-for items) seems too much info

type People

type People struct {
	Name       string
	Job        string
	Category   string
	Imdb_id    string
	Characters []string
}

type PersonName

type PersonName struct {
	Name          string
	Imdb_id       string
	Image         Image
	Birth_place   string
	Gender        string
	Bios          string
	Date_of_birth time.Time
	Filmography   []string
}

type PlotSummary

type PlotSummary struct {
	Author      string `json:"author,omitempty"`
	PlotSummary string `json:"PlotSummary,omitempty"`
}

PlotSummary a single Plot Summary

type Rating

type Rating struct {
	Rating      float64 `json:"rating"`
	RatingCount int     `json:"ratingCount"`
}

Rating basic Rating info

type SingleCredit

type SingleCredit struct {
	ID         string `json:"ID,omitempty"`
	Name       string `json:"name,omitempty"`
	Category   string `json:"category,omitempty"`
	Image      `json:"image"`
	Akas       []string `json:"akas,omitempty"`
	Job        string   `json:"job,omitempty"`
	LegacyName string   `json:"legacyName,omitempty"`
}

SingleCredit a single credit for a person in a title

type SingleEpisode

type SingleEpisode struct {
	ID        string `json:"id"`
	Season    int    `json:"season"`
	Episode   int    `json:"episode"`
	Title     string `json:"title"`
	TitleType string `json:"titleType"`
	Year      int    `json:"year"`
}

SingleEpisode single episode info

type SingleSearchNameResult

type SingleSearchNameResult struct {
	Image    ImageBasic `json:"image"`              // imageData
	ID       string     `json:"ID"`                 // imdb ID
	Name     string     `json:"name,omitempty"`     //title
	KnownFor string     `json:"knownFor,omitempty"` //top names
}

SingleSearchNameResult a single result when searching for a name

type SingleSearchTitleResult

type SingleSearchTitleResult struct {
	Image    ImageBasic `json:"image"`           // imageData
	ID       string     `json:"ID"`              // imdb ID
	Title    string     `json:"title,omitempty"` //title
	TypeName string     `json:"typeName,omitempty"`
	TypeCode string     `json:"typeCode,omitempty"`
	TopCast  []string   `json:"topCast,omitempty"` //top names
	Year     int        `json:"year,omitempty"`    // year out
	Years    string     `json:"years,omitempty"`   // year range if multiple years
}

SingleSearchTitleResult a single result when searching for a title

type SingleSeason

type SingleSeason struct {
	Season   int             `json:"season,omitempty"`
	Episodes []SingleEpisode `json:"episodes,omitempty"`
}

SingleSeason single season & its episodes

type SingleVersion

type SingleVersion struct {
	Attributes []string `json:"attributes,omitempty"`
	Language   string   `json:"language,omitempty"`
	Region     string   `json:"region,omitempty"`
	Title      string   `json:"title"`
}

SingleVersion one Version of a title

type Size

type Size struct {
	Height int `json:"height"`
	Width  int `json:"width"`
}

Size Image size, used in all images returned by the API

type SoundTrack

type SoundTrack struct {
	Comment      string      `json:"comment" `
	Name         string      `json:"name" `
	RelatedNames []NameBasic `json:"relatedNames"`
}

SoundTrack a single SoundTrack result

type T

type T struct {
	Meta struct {
		Operation     string  `json:"operation"`
		RequestId     string  `json:"requestId"`
		ServiceTimeMs float64 `json:"serviceTimeMs"`
	} `json:"@meta"`
	Resource struct {
		Type string `json:"@type"`
		Base struct {
			Episode int    `json:"episode"`
			Id      string `json:"id"`
			Image   struct {
				Height int    `json:"height"`
				Id     string `json:"id"`
				Url    string `json:"url"`
				Width  int    `json:"width"`
			} `json:"image"`
			RunningTimeInMinutes int    `json:"runningTimeInMinutes"`
			Season               int    `json:"season"`
			NextEpisode          string `json:"nextEpisode"`
			ParentTitle          struct {
				Id    string `json:"id"`
				Image struct {
					Height int    `json:"height"`
					Id     string `json:"id"`
					Url    string `json:"url"`
					Width  int    `json:"width"`
				} `json:"image"`
				Title     string `json:"title"`
				TitleType string `json:"titleType"`
				Year      int    `json:"year"`
			} `json:"parentTitle"`
			PreviousEpisode string `json:"previousEpisode"`
			SeriesEndYear   int    `json:"seriesEndYear"`
			SeriesStartYear int    `json:"seriesStartYear"`
			Title           string `json:"title"`
			TitleType       string `json:"titleType"`
			Year            int    `json:"year"`
		} `json:"base"`
		FilmingLocations []struct {
			Id       string `json:"id"`
			Location string `json:"location"`
		} `json:"filmingLocations"`
		MetacriticScore struct {
			Type            string `json:"@type"`
			ReviewCount     int    `json:"reviewCount"`
			UserRatingCount int    `json:"userRatingCount"`
		} `json:"metacriticScore"`
		Plot struct {
			Outline struct {
				Id   string `json:"id"`
				Text string `json:"text"`
			} `json:"outline"`
			Summaries []struct {
				Author string `json:"author"`
				Id     string `json:"id"`
				Text   string `json:"text"`
			} `json:"summaries"`
			TotalSummaries int `json:"totalSummaries"`
		} `json:"plot"`
		Ratings struct {
			Episode           int     `json:"episode"`
			Id                string  `json:"id"`
			Season            int     `json:"season"`
			Title             string  `json:"title"`
			TitleType         string  `json:"titleType"`
			Year              int     `json:"year"`
			CanRate           bool    `json:"canRate"`
			Rating            float64 `json:"rating"`
			RatingCount       int     `json:"ratingCount"`
			RatingsHistograms struct {
				FemalesAged3044 struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"Females Aged 30-44"`
				Aged1829 struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"Aged 18-29"`
				NonUSUsers struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"Non-US users"`
				MalesAged45 struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"Males Aged 45+"`
				Males struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"Males"`
				Females struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"Females"`
				MalesAged3044 struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"Males Aged 30-44"`
				Top1000Voters struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"Top 1000 voters"`
				MalesAged1829 struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"Males Aged 18-29"`
				FemalesAged45 struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"Females Aged 45+"`
				IMDbUsers struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"IMDb Users"`
				IMDbStaff struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"IMDb Staff"`
				FemalesAgedUnder18 struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"Females Aged under 18"`
				FemalesAged1829 struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"Females Aged 18-29"`
				Aged45 struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"Aged 45+"`
				USUsers struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"US users"`
				MalesAgedUnder18 struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"Males Aged under 18"`
				AgedUnder18 struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"Aged under 18"`
				Aged3044 struct {
					AggregateRating float64 `json:"aggregateRating"`
					Demographic     string  `json:"demographic"`
					Histogram       struct {
						Field1  int `json:"1"`
						Field2  int `json:"2"`
						Field3  int `json:"3"`
						Field4  int `json:"4"`
						Field5  int `json:"5"`
						Field6  int `json:"6"`
						Field7  int `json:"7"`
						Field8  int `json:"8"`
						Field9  int `json:"9"`
						Field10 int `json:"10"`
					} `json:"histogram"`
					TotalRatings int `json:"totalRatings"`
				} `json:"Aged 30-44"`
			} `json:"ratingsHistograms"`
		} `json:"ratings"`
	} `json:"resource"`
}

type Title

type Title struct {
	TitleBasic    `json:"titleBasic"`
	PlotSummaries []PlotSummary `json:"plotSummaries,omitempty"`
	Rating        Rating        `json:"rating" json:"rating"`
	// contains filtered or unexported fields
}

Title type - This type holds the most basic information from the API. Additional calls to its various methods will return additional data

func (*Title) GetTitleCredits

func (t *Title) GetTitleCredits() (crds map[string][]SingleCredit, err error)

get the credits for a title (all the possible positions and people that were involved in it).

func (*Title) GetTitleEpisodes

func (t *Title) GetTitleEpisodes() ([]SingleSeason, error)

GetTitleEpisodes - get all episodes for a series title

func (*Title) GetTitleGenres

func (t *Title) GetTitleGenres() ([]string, error)

get the Genres of a title

func (*Title) GetTitleImages

func (t *Title) GetTitleImages() (imgs []ImageDetail, err error)

get Images for a title

func (*Title) GetTitleVersions

func (t *Title) GetTitleVersions() (vr VersionInfo, err error)

get Versions (i.e. different countires, languages etc) for a title

type Title1

type Title1 struct {
	Type          string
	Certification string
	Year          int
	Genres        *[]string
	Writers       *[]People
	Creators      *[]People
	//Credits       *[]People  /removed since hard to get data from json need reflection
	Directors    *[]People
	Stars        *[]People
	Image        Image
	Episodes     int
	Rating_count int
	Releases     *TitleReleases
	Season       int
	Episode      int
	Rating       float64
	Plot_outline string
	Release_date time.Time
	Runtime      int
	// contains filtered or unexported fields
}

Response data models - this is the json of the various repsonses I picked up.

Title represnet a movie or tvseries title. The data is extracted as best as possible from the json returned by the api

type TitleBasic

type TitleBasic struct {
	TitleMinimal
	SeriesEndYear    int    `json:"seriesEndYear"`
	SeriesStartYear  int    `json:"seriesStartYear"`
	Episode          int    `json:"episode"`
	Season           int    `json:"season"`
	NextEpisode      string `json:"nextEpisode"`
	PreviousEpisode  string `json:"previousEpisode"`
	NumberOfEpisodes int    `json:"numberOfEpisodes"`
	PlotOutline      string
	ParentTitle      TitleMinimal // holds the id of the parent series

}

TitleBasic Basic title information

type TitleEpisodes

type TitleEpisodes struct {
	Imdb_id  string
	Count    int
	Episodes []Episode
}

type TitleMinimal

type TitleMinimal struct {
	ID        string     `json:"id"`
	Image     ImageBasic `json:"image"`
	Title     string     `json:"title"`
	TitleType string     `json:"titleType"`
	Year      int        `json:"year"`
	RunTime   int        `json:"runningTimeInMinutes"`
}

TitleMinimal minimal info title (this is returned in similarities etc)

type TitleRelease

type TitleRelease struct {
	Date time.Time
	// contains filtered or unexported fields
}

type TitleReleases

type TitleReleases []TitleRelease

type VersionInfo

type VersionInfo struct {
	Releases        []SingleVersion `json:"releases,omitempty"`
	OriginalTitle   string          `json:"originalTitle,omitempty"`
	DefaultTitle    string          `json:"defaultTitle,omitempty"`
	Origins         []string        `json:"origins,omitempty"`
	SpokenLanguages []string        `json:"spokenLanguages,omitempty"`
}

VersionInfo Versions information

Jump to

Keyboard shortcuts

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