Code Monkey home page Code Monkey logo

php-imdb-api's Introduction

PHP IMDB API

Latest Stable Version CircleCI Coverage Status

PHP IMDB-API that can fetch film data and search results.

Install

Install the latest version using composer.

$ composer require hmerritt/imdb-api

Usage

// Assuming you installed from Composer:
require "vendor/autoload.php";
use hmerritt\Imdb;

$imdb = new Imdb;

// Search imdb
// -> returns array of films and people found
$imdb->search("Apocalypse");

// Get film data
// -> returns array of film data (title, year, rating...)
$imdb->film("tt0816692");

Options

Name Type Default Value Description
curlHeaders array ['Accept-Language: en-US,en;q=0.5'] Custom headers can be passed to cURL when fetching the IMDB page
cache bool true Caches film data to speed-up future requests for the same film
cacheType string file or redis Choose how the caching is done. Either a local file database, or connect to a redis server
cacheRedis array [ 'scheme' => 'tcp', 'host' => '127.0.0.1', 'port' => 6379, 'password' => '', 'database' => 0 ] Redis options
techSpecs bool true Loads a films technical specifications (this will take longer as it makes a separate request)
category string all What category to search for (films tt, people nm or companies co)
$imdb = new Imdb;

//  Options are passed as an array as the second argument
//  These are the default options
$imdb->film("tt0816692", [
    'cache'        => true,
    'curlHeaders'  => ['Accept-Language: en-US,en;q=0.5'],
    'techSpecs'    => true,
]);

$imdb->search("Interstellar", [
    'category'     => 'all',
    'curlHeaders'  => ['Accept-Language: en-US,en;q=0.5'],
]);

Best Match

If you do not know the imdb-id of a film, a search string can be entered. This will search imdb and use the first result as the film to fetch data for.

Note that this will take longer than just entering the ID as it needs to first search imdb before it can get the film data.

// Searches imdb and gets the film data of the first result
// -> will return the film data for 'Apocalypse Now'
$imdb->film("Apocalypse");

Features

Film Data

- Title
- Genres
- Year
- Length
- Plot
- Rating
- Rating Votes (# of votes)
- Poster
- Trailer
    - id
    - link
- Cast
    - actor name
    - actor id
    - character
    - avatar
    - avatar_hq (high quality avatar)
- Technical Specs

Search

Search IMDB to return an array of films, people and companies

- Films
    - id
    - title
    - image
- People
    - id
    - name
    - image
- Companies
    - id
    - name
    - image

Dependencies

All dependencies are managed automatically by composer.

php-imdb-api's People

Contributors

antonmarin avatar chainofchaos avatar hmerritt avatar kas7err avatar kaustuv90 avatar medram avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

php-imdb-api's Issues

Year info is wrong

Hi.
There's an error in api that show the year of the movie in a wrong way:

'year' => string 'Cast & crew'

trailer link

could you please add trailer link in this api ??? Thanks in advance

Malformed UTF-8 characters

This seems promising, but I can't seem to get it to work. I keep getting the following when I use your class (installed via Composer):

Fatal error: Uncaught Filebase\Format\EncodingException: json_encode: 'Malformed UTF-8 characters, possibly incorrectly encoded' in /var/www/html/vendor/tmarois/filebase/src/Format/Json.php:29 Stack trace: #0 /var/www/html/vendor/tmarois/filebase/src/Database.php(237): Filebase\Format\Json::encode() #1 /var/www/html/vendor/tmarois/filebase/src/Document.php(58): Filebase\Database->save() #2 /var/www/html/vendor/hmerritt/imdb-api/src/Cache.php(42): Filebase\Document->save() #3 /var/www/html/vendor/hmerritt/imdb-api/src/Imdb.php(120): hmerritt\Cache->add() #4 /var/www/html/demo.php(20): hmerritt\Imdb->film() #5 {main} Next Filebase\Filesystem\SavingException: Can not encode document. in /var/www/html/vendor/tmarois/filebase/src/Database.php:240 Stack trace: #0 /var/www/html/vendor/tmarois/filebase/src/Document.php(58): Filebase\Database->save() #1 /var/www/html/vendor/hmerritt/imdb-api/src/Cache.php(42): Filebase\Document->save() #2 /var/www/html/vendor/hmerritt/imdb-api/src/Imdb.php(120): hmerritt\Cache->add() #3 /var/www/ in /var/www/html/vendor/tmarois/filebase/src/Database.php on line 240

Any idea what this means, or how to resolve it?

rating_votes is empty

Hi,
rating_votes attribute is empty due to changed IMDb HTML structure for this value.
Please check and fix.
Thank you.

Errors

Hello
I get this

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /home/gmtk/vendor/voku/portable-utf8/src/voku/helper/UTF8.php on line 4653

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /home/gmtk/vendor/voku/portable-utf8/src/voku/helper/UTF8.php on line 4664

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /home/gmtk/vendor/voku/portable-utf8/src/voku/helper/UTF8.php on line 5731

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /home/gmtk/vendor/voku/portable-utf8/src/voku/helper/UTF8.php on line 5742

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /home/gmtk/vendor/voku/portable-utf8/src/voku/helper/UTF8.php on line 13398

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /home/gmtk/vendor/voku/portable-utf8/src/voku/helper/UTF8.php on line 13398

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /home/gmtk/vendor/voku/portable-utf8/src/voku/helper/UTF8.php on line 13409

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /home/gmtk/vendor/voku/portable-utf8/src/voku/helper/UTF8.php on line 13409

Deprecated: Return type of PHPHtmlParser\Dom\Collection::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/gmtk/vendor/paquettg/php-html-parser/src/PHPHtmlParser/Dom/Collection.php on line 140

Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /home/gmtk/vendor/hmerritt/imdb-api/src/HtmlPieces.php on line 351

Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /home/gmtk/vendor/hmerritt/imdb-api/src/HtmlPieces.php on line 351

Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /home/gmtk/vendor/hmerritt/imdb-api/src/HtmlPieces.php on line 351

Deprecated: Creation of dynamic property hmerritt\Cache::$cache is deprecated in /home/gmtk/vendor/hmerritt/imdb-api/src/Cache.php on line 21

No year returned on TV series

When searching for a string or requesting information about a specific ID, no year is returned for TV series - only for movies.

For example:
$imdb->film('tt3904078', [
'cache' => false,
'curlHeaders' => ['Accept-Language: en-US,en-GB,en;q=0.9'],
'techSpecs' => false,
]);

returns an array where "year" is blank - only an empty string. There doesn't seem to be any other way of returning the year(s) either, as that information turns up nowhere in the array. Year is however returned successfully on short films and feature films.

Is this a limitation on the data IMDb returns, or is there something you can do to rectify it so that we can find out the year or years of the series?

When looking at IMDb directly (https://www.imdb.com/title/tt3904078/), the year is fully visible - on the page about the series both the start and end year, and on the search results only the start year. So I would assume that at least the starting year should be possible to find out programmatically.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.