/** * Hent ut HTML-siden til filmen på IMDB */ protected function get_imdb_page($cache = true, $save = true, $fetch = false) { // benytte cache? if ($cache && file_exists($this->path . "/" . self::FILE_IMDB_CACHE)) { $this->imdb_data = file_get_contents($this->path . "/" . self::FILE_IMDB_CACHE); return true; } // ikke hente data? if (!$fetch) { return false; } $this->cache = null; // hent ut ID for filmen $id = $this->get_imdb_id($cache, $save, true); if (!$id) { return false; } // hent data $data = IMDB::get_imdb_data($id); switch ($data) { case "request-failed": $this->set_failed_status("HTTP request failed"); return false; case "not-found": $this->set_failed_status("Movie ID {$id} incorrect"); return false; } // lagre data? if ($save) { // flytt gammel fil if (file_exists($this->path . "/" . self::FILE_IMDB_CACHE)) { rename($this->path . "/" . self::FILE_IMDB_CACHE, $this->path . "/" . self::FILE_IMDB_CACHE . "-previous"); } file_put_contents($this->path . "/" . self::FILE_IMDB_CACHE, "HenriSt filminfo\n{$id}\n" . date("r") . "\n\n" . $data); } $this->imdb_data = $data; return true; }