Originally written by MVP (mostvotedplaya)
Run this sql against your database using whatever tools you use (phpmyadmin, etc)
ALTER TABLE `torrents` ADD `imdb` varchar(80) DEFAULT NULL;
Add to languages/english.php
$LANG["_IMDB_"] = "DB";
$LANG["IMDB"] = "Internet Movie Database:";
$LANG["IMDB_LINK"] = "Link";
$LANG["IMDB_INFO"] = "If a valid imdb is given we can autofill the description.";
$LANG["IMDB_RELEASED"] = "Released";
$LANG["IMDB_RATED"] = "Rated";
$LANG["IMDB_ALIAS"] = "Also Known As";
$LANG["IMDB_GENRE"] = "Genre";
$LANG["IMDB_DIRECTOR"] = "Director";
$LANG["IMDB_YEAR"] = "Year";
$LANG["IMDB_WRITER"] = "Writer";
$LANG["IMDB_RUNTIME"] = "Runtime";
$LANG["IMDB_VOTES"] = "Votes";
$LANG["IMDB_ACTORS"] = "Actors";
$LANG["IMDB_PLOT"] = "Plot";
$LANG["IMDB_SHORT"] = "IMDB";
$LANG["IMDB_LASTUPDATED"] = "Last Updated";
Search : torrents-upload.php
$shortfname = $torrent = $matches[1];
if (!empty($_POST["name"]))
$name = $_POST["name"];
Add After :
if (!empty($_POST['imdb']))
$imdb = unesc($_POST['imdb']);
Search :
print ("<tr><td align='right'>" . T_("TORRENT_NAME") . ": </td><td align='left'><input type='text' name='name' size='60' value='" . $_POST['name'] . "' /><br />".T_("THIS_WILL_BE_TAKEN_TORRENT")." \n</td></tr>");
Add After :
print ("<tr><td align='right'>" . T_("IMDB") . ": </td><td align='left'> <input type='text' name='imdb' size='60' value='" . $_POST['imdb'] . "' /><br />(Link from IMDB. <b>Only for movie.</b>)<br /><font color=red><b>You Must include a Imdb at all times on Upload</b></font>\n</td></tr>");
Search :
$ret = SQL_Query_exec("INSERT INTO torrents (filename, owner, name, descr, image1, image2, category, added, info_hash, size, numfiles, save_as, announce, external, nfo, torrentlang, anon, last_action) VALUES (".sqlesc($fname).", '".$CURUSER['id']."', ".sqlesc($name).", ".sqlesc($descr).", '".$inames[0]."', '".$inames[1]."', '".$catid."', '" . get_date_time() . "', '".$infohash."', '".$torrentsize."', '".$filecount."', ".sqlesc($fname).", '".$announce."', '".$external."', '".$nfo."', '".$langid."','$anon', '".get_date_time()."')");
Replace with:
$ret = SQL_Query_exec("INSERT INTO torrents (filename, owner, name, descr, image1, image2, category, added, info_hash, size, numfiles, save_as, announce, external, nfo, torrentlang, anon, last_action, imdb) VALUES (".sqlesc($fname).", '".$CURUSER['id']."', ".sqlesc($name).", ".sqlesc($descr).", '".$inames[0]."', '".$inames[1]."', '".$catid."', '" . get_date_time() . "', '".$infohash."', '".$torrentsize."', '".$filecount."', ".sqlesc($fname).", '".$announce."', '".$external."', '".$nfo."', '".$langid."','$anon', '".get_date_time()."', '".$imdb."')");
torrents-details.php Search :
torrents.name,
Add After :
torrents.imdb,
Search :
//END DEFINE RATING VARIABLE
echo "<br />";
Add After :
$TTIMDB = new TTIMDB;
if ((($_data = $TTCache->Get("imdb/$id", 900)) === false) && ($_data = $TTIMDB->Get($row['imdb']))){
$_data->Poster = $TTIMDB->getImage($_data->Poster, $id);
if ( ! isset( $_data->imdbTime ) ){
$_data->imdbTime = time();
$_data->Alias = 'N/A';
$_data->imdbVideo = null;
}
$TTCache->Set("imdb/$id", $_data, 900);
}
if ( is_object($_data) ): ?>
<fieldset class="download">
<legend><b><?php echo T_("IMDB_SHORT"); ?> - <?php echo $_data->Title; ?></b></legend>
<table border="0" cellpadding="3" cellspacing="2" width="100%">
<tr>
<td width="230"><img src="<?php echo $_data->Poster; ?>" alt="<?php echo $_data->Title; ?>" title="<?php echo $_data->Title; ?>" height="317px" width="214px" /></td>
<td valign="top">
<b><?php echo T_("IMDB_LINK"); ?></b><br /> <a href="<?php echo $row['imdb']; ?>" target="_blank"><?php echo htmlspecialchars($row['imdb']); ?></a><br /><br />
<b><?php echo T_("IMDB_RATED"); ?></b><br /> <?php echo $TTIMDB->getRated( $_data->Rated ); ?><br /><br />
<b><?php echo T_("IMDB_ALIAS"); ?></b><br /> <?php echo $_data->Alias; ?><br /><br />
<b><?php echo T_("IMDB_RELEASED"); ?></b><br /> <?php echo $TTIMDB->getReleased($_data->Released); ?><br /><br />
<b><?php echo T_("IMDB_YEAR"); ?></b><br /> <?php echo $_data->Year; ?><br /><br />
<b><?php echo T_("IMDB_RUNTIME"); ?></b><br /> <?php echo $_data->Runtime; ?><br /><br />
<b><?php echo T_("IMDB_GENRE"); ?></b><br /> <?php echo $_data->Genre; ?><br /><br />
<b><?php echo T_("IMDB_DIRECTOR"); ?></b><br /> <?php echo $_data->Director; ?><br /><br />
<b><?php echo T_("IMDB_WRITER"); ?></b><br /> <?php echo $_data->Writer; ?><br /><br />
<b><?php echo T_("IMDB_ACTORS"); ?></b><br /> <?php echo $_data->Actors; ?><br /><br />
<b><?php echo T_("IMDB_PLOT"); ?></b><br /> <?php echo $_data->Plot; ?>
</td>
<?php if (($rating = $TTIMDB->getRating($_data->imdbRating)) !== null): ?>
<td valign="top" align="center">
<?php echo $rating; ?><br /><br />
<b><?php echo T_("IMDB_VOTES"); ?></b> <?php echo $_data->imdbVotes; ?>
</td>
<?php endif; ?>
</tr>
<tr>
<td align="right" colspan="3">
<b><?php echo T_("IMDB_LASTUPDATED"); ?></b> <i><?php echo $TTIMDB->getUpdated($_data->imdbTime); ?></i>
</td>
</tr>
</table>
</fieldset>
<br />
<?php if ( strlen( $_data->imdbVideo ) > 3 ): ?>
<center><iframe src="http://www.imdb.com/video/imdb/<?php echo $_data->imdbVideo; ?>/player?stop=1" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" height="480" width="643"></iframe></center><br />
<?php endif;
endif;
torrents-edit.php Search :
if (@is_uploaded_file($nfofilename) && @filesize($nfofilename) > 0){
@move_uploaded_file($nfofilename, "$nfo_dir/$id.nfo");
$updateset[] = "nfo = 'yes'";
}//success
}
Add After :
if (!empty($_POST["name"]))
$updateset[] = "name = " . sqlesc($_POST["name"]);
if ( $_POST['imdb'] != $row['imdb'] ){
$updateset[] = "imdb = " . sqlesc($_POST["imdb"]);
$TTCache->Delete("imdb/$id");
}
Search :
echo "<tr><td class='table_col1' align='right'><b>".T_("CATEGORIES").": </b></td><td class='table_col2'>".$catdropdown."</td></tr>";
Add After :
echo "<tr><td class='table_col1' align='right'><b>".T_("IMDB")."</b></td><td class='table_col2'><input type=\"text\" name=\"imdb\" value=\"" . htmlspecialchars($row["imdb"]) . "\" size=\"60\" /></td></tr>";
@backend/functions.php add
function __autoload($f){
require_once('backend/' . $f . '.php');
}
Add the contents of the cache folder to cache imdb and chmod 0777
Add the imdb folder to root and chmod 0777
Add the uploads folder and chmod 0777 (it will add a new folder inside of uploads called imdb that also needs chmodded to 777)
Add IMDB.php and TTIMDB.php to the backend folder
Go get your free api key to use the omdb database
http://omdbapi.com/
Open backend/TTIMDB.php, add your key at the top as you see below (replace KEY_HERE with your key)
private $_nodes = array('https://omdbapi.com/?apikey=KEY_HERE&i=%s');
[ATTACH type="full"]5236[/ATTACH]
If for any reason you would like to add the image and plot description to the DB. Usually only useful if you have other mods that display these things, like site catalogs, torrent details page, the balloon mod, etc. It does no harm in adding these edits either way other than adding more info to your DB, so if a few kb of added DB size is a concern, well......... In torrents-details.php find
$TTIMDB = new TTIMDB;
if ((($_data = $TTCache->Get("imdb/$id", 900)) === false) && ($_data = $TTIMDB->Get($row['imdb']))){
$_data->Poster = $TTIMDB->getImage($_data->Poster, $id);
if ( ! isset( $_data->imdbTime ) ){
$_data->imdbTime = time();
$_data->Alias = 'N/A';
$_data->imdbVideo = null;
}
add below
/// add poster to image 1 in DB
if (($imdb_image = $TTIMDB->getImage_1($_data->Poster, $site_config['torrent_dir'] . "/images/", $id))) {
SQL_Query_exec("UPDATE `torrents` SET `image1` = '" . $imdb_image . "' WHERE `id` = $id");
}
/// end add poster to image 1 in DB
/// add a description pulled from the IMDB plot and put it in mysql as the descr
if ($row["descr"]=='No description given.'){
SQL_Query_exec("UPDATE `torrents` SET `descr` = '".mysqli_real_escape_string($GLOBALS["DBconnector"],$_data->Plot). "' WHERE `id` = $id");
}
/// end add description