movies

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const BaseURL = "https://www.imdb.com"

BaseURL is the base for IMDb URLS.

Variables

This section is empty.

Functions

func ExtractIMDbID

func ExtractIMDbID(url string) (string, error)

ExtractIMDbID will extract the IMDb ID of a movie from its URL. Assuming that the URL is in the format: https://www.imdb.com/title/tt0848228/

func FormatIMDbID

func FormatIMDbID(id string) (string, error)

FormatIMDbID formats the given ID to its canonical 7-digit value.

func IsIMDbID

func IsIMDbID(str string) bool

IsIMDbID returns true if the string is in a valid IMDbID format.

func IsIMDbURL

func IsIMDbURL(str string) bool

IsIMDbURL returns true if the string is in a valid IMDb URL.

Types

type Movie

type Movie struct {
	MovieID
	Duration  int      `json:"duration"`
	Rating    float32  `json:"rating"`
	PosterURL string   `json:"poster_url"`
	Genres    []string `json:"genres"`
}

Movie holds all the information regarding a movie on IMDb.

func GetMovie

func GetMovie(imdbID string) (*Movie, error)

GetMovie will scrape the IMDb page of the movie with the given id and return its details.

func ParseIMDbPage

func ParseIMDbPage(doc *goquery.Document) Movie

ParseIMDbPage extracts a movie's details from its IMDb page.

func (Movie) FormattedDuration

func (m Movie) FormattedDuration() string

FormattedDuration returns the duration of the movie in human-readable format.

func (Movie) GetGenresString added in v0.15.0

func (m Movie) GetGenresString() string

GetGenresString returns the movie's genres as a comma-separated string.

func (Movie) GetSearchQuery added in v0.14.0

func (m Movie) GetSearchQuery(useAltTitle bool) string

GetSearchQuery returns the string that should be used in the query, when searching for torrents for this movie.

func (Movie) GetSearchTerms added in v0.14.0

func (m Movie) GetSearchTerms(useAltTitle bool) []string

GetSearchTerms returns a list of distinct substrings that should be present in the title of a torrent for this movie.

func (Movie) GetTorrent

func (m Movie) GetTorrent(filters torrents.SearchFilters) (*torrents.Torrent, error)

GetTorrent will search The Pirate Bay and return the best torrent that complies with the given filters.

func (Movie) GetTorrents

func (m Movie) GetTorrents(filters torrents.SearchFilters) ([]torrents.Torrent, error)

GetTorrents will search The Pirate Bay for torrents of this movie that comply with the given filters. It will return one torrent for each video quality.

type MovieID

type MovieID struct {
	IMDbID   string `json:"imdb_id"`
	Title    string `json:"title"`
	Year     uint   `json:"year"`
	AltTitle string `json:"alt_title"`
}

MovieID holds the defining properties of an IMDb movie as they appear in search results.

func ParseSearchPage

func ParseSearchPage(doc *goquery.Document) []MovieID

ParseSearchPage will parse the result page of an IMDb search and return the titles and IDs of all movies in it.

func Search(query string) ([]MovieID, error)

Search performs a text search on IMDb, limited to movies, and returns the results.

func (MovieID) GetURL

func (m MovieID) GetURL() (*url.URL, error)

GetURL formats the IMDbID of the movie object and returns the full URL to the movie's page on IMDb.

type OMDBCredentials added in v0.17.0

type OMDBCredentials struct {
	APIKey string `toml:"api_key"`
}

OMDBCredentials holds the API key for access to the OMDB API.

func EnvOMDBCredentials added in v0.17.0

func EnvOMDBCredentials() OMDBCredentials

EnvOMDBCredentials returns an OMDBCredentials struct variable which contains the credentials found in the TVDB_API_KEY.

func (*OMDBCredentials) GetMovie added in v0.17.0

func (omdb *OMDBCredentials) GetMovie(imdbID string) (*Movie, error)

GetMovie fetches a movie using the OMDB API.

func (*OMDBCredentials) IsEnabled added in v0.17.0

func (omdb *OMDBCredentials) IsEnabled() bool

IsEnabled returns true if an API key has been provided for the OMDb API.

func (*OMDBCredentials) Search added in v0.17.0

func (omdb *OMDBCredentials) Search(query string) ([]MovieID, error)

Search searches for a movie on the OMDb API, given a string as query.

Jump to

Keyboard shortcuts

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