Skip to content

Commit 46e82dc

Browse files
committed
Merge branch 'master' of https://github.com/andig/videodb
2 parents a91cc74 + d22aa5f commit 46e82dc

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

engines/imdb.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ function imdbData($imdbID)
175175
$data['subtitle'] = trim($s);
176176
}
177177
# orig. title
178-
preg_match('/<span class="title-extra".+?>\s*(.*?)\s*<i>\(original title\)<\/i>\s*</si', $resp['data'], $ary);
178+
preg_match('/<span class="title-extra".+?>\s*"?(.*?)"?\s*<i>\(original title\)<\/i>\s*</si', $resp['data'], $ary);
179179
$data['origtitle'] = trim($ary[1]);
180180

181181
// Cover URL
@@ -269,15 +269,19 @@ function imdbData($imdbID)
269269
if (!$resp['success']) $CLIENTERROR .= $resp['error']."\n";
270270

271271
// Cast
272-
if (preg_match('#<table class="cast">(.*)#si', $resp['data'], $match))
272+
if (preg_match('#<table class="cast_list">(.*)#si', $resp['data'], $match))
273273
{
274-
if (preg_match_all('#<td class="nm"><a href="/name/(.*?)/?".*?>(.*?)</a>.*?<td class="char">(.*?)</td>#si', $match[1], $ary, PREG_PATTERN_ORDER))
274+
// no idea why it does not always work with (.*?)</table
275+
// could be some maximum length of .*?
276+
// anyways, I'm cutting it here
277+
$casthtml = substr($match[1],0,strpos( $match[1],'</table'));
278+
if (preg_match_all('#<td .*? itemprop="actor".*?>\s+<a href="/name/(nm\d+)/?.*?".*?>(.*?)</a>.*?<td class="character">(.*?)</td>#si', $casthtml, $ary, PREG_PATTERN_ORDER))
275279
{
276280
for ($i=0; $i < sizeof($ary[0]); $i++)
277281
{
278282
$actorid = trim(strip_tags($ary[1][$i]));
279283
$actor = trim(strip_tags($ary[2][$i]));
280-
$character = trim(strip_tags($ary[3][$i]));
284+
$character = trim( preg_replace('/\s+/', ' ', strip_tags( preg_replace('/&nbsp;/', ' ', $ary[3][$i]))));
281285
$cast .= "$actor::$character::$imdbIdPrefix$actorid\n";
282286
}
283287
}
@@ -410,7 +414,7 @@ function imdbActor($name, $actorid)
410414
// now we should have loaded the best match
411415

412416
// only search in img_primary <td> - or we get far to many useless images
413-
preg_match('/<td\s+id="img_primary".*?>(.*?)<\/td>/si',$resp['data'], $match);
417+
preg_match('/<td.*?id="img_primary".*?>(.*?)<\/td>/si',$resp['data'], $match);
414418

415419
if (preg_match('/.*?<a.*?href="(.+?)"\s*?>\s*<img\s+.*?src="(.*?)"/si', $match[1], $m))
416420
{

test/test_imdb.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ function testMovie5() {
117117
$this->assertTrue($data['runtime'] >= 99 && $data['runtime'] <= 101);
118118
}
119119

120+
/*
121+
Disabled test.
122+
Runtime of this movie was removed on IMDB
123+
120124
function testMovie6() {
121125
// She's Out of My League
122126
// http://www.imdb.com/title/tt0815236/
@@ -127,6 +131,7 @@ function testMovie6() {
127131
128132
$this->assertEqual($data['runtime'], 104);
129133
}
134+
*/
130135

131136
function testMovie7() {
132137
// Romasanta
@@ -235,7 +240,7 @@ function testSeriesEpisode()
235240
$this->assertTrue( in_array('Jonathan Frakes::Commander William T. Riker::imdb:nm0000408', $cast) );
236241
$this->assertTrue( in_array('Marina Sirtis::Counselor Deanna Troi::imdb:nm0000642', $cast) );
237242
$this->assertTrue( in_array('John de Lancie::Q (as John deLancie)::imdb:nm0209496', $cast) );
238-
$this->assertTrue( in_array('Rob Bowman::Borg (voice)::imdb:nm0101385', $cast) );
243+
$this->assertTrue( in_array('Rob Bowman::Borg (voice) (uncredited)::imdb:nm0101385', $cast) );
239244
$this->assertTrue( sizeof($cast) > 15 );
240245
$this->assertTrue( sizeof($cast) < 30 );
241246

0 commit comments

Comments
 (0)