@@ -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 ( ' / / ' , ' ' , $ 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 {
0 commit comments