/** Read the config
  * @constructor pilotsearch
  */
 function __construct()
 {
     parent::__construct('');
     if (empty($this->pilot_apikey)) {
         trigger_error('Please provide a valid api key or contact api@moviepilot.de.', E_USER_WARNING);
     }
     $this->search_episodes(FALSE);
 }
 /** Initialize class
  * @constructor movieposterdb
  * @param string id IMDBID to use for data retrieval
  * @param optional integer limit maximum amount of images to retrieve
  *        (default: 20). Can be changed via set_limit()
  * @param optional boolean recurse whether to recurse if multiple versions
  *        are available (default: TRUE). Can be changed via set_recurse()
  */
 function __construct($id, $limit = 20, $recurse = TRUE)
 {
     parent::__construct($id);
     $this->setid($id);
     $this->reset_vars();
     $this->set_limit($limit);
     $this->set_recurse($recurse);
     $this->urlparams = array('poster' => 'cid=1', 'cover' => 'cid=2', 'textless' => 'cid=3', 'logo' => 'cid=4', 'other' => 'cid=5', 'custom' => 'cid=6', 'unset' => 'cid=9');
     $this->reset_lang();
 }
 /** Initialize class
  * @constructor movieposterdb
  * @param string id IMDBID to use for data retrieval
  * @param optional integer limit maximum amount of images to retrieve
  *        (default: 20). Can be changed via set_limit()
  * @param optional boolean recurse whether to recurse if multiple versions
  *        are available (default: TRUE). Can be changed via set_recurse()
  */
 function __construct($id, $limit = 20, $recurse = TRUE)
 {
     parent::__construct($id);
     $this->setid($id);
     $this->reset_lang();
     if ($this->force_agent) {
         $this->user_agent = $this->force_agent;
     } elseif (in_array('HTTP_USER_AGENT', array_keys($_SERVER))) {
         $this->user_agent = $_SERVER['HTTP_USER_AGENT'];
     } else {
         $this->user_agent = $this->default_agent;
     }
     $this->image_exts = array('jpg', 'png', 'gif', 'bmp');
 }
 /** Initialize class
  * @constructor movieposterdb
  * @param string id IMDBID to use for data retrieval
  * @param optional integer limit maximum amount of images to retrieve
  *        (default: 20). Can be changed via set_limit()
  * @param optional boolean recurse whether to recurse if multiple versions
  *        are available (default: TRUE). Can be changed via set_recurse()
  */
 function __construct($id, $limit = 20, $recurse = TRUE, mdb_config $config = null)
 {
     parent::__construct($config);
     $this->setid($id);
     $this->reset_lang();
     $this->revision = preg_replace('|^.*?(\\d+).*$|', '$1', '$Revision$');
     if ($this->force_agent) {
         $this->user_agent = $this->force_agent;
     } elseif (in_array('HTTP_USER_AGENT', array_keys($_SERVER))) {
         $this->user_agent = $_SERVER['HTTP_USER_AGENT'];
     } else {
         $this->user_agent = $this->default_agent;
     }
     $this->image_exts = array('jpg', 'png', 'gif', 'bmp');
 }
 /** Initialize class
  * @constructor movieposterdb
  * @param string id IMDBID to use for data retrieval
  * @param optional integer limit maximum amount of images to retrieve
  *        (default: 20). Can be changed via set_limit()
  * @param optional boolean recurse whether to recurse if multiple versions
  *        are available (default: TRUE). Can be changed via set_recurse()
  */
 function __construct($id, $limit = 20, $recurse = TRUE)
 {
     parent::__construct($id);
     $this->setid($id);
     $this->reset_vars();
     $this->set_limit($limit);
     $this->set_recurse($recurse);
     $this->urlparams = array('poster' => 'cid=1', 'cover' => 'cid=2', 'textless' => 'cid=3', 'logo' => 'cid=4', 'other' => 'cid=5', 'custom' => 'cid=6', 'unset' => 'cid=9');
     $this->reset_lang();
     if ($this->force_agent) {
         $this->user_agent = $this->force_agent;
     } elseif (in_array('HTTP_USER_AGENT', array_keys($_SERVER))) {
         $this->user_agent = $_SERVER['HTTP_USER_AGENT'];
     } else {
         $this->user_agent = $this->default_agent;
     }
     $this->image_exts = array('jpg', 'png', 'gif', 'bmp');
 }
 protected function makeRequest($url)
 {
     mdb_base::debug_scalar("imdbsearch: Using URL {$url}");
     $be = new MDB_Request($url, $this);
     $be->sendrequest();
     $body = $be->getResponseBody();
     // @TODO The intricacies of http should be delt with by the http library
     // @TODO does this ever happen?
     if ($header = $be->getResponseHeader("Location")) {
         mdb_base::debug_scalar("imdbsearch: No immediate response body - we are redirected.<br>New URL: {$header}");
         if (substr($header, 0, 1) == '/') {
             return $this->makeRequest($this->imdbsite . $header);
         } else {
             return $this->makeRequest($header);
         }
     }
     return $body;
 }
 /** Initialize class
  * @constructor imdb_person
  * @param string id IMDBID to use for data retrieval
  */
 function __construct($id)
 {
     parent::__construct($id);
     $this->revision = preg_replace('|^.*?(\\d+).*$|', '$1', '$Revision: 270 $');
     $this->setid($id);
 }
 /** Setup search results
  * @method results
  * @param optional string URL Replace search URL by your own (Default: empty string)
  * @param optional boolean series whether to include TV series in search results (default: TRUE)
  * @param optional boolean s_episodes whether to include TV episodes in search results (default: TRUE)
  * @param optional boolean s_games whether to include games in search results (default: TRUE)
  * @param optional boolean s_video whether to include videos in search results (default: TRUE). These are often Making Ofs and the like
  * @param optional boolean s_short whether to include shorts in search results (default: TRUE)
  * @param optional boolean s_special whether to include specials in search results (default: TRUE)
  * @return array results array of objects (instances of the imdb class)
  */
 public function results($url = "", $series = TRUE, $s_episodes = TRUE, $s_games = TRUE, $s_video = TRUE, $s_short = TRUE, $s_special = TRUE)
 {
     if ($this->page == "") {
         if ($this->usecache && empty($url)) {
             // Try to read from cache
             $this->cache_read(urlencode(strtolower($this->name)) . '.search', $this->page);
         }
         // end cache read
         if ($this->page == "") {
             // not found in cache - go and get it!
             if (empty($url)) {
                 $url = $this->mkurl();
             }
             mdb_base::debug_scalar("imdbsearch::results() called. Using URL {$url}");
             $be = new MDB_Request($url);
             $be->sendrequest();
             $fp = $be->getResponseBody();
             if (!$fp) {
                 if ($header = $be->getResponseHeader("Location")) {
                     mdb_base::debug_scalar("No immediate response body - we are redirected.<br>New URL: {$header}");
                     if (preg_match('!\\.imdb\\.(com|de|it)/find\\?!', $header)) {
                         return $this->results($header);
                         break 4;
                     }
                     $url = explode("/", $header);
                     $id = substr($url[count($url) - 1], 2);
                     $this->resu[0] = new imdb($id);
                     return $this->resu;
                 } else {
                     mdb_base::debug_scalar('No response body, no redirect - going to Nirwana');
                     return NULL;
                 }
             }
             $this->page = $fp;
         }
         if ($this->storecache && $this->page != "cannot open page" && $this->page != "") {
             //store cache
             $this->cache_write(urlencode(strtolower($this->name)) . '.search', $this->page);
         }
     }
     // end (page="")
     // now we have the search content - go and parse it!
     if ($this->maxresults > 0) {
         $maxresults = $this->maxresults;
     } else {
         $maxresults = 999999;
     }
     if (preg_match_all('!class="result_text"\\s*>\\s*<a href="/title/tt(?<imdbid>\\d{7})/[^>]*>(?<title>.*?)</a>\\s*(\\([^\\d{4}]\\)\\s*)?(\\((?<year>\\d{4})(.*?|)\\)|)(?<addons>[^<]*)!ims', $this->page, $matches)) {
         $this->last_results = count($matches[0]);
         $mids_checked = array();
         for ($i = 0; $i < $this->last_results; ++$i) {
             if (count($this->resu) == $maxresults) {
                 break;
             }
             // limit result count
             if (substr(trim($matches[2][$i]), 0, 4) == "<img") {
                 continue;
             }
             // cover mini
             if (empty($matches[2][$i]) || substr(trim($matches[2][$i]), 0, 4) == '<img' || in_array($matches[1][$i], $mids_checked)) {
                 continue;
             }
             // empty titles just come from the images
             if (!$series && (preg_match('!&#x22;.+&#x22;!', $matches[2][$i]) || strpos(strtoupper($matches['addons'][$i]), 'TV SERIES') !== FALSE)) {
                 continue;
             }
             // skip series if commanded so
             if (!$s_episodes && strpos(strtoupper($matches['addons'][$i]), 'TV EPISODE') !== FALSE) {
                 continue;
             }
             // skip episodes if commanded so
             if (!$s_games && strpos(strtoupper($matches['addons'][$i]), 'VIDEO GAME') !== FALSE) {
                 continue;
             }
             // skip games if commanded so
             if (!$s_video && strpos(strtoupper($matches['addons'][$i]), '(VIDEO)') !== FALSE) {
                 continue;
             }
             // skip games if commanded so
             if (!$s_short && strpos(strtoupper($matches['addons'][$i]), '(SHORT)') !== FALSE) {
                 continue;
             }
             // skip shorts if commanded so
             if (!$s_special && strpos(strtoupper($matches['addons'][$i]), 'SPECIAL)') !== FALSE) {
                 continue;
             }
             // skip specials if commanded so
             $mids_checked[] = $matches['imdbid'][$i];
             $tmpres = new imdb($matches['imdbid'][$i]);
             // make a new imdb object by id
             $tmpres->main_title = $matches['title'][$i];
             $tmpres->main_year = $matches['year'][$i];
             $tmpres->addon_info = $matches['addons'][$i];
             $this->resu[] = $tmpres;
         }
     }
     return $this->resu;
 }
 /** Initialize class
  * @constructor person_base
  * @param string id IMDBID to use for data retrieval
  */
 function __construct($id)
 {
     parent::__construct($id);
 }
 /** Setup search results
  * @method results
  * @param optional string URL Replace search URL by your own (Default: empty string)
  * @param optional boolean series whether to include TV series in search results (default: TRUE)
  * @return array results array of objects (instances of the imdb class)
  */
 public function results($url = "", $series = TRUE)
 {
     if ($this->page == "") {
         if ($this->usecache && empty($url)) {
             // Try to read from cache
             $this->cache_read(urlencode(strtolower($this->name)) . '.search', $this->page);
         }
         // end cache read
         if ($this->page == "") {
             // not found in cache - go and get it!
             if (empty($url)) {
                 $url = $this->mkurl();
             }
             mdb_base::debug_scalar("imdbsearch::results() called. Using URL {$url}");
             $be = new MDB_Request($url);
             $be->sendrequest();
             $fp = $be->getResponseBody();
             if (!$fp) {
                 if ($header = $be->getResponseHeader("Location")) {
                     mdb_base::debug_scalar("No immediate response body - we are redirected.<br>New URL: {$header}");
                     if (preg_match('!\\.imdb\\.(com|de|it)/find\\?!', $header)) {
                         return $this->results($header);
                         break 4;
                     }
                     $url = explode("/", $header);
                     $id = substr($url[count($url) - 2], 2);
                     $this->resu[0] = new imdb($id);
                     return $this->resu;
                 } else {
                     mdb_base::debug_scalar('No response body, no redirect - going to Nirwana');
                     return NULL;
                 }
             }
             $this->page = $fp;
         }
         if ($this->storecache && $this->page != "cannot open page" && $this->page != "") {
             //store cache
             $this->cache_write(urlencode(strtolower($this->name)) . '.search', $this->page);
         }
     }
     // end (page="")
     // now we have the search content - go and parse it!
     if ($this->maxresults > 0) {
         $maxresults = $this->maxresults;
     } else {
         $maxresults = 999999;
     }
     if (preg_match_all('!href="/title/tt(\\d{7})/"[^>]*>(.*?)</a>\\s*(\\((\\d{4})(/.+?|)\\)|)[^<]*(<small>(.*?)</small>|)!ims', $this->page, $matches)) {
         $this->last_results = count($matches[0]);
         $mids_checked = array();
         for ($i = 0; $i < $this->last_results; ++$i) {
             if (count($this->resu) == $maxresults) {
                 break;
             }
             // limit result count
             if (empty($matches[2][$i]) || substr(trim($matches[2][$i]), 0, 4) == '<img' || in_array($matches[1][$i], $mids_checked)) {
                 continue;
             }
             // empty titles just come from the images
             if (!$series && (preg_match('!&#x22;.+&#x22;!', $matches[2][$i]) || strpos(strtoupper($matches[7][$i]), 'TV SERIES') !== FALSE)) {
                 continue;
             }
             // skip series if commanded so
             if (!preg_match('!onclick!i', $matches[0][$i])) {
                 continue;
             }
             // just mentioned something in the AKAs listing
             $mids_checked[] = $matches[1][$i];
             $tmpres = new imdb($matches[1][$i]);
             // make a new imdb object by id
             $tmpres->main_title = $matches[2][$i];
             $tmpres->main_year = $matches[4][$i];
             $this->resu[] = $tmpres;
         }
     }
     return $this->resu;
 }
 /** Initialize class
  * @constructor movie_base
  * @param string id IMDBID to use for data retrieval
  */
 function __construct($id)
 {
     parent::__construct($id);
     $this->reset_vars();
 }
 /**
  * Initialize class
  * @param string $id IMDBID to use for data retrieval
  * @param mdb_config $config *optional* override default config
  */
 function __construct($id, mdb_config $config = null)
 {
     parent::__construct($config);
     $this->reset_vars();
 }
 /** Setup search results
  * @method results
  * @param optional string URL Replace search URL by your own
  * @return array results array of objects (instances of the imdb class)
  */
 public function results($url = "")
 {
     if ($this->page == "") {
         if ($this->usecache && empty($url)) {
             // Try to read from cache
             $this->cache_read(urlencode(strtolower($this->name)) . '.search', $this->page);
         }
         // end cache read
         if ($this->page == "") {
             // not found in cache - go and get it!
             if (empty($url)) {
                 $url = $this->mkurl();
             }
             mdb_base::debug_scalar("imdbsearch::results() called. Using URL {$url}");
             $be = new MDB_Request($url);
             $be->sendrequest();
             $fp = $be->getResponseBody();
             if (!$fp) {
                 if ($header = $be->getResponseHeader("Location")) {
                     mdb_base::debug_scalar("No immediate response body - we are redirected.<br>New URL: {$header}");
                     if (preg_match('!\\.imdb\\.(com|de|it)/find\\?!', $header)) {
                         return $this->results($header);
                         break 4;
                     }
                     $url = explode("/", $header);
                     $id = substr($url[count($url) - 2], 2);
                     $this->resu[0] = new imdb($id);
                     return $this->resu;
                 } else {
                     mdb_base::debug_scalar('No response body, no redirect - going to Nirwana');
                     return NULL;
                 }
             }
             $this->page = $fp;
         }
         if ($this->storecache && $this->page != "cannot open page" && $this->page != "") {
             //store cache
             $this->cache_write(urlencode(strtolower($this->name)) . '.search', $this->page);
         }
     }
     // end (page="")
     // now we have the search content - go and parse it!
     $searchstring = array('<A HREF="/title/tt', '<A href="/title/tt', '<a href="/Title?', '<a href="/title/tt');
     $i = 0;
     if ($this->maxresults > 0) {
         $maxresults = $this->maxresults;
     } else {
         $maxresults = 999999;
     }
     foreach ($searchstring as $srch) {
         $res_e = 0;
         $res_s = 0;
         $mids_checked = array();
         $len = strlen($srch);
         while (($res_s = strpos($this->page, $srch, $res_e)) > 10) {
             if ($i == $maxresults) {
                 break 2;
             }
             // limit result count
             $res_e = strpos($this->page, "(", $res_s);
             $imdb_id = substr($this->page, $res_s + $len, 7);
             $ts = strpos($this->page, ">", $res_s) + 1;
             // >movie title</a>
             $te = strpos($this->page, "<", $ts);
             $title = substr($this->page, $ts, $te - $ts);
             if ($title == "" || in_array($imdb_id, $mids_checked)) {
                 continue;
             }
             // empty titles just come from the images
             $mids_checked[] = $imdb_id;
             $tmpres = new imdb($imdb_id);
             // make a new imdb object by id
             $tmpres->main_title = $title;
             $ts = strpos($this->page, "(", $te) + 1;
             $te = strpos($this->page, ")", $ts);
             $tmpres->main_year = substr($this->page, $ts, $te - $ts);
             $i++;
             $this->resu[] = $tmpres;
         }
     }
     return $this->resu;
 }
 /**
  * Create the IMDB URL for the name search
  * @method protected mkurl
  * @return string url
  */
 protected function mkurl()
 {
     if ($this->url !== NULL) {
         $url = $this->url;
     } else {
         $query = "&s=nm";
         if (!isset($this->maxresults)) {
             $this->maxresults = 20;
         }
         if ($this->maxresults > 0) {
             $query .= "&mx=20";
         }
         $url = "http://" . $this->imdbsite . "/find?q=" . urlencode($this->name) . $query;
     }
     mdb_base::debug_scalar("Using search URL '{$url}'");
     return $url;
 }
 /** Setup search results
  * @method results
  * @param optional string URL Replace search URL by your own
  * @param optional boolean series not used, just for inheritance compatibility issues with PHP5.3+
  * @return array results array of objects (instances of the imdb_person class)
  */
 public function results($url = "", $series = TRUE)
 {
     if ($this->page == "") {
         if ($this->usecache && empty($url)) {
             // Try to read from cache
             $this->cache_read(urlencode(strtolower($this->name)) . '.search', $this->page);
         }
         // end cache read
         if (empty($url)) {
             $url = $this->mkurl();
         }
         $be = new MDB_Request($url);
         $be->sendrequest();
         $fp = $be->getResponseBody();
         if (!$fp) {
             if ($header = $be->getResponseHeader("Location")) {
                 mdb_base::debug_scalar("No immediate response body - we are redirected.<br>New URL: {$header}");
                 if (strpos($header, $this->imdbsite . "/find?")) {
                     return $this->results($header);
                     break 4;
                 }
                 $url = explode("/", $header);
                 $id = substr($url[count($url) - 2], 2);
                 $this->resu[0] = new imdb_person($id);
                 return $this->resu;
             } else {
                 mdb_base::debug_scalar("No result, no redirection -- something's wrong here...");
                 return NULL;
             }
         }
         $this->page = $fp;
         if ($this->storecache && $this->page != "cannot open page" && $this->page != "") {
             //store cache
             $this->cache_write(urlencode(strtolower($this->name)) . '.search', $this->page);
         }
     }
     // end (page="")
     if ($this->maxresults > 0) {
         $maxresults = $this->maxresults;
     } else {
         $maxresults = 999999;
     }
     // make sure to catch col #3, not #1 (pic only)
     //                        photo           name                   1=id        2=name        3=details
     preg_match_all('|<tr.*>\\s*<td.*>.*</td>\\s*<td.*<a href="/name/nm(\\d{7})[^>]*>([^<]+)</a>\\s*(.*)</td>|Uims', $this->page, $matches);
     $mc = count($matches[0]);
     mdb_base::debug_scalar("{$mc} matches");
     $mids_checked = array();
     for ($i = 0; $i < $mc; ++$i) {
         if ($i == $maxresults) {
             break;
         }
         // limit result count
         $pid = $matches[1][$i];
         if (in_array($pid, $mids_checked)) {
             continue;
         }
         $mids_checked[] = $pid;
         $name = $matches[2][$i];
         $info = $matches[3][$i];
         $tmpres = new imdb_person($pid);
         $tmpres->fullname = $name;
         if (!empty($info)) {
             if (preg_match('|<small>\\((.*),\\s*<a href="/title/tt(\\d{7}).*"\\s*>(.*)</a>\\s*\\((\\d{4})\\)\\)|Ui', $info, $match)) {
                 $role = $match[1];
                 $mid = $match[2];
                 $movie = $match[3];
                 $year = $match[4];
                 $tmpres->setSearchDetails($role, $mid, $movie, $year);
             }
         }
         $this->resu[$i] = $tmpres;
         unset($tmpres);
     }
     return $this->resu;
 }