Пример #1
0
/**
 * Validates a IMDB url
 * @param $uri string
 * @return true if $uri is a IMDB url
 */
function is_imdb_url($url)
{
    if (Imdb::getIdFromUrl($url)) {
        return true;
    }
    return false;
}
Пример #2
0
 public function test_getIdFromUrl()
 {
     $this->assertEquals(Imdb::getIdFromUrl('http://www.imdb.com/title/tt1837642/'), 'tt1837642');
 }
Пример #3
0
<?php

include_once "includes/functions.inc.php";
$imdb = new Imdb();
$file = cleanWAMP(getDataFileName("{$_GET['raw']}"));
if (!file_exists($dataFolder . $file)) {
    exit;
}
//error
$handle = fopen($dataFolder . $file, "r");
$cleanTitle = clean_title($file);
if (isset($_GET['tab']) && $_GET['tab'] == "photos") {
    $movieArray = $imdb->getMovieInfo($cleanTitle, 3);
} else {
    if ($settings_data['imdb_mode'] == 'false') {
        $movieArray = arrayFile("{$dataFolder}/{$file}");
    } else {
        $movieArray = $imdb->getMovieInfo($cleanTitle, 2);
    }
}
if ($handle) {
    $videodata = explode("\n", file_get_contents("{$dataFolder}/{$file}"));
    $toggle = cleanWAMP($videodata[2]);
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title><?php 
echo $template->videoTitle($movieArray['title'], $movieArray['year']);
Пример #4
0
 protected function saveNewMovie($id)
 {
     $imdb = new Imdb();
     $movie_new = $imdb->getMovieInfo($id);
     if ($movie_new['response'] != 'ok') {
         return $movie_new['response'];
     } else {
         $model = new Movie();
         $movie_new['votes'] = intval(str_replace(',', '', $movie_new['votes']));
         $movie_new['release_date'] = date('Y-m-d', strtotime($movie_new['release_date']));
         $model->setAttributes($movie_new, false);
         $model->created_at = $model->updated_at = time();
         $model->save();
     }
 }
Пример #5
0
<?php

session_start();
$n = 0;
$conn = mysql_connect("localhost", "root", "");
$db = mysql_select_db("moviecol", $conn);
include "imdbshort.php";
$imdb = new Imdb();
$boolean = 'hello';
$cars[0] = strtolower($_POST['movie_name']);
$result = mysql_query("select * from movie where lower(movie_title)='{$cars['0']}'", $conn);
$n = mysql_num_rows($result);
echo $n;
//$cog=$_SESSION['cog'];
//echo $cog;
if ($n != 0) {
    $row = mysql_fetch_array($result);
    echo '<table cellpadding="3" cellspacing="2" border="1" width="80%" align="center">';
    echo '<tr><th>ID</th><td>' . $row['id'] . '</td></tr>';
    echo '<tr><th>Movie URL</th><td>' . $row['movie_url'] . '</td></tr>';
    echo '<tr><th>Movie Title</th><td>' . $row['movie_title'] . '</td></tr>';
    echo '<tr><th>Movie Year</th><td>' . $row['movie_year'] . '</td></tr>';
    echo '<tr><th>Movie Rating</th><td>' . $row['movie_rating'] . '</td></tr>';
    echo '<tr><th>Movie Release</th><td>' . $row['movie_release'] . '</td></tr>';
    echo '<tr><th>Movie Plot</th><td>' . $row['movie_plot'] . '</td></tr>';
    echo '<tr><th>Movie Poster</th><td><img src="' . $row['movie_poster'] . '"></td></tr>';
    echo '<tr><th>Runtime</th><td>' . $row['runtime'] . '</td></tr>';
    echo '<tr><th>Cost</th><td>' . $row['cost'] . '</td></tr>';
    echo '</table>';
    $_SESSION['id'] = $row['id'];
    echo $_SESSION['id'];
Пример #6
0
<?php

include_once "includes/functions.inc.php";
$imdb = new Imdb();
$file = cleanWAMP(getDataFileName("{$_GET['raw']}"));
$cleanTitle = clean_title($file);
if (file_exists($dataFolder . $cleanTitle) !== false) {
    exit;
}
//error
$handle = fopen($dataFolder . $file, "r");
if (isset($_GET['tab']) && $_GET['tab'] == "photos") {
    $movieArray = $imdb->getMovieInfo($cleanTitle, 3);
} else {
    if ($settings_data['imdb_mode'] == 'false') {
        $movieArray = arrayFile("{$dataFolder}/{$file}");
    } else {
        $movieArray = $imdb->getMovieInfo($cleanTitle, 2);
    }
}
if ($handle) {
    $videodata = explode("\n", file_get_contents("{$dataFolder}/{$file}"));
    $toggle = cleanWAMP($videodata[2]);
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title><?php 
echo $template->videoTitle($movieArray['title'], $movieArray['year']);
Пример #7
0
 public function addqueue()
 {
     if ($this->chars == 9) {
         $sql = "SELECT id FROM movies\n \t\t\t\t\tWHERE imdbid = :imdbid";
         $resultfrommovies = $this->db->select_query($sql, array(':imdbid' => $_POST['imdbid']));
         if (sizeof($resultfrommovies)) {
             header("Location:" . URL . "movie/display/" . $resultfrommovies[0]['id']);
             break;
         }
         $sql = "SELECT id FROM queue\n \t\t\t\t\tWHERE imdb = :imdbid";
         $resultfromqueue = $this->db->select_query($sql, array(':imdbid' => $_POST['imdbid']));
         if (sizeof($resultfromqueue)) {
             header("Location:" . URL . "movie/queue");
             break;
         }
         $imdb = new Imdb();
         $imdbid = $this->imdbid;
         $movieData = $imdb->getMovieInfoById($imdbid);
         $title = trim($movieData['title']);
         $year = $movieData['year'];
         $sql = "SELECT title FROM movies\n\t\t\t\t\tWHERE movies.title = :title\n\t\t\t\t\tUNION\n\t\t\t\t\tSELECT title FROM queue\n\t\t\t\t\tWHERE queue.title = :title";
         $result = $this->db->select_query($sql, array(':title' => $title));
         if (sizeof($result) == 0) {
             $sql = "INSERT INTO queue (imdb , title, year, added)\n\t \t\t\t\t\tVALUES (:imdbid, :title, :year, CURDATE())";
             $imdbidt = $this->imdbid;
             $result = $this->db->select_query($sql, array(':imdbid' => $imdbidt, ':title' => $title, ':year' => $year));
             $mid = $this->db->lastInsertId('id');
             foreach ($movieData['genres'] as $genre) {
                 $param[] = array(':genre' => $genre);
             }
             $sql = "SELECT id FROM genres\n\t\t\t\t\t\tWHERE genre = :genre";
             $result = $this->db->multi_query($sql, $param);
             echo '<pre>';
             var_dump($result);
             echo '</pre>';
             foreach ($result as $key => $value) {
                 echo sizeof($value);
                 if (sizeof($value) == 0) {
                     $insertparam[] = $param[$key];
                 } else {
                     $genreparam[] = $value[0];
                 }
             }
             $sql = "INSERT INTO genres (genre)\n\t\t\t\t\t\tVALUES(:genre)";
             $this->db->multi_query($sql, $insertparam);
             $gid = $this->db->lastInsertId('id');
             for ($i = $gid - sizeof($insertparam) + 1; $i <= $gid; $i++) {
                 $genreparam[] = $i;
             }
             $ar = new ArrayTools();
             $genres = $ar->unique_flat_array($genreparam);
             foreach ($genres as $value) {
                 $genresin[] = array(':gid' => $value, ':mid' => $mid);
             }
             $sql = "INSERT INTO genresinqueue (movie_id,genre_id)\n\t\t\t\t\t\tVALUES (:mid,:gid)";
             $this->db->multi_query($sql, $genresin);
             header("Location:" . URL . "movie/queue");
         } else {
             $sql = "SELECT id FROM movies\n\t\t\t\t\t\tWHERE title = :title";
             $resultfrommovies = $this->db->select_query($sql, array(':title' => $title));
             if (sizeof($resultfrommovies) > 0) {
                 header("Location:" . URL . "movie/display/" . $resultfrommovies[0]['id']);
                 break;
             } else {
                 header("Location:" . URL . "movie/queue");
             }
         }
         break;
     }
     $this->viewModel->set('urlValues', $this->urlValues);
     $this->viewModel->set('pageTitle', TITLE . 'Köa en film');
     return $this->viewModel;
 }
Пример #8
0
<?php

include_once 'functions.inc.php';
if (isset($_GET['report'])) {
    ?>
<script src="includes/js/jquery-1.10.2.min.js"></script>
<?php 
}
$data_array = arraySettings($settings_data["directories"]);
$imdb = new Imdb();
$prefix = '.././';
foreach ($data_array as $directories) {
    $directories = $prefix . $directories;
    if ($handle = opendir($directories)) {
        while (false !== ($entry = readdir($handle))) {
            if (in_array($entry, $garbage)) {
                continue;
            }
            $contents[] = $directories . '/' . $entry;
        }
    }
}
if (!$contents) {
    exit('<div class="error_msg">' . $lang_check_cantLocate . '</div>');
}
if (ob_get_level() == 0) {
    ob_start();
}
foreach ($contents as $value) {
    if (in_array($value, $garbage)) {
        continue;
Пример #9
0
 * 
 * $imdbObj    = new Imdb();
 * $movieInfo  = $imdbObj->get('http://www.imdb.com/title/tt0367882/');
 * 
 * $movieInfo should contain all the details of that movie in associative Array Format
 * 
 * You can also grab based on a search string like:
 * $movieInfo  = $imdbObj->get('The Matrix');
 * 
 * For Full Details, refer to:
 * http://www.itsalif.info/content/imdb-details-grabber-using-php-dom-xpath-extract-movie-details
 */
include 'class.imdb.php';
// only showing error, i.e turning off warning as new imdb layout throws bunch of warnings
error_reporting(E_ERROR);
$imdbObj = new Imdb();
// a helper function to echo movie details
function echoMovieDetails(&$movieInfo)
{
    if ($movieInfo != false) {
        echo '<pre>';
        print_r($movieInfo);
        echo '</pre>';
    } else {
        echo '<pre>Invalid Search Term or Invalid Imdb URL. No such Movie exists on IMDB</pre>';
    }
}
$path = 'http://www.imdb.com/title/tt0133093/';
// the Matrix Movie
$matrixInfo = $imdbObj->get($path);
echoMovieDetails($matrixInfo);
Пример #10
0
// Free PHP IMDb Scraper Web Service API
// Author: Abhinay Rathore
// Website: http://www.AbhinayRathore.com
// Blog: http://web3o.blogspot.com
// Demo: http://lab.abhinayrathore.com/imdb/
// More Info: http://web3o.blogspot.com/2010/10/php-imdb-scraper-for-new-imdb-template.html
// Last Updated: July 3, 2011
/////////////////////////////////////////////////////////////////////////////////////////////////////////
include "imdb.php";
$movieName = $_REQUEST["m"];
$output = strtolower($_REQUEST["o"]);
if ($output != "xml" && $output != "json" && $output != "jsonp") {
    $output = "xml";
    //Set default to XML
}
$i = new Imdb();
$mArr = array_change_key_case($i->getMovieInfo($movieName), CASE_UPPER);
///////////////[ XML Output ]/////////////////
if ($output == "xml") {
    header("Content-Type: text/xml");
    $doc = new DomDocument('1.0');
    $doc->formatOutput = true;
    $movie = $doc->createElement('MOVIE');
    $movie = $doc->appendChild($movie);
    foreach ($mArr as $k => $v) {
        if (is_array($v)) {
            $node = $doc->createElement($k);
            $node = $movie->appendChild($node);
            $c = 0;
            foreach ($v as $a) {
                $c++;
Пример #11
0
<p>
	Enter a movie name: 
</p>
<p>
	<input type="text" name="movie" value="" size="35"/>
</p>
<p>
	<input type="submit" name="submit" value="Grab" /> &nbsp;
	<input type="reset" name="reset" value="Reset" />
</p>
</form>

<div class="movieInfo">
<?php 
include 'class.imdb.php';
$imdb = new Imdb();
if (isset($_POST['movie'])) {
    $movieInfo = $imdb->showCast(true)->get(trim($_POST['movie']));
    if ($movieInfo == false) {
        $movieInfo = array('error' => 'Invalid Search Term or URL');
    } else {
        foreach ($movieInfo as $k => $v) {
            $k = ucfirst($k);
            if ($k != 'Cast:') {
                echo <<<_INFO_
<p>
<h3><b>{$k}</b></h3>
{$v}
</p>
_INFO_;
            } else {
Пример #12
0
<?php

include 'imdb.php';
$name = $argv[1];
$runner = new Imdb();
$info = $runner->getMultipleMovieInfo($name);
$end_str = '';
if (is_array($info)) {
    if (array_key_exists('error', $info)) {
        if ($info['error'] == "No Title found in Search Results!") {
            $end_str = 'No Titles Found';
        }
    }
} else {
    $end_str = 'No Titles Found';
}
if (is_array($info)) {
    foreach ($info as $key => $arr) {
        if (is_array($arr)) {
            $end_str .= "-MTM_TITLE_MTM-";
            $top_group = ':-MTM-SUBARRAY-:TopLevel:-::MTM::-';
            if (array_key_exists('error', $arr)) {
                if ($arr['error'] == "No Title found in Search Results!") {
                    $end_str = 'No Titles Found';
                }
            } else {
                foreach ($arr as $key => $val) {
                    if (is_array($val)) {
                        $end_str .= ":-MTM-SUBARRAY-:{$key}:-::MTM::-";
                        foreach ($val as $subkey => $subval) {
                            $end_str .= ":-MTM-FIELD-:{$subkey}=>{$subval}";
Пример #13
0
 public function updateMovieInfoFromTitle($id, $title, $code)
 {
     $del = array('2015', '2014', '2013', '2012', '2011', '2010', '2009', '2008', '2007', '2006', '2005', '2004', '2003', '2002', '2001', '2000', '(', '[', 'DVD', 'BR', 'CAM', 'TS', '1080', '720', 'BlueRay', 'S0', 'S1', 'S2', 'S3', '1x', '2x', '3x', '4x', '5x', '6x', '7x', '8x', '9x', '10x');
     $titleArray = explode($del[0], str_replace($del, $del[0], $title));
     $searchTitle = trim($titleArray[0]);
     $imdb = new Imdb();
     $movieArray = $imdb->getMovieInfo($searchTitle);
     if (isset($movieArray['title_id'])) {
         $title_id = $movieArray['title_id'];
         $bad = array(':', ' -', "'");
         $y = str_replace($bad, '', $movieArray['title']);
         //                        $title = urlencode($y);
         $title = $y;
         //strip everything for image title
         $bad = array(':', '-', "'", " ");
         $z = str_replace($bad, '', $movieArray['title']);
         $imageTitle = urlencode($z);
         $year = $movieArray['year'];
         $rating = $movieArray['rating'];
         $mpaa_rating = $movieArray['mpaa_rating'];
         $plot = $movieArray['plot'];
         $imdb_url = $movieArray['imdb_url'];
         $poster = NULL;
         //SAVE THE IMAGES
         //@todo: do we need all of these images
         if ($movieArray['poster'] !== '') {
             if (strstr($movieArray['poster'], 'b.scorecardresearch.com')) {
                 $title_id = NULL;
             } else {
                 $content = file_get_contents($movieArray['poster']);
                 $poster = $code . "-" . $id . "-" . $title_id . ".jpg";
                 $filename = "../media/imdb/" . $poster;
                 $x = file_put_contents($filename, $content);
             }
         }
         //                        var_dump($movieArray);
         //now we need to process the attributes for the db
         foreach ($movieArray as $attrName => $attrVal) {
             //check if movie attribute is an array of string
             if (is_array($attrVal)) {
                 //check to see if an empty array
                 if (count($attrVal) == 0) {
                     ${$attrName} = NULL;
                 } else {
                     $y = NULL;
                     foreach ($attrVal as $x) {
                         str_replace('"', "", $y);
                         $y[] = $x;
                     }
                     ${$attrName} = serialize($y);
                     $y = NULL;
                 }
             }
         }
         $imdbTable = "pbay_" . $code . "_imdb";
         $sql = "INSERT INTO {$imdbTable} (media_id, imdb_id, imdb_title, year, rating, genres, directors, writers, stars, cast, mpaa_rating, plot, poster, imdb_url) VALUES ('{$id}', '{$title_id}', '{$title}', '{$year}', '{$rating}', '{$genres}', '{$directors}', '{$writers}', '{$stars}', '{$cast}', '{$mpaa_rating}', '{$plot}', '{$poster}', '{$imdb_url}')";
         $query = $this->dbUpdate($sql);
         return true;
     } else {
         return false;
     }
 }