コード例 #1
0
ファイル: cache.php プロジェクト: Rattatouille/myaqa_test
            if (preg_match('|.pilot$|', $entry)) {
                $movies[$imdbid]['pilot'] = 1;
            } else {
                $movies[$imdbid]['imdb'] = 1;
            }
        }
    }
}
if (!empty($movies)) {
    echo "<TABLE ALIGN='center' BORDER='1' STYLE='border-collapse:collapse;margin-top:20px;'>\n" . " <TR><TH STYLE='background-color:#ffb000'>Movie</TH><TH STYLE='background-color:#ffb000'>IMDB</TH><TH STYLE='background-color:#ffb000'>MoviePilot</TR>\n";
    foreach ($movies as $movie) {
        if ($movie['imdb']) {
            $imdb->setid($imdbid);
            $title = $imdb->title();
        } else {
            $pilot->setid($imdbid);
            $title = $pilot->title();
        }
        echo " <TR><TD>{$title}</TD><TD>";
        // IMDB
        if ($movie['imdb']) {
            echo "<a href='movie.php?engine=imdb&mid={$imdbid}'>Cache</a> | ";
        } else {
            echo "Cache | ";
        }
        echo "<a href='http://us.imdb.com/title/tt{$imdbid}'>Remote</TD><TD>";
        // MoviePilot
        if ($movie['pilot']) {
            echo "<a href='movie.php?engine=pilot&mid={$imdbid}'>Cache</a> | ";
        } else {
            echo "Cache | ";
コード例 #2
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 class)
  */
 public function results($url = "")
 {
     if (empty($this->pilot_apikey)) {
         trigger_error('Please provide a valid api key or contact api@moviepilot.de.', E_USER_WARNING);
         return array();
     }
     // get the result list
     if ($this->page == "") {
         if (empty($url)) {
             $url = $this->mkurl();
         }
         $be = new MDB_Request($url);
         $be->sendrequest();
         $fp = $be->getResponseBody();
         if ($fp == '{"error":"please provide a valid api key or contact api@moviepilot.de"}') {
             $this->debug_scalar('ERROR: invalid API key');
             trigger_error('Please provide a valid api key or contact api@moviepilot.de.', E_USER_WARNING);
             return array();
         }
         $this->page = json_decode($fp);
     }
     // end (page="")
     // parse results
     $i = 0;
     if (!empty($this->page->movies)) {
         foreach ($this->page->movies as $movie) {
             if ($this->maxresults && $i > $this->maxresults) {
                 break;
             }
             ++$i;
             $mid = str_pad($movie->alternative_identifiers->imdb, 7, 0, STR_PAD_LEFT);
             $item = new pilot($mid);
             $item->page['Title'] = $movie;
             $item->setid($mid);
             $this->resu[] = $item;
             if ($this->storecache) {
                 $this->cache_write($mid . '.' . 'Title.pilot', json_encode($movie));
             }
         }
     }
     return $this->resu;
 }