Example #1
0
         $m->updateMovieInfo($_REQUEST['add']);
     }
     $usermovies = $um->addMovie($page->users->currentUserId(), $_REQUEST['add'], $cats);
 } else {
     if (!isset($_REQUEST['id'])) {
         $page->show404();
     }
     $tmdb = new TMDb($page->settings->getSetting('tmdbkey'), $page->settings->getSetting('imdblanguage'));
     $m = new Movie(['Settings' => $page->settings, 'TMDb' => $tmdb]);
     if (is_numeric($_REQUEST['id'])) {
         $movie = $m->fetchTMDBProperties($_REQUEST['id']);
         if ($movie !== false) {
             $obj = array($movie);
         }
     } else {
         $searchm = $tmdb->searchMovie($_REQUEST['id']);
         if ($searchm !== false) {
             if (isset($searchm['results'])) {
                 $obj = array();
                 $limit = 0;
                 foreach ($searchm['results'] as $movie) {
                     $limit++;
                     $movieinfo = $m->fetchTMDBProperties($movie['id'], true);
                     if ($movieinfo !== false) {
                         $obj[] = $movieinfo;
                     }
                     if ($limit > 4) {
                         break;
                     }
                 }
             }
Example #2
0
    $mi = $m->getMovieInfo($_REQUEST["add"]);
    if (!$mi) {
        $m->updateMovieInfo($_REQUEST["add"]);
    }
    $usermovies = $um->addMovie($users->currentUserId(), $_REQUEST["add"], $cats);
} else {
    if (!isset($_REQUEST["id"])) {
        $page->show404();
    }
    $s = new Sites();
    $site = $s->get();
    $tmdb = new TMDb($site->tmdbkey);
    if (is_numeric($_REQUEST["id"])) {
        $obj = json_decode($tmdb->getMovie($_REQUEST["id"], TMDb::IMDB));
    } else {
        $obj = json_decode($tmdb->searchMovie($_REQUEST["id"]));
    }
    $imdbids = array();
    if (count($obj) > 0) {
        foreach ($obj as $movie) {
            if (isset($movie->name) && isset($movie->imdb_id)) {
                $imdbids[] = str_replace("tt", "", $movie->imdb_id);
                if (isset($movie->posters) && sizeof($movie->posters) > 0) {
                    foreach ($movie->posters as $poster) {
                        if ($poster->image->size == 'cover') {
                            $movie->coverimg = $poster->image->url;
                            break;
                        }
                    }
                }
            } else {
Example #3
0
 /**
  * Search for a movie on tmdb by querystring.
  */
 public function searchTmdb($search, $limit = 10)
 {
     $tmdb = new TMDb($this->apikey, $this->lookuplanguage);
     try {
         $movies = $tmdb->searchMovie($search);
     } catch (Exception $e) {
         return false;
     }
     if (!$movies || !isset($movies['results'])) {
         return false;
     }
     $ret = array();
     $c = 0;
     foreach ($movies['results'] as $movie) {
         $c++;
         if ($c >= $limit) {
             continue;
         }
         $m = $this->fetchTmdbProperties($movie['id'], false);
         if ($m !== false) {
             $ret[] = $m;
         }
     }
     return $ret;
 }
<?php

require_once 'functions.php';
require_once 'config.php';
require_once 'db.php';
require_once 'TMDb-PHP-API/TMDb.php';
if (isloggedin()) {
    $tmdb = new TMDb(TMDB_APIKEY);
    $movies = $tmdb->searchMovie($_GET['search_keyword']);
    if (count($movies['results']) > 0) {
        for ($i = 0; $i < count($movies['results']); $i++) {
            $ratedArr[] = $movies["results"][$i];
        }
        echo "<div class='row-fluid'>";
        $i = 3;
        foreach ($ratedArr as $r) {
            $r['poster_path_w185'] = $tmdb->getImageUrl($r['poster_path'], 'poster', "w185");
            $i++;
            if ($i > 3) {
                echo "</div><div class='row-fluid'>";
                $i = 0;
            }
            ?>
			<div class="item span3">
				<a href="import.php?action=importsingle&tmdb_id=<?php 
            echo $r["id"];
            ?>
">
				<img src="<?php 
            echo $r["poster_path_w185"];
            ?>
 /**
  * List all movies matching submitted title using the API's search
  * method.
  * 
  * If no result were returned, display a notification. More than one
  * results means the search is not accurate, display first results in
  * case one of them matches the search and add a notification to try a
  * more specific search. If only on movie showed up, it should be the
  * one, call the API using the movie ID.
  * 
  * If more than one result, all movies listed will link to a new AJAX
  * call to load the movie by ID.
  *
  * @since    1.0
  * 
  * @param    string    $title Query to search after in the TMDb database
  * @param    string    $lang Lang to use in the query
  * @param    int       $post_id Related Post ID
  */
 public static function _get_movie_by_title($title, $lang, $post_id = null)
 {
     $tmdb = new TMDb();
     $config = $tmdb->getConfig();
     $title = preg_replace('/[^\\p{L}\\p{N}\\s]/u', '', trim($title));
     $data = $tmdb->searchMovie($title, 1, FALSE, NULL, $lang);
     if (is_wp_error($data)) {
         return $data;
     }
     $_result = 'empty';
     $_message = __('Sorry, your search returned no result. Try a more specific query?', 'wpmovielibrary');
     $_movies = array();
     $_post_id = $post_id;
     if (isset($data['status_code'])) {
         return new WP_Error(esc_attr($data['status_code']), esc_attr($data['status_message']), array('_id' => $post_id));
     } else {
         if (!isset($data['total_results'])) {
             $_result = 'empty';
             $_message = __('Sorry, your search returned no result. Try a more specific query?', 'wpmovielibrary');
             $_post_id = $post_id;
         } else {
             if (1 == $data['total_results']) {
                 $_result = 'movie';
                 $_message = null;
                 $_movie = self::get_movie_by_id($data['results'][0]['id'], $lang, $post_id);
                 if (is_wp_error($_movie)) {
                     return $_movie;
                 }
                 $_movies[] = $_movie;
                 $_post_id = $post_id;
             } else {
                 if ($data['total_results'] > 1) {
                     $_result = 'movies';
                     $_message = __('Your request showed multiple results. Select your movie in the list or try another search:', 'wpmovielibrary');
                     $_movies = array();
                     $_post_id = $post_id;
                     foreach ($data['results'] as $movie) {
                         if (!is_null($movie['poster_path'])) {
                             $movie['poster_path'] = self::get_image_url($movie['poster_path'], 'poster', 'small');
                         } else {
                             $movie['poster_path'] = str_replace('{size}', '-medium', WPMOLY_DEFAULT_POSTER_URL);
                         }
                         $_movies[] = array('id' => $movie['id'], 'poster' => $movie['poster_path'], 'title' => $movie['title'], 'year' => apply_filters('wpmoly_format_movie_date', $movie['release_date'], 'Y'), 'json' => json_encode($movie), '_id' => $post_id);
                     }
                 }
             }
         }
     }
     $movies = array('result' => $_result, 'message' => $_message, 'movies' => $_movies, 'post_id' => $_post_id);
     return $movies;
 }
Example #6
0
<?php

//This script will update all records in the movieinfo table
define('FS_ROOT', realpath(dirname(__FILE__)));
require_once FS_ROOT . "/../../www/config.php";
require_once FS_ROOT . "/../../www/lib/framework/db.php";
require_once FS_ROOT . "/../../www/lib/TMDb.php";
require_once FS_ROOT . "/../../www/lib/site.php";
$s = new Sites();
$site = $s->get();
$tmdb = new TMDb($site->tmdbkey);
print_r(json_decode($tmdb->searchMovie("inception")));