/** Retrieve trailers from azmovietrailers.com * @method getAZMovieTrailers * @param string url page url as retrieved with imdb::videosites * @return array [0..n] of array[url,format] of movie trailers (Flash) */ function getAZMovieTrailers($url) { $req = new Request($url, $this->config); $req->sendRequest(); $this->page = $req->getResponseBody(); if ($this->page == "" || $this->page == false) { return false; } preg_match('|flashvars\\="file\\=(http.*)\\&|iUms', $this->page, $match); preg_match('|\\.(.{3})$|i', $match[1], $format); if (!empty($match[1])) { return array(array("url" => $match[1], "format" => $format[1])); } }
/** Convert IMDB redirect-URLs of external sites to real URLs * @method convertIMDBtoRealURL * @param string url redirect-url * @return string url real-url */ protected function convertIMDBtoRealURL($url) { if (preg_match('/^https?:\\/\\//', $url)) { return $url; } $req = new Request("http://" . $this->imdbsite . $url, $this->config); if ($req->sendRequest() !== FALSE) { $head = $req->getLastResponseHeaders(); foreach ($head as $header) { if (preg_match('/:/', $header)) { list($type, $value) = explode(':', $header, 2); if ($type == 'Location') { return preg_replace('/\\s/', '', $value); } } } } return false; }
/** * Save the photo to disk * @param string path where to store the file * @param optional boolean thumb get the thumbnail (100x140, default) or the * bigger variant (400x600 - FALSE) * @return boolean success * @see IMDB person page / (Main page) */ public function savephoto($path, $thumb = TRUE, $rerun = FALSE) { $photo_url = $this->photo($thumb); if (!$photo_url) { return FALSE; } $req = new Request($photo_url, $this->config); $req->sendRequest(); if (strpos($req->getResponseHeader("Content-Type"), 'image/jpeg') === 0 || strpos($req->getResponseHeader("Content-Type"), 'image/gif') === 0 || strpos($req->getResponseHeader("Content-Type"), 'image/bmp') === 0) { $fp = $req->getResponseBody(); } else { if ($rerun) { $this->debug_scalar("<BR>*photoerror* at " . __FILE__ . " line " . __LINE__ . ": " . $photo_url . ": Content Type is '" . $req->getResponseHeader("Content-Type") . "'<BR>"); return FALSE; } else { $this->debug_scalar("<BR>Initiate second run for photo '{$path}'<BR>"); return $this->savephoto($path, $thumb, TRUE); } } $fp2 = fopen($path, "w"); if (!$fp || !$fp2) { $this->debug_scalar("image error...<BR>"); return false; } fputs($fp2, $fp); return TRUE; }