NAME
TMDB - Perl wrapper for The MovieDB API
SYNOPSIS
use
TMDB;
# Initialize
my
$tmdb
= TMDB->new(
apikey
=>
'xxxxxxxxxx'
);
# Search
# =======
# Search for a movie
my
@results
=
$tmdb
->search->movie(
'Snatch'
);
foreach
my
$result
(
@results
) {
printf
(
"%s:\t%s (%s)\n"
,
$result
->{id},
$result
->{title},
split
( /-/,
$result
->{release_date}, 1 ) );
}
# Search for an actor
my
@results
=
$tmdb
->search->person(
'Sean Connery'
);
foreach
my
$result
(
@results
) {
printf
(
"%s:\t%s\n"
,
$result
->{id},
$result
->{name} );
}
# Search for a TV show
my
@results
=
$tmdb
->search->tv(
'The Big Bang Theory'
);
foreach
my
$result
(
@results
) {
printf
(
"%s:\t%s (%s)\n"
,
$result
->{id},
$result
->{name},
split
( /-/,
$result
->{first_air_date}, 1 ) );
}
# Movie Data
# ===========
# Movie Object
my
$movie
=
$tmdb
->movie(
id
=>
'107'
);
# Movie details
my
$movie_title
=
$movie
->title;
my
$movie_year
=
$movie
->year;
my
$movie_tagline
=
$movie
->tagline;
my
$movie_overview
=
$movie
->overview;
my
$movie_website
=
$movie
->homepage();
my
@movie_directors
=
$movie
->director;
my
@movie_actors
=
$movie
->actors;
my
@studios
=
$movie
->studios;
printf
(
"%s (%s)\n%s"
,
$movie_title
,
$movie_year
,
'='
x
length
(
$movie_title
) );
printf
(
"Tagline: %s\n"
,
$movie_tagline
);
printf
(
"Overview: %s\n"
,
$movie_overview
);
printf
(
"Directed by: %s\n"
,
join
(
','
,
@movie_directors
) );
(
"\nCast:\n"
);
printf
(
"\t-%s\n"
,
$_
)
for
@movie_actors
;
# Person Data
# ===========
# Person Object
my
$person
=
$tmdb
->person(
id
=>
'1331'
);
# Person Details
my
$person_name
=
$person
->name;
my
$person_bio
=
$person
->bio;
my
@person_movies
=
$person
->starred_in;
printf
(
"%s\n%s\n%s\n"
,
$person_name
,
'='
x
length
(
$person_name
),
$person_bio
);
(
"\nActed in:\n"
);
printf
(
"\t-%s\n"
,
$_
)
for
@person_movies
;
# TV Show Data
# ===========
# TV Show Object
my
$show
=
$tmdb
->tv(
id
=>
'1418'
);
my
$season
=
$show
->season(5);
my
$episode
=
$show
->episode(2, 3);
DESCRIPTION
The MovieDB is a free and open movie database. This module provides a Perl wrapper to The MovieDB API. In order to use this module, you must first get an API key by signing up.
NOTE: TMDB-v0.04 and higher uses TheMoviDB API version /3
. This brings some significant differences both to the API and the interface this module provides, along with updated dependencies for this distribution. If you like to continue to use v2.1 API, you can continue to use TMDB-0.03x.
METHODS
new
# Initialize
my
$tmdb
= TMDB->new(
apikey
=>
'xxxxxxxxxx...'
,
# API Key
lang
=>
'en'
,
# A valid ISO 639-1 (Aplha-2) language code
client
=>
$http_tiny
,
# A valid HTTP::Tiny object
json
=>
$json_object
,
# A Valid JSON object
);
The constructor accepts the following options:
- apikey
-
This is your API key
- lang
-
This must be a valid ISO 639-1 (Alpha-2) language code. Note that with
/3
, the API no longer falls back to an English default. - client
-
You can provide your own HTTP::Tiny object, otherwise a default one is used.
- json
-
You can provide your own JSON implementation that can
decode
JSON. This will fall back to using JSON::MaybeXS. However, JSON::XS is recommended. - apiurl
-
The API endpoint to use. Defaults to https://api.themoviedb.org/3
config
# Get Config
my
$config
=
$tmdb
->config;
Dumper
$config
->config;
# Get all of it
# Get the base URL
my
$base_url
=
$config
->img_base_url();
my
$secure_base_url
=
$config
->img_secure_base_url();
# Sizes (All are array-refs)
my
$poster_sizes
=
$config
->img_poster_sizes();
my
$backdrop_sizes
=
$config
->img_backdrop_sizes();
my
$profile_sizes
=
$config
->img_profile_sizes();
my
$logo_sizes
=
$config
->img_logo_sizes();
# List of _change keys_
my
$change_keys
=
$config
->change_keys();
This provides the configuration for the /3
API. See http://docs.themoviedb.apiary.io/#configuration for more details.
search
# Configuration
my
$search
=
$tmdb
->search(
include_adult
=>
'false'
,
# Include adult results. 'true' or 'false'
max_pages
=> 5,
# Max number of paged results
);
# Search
my
$search
=
$tmdb
->search();
my
@results
=
$search
->movie(
'Snatch (2000)'
);
# Search for movies
my
@results
=
$search
->tv(
'The Big Bang Theory (2007)'
)
# Search for TV shows
my
@results
=
$search
->person(
'Brad Pitt'
);
# Search people by Name
my
@results
=
$search
->company(
'Sony Pictures'
);
# Search for companies
my
@results
=
$search
->keyword(
'thriller'
);
# Search for keywords
my
@results
=
$search
->collection(
'Star Wars'
);
# Search for collections
my
@results
=
$search
->list(
'top 250'
);
# Search lists
# Find using external sources
my
@results
=
$search
->find(
id
=>
'tt12345'
,
source
=>
'imdb_id'
);
# Discover
my
@results
=
$search
->discover(
{
sort_by
=>
'popularity.asc'
,
'vote_average.gte'
=>
'7.2'
,
'vote_count.gte'
=>
'10'
,
}
);
# Get Lists
my
$lists
=
$tmdb
->search();
my
$latest
=
$lists
->latest();
# Latest movie added to TheMovieDB
my
$latest_person
=
$lists
->latest_person;
# Latest person added to TheMovieDB
my
@now_playing
=
$lists
->now_playing();
# What's currently in theaters
my
@upcoming
=
$lists
->upcoming();
# Coming soon ...
my
@popular
=
$lists
->popular();
# What's currently popular
my
@popular_people
=
$lists
->popular_people();
# Who's currently popular
my
@top_rated
=
$lists
->top_rated();
# Get the top rated list
movie
# Get the movie object
my
$movie
=
$tmdb
->movie(
id
=>
'49521'
);
# Movie Data (as returned by the API)
Dumper
$movie
->info;
Dumper
$movie
->alternative_titles;
Dumper
$movie
->cast;
Dumper
$movie
->crew;
Dumper
$movie
->images;
Dumper
$movie
->keywords;
Dumper
$movie
->releases;
Dumper
$movie
->trailers;
Dumper
$movie
->translations;
Dumper
$movie
->lists;
Dumper
$movie
->reviews;
Dumper
$movie
->changes;
# Filtered Movie data
$movie
->title;
$movie
->year;
$movie
->tagline;
$movie
->overview;
$movie
->description;
# Same as `overview`
$movie
->genres;
$movie
->imdb_id;
$movie
->collection;
# Collection ID
$movie
->actors;
# Names of Actors
$movie
->director;
# Names of Directors
$movie
->producer;
# Names of Producers
$movie
->executive_producer;
# Names of Executive Producers
$movie
->writer;
# Names of Writers/Screenplay
# Images
$movie
->poster;
# Main Poster
$movie
->posters;
# list of posters
$movie
->backdrop;
# Main backdrop
$movie
->backdrops;
# List of backdrops
$movie
->trailers_youtube;
# List of Youtube trailers URLs
# Latest Movie on TMDB
Dumper
$movie
->latest;
# Get TMDB's version to check if anything changed
$movie
->version;
person
# Get the person object
my
$person
=
$tmdb
->person(
id
=>
'1331'
);
# Movie Data (as returned by the API)
Dumper
$person
->info;
Dumper
$person
->credits;
Dumper
$person
->images;
# Filtered Person data
$person
->name;
$person
->aka;
# Also Known As (list of names)
$person
->bio;
$person
->image;
# Main profile image
$person
->starred_in;
# List of titles (as cast)
$person
->directed;
# list of titles Directed
$person
->produced;
# list of titles produced
$person
->executive_produced;
# List of titles as an Executive Producer
$person
->wrote;
# List of titles as a writer/screenplay
# Get TMDB's version to check if anything changed
$person
->version;
collection
# Get the collection object
my
$collection
=
$tmdb
->collection(
id
=>
'2344'
);
# Collection data (as returned by the API)
use
Data::Dumper;
Dumper
$collection
->info;
# Filtered Collection Data
$collection
->titles;
# List of titles in the collection
$collection
->ids;
# List of movie IDs in the collection
# Get TMDB's version to check if anything changed
$collection
->version;
company
# Get the company object
my
$company
=
$tmdb
->company(
id
=>
'1'
);
# Company info (as returned by the API)
Dumper
$company
->info;
Dumper
$company
->movies;
# Filtered company data
$company
->name;
# Name of the Company
$company
->logo;
# Logo
# Get TMDB's version to check if anything changed
$company
->version;
genre
# Get a list
my
@genres
=
$tmdb
->genre->list();
# Get a list of movies
my
@movies
=
$tmdb
->genre(
id
=>
'35'
)->movies;
tv
# Get the TV show object
my
$show
=
$tmdb
->tv(
id
=>
'1418'
);
# TV Show Data (as returned by the API)
Dumper
$show
->info;
Dumper
$show
->alternative_titles;
Dumper
$show
->cast;
Dumper
$show
->crew;
Dumper
$show
->images;
Dumper
$show
->keywords;
Dumper
$show
->videos;
Dumper
$show
->translations;
Dumper
$show
->content_ratings;
Dumper
$show
->changes;
# Get Season and Episode info
Dumper
$show
->season(5);
Dumper
$show
->episode(1, 1);
# Get TMDB's version to check if anything changed
$show
->version;
session
# Return the current TMDB API session.
my
$session
=
$tmdb
->session;
DEPENDENCIES
BUGS AND LIMITATIONS
This module not (yet!) support POST-ing data to TheMovieDB
All data returned is UTF-8 encoded
Please report any bugs or feature requests at https://github.com/mithun/perl-tmdb/issues
SEE ALSO
AUTHOR
Mithun Ayachit mithun@cpan.org
LICENSE AND COPYRIGHT
Copyright (c) 2015, Mithun Ayachit. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.