2017 © Pedro Peláez
 

library imdbphp

Library for retrieving film and tv information from IMDb

image

imdbphp/imdbphp

Library for retrieving film and tv information from IMDb

  • Sunday, July 29, 2018
  • by tboothman
  • Repository
  • 25 Watchers
  • 134 Stars
  • 8,237 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 46 Forks
  • 9 Open issues
  • 44 Versions
  • 14 % Grown

The README.md

imdbphp

PHP library for retrieving film and TV information from IMDb. Retrieve most of the information you can see on IMDb including films, TV series, TV episodes, people. Search for titles on IMDb, including filtering by type (film, tv series, etc). Download film posters and actor images., (*1)

Quick Start

  • Include imdbphp/imdbphp using composer, clone this repo or download the latest release zip.
  • Find a film you want the metadata for e.g. Lost in translation http://www.imdb.com/title/tt0335266/
  • If you're not using composer or an autoloader include bootstrap.php.
  • Get some data
$title = new \Imdb\Title(335266);
$rating = $title->rating();
$plotOutline = $title->plotoutline();

# Find out about the director
$person = new \Imdb\Person($title->director()[0]['imdb']);
$name = $person->name();
$photo = $person->photo();

Installation

This library scrapes imdb.com so changes their site can cause parts of this library to fail. You will probably need to update a few times a year. Keep this in mind when choosing how to install/configure., (*2)

Get the files with one of: * Composer (recommended). Include the imdbphp/imdbphp package. * Git clone. Checkout the latest release tag. * Zip/Tar download, (*3)

Requirements

  • PHP >= 5.6
  • PHP cURL extension

Configuration

imdbphp needs no configuration by default but can cache imdb lookups, store images and change languages if configured., (*4)

Configuration is done by the \Imdb\Config class in src/Imdb/Config.php which has detailed explanations of all the config options available. You can alter the config by creating the object, modifying its properties then passing it to the constructor for imdb., (*5)

$config = new \Imdb\Config();
$config->language = 'de-DE,de,en';
$imdb = new \Imdb\Title(335266, $config);
$imdb->title(); // Lost in Translation - Zwischen den Welten
$imdb->orig_title(); // Lost in Translation

If you're using a git clone you might prefer to configure IMDbPHP by putting an ini file in the conf folder. 900_localconf.sample has some sample settings., (*6)

The cache folder is ./cache by default. Requests from imdb will be cached there for a week (by default) to speed up future requests., (*7)

Advanced Configuration

Replacing the default cache (disk cache)

You can replace the caching mechanism that ImdbPHP uses to any PSR-16 (simple cache) cache by passing one into the constructor of any ImdbPHP class., (*8)

The only piece of imdbphp config that will be used with your cache is the TTL which is set by \Imdb\Config::$cache_expire and defaults to 1 week., (*9)

$cache = new \Cache\Adapter\PHPArray\ArrayCachePool();
// Search results will be cached
$search = new \Imdb\TitleSearch(null /* config */, null /* logger */, $cache);
$firstResultTitle = $search->search('The Matrix')[0];
// $firstResultTitle, an \Imdb\Title will also be using $cache for caching any page requests it does
$cache = new \Cache\Adapter\PHPArray\ArrayCachePool();
$title = new \Imdb\Title(335266, null /* config */, null /* logger */, $cache);

Replacing the default logger (which echos coloured html, and is disabled by default)

The logger will mostly tell you about http requests that failed at error level, each http request at info and some stuff like cache hits at debug., (*10)

$logger = new \Monolog\Logger('name');
$title = new \Imdb\Title(335266, null /* config */, $logger);

Searching for a film

// include "bootstrap.php"; // Load the class in if you're not using an autoloader
$search = new \Imdb\TitleSearch(); // Optional $config parameter
$results = $search->search('The Matrix', array(\Imdb\TitleSearch::MOVIE)); // Optional second parameter restricts types returned

// $results is an array of Title objects
// The objects will have title, year and movietype available
// immediately, but any other data will have to be fetched from IMDb
foreach ($results as $result) { /* @var $result \Imdb\Title */
    echo $result->title() . ' ( ' . $result->year() . ')';
}

Searching for a person

// include "bootstrap.php"; // Load the class in if you're not using an autoloader
$search = new \Imdb\PersonSearch(); // Optional $config parameter
$results = $search->search('Forest Whitaker');

// $results is an array of Person objects
// The objects will have name and imdbid available, everything else must be fetched from IMDb
foreach ($results as $result) { /* @var $result \Imdb\Person */
    echo $result->name();
}

Demo site

The demo site gives you a quick way to make sure everything's working, some sample code and lets you easily see some of the available data., (*11)

From the demo folder in the root of this repository start up php's inbuilt webserver and browse to http://localhost:8000, (*12)

php -S localhost:8000, (*13)

Gotchas / Help

SSL certificate problem: unable to get local issuer certificate

Windows

The cURL library either hasn't come bundled with the root SSL certificates or they're out of date. You'll need to set them up: 1. Download cacert.pem
2. Store it somewhere in your computer.
C:\php\extras\ssl\cacert.pem
3. Open your php.ini and add the following under [curl]
curl.cainfo = "C:\php\extras\ssl\cacert.pem"
4. Restart your webserver., (*14)

Linux

cURL uses the certificate authority file that's part of linux by default, which must be out of date. Look for instructions for your OS to update the CA file or update your distro., (*15)

Configure languages

Sometimes IMDb gets unsure that the specified language are correct, if you only specify your unique language and territory code (de-DE). In the example below, you can find that we have chosen to include de-DE (German, Germany), de (German) and en (English). If IMDb can’t find anything matching German, Germany, you will get German results instead or English if there are no German translation., (*16)

$config = new \Imdb\Config();
$config->language = 'de-DE,de,en';
$imdb = new \Imdb\Title(335266, $config);
$imdb->title(); // Lost in Translation - Zwischen den Welten
$imdb->orig_title(); // Lost in Translation

Please use The Unicode Consortium Langugage-Territory Information database for finding your unique language and territory code., (*17)

Langauge Code Territory Code
German de Germany {O} DE

After you have found your unique language and territory code you will need to combine them. Start with language code (de), add a separator (-) and at last your territory code (DE); de-DE. Now include your language code (de); de-DE,de. And the last step add English (en); de-DE,de,en., (*18)

The Versions

29/07 2018

dev-master

9999999-dev

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0 GPL-2.0-or-later

The Requires

 

The Development Requires

19/04 2018

v6.0.1

6.0.1.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0-or-later

The Requires

 

The Development Requires

26/02 2018

v6.0.0

6.0.0.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0-or-later

The Requires

 

The Development Requires

24/02 2018

v5.2.6

5.2.6.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0-or-later

The Requires

 

The Development Requires

05/02 2018

v5.2.5

5.2.5.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0-or-later

The Requires

 

The Development Requires

07/11 2017

v5.2.4

5.2.4.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

18/09 2017

v5.2.3

5.2.3.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

20/08 2017

v5.2.2

5.2.2.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

07/07 2017

v5.2.1

5.2.1.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

19/04 2017

v5.2.0

5.2.0.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

21/02 2017

v5.1.1

5.1.1.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

20/02 2017

v5.1.0

5.1.0.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

21/01 2017

v5.0.3

5.0.3.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

21/01 2017

dev-soundtrack

dev-soundtrack

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

14/12 2016

v5.0.2

5.0.2.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

10/12 2016

v5.0.1

5.0.1.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

16/10 2016

v5.0.0

5.0.0.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

14/09 2016

v4.1.1

4.1.1.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

21/07 2016

v4.1.0

4.1.0.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

17/07 2016

v4.0.1

4.0.1.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

05/07 2016

v4.0.0

4.0.0.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

17/04 2016

v3.3.0

3.3.0.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.3

 

The Development Requires

01/02 2016

v3.2.0

3.2.0.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.3

 

The Development Requires

27/01 2016

v3.1.5

3.1.5.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.3

 

The Development Requires

13/01 2016

v3.1.4

3.1.4.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.3

 

The Development Requires

12/12 2015

v3.1.2

3.1.2.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.3

 

The Development Requires

28/11 2015

v3.1.1

3.1.1.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.3

 

The Development Requires

21/11 2015

v3.1.0

3.1.0.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.3

 

The Development Requires

04/11 2015

v3.0.2

3.0.2.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.3

 

The Development Requires

17/06 2015

v3.0.1

3.0.1.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.3

 

The Development Requires

08/06 2015

v3.0.0

3.0.0.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.3

 

The Development Requires

19/05 2015

v2.6.1

2.6.1.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.0

 

The Development Requires

03/05 2015

v2.6.0

2.6.0.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.0

 

The Development Requires

25/03 2015

v2.5

2.5.0.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.0

 

The Development Requires

02/01 2015

v2.4.1

2.4.1.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.0

 

The Development Requires

13/12 2014

v2.4.0

2.4.0.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.0

 

The Development Requires

21/11 2014

v2.3.6

2.3.6.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.0

 

The Development Requires

02/11 2014

v2.3.5

2.3.5.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.0

 

The Development Requires

11/10 2014

v2.3.4

2.3.4.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.0

 

The Development Requires

21/08 2014

2.3.3

2.3.3.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.0

 

The Development Requires

05/08 2014

2.3.2

2.3.2.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.0

 

The Development Requires

04/08 2014

2.3.1

2.3.1.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.0

 

The Development Requires

31/07 2014

2.2.4

2.2.4.0

  Sources   Download

31/07 2014

2.3.0

2.3.0.0

Library for retrieving film and tv information from IMDb

  Sources   Download

GPL-2.0

The Requires

  • php >5.0

 

The Development Requires