function delete_group($name) { include 'config.php'; $db = new IMDB(); $res = $db->delete_item_from_table("grp", array("name" => "'" . $name . "'")); $db->close(); return $res; }
public static function buildMovies($array) { $movies = array(); foreach ($array as $index => $row) { $movie = new Movie(); foreach ($row as $key => $value) { IMDB::saveKeyValue($movie, $key, $value); } $movies[] = $movie; } return $movies; }
return strtolower($title); } if (isset($_POST["source"])) { $source = $_POST["source"]; } $fileName = upload($source); echo $fileName . "<br/>"; echo $source . "<br/>"; if ($fileName != null) { $db = new MongoHQ(array('collectionName' => 'watched')); $csv = new parseCSV($fileName); $csv->auto(); $data = $csv->data; //print_r($data); if ($source == "imdb") { $movies = IMDB::buildMovies($data); var_dump(Movie::toMoviesDB($movies)); $db->saveMany(Movie::toMoviesDB($movies)); } else { if ($source == "google") { $hashMap = buildHash($data); $db_movies = $db->find(); $mismatched = array(); foreach (Movie::toMovies($db_movies) as $movie) { $title = $movie->TITLE; //echo "<br/><div>[" . $$movie->POSITION . "] processing movie title: " . $title . " [db/rotten]</div>"; if (isset($hashMap[hkey($title)])) { $rating = intval($hashMap[hkey($title)]['Rate']); $movie->RATING = $rating; //echo "<div>" . $movie->RATING . "</div>"; $db->save($movie->get());
die; } if (isset($delete) && $delete) { $misc->deleteLink($delete); } if (isset($approve) && $approve) { $link_data = $movie->getLink($approve); if ($link_data) { $movie_data = $movie->getByImdb($link_data['imdb_id']); if ($movie_data) { // existing movie $movie_id = $movie_data['id']; } else { // new movie require_once "../includes/imdb.class.php"; $imdb = new IMDB(); $imdb_data = $imdb->getById($link_data['imdb_id']); $movie_data = array(); if (count($imdb_data)) { $movie_data['imdb_id'] = $link_data['imdb_id']; if (isset($imdb_data['title']) && $imdb_data['title']) { $movie_data['title'] = array(); foreach ($global_languages as $lang_code => $lang_name) { $movie_data['title'][$lang_code] = $imdb_data['title']; } } if (isset($imdb_data['summary']) && $imdb_data['summary']) { $movie_data['description'] = array(); foreach ($global_languages as $lang_code => $lang_name) { $movie_data['description'][$lang_code] = $imdb_data['summary']; }
function change_order($id, $user, $order, $new_order) { include 'config.php'; $res = ""; $db = new IMDB(); $fields = array("ord" => $order); $where = array("ord" => $new_order, "imuser" => "'" . $user . "'"); $res = $db->edit_item_from_table("credentials", $fields, $where); if (strlen($res) == 0) { $fields = array("ord" => $new_order); $where = array("rowid" => $id); $res = $db->edit_item_from_table("credentials", $fields, $where); } $db->close(); return $res; }
/** * Sørg for at poster er lastet ned */ public function build_cache_poster($rebuild = false) { // sjekk for poster if ($poster_src = $this->get("poster_src")) { $file_poster_src = $this->path . "/" . self::FILE_IMDB_POSTER_SRC; $file_poster = $this->path . "/" . self::FILE_IMDB_POSTER; // har vi denne allerede? (sjekk også for korrekt bilde) if ($rebuild || (!file_exists($file_poster_src) || !file_exists($file_poster) || @file_get_contents($file_poster_src) != $poster_src)) { // hent ny poster $t = microtime(true); $data = file_get_contents($poster_src); if ($data === false) { throw new \Exception("Kunne ikke hente poster for filmen: {$poster_src}"); } IMDB::log_imdb_http("(" . str_pad(round((microtime(true) - $t) * 1000, 0), 4, " ", STR_PAD_LEFT) . "ms) Fetched {$poster_src}"); file_put_contents($file_poster, $data); file_put_contents($file_poster_src, $poster_src); } } }
$title = urldecode($_GET['title']); } else { $title = false; } if (isset($_POST['imdb_id'])) { $imdb_id = urldecode($_POST['imdb_id']); } elseif (isset($_GET['imdb_id'])) { $imdb_id = urldecode($_GET['imdb_id']); } else { $imdb_id = false; } if (!$imdb_id && !$title) { print "0"; exit; } $imdb = new IMDB(); if ($imdb_id) { $data = $imdb->getById($imdb_id); } else { $data = $imdb->getDetails($title); } if ($data) { $ret = array(); if (isset($data['imdb_id'])) { $ret['imdb_id'] = $data['imdb_id']; } if (isset($imdb_id) && $imdb_id) { $ret['imdb_id'] = $imdb_id; } if (isset($data['title'])) { $ret['title'] = $data['title'];
} } else { echo '<p>Movie not found!</p>'; } ?> <hr> <?php $oIMDB = new IMDB('http://www.imdb.com/title/tt1022603/'); if ($oIMDB->isReady) { echo '<p><a href="' . $oIMDB->getUrl() . '">' . $oIMDB->getTitle() . '</a> got rated ' . $oIMDB->getRating() . '.</p>'; echo '<p><img src="' . $oIMDB->getPoster() . '" style="float:left;margin:4px 10px 10px 0;"> <b>About the movie:</b> ' . $oIMDB->getPlot() . '</p>'; } else { echo '<p>Movie not found!</p>'; } ?> <hr> <?php $oIMDB = new IMDB('Fabian Beiner never made a movie. Yet!'); if ($oIMDB->isReady) { echo '<p><b>' . $oIMDB->getTitle() . '</b></p>'; } else { echo '<p>Movie not found!</p>'; } ?> </body> </html>
h1 { font-size: 32px; text-align: center; font-weight: 700; } </style> </head> <body> <?php include_once '../imdb.class.php'; $aTests = array('http://www.imdb.com/title/tt0460681/', 'tt1124379', 'tt0187775 ', 'http://www.imdb.com/title/tt1231587/', 'http://www.imdb.com/title/tt1392190/', 'http://www.imdb.com/title/tt0421974/', 'http://www.imdb.com/title/tt0094618/', 'http://www.imdb.com/title/tt0448157/', 'Matrix', 'Donner Pass', 'If only', 'http://www.imdb.com/title/tt1604113/', 'Wyse Guys', 'http://www.imdb.com/title/tt2005268/', 'Wer ist Clark Rockefeller?', 'North by Northwest', 'Iron Man 2', 'One Tree Hill', 'Formosa Betrayed', 'New York, I Love You', 'http://us.imdb.com/Title?0144117', 'http://www.imdb.com/title/tt1022603/', 'Fabian Beiner never made a movie. Yet!'); set_time_limit(count($aTests) * 15); $i = 0; foreach ($aTests as $sMovie) { $i++; $oIMDB = new IMDB($sMovie); if ($oIMDB->isReady) { echo '<h1>' . $sMovie . '</h1>'; foreach ($oIMDB->getAll() as $aItem) { echo '<p><b>' . $aItem['name'] . '</b>: ' . $aItem['value'] . '</p>'; } } else { echo '<p><b>Movie not found</b>: ' . $sMovie . '</p>'; } echo '<hr>'; } ?> </body> </html>
<?php set_time_limit(0); require_once "../vars.php"; require_once "../includes/curl.php"; require_once "../includes/imdb.class.php"; $imdb = new IMDB(); print "updating shows\n"; $e = mysql_query("SELECT * FROM shows WHERE imdb_id!='' AND meta=''") or die(mysql_error()); if (mysql_num_rows($e)) { while ($s = mysql_fetch_assoc($e)) { $imdb_data = $imdb->getById($s['imdb_id']); if ($imdb_data) { if (isset($imdb_data['rating']) && $imdb_data['rating']) { $imdb_rating = $imdb_data['rating']; } else { $imdb_rating = 0; } $meta = array(); if (isset($imdb_data['year_started']) && $imdb_data['year_started']) { $meta['year_started'] = (int) $imdb_data['year_started']; } if (isset($imdb_data['stars']) && $imdb_data['stars'] && is_array($imdb_data['stars']) && count($imdb_data['stars'])) { $stars = array(); foreach ($imdb_data['stars'] as $key => $star) { if (trim($star)) { $stars[] = $star; } } if (count($stars)) { $meta['stars'] = $stars;
<?php set_time_limit(0); require_once "../vars.php"; require_once "../includes/curl.php"; require_once "../includes/imdb.class.php"; require_once "../includes/movie.class.php"; $curl = new Curl(); $movie = new Movie(); $imdb = new IMDB($curl); $movies = $movie->getMovies("en"); if (count($movies)) { foreach ($movies as $movie_id => $movie_data) { if (!$movie_data['meta']) { $imdb_id = $movie_data['imdb_id']; $imdb_data = $imdb->getById($imdb_id); $meta = array(); if (isset($imdb_data['rating']) && $imdb_data['rating']) { $meta['imdb_rating'] = $imdb_data['rating']; } if (isset($imdb_data['stars']) && !empty($imdb_data['stars'])) { $meta['stars'] = $imdb_data['stars']; } if (isset($imdb_data['director']) && !empty($imdb_data['director'])) { $meta['director'] = $imdb_data['director']; } if (isset($imdb_data['year']) && !empty($imdb_data['year'])) { $meta['year'] = $imdb_data['year']; } $movie->updateMeta($movie_id, $meta); print "updated\t" . $movie_data['title'] . "\n";
function delete_radl($id) { include 'config.php'; $db = new IMDB(); $res = $db->delete_item_from_table("radls", array("rowid" => "'" . $id . "'")); $db->close(); return $res; }
function delete_user($username) { include 'config.php'; $res = ""; $db = new IMDB(); $res = $db->delete_item_from_table("user", array("username" => "'" . $username . "'")); // remove the groups $res = $db->delete_item_from_table("users_grp", array("username" => "'" . $username . "'")); // remove the credencials $res = $db->delete_item_from_table("credentials", array("imuser" => "'" . $username . "'")); // remove the radls $res = $db->delete_item_from_table("radls", array("imuser" => "'" . $username . "'")); $db->close(); return $res; }
<?php include_once "IMDB.class.php"; $imdb = new IMDB(); /* $ratings = $imdb->getRatings(); //DEBUG: echo"<pre>";print_r($ratings);echo"</pre>"; */ $i = 0; echo '<ul>'; foreach ($imdb->getRatings() as $rating) { if ($i > 0) { $title = $imdb->getRatingsTitle($rating); $link = str_replace("/title/", "", substr($imdb->getRatingsTitleLink($rating), 0, -1)); $year = $imdb->getRatingsTitleYear($rating); $your_rating = $imdb->getRatingsYourRating($rating); $user_rating = $imdb->getRatingsAverageRating($rating); $votes = $imdb->getRatingsNumberOfVotes($rating); $date = $imdb->getRatingsDate($rating); echo '<li><a href="movie.php?m=' . $link . '" target="_blank">' . $title . '</a> ' . $your_rating . ' | ' . $user_rating . ' (' . $votes . ') - ' . $date . '</li>'; //HTML output // "INSERT INTO movie (title, image, link, description, year, date, user_rating, average_rating) VALUES ('{$title}', '{$image}', '{$link}', '{$desc}', {$year}, {$date}, {$user_rating}, {$your_rating});" //write to database } $i++; } echo '</ul>';