themoviedb-1.1.4.0: Haskell API bindings for http://themoviedb.org

Safe HaskellNone
LanguageHaskell2010

Network.API.TheMovieDB

Contents

Description

This library provides some data types and functions for fetching movie metadata from http://TheMovieDB.org. To use this library start by requesting an API key from http://docs.themoviedb.apiary.io.

Example:

import Network.API.TheMovieDB

main :: IO ()
main = do
  -- The API key assigned to you (as a Text value).
  let key = "your API key"

  -- The fetch function will get a Movie record based on its ID.
  result <- runTheMovieDB key (fetchMovie 9340)

  -- Do something with the result (or error).
  putStrLn (show result)

This library also includes an example executable in the example directory.

Synopsis

Types

data Movie Source #

Metadata for a movie.

Constructors

Movie 

Fields

data TV Source #

Metadata for a TV series.

Constructors

TV 

Fields

Instances

Eq TV Source # 

Methods

(==) :: TV -> TV -> Bool #

(/=) :: TV -> TV -> Bool #

Ord TV Source # 

Methods

compare :: TV -> TV -> Ordering #

(<) :: TV -> TV -> Bool #

(<=) :: TV -> TV -> Bool #

(>) :: TV -> TV -> Bool #

(>=) :: TV -> TV -> Bool #

max :: TV -> TV -> TV #

min :: TV -> TV -> TV #

Show TV Source # 

Methods

showsPrec :: Int -> TV -> ShowS #

show :: TV -> String #

showList :: [TV] -> ShowS #

FromJSON TV Source # 

data Season Source #

Metadata for a TV Season.

Constructors

Season 

Fields

data Episode Source #

Metadata for a TV Episode.

Constructors

Episode 

Fields

data Genre Source #

Metadata for a genre.

Constructors

Genre 

Fields

data Error Source #

Possible errors returned by the API.

Constructors

InvalidKeyError

Missing or invalid API key. Make sure you are using a valid API key issued by https://www.themoviedb.org/faq/api.

HttpExceptionError HttpException

An exception relating to HTTP was thrown while interacting with the API.

ServiceError String

The HTTP interaction with the API service did not result in a successful response. Information about the failure is encoded in the String.

ResponseParseError String (Maybe ByteString)

Invalid or error response from the API.

Instances

type ItemID = Int Source #

Type to represent IDs used by the API.

type Key = Text Source #

Type for the API key issued by TheMovieDB.

API Functions

data TheMovieDB a Source #

Result type for operations involving TheMovieDB API.

Instances

runTheMovieDB Source #

Arguments

:: Key

The API key to include in all requests.

-> TheMovieDB a

The API calls to make.

-> IO (Either Error a)

Response or error.

Execute requests for TheMovieDB with the given API key and produce either an error or a result.

This version creates a temporary Manager using tlsManagerSettings. If you want to use an existing Manager you should use runTheMovieDBWithManager instead.

runTheMovieDBWithManager Source #

Arguments

:: Manager

The Manager to use.

-> Key

The API key to include in all requests.

-> TheMovieDB a

The API calls to make.

-> IO (Either Error a)

Response or error.

Execute requests for TheMovieDB with the given API key and produce either an error or a result.

This version allows you to provide a Manager value which should have been created to allow TLS requests (e.g., with tlsManagerSettings).

searchMovies :: Text -> TheMovieDB [Movie] Source #

Search TheMovieDB using the given query string.

The movies returned will not have all their fields completely filled out, to get a complete record you'll need to follow this call up with a call to fetchMovie.

fetchMovie Source #

Arguments

:: ItemID

TheMovieDB ID for the movie.

-> TheMovieDB Movie 

Fetch the metadata for the Movie with the given ID.

searchTV :: Text -> TheMovieDB [TV] Source #

Search TheMovieDB for matching TV series.

The TV values returned from this function will be partial records. The only fields that will be available are tvID, tvName, tvPosterPath, tvPopularity, and possibly tvFirstAirDate.

To get full TV records you need to follow this function with a call to fetchTV using the desired tvID value.

fetchTV Source #

Arguments

:: ItemID

TheMovieDB ID for the TV series.

-> TheMovieDB TV 

Fetch metadata for a TV series given its TheMovieDB ID. The metadata for Seasons listed in the TV series will not have complete Episode information.

After calling this function you should call fetchTVSeason to fill in the Episode metadata, or just begin with fetchFullTVSeries.

fetchTVSeason Source #

Arguments

:: ItemID

TheMovieDB ID for the TV series.

-> Int

Season number (not season ID).

-> TheMovieDB Season 

Fetch metadata for a Season, including all Episodes.

fetchFullTVSeries Source #

Arguments

:: ItemID

TheMovieDB ID for the TV series.

-> TheMovieDB TV 

Fetch full metadata for a TV series, including all seasons and episodes.

This function will make multiple HTTP requests to TheMovieDB API.

Utility Types and Functions

data Configuration Source #

TheMovieDB API tries to preserve bandwidth by omitting information (such as full URLs for poster images) from most of the API calls. Therefore in order to construct a complete URL for a movie poster you'll need to use the config function to retrieve API configuration information.

A helper function is provided (moviePosterURLs) that constructs a list of all poster URLs given a Movie and Configuration.

According to the API documentation for TheMovieDB, you should cache the Configuration value and only request it every few days. Therefore, it is an instance of the Binary class so it can be serialized to and from a cache file on disk.

Alternatively, the FromJSON and ToJSON instances can be used to cache the Configuration value.

config :: TheMovieDB Configuration Source #

Fetch the API configuration information such as base URLs for movie posters. The resulting configuration value should be cached and only requested every few days.

moviePosterURLs :: Configuration -> Movie -> [Text] Source #

Return a list of URLs for all possible movie posters.

tvPosterURLs :: Configuration -> TV -> [Text] Source #

Return a list of URLs for all possible TV posters.

seasonPosterURLs :: Configuration -> Season -> [Text] Source #

Return a list of URLs for all possible season posters.

episodeStillURLs :: Configuration -> Episode -> [Text] Source #

Return a list of URLs for all possible episode still images.