Beispiel #1
0
 /**
  * Fetch info for IMDB id from TMDB.
  *
  * @param string  $imdbId
  * @param boolean $text
  *
  * @return array|bool
  */
 public function fetchTMDBProperties($imdbId, $text = false)
 {
     $lookupId = $text === false ? 'tt' . $imdbId : $imdbId;
     try {
         $tmdbLookup = $this->tmdb->getMovie($lookupId);
     } catch (\Exception $e) {
         return false;
     }
     if (!$tmdbLookup || isset($tmdbLookup['status_code']) && $tmdbLookup['status_code'] !== 1) {
         return false;
     }
     $ret = [];
     $ret['title'] = $tmdbLookup['title'];
     if ($this->currentTitle !== '') {
         // Check the similarity.
         similar_text($this->currentTitle, $ret['title'], $percent);
         if ($percent < 40) {
             if ($this->debug) {
                 $this->debugging->log(get_class(), __FUNCTION__, 'Found (' . $ret['title'] . ') from TMDB, but it\'s only ' . $percent . '% similar to (' . $this->currentTitle . ')', Logger::LOG_INFO);
             }
             return false;
         }
     }
     $ret['tmdb_id'] = $tmdbLookup['id'];
     $ImdbID = str_replace('tt', '', $tmdbLookup['imdb_id']);
     $ret['imdb_id'] = $ImdbID;
     if (isset($tmdbLookup['vote_average'])) {
         $ret['rating'] = $tmdbLookup['vote_average'] == 0 ? '' : $tmdbLookup['vote_average'];
     }
     if (isset($tmdbLookup['overview'])) {
         $ret['plot'] = $tmdbLookup['overview'];
     }
     if (isset($tmdbLookup['tagline'])) {
         $ret['tagline'] = $tmdbLookup['tagline'];
     }
     if (isset($tmdbLookup['release_date'])) {
         $ret['year'] = date("Y", strtotime($tmdbLookup['release_date']));
     }
     if (isset($tmdbLookup['genres']) && sizeof($tmdbLookup['genres']) > 0) {
         $genres = [];
         foreach ($tmdbLookup['genres'] as $genre) {
             $genres[] = $genre['name'];
         }
         $ret['genre'] = $genres;
     }
     if (isset($tmdbLookup['poster_path']) && sizeof($tmdbLookup['poster_path']) > 0) {
         $ret['cover'] = "http://image.tmdb.org/t/p/w185" . $tmdbLookup['poster_path'];
     }
     if (isset($tmdbLookup['backdrop_path']) && sizeof($tmdbLookup['backdrop_path']) > 0) {
         $ret['backdrop'] = "http://image.tmdb.org/t/p/original" . $tmdbLookup['backdrop_path'];
     }
     if ($this->echooutput) {
         $this->pdo->log->doEcho($this->pdo->log->primaryOver("TMDb Found ") . $this->pdo->log->headerOver($ret['title']), true);
     }
     return $ret;
 }
<?
require_once('../functions.php');
require_once('../config.php');
require_once('../db.php');
require_once('../TMDb-PHP-API/TMDb.php');
require_once('../header.php');

$id = htmlspecialchars($_GET['url']);

$tmdb = new TMDb(TMDB_APIKEY);
$person = $tmdb->getPerson($id);
?>
<div class="container">
<div style="opacity: 100; margin-left: 100px; margin-top: 0%;" class="person_content">
	<div class='title'><?php 
echo $person['name'];
?>
</div>
        <div class="row-fluid">
		<div class="span3">
<?
echo "<img src=\"".$tmdb->getImageUrl($person['profile_path'],'profile', 'w185')."\" class=\"person_profile\" width=\"100%\">\n";
echo "<strong>Born:</strong><br />".$person['birthday']." - ".$person['place_of_birth'];
if ($person['deathday'] != "") {
	echo "<br /><strong>Died:</strong><br />".$person['deathday'];
}
?>
		</div>
		<div class="span9">
			<h2>Biography</h2>
			<p><?php 
Beispiel #3
0
 public function fetchTmdbProperties($imdbId)
 {
     $tmdb = new TMDb($this->apikey);
     $lookupId = 'tt' . $imdbId;
     $tmdbLookup = json_decode($tmdb->getMovie($lookupId, TMDb::IMDB));
     if (!$tmdbLookup) {
         return false;
     }
     $movie = array_shift($tmdbLookup);
     if ($movie == 'Nothing found.') {
         return false;
     }
     $ret = array();
     $ret['title'] = $movie->name;
     $ret['tmdb_id'] = $movie->id;
     $ret['imdb_id'] = $imdbId;
     $ret['rating'] = $movie->rating == 0 ? '' : $movie->rating;
     $ret['plot'] = $movie->overview;
     $ret['year'] = date("Y", strtotime($movie->released));
     if (isset($movie->genres) && sizeof($movie->genres) > 0) {
         $genres = array();
         foreach ($movie->genres as $genre) {
             $genres[] = $genre->name;
         }
         $ret['genre'] = $genres;
     }
     if (isset($movie->posters) && sizeof($movie->posters) > 0) {
         foreach ($movie->posters as $poster) {
             if ($poster->image->size == 'cover') {
                 $ret['cover'] = $poster->image->url;
                 break;
             }
         }
     }
     if (isset($movie->backdrops) && sizeof($movie->backdrops) > 0) {
         foreach ($movie->backdrops as $backdrop) {
             if ($backdrop->image->size == 'original') {
                 $ret['backdrop'] = $backdrop->image->url;
                 break;
             }
         }
     }
     return $ret;
 }
Beispiel #4
0
 if (isset($_REQUEST['add'])) {
     // Derive cats from user preferences.
     $cats = array();
     $cats[] = '2030';
     $cats[] = '2040';
     $m = new Movie(['Settings' => $page->settings]);
     $mi = $m->getMovieInfo($_REQUEST['add']);
     if (!$mi) {
         $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);
Beispiel #5
0
    $cats = array();
    $cats[] = "2030";
    $cats[] = "2040";
    $m = new Movie(false);
    $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;
<?php

require_once 'config.php';
require_once 'db.php';
require_once 'functions.php';
require_once 'TMDb-PHP-API/TMDb.php';
if (isloggedin()) {
    if (!isset($_GET['rating'])) {
        die;
    }
    if (!isset($_GET['tmdb_id'])) {
        die;
    }
    $rating = intval($_GET['rating']);
    $tmdb_id = intval($_GET['tmdb_id']);
    mysql_query("UPDATE movies set rating = " . $rating . " where tmdb_id = '" . $tmdb_id . "'") or die('Query failed: ' . mysql_error());
    $tmdb = new TMDb(TMDB_APIKEY);
    $tmdb->addMovieRating($_SESSION['tmdb_session_id'], $tmdb_id, $rating / 10);
    die("ok");
}
<?php

include 'TMDb.php';
// Default English language
$tmdb = new TMDb('API-key');
// Set-up the class with your own language
$tmdb_nl = new TMDb('API-key', 'nl');
// If you want to load the TMDb-config (default FALSE)
$tmdb_load_config = new TMDb('API-key', 'en', TRUE);
// After initialize the class
// First request a token from API
$token = $tmdb->getAuthToken();
// Request valid session for that particular user from API
$session = $tmdb->getAuthSession();
//Retrieve config with initialisation of the class
$tmdb = new TMDb('API-key', 'en', TRUE);
//Retrieve (cached) config when the class is already initialised
$config = $tmdb->getConfig();
//Retrieve config when the class is already initialised from TMDb (always new request)
$config = $tmdb->getConfiguration();
//Filepath retrieved from a method (Backdrop image)
$filepath = '/eJhymb0SiOd39L3BDe7aO7iQhQx.jpg';
//Get image URL for the backdrop image in its original size
$image_url = $tmdb->getImageUrl($filepath, TMDb::IMAGE_BACKDROP, 'original');
Beispiel #8
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"];
            ?>
<?php

require_once 'functions.php';
require_once 'config.php';
require_once 'db.php';
require_once 'TMDb-PHP-API/TMDb.php';
// Default English language
$tmdb = new TMDb(TMDB_APIKEY);
$token = $_GET['request_token'];
$session = $tmdb->getAuthSession($token);
$_SESSION['tmdb_session_id'] = $session['session_id'];
logg("New session started with token:{$token} and tmdb_session_id:" . $session['session_id']);
session_write_close();
header("Location: import.php");
die;
<?php

require_once 'functions.php';
require_once 'config.php';
require_once 'db.php';
require_once 'TMDb-PHP-API/TMDb.php';
require_once 'header.php';
$tmdb = new TMDb(TMDB_APIKEY);
?>
<class="row-fluid">
	<div class="span3">
		<ul class="nav nav-list">
          		<li class="active"><a href="import.php"><i class="icon-chevron-right"></i> Import</a></li>
          		<li><a href="logs.php"><i class="icon-chevron-right"></i> Logs</a></li>
        	</ul>
	</div>
	<div class="span9">
		<h2>Imports</h2>


<?php 
if (!isset($_SESSION) || empty($_SESSION['tmdb_session_id'])) {
    $token = $tmdb->getAuthToken();
    ?>
<a href="<?php 
    echo $token['Authentication-Callback'];
    ?>
?redirect_to=http://<?php 
    echo $_SERVER["SERVER_NAME"];
    echo SUBDIR;
    ?>
 /**
  * Load all available Posters for a movie.
  * 
  * Filter the posters returned by the API to exclude the ones we
  * have already imported.
  *
  * @since    1.0
  *
  * @param    int    Movie TMDb ID
  * 
  * @return   array  All fetched posters minus the ones already imported
  */
 public static function get_movie_posters($tmdb_id)
 {
     $tmdb = new TMDb();
     if (is_null($tmdb_id)) {
         return false;
     }
     $images = $tmdb->getMovieImages($tmdb_id, '');
     $images = $images['posters'];
     foreach ($images as $i => $image) {
         $file_path = substr($image['file_path'], 1);
         $exists = apply_filters('wpmoly_check_for_existing_images', $tmdb_id, 'poster', $file_path);
         if (false !== $exists) {
             unset($images[$i]);
         }
     }
     return $images;
 }
Beispiel #13
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")));