tboothman / imdbphp Goto Github PK
View Code? Open in Web Editor NEWPHP library for retrieving film and tv information from IMDb
PHP library for retrieving film and tv information from IMDb
The html character
is added to the 'role' index.
example from 'Homeland':
0 =>
array (size=5)
'imdb' => string '0000132' (length=7)
'name' => string 'Claire Danes' (length=12)
'role' => string ' Carrie Mathison
(48 episodes, 2011-2014)' (length=64)
'thumb' => string 'http://ia.media-imdb.com/images/M/MV5BMTMyMzQ1Mjk3M15BMl5BanBnXkFtZTcwNzk3ODMxNw@@._V1_SY44_CR1,0,32,44_AL_.jpg' (length=111)
'photo' => string 'http://ia.media-imdb.com/images/M/MV5BMTMyMzQ1Mjk3M15BMl5BanBnXkFtZTcwNzk3ODMxNw@@._V1_SY44_CR1,0,32,44_AL_.jpg' (length=111)
1 =>
array (size=5)
'imdb' => string '0001597' (length=7)
'name' => string 'Mandy Patinkin' (length=14)
'role' => string ' Saul Berenson
(48 episodes, 2011-2014)' (length=62)
'thumb' => string 'http://ia.media-imdb.com/images/M/MV5BMjAzNjU1NTE3NF5BMl5BanBnXkFtZTcwNjIyMzcyNw@@._V1_SY44_CR0,0,32,44_AL_.jpg' (length=111)
'photo' => string 'http://ia.media-imdb.com/images/M/MV5BMjAzNjU1NTE3NF5BMl5BanBnXkFtZTcwNjIyMzcyNw@@._V1_SY44_CR0,0,32,44_AL_.jpg' (length=111)
Default config should work so it's very easy to get started.
Disable caching by default? (will people use caching then? will people notice their caching which maybe used to work now doesn't?)
Add a cache folder to the repo? (will probably cause a notice when using composer install/update as the folder has changed ... but they should change their config anyway)
Throws all sorts of errors .. doesn't produce a single useable URL
PHP Notice: Undefined index: fmt_url_map in C:\Users\Tom\code\imdbphp\imdb_trailers.class.php on li
ne 149
Notice: Undefined index: fmt_url_map in C:\Users\Tom\code\imdbphp\imdb_trailers.class.php on line 14
9
PHP Notice: Undefined variable: fmt in C:\Users\Tom\code\imdbphp\imdb_trailers.class.php on line 15
1
Notice: Undefined variable: fmt in C:\Users\Tom\code\imdbphp\imdb_trailers.class.php on line 151
PHP Notice: Undefined index: Location in C:\Users\Tom\code\imdbphp\imdb_trailers.class.php on line
153
Notice: Undefined index: Location in C:\Users\Tom\code\imdbphp\imdb_trailers.class.php on line 153
PHP Notice: Undefined offset: 0 in C:\Users\Tom\code\imdbphp\imdb_trailers.class.php on line 156
I think the runtime has been moved out from the main imdb movie page, so now it returns null.
For example in The Fountain: http://akas.imdb.com/title/tt0414993
Minor issue, but if a movie has no cast available, the script throws up an error.
Warning: Invalid argument supplied for foreach() in imdb.class.php on line 1185
Cache purging occurs every time an imdb class is created. This is hugely wasteful, especially if there are lots of cache files.
Either remember the last purge time across requests and only do a purge every x hours or make sure it only happens once per request.
how to configure this code to save the titles in English
I live in Russia, and these tiles are saved in "Russian language"
thank you
` /**
IMDB server to use.
choices are www.imdb.<lang> with <lang> being one of
de|es|fr|it|pt, uk.imdb.com, and akas.imdb.com - the localized ones are
only qualified to find the movies IMDB ID (with the imdbsearch class;
akas.imdb.com will be the best place to search as it has all AKAs) -- but
parsing (with the imdb class) for most of the details will fail for
most of the details.
@var string imdbsite
*/
public $imdbsite = "akas.imdb.com";
/**
Tell IMDB which is the preferred language.
Any valid language code can be used here (e.g. en-US, de, pt-BR).
If this option is specified, the Accept-Language header with this value
will be included in the requests.
@var string
*/
public $language = "en-US";`
My apologies if this is not the right way to ask
Is it possible to get a method for Alternate Versions?
It seems to be not in the class afaik
Thanks in advance
Ed
... just because of one line of code which uses the "new" []
syntax instead of array()
Hi.
My server runs on Centos 7 with NGiNX & PHP-FPM
I tried installing imdbphp2 via the IzzySoft repo but I noticed that I was also getting httpd & httpd-tools installed.
Is there a way to use the repository to install and keep updated imdbphp without having to install httpd & httpd-tools?
Thanks!
Hi there
I'm trying to get the top250 but i think imdb changed it's site again because it's not working.
On their site it now list as Top Rated Movies #number if the movie is listed on the top250 list
I'm not very good at php preg_match but i think i'm in the right direction with this?
@preg_match('!<a href="[^"]*/chart/top\?(.*?)><strong> Top Rated Movies #(\d+)\s*</strong></a>!si'
But it doesn't work at all
I used this movie as example: http://www.imdb.com/title/tt0066921/
The source code of the imdb title page (This is the full <div>
where the info is listed) looks like this:
<div class="article highlighted" id="titleAwardsRanks">
<strong>
<a href="/chart/top?ref_=tt_awd"
> Top Rated Movies #80
</a> </strong>
|
<span itemprop="awards">
<b>
Nominated for
4
Oscars.
</b>
</span>
<span itemprop="awards">
Another
8 wins & 17 nominations.
</span>
<span class="see-more inline">
<a href="/title/tt0066921/awards?ref_=tt_awd"
class="btn-full" >See more awards</a> » </span>
</div>
I need some help to get this fixed
Thanks
Ed
ps I comment this in a earlier issue but later realized that it was closed..
The poster and images variables are empty.
I think it is irrelevant with the cache although i have cache dir correctly as said in documentation
print_r ($movie);
echo $movie->photo_localurl().$movie->title().$movie->photo().$movie->thumbphoto();exit;
the following variables returned empty
movie->photo_localurl().$movie->title().$movie->photo().$movie->thumbphoto();
Please advise
If the cache folder is not in the directory, the application crashed.
therefore, i've added this little piece of code to the project where i'm using your great work.
/*
* Check if the cache folder exists in the imdbphp api.
* if it doesn't - then create it!
*/
if (!file_exists('../includes/api/imdbphp/cache'))
{
mkdir('../includes/api/imdbphp/cache', 0777, true);
}
Anyway, Thanks for sharing this!
How to recreate the bug:
This is the error: the file imdb.php does not exist.
Best regards to all
Luigi, Verona
TV filtering doesn't work and it throws lots of notices.
v3.2.0 gives "No photo available" on all movies
version 3.2.0 gets no image/photo out of imdb (eg. /demo/movie.php?mid=0212985). is this a problem of configuration? or a bug?
The new iMDB layout is back and this time it seems to have replaced the old one..!!
Some info such as the poster url and the number of voters cannot be parsed correctly.
This awesome library will be more awesome if support for Namespace and PSR-standard
I noticed this in the changelog:
Fix cast()
parsing of role. The role field no longer contains anything other than the name of the role played
So, am I reading it right in that this is intentional, or is this an unfixed bug? I really think that this is pretty important information...
I have several mistyped iMDB ids in my DB. When these ids are used with imdbPHP I get the an error saying
Imdb\Exception\Http: Uncaught exception 'Imdb\Exception\Http' with message 'Failed to retrieve url [http://akas.imdb.com/title/tt1223602/]. Status code [404]' in /'path_to_imdbPHP'/src/Imdb/Pages.php
This error breaks my script. It would be very useful if there was a small check function in imdbPHP which could be used to verify that the iMDB id we are using corresponds to an valid page. Is this something you would consider incorporating?
The photo() 's weren't working on my system. When I increased:
ini_set('pcre.backtrack_limit',1000000);
They would work. The default is 100000 and the imdb page must be longer than that.
The ".*" in the thumbphoto regex was the cause.
Changing to ".*?" (non greedy) worked.
imdb.class.php:
protected function thumbphoto() {
$this->getPage("Title");
# preg_match('!id="img_primary">.*?<img [^>]+src="(.+?)".*<td id="overview-top"!ims',$this->page["Title"],$match);
preg_match('!id="img_primary">.*?<img [^>]+src="(.+?)".*?<td id="overview-top"!ims',$this->page["Title"],$match);
if (empty($match[1])) return FALSE;
$this->main_thumb = $match[1];
if ( preg_match('|(.*\._V1).*|iUs',$match[1],$mo) ) {
$this->main_photo = $mo[1];
return true;
}
else return FALSE;
}
interface CacheInterface
{
public function get($key);
public function set($key, $value);
}
setLogger
, maybe we can have similar method setCache
as well?MdbBase
(i.e. Title
), b) set log for cache c) set cache for Title
.cachetype
and logtype
which are class names for cache and loggerI can work on that points and make a pull request soon
Any thoughts on updating the script to use xpath which is a much more robust way of parsing HTML. I have some of the functionality already written before discovering this library using xpath and it is much easier to maintain. Any interest in this?
Good job fixing #12 - much appreciated.
However, this does introduce one new bug (or it was a recent bug that I missed). Some roles have slashes in them to separate multiple characters that an actor played in that movie, but any role that has a slash in it gets truncated.
Example, see: http://www.imdb.com/title/tt0462538/fullcredits
role = Marge Simpson / Selma / Patty
gets truncated to
role = Marge Simpson /
If i want the recommendations of the movie 1408 http://www.imdb.com/title/tt0450385/
Then the last entry (the movie Mirrors) has no year because of a small change in that titel.
All titles are like this: Name (year) but the last one looks like this: Mirrors I (2008)
Source code looks like this:
<div class="rec_details">
<div class="rec-info">
<div class="rec-jaw-upper">
<div class="rec-title">
<a href="/title/tt0790686/?ref_=tt_rec_tt"><b>Mirrors</b></a>
<span>I</span>
<span class="nobr">(2008)</span>
</div>
Thanks
Ed
While most people will use this data and dump it into a web document ... the library should be agnostic to that. It should turn any html entities into their utf8 equivalent.
Pretty sure that IMDb is entirely utf8 now... need to make sure though.
It seems that the episodes() function does not take into account the seasons labelled as 'unknown'. Here's an example: http://www.imdb.com/title/tt4508902
I can only see the 12 episodes from season 1, but nothing from the Unknown season..
Budget figures have local number formatting in them. Remove it to make the figure an integer.
e.g. imdb_budget.class.php, line 187
$this->goofs
returns
Array ( [0] => Array ( [type] => Audio/visual unsynchronised [content] => ) [1] => Array ( [type] => Factual errors [content] => ) [2] => Array ( [type] => Revealing mistakes [content] => ) )
not the actual goof data
tested for the movie oblivion example http://www.imdb.com/title/tt1483013/trivia?tab=gf&ref_=tt_trv_gf
This method is broken due to site changes i guess
page source looks like this:
<div id="qt0396883" class="quote soda sodavote odd" ><div class="sodatext">
<p>
<a href="/name/nm0000131/?ref_=tt_trv_qu"
><span class="character">Mike Enslin</span></a>:
[<span class="fine">Olin gives Enslin the room key</span>]
Most hotels have switched to magnetics. An actual key. That's a nice touch, it's antiquey. </p>
the preg_match like this
preg_match_all('!class="quote soda (odd|even)"\s*><p>\s*(.*?)\s*</p>\s*<div class=!ims',str_replace("\n"," ",$this->page["Quotes"]),$matches)
I tried to fix it myself but my skills with preg_match are slim.
obviously the class name is wrong but that is as far as i get
Thanks
Ed
Hello,
if no date is specified for the Gross value on the "Box office / business" page
the function get_gross
from title.php generates a "Undefined variable" error
for $dateValue
.
The Makefile
hasn't been updated to reflect the huge structural changes implemented with v3.0.0, hence:
.deb
/.rpm
builds are impossible for the release tag, henceAdditional issues due to the restructuring:
master
branch) imdb.class.php
having a pseudo imdb
class extending the real one), which especially affects those currently unmaintained (as e.g. phpVideoPro), where such a "compatibility layer" had easily fixed it.Sorry, @tboothman โ but that's why I said we should communicate when you're done with restructuring, but before you merge that into master
๐ท
When setting a custom configuration undefined constant errors are thrown.
require './vendor/autoload.php';
$config = new \mdb_config();
Gives Notice: Use of undefined constant NO_ACCESS - assumed 'NO_ACCESS'
Hello how can I limit in a search for the movie or series
the number of directors and actors
, $ Imdb-> director (), $ imdb-> cast ()
pq returns a very large list of names
The function call in getWebPage() in mdb_base.class.php#130 is using $target retrieved from the HTTP header field location. But the location does not contain the full URL, only "/title/tt#######/". Below is the header for http://www.imdb.com/title/tt2768262/
301 Moved Permanently
content-length:0
vary:User-Agent
server:Server
location:/title/tt2386868/
date:Thu, 09 Oct 2014 20:06:09 GMT
x-frame-options:SAMEORIGIN
p3p:policyref="http://i.imdb.com/images/p3p.xml",CP="CAO DSP LAW CUR ADM IVAo IVDo CONo OTPo OUR DELi PUBi OTRi BUS PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA HEA PRE LOC GOV OTC "
it seems that original title is always returning an empty reply. As an example: http://www.imdb.com/title/tt2938956/
Also note this somehow related: setting $config->language = 'en-US'; does not seem to force akas.imdb to return the titles as if the request came from the US..
Before ("Add a Plot"):
Now ("Know what this is about? Be the first one to add a plot."):
It would be awesome if we could have movies_actor() just for actual movies, and tvshows_actor() for instance for tvshows. Alternatively, a title_actor() method that would include a field indicating the type of the title (Movie, TvShow or TvEpisode).
I believe this is feasible, since by just looking at a person page (e.g. http://www.imdb.com/name/nm0933988/) we can deduce the type of each title that person had a role in. My point is that is does not seem to require further page request to each title entry in the Person filmography..
Could it possible for you to consider implementing this?
Add to constructor or add setter method. Probably should wait for namespaces?
Since a few weeks ago, the writing() method does not work anymore with TV series and returns an empty string: for those, IMDb updated the string to parse from "Writing Credits" to "Series Writing Credits".
Thanks!
release 2-2.6.1
function photo never return url for big cover.
and possible in "person" script download entire filmography?
Now there are only "Herself" and not movie
thank you
I couldn't find out an exact reason why, but occasionally, death location would not be returned properly. For an example, see:
http://akas.imdb.com/name/nm0662730/bio
His death location shows up as expected on the page, but the script will not return it.
Fix... imdb_person.class.php, line 417-418, replace with:
if (!preg_match('|/search/name\?death_place=.*?"\s*>(.*?)<|ims',$match[1],$dloc))
preg_match('|/search/name\?death_place=.*?"\s*>(.*?)<|ims',$match[1],$dloc);
line 420, replace:
"place"=>@trim(strip_tags($dloc[3]))
with:
"place"=>@trim(strip_tags($dloc[1]))
Sometimes the runtime is not pulled correctly if it isn't referenced on the main movie page below "technical specs".
Working:
http://www.imdb.com/title/tt0118528/
Not working:
http://www.imdb.com/title/tt1570728/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.