Esempio n. 1
0
 /** Constructor: Get data from the charts page
  * @constructor imdb_topcharts
  */
 function imdb_topcharts()
 {
     $req = new IMDB_Request($this->chartspage);
     $req->sendRequest();
     $this->page = $req->getResponseBody();
     $this->revision = preg_replace('|^.*?(\\d+).*$|', '$1', '$Revision: 253 $');
 }
 /** Save the photo to disk
  * @method savephoto
  * @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
  */
 function savephoto($path, $thumb = true)
 {
     $req = new IMDB_Request("");
     $photo_url = $this->photo($thumb);
     if (!$photo_url) {
         return FALSE;
     }
     $req->setURL($photo_url);
     $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 {
         $this->debug_scalar("<BR>*photoerror* " . $photo_url . ": Content Type is '" . $req->getResponseHeader("Content-Type") . "'<BR>");
         return false;
     }
     $fp2 = fopen($path, "w");
     if (!$fp || !$fp2) {
         $this->debug_scalar("image error...<BR>");
         return false;
     }
     fputs($fp2, $fp);
     return TRUE;
 }
Esempio n. 3
0
 /** Setup search results
  * @method results
  * @return array results
  */
 function results($url = "")
 {
     if ($this->page == "") {
         if (empty($url)) {
             $url = $this->mkurl();
         }
         $be = new IMDB_Request($url);
         $be->sendrequest();
         $fp = $be->getResponseBody();
         if (!$fp) {
             if ($header = $be->getResponseHeader("Location")) {
                 if (strpos($header, $this->imdbsite . "/find?")) {
                     return $this->results($header);
                     break 4;
                 }
                 #--- @moonface variant (not tested)
                 # $idpos = strpos($header, "/Title?") + 7;
                 # $this->resu[0] = new imdb( substr($header, $idpos,7));
                 #--- end @moonface / start sevec variant
                 $url = explode("/", $header);
                 $id = substr($url[count($url) - 2], 2);
                 $this->resu[0] = new imdb($id);
                 #--- end Sevec variant
                 return $this->resu;
             } else {
                 return NULL;
             }
         }
         $this->page = $fp;
     }
     // end (page="")
     $searchstring = array('<A HREF="/title/tt', '<A href="/title/tt', '<a href="/Title?', '<a href="/title/tt');
     $i = 0;
     foreach ($searchstring as $srch) {
         $res_e = 0;
         $res_s = 0;
         $len = strlen($srch);
         while (($res_s = strpos($this->page, $srch, $res_e)) > 10) {
             $res_e = strpos($this->page, "(", $res_s);
             $tmpres = new imdb(substr($this->page, $res_s + $len, 7));
             // make a new imdb object by id
             $ts = strpos($this->page, ">", $res_s) + 1;
             // >movie title</a>
             $te = strpos($this->page, "<", $ts);
             $tmpres->main_title = substr($this->page, $ts, $te - $ts);
             $ts = strpos($this->page, "(", $te) + 1;
             $te = strpos($this->page, ")", $ts);
             $tmpres->main_year = substr($this->page, $ts, $te - $ts);
             $i++;
             $this->resu[$i] = $tmpres;
         }
     }
     return $this->resu;
 }
 /** 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)
  */
 function results($url = "")
 {
     if ($this->page == "") {
         if (empty($url)) {
             $url = $this->mkurl();
         }
         $be = new IMDB_Request($url);
         $be->sendrequest();
         $fp = $be->getResponseBody();
         if (!$fp) {
             if ($header = $be->getResponseHeader("Location")) {
                 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($id);
                 return $this->resu;
             } else {
                 return NULL;
             }
         }
         $this->page = $fp;
     }
     // end (page="")
     $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[$i] = $tmpres;
         }
     }
     return $this->resu;
 }
Esempio n. 5
0
 /** Retrieve trailers from azmovietrailers.com
  * @method getAZMovieTrailers
  * @param string url page url as retrieved with imdb::trailers
  * @return array [0..n] of array[url,format] of movie trailers (Flash)
  */
 function getAZMovieTrailers($url)
 {
     $req = new IMDB_Request($url);
     $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]));
     }
 }
Esempio n. 6
0
 /** 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_person class)
  */
 function results($url = "")
 {
     if ($this->page == "") {
         if (empty($url)) {
             $url = $this->mkurl();
         }
         $be = new IMDB_Request($url);
         $be->sendrequest();
         $fp = $be->getResponseBody();
         if (!$fp) {
             if ($header = $be->getResponseHeader("Location")) {
                 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 {
                 return NULL;
             }
         }
         $this->page = $fp;
     }
     // end (page="")
     if ($this->maxresults > 0) {
         $maxresults = $this->maxresults;
     } else {
         $maxresults = 999999;
     }
     // make sure to catch col #3, not #1 (pic only)
     preg_match_all('|<tr>\\s*<td.*>.*</td>\\s*<td.*>.*</td>\\s*<td.*<a href="/name/nm(\\d{7})[^>]*>([^<]+)</a>(.*)</td>|Uims', $this->page, $matches);
     $mc = count($matches[0]);
     $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})/">(.*)</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;
 }