Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   FreeTSP (http://www.bvlist.com/forumdisplay.php?f=120)
-   -   couchpotato.php (http://www.bvlist.com/showthread.php?t=10783)

Atmosos 24th March 2016 00:50

couchpotato.php
 
Hi all,

I was wondering if someone could port this for freetsp. I tried to edit the script but i failed. If someone needs an invite for my site to test please send me your email.
i have created a db field for the imdb ttcode and its also populated.

https://github.com/CouchPotato/Couch...rrent-provider

Bump: fixed it myself... only need some help on how to download the torrent without login in...

Code:


/*
* Written By: AtheistP3ace
* -> PiXELHD.me
* Adjusted by Atmosos for freetsp!
* Most of this code will work on gazelle based trackers.
* Added some extra security in as well. Some of that extra security
* will require code added to other parts of your site. All this code
* does not use any of the wrappers from original gazelle code
* except Cache which also can be stripped out if your site is small.
* Mostly you only need your specific SQL added to match your tables.
*
*/


$mysql_host = "localhost"; # Your mysql host name -- localhost is the default
$mysql_user = ""; # Your mysql username
$mysql_pass = ""; # Your mysql password
$mysql_db = ""; # Your mysql data base name


// Set content type
header('Content-Type: application/json');

// Do parameters match what we expect?

if (empty($_REQUEST['passkey']) || strlen($_REQUEST['passkey']) != 32 || (empty($_REQUEST['imdbid'])) || empty($_REQUEST['user'])) {
echo json_encode(array("error" => "Incorrect parameters."));
die();
}

// Connect to DB manually for exposed service. Variables below come from config.php loaded above
$mysqli = new mysqli($mysql_host, $mysql_user, $mysql_pass, $mysql_db);

if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}

$Username = $mysqli->escape_string($_REQUEST['user']);
$PassKey = $mysqli->escape_string($_REQUEST['passkey']);
$IMDbID = $mysqli->escape_string($_REQUEST['imdbid']);


// Get needed data on user attached to Username and passkey
// Forcing both values to be passed makes security a bit harder and allows us to make a couch potato key
$FindUserQuery = $mysqli->query("SELECT id FROM users WHERE passkey = '$PassKey' AND username = '$Username'");
// Does user exist?

if ($FindUserQuery->num_rows == 0) {
echo json_encode(array("error" => "Death by authorization."));
die();
}

$FindUserResult = mysqli_fetch_array($FindUserQuery);
$UserID = $FindUserResult['id'];


/*
* The next bit is all for security. You can remove this if you don't care about that.
* It basically checks if user is an enabled user, has permissions to access service,
* user enabled access from their profile to generate a hashed passkey. None is
* necessary but helpful if security is your thing.
*/

$MediaQuery = "SELECT
id,
name,
filename,
size,
imdbcode,
leechers,
seeders
FROM torrents
WHERE";
if (!empty($IMDbID)) {
$MediaQuery .= " imdbcode = '$IMDbID'";
}

$MediaLookupResults = $mysqli->query($MediaQuery);

// Check for results
$TotalResults = $MediaLookupResults->num_rows;
if ($TotalResults == 0) {
echo json_encode(array("total_results" => $TotalResults));
}
else {
// Initialize for output
$JSONOutput = array();

// For each returned row build JSON output
while($ResultRow = mysqli_fetch_array($MediaLookupResults)) {

// Release Name
$Name = $ResultRow['name'];

// Torrent ID
$TorrentID = $ResultRow['id'];

// Build details page URL
$DetailsURL = "http://site.com/details.php?id=".$ResultRow['id'];

// Build download URL
$DownloadURL = "http://site.com/download.php/".$ResultRow['id']."/".$ResultRow['filename']."";


// Add in IMDb ID for searches by text
$IMDB_ID = $ResultRow['imdbcode'];

// Get download size (B -> KB -> MB)
$MediaSize = round(intval($ResultRow['size']) / 1024 / 1024, 0);

// Get Leechers
$Leechers = intval($ResultRow['leechers']);

// Get Seeders
$Seeders = intval($ResultRow['seeders']);

// movie_name + edition + movie_year + resolution + audio + media + release_type
$ReleaseName = str_replace(" ", ".", $Name);

// Build array for JSON encoding
$Details = array(
"release_name" => $ReleaseName,
"torrent_id" => $TorrentID,
"details_url" => $DetailsURL,
"download_url" => $DownloadURL,
"imdb_id" => $IMDB_ID,
"size" => $MediaSize,
"leechers" => $Leechers,
"seeders" => $Seeders);

// Add to final output array
array_push($JSONOutput, $Details);
}

// Encode and return data!!
echo json_encode(array("results" => $JSONOutput, "total_results" => $TotalResults));
}


firefly007 22nd August 2016 17:20

Hi, welcome to Bvlist :)

I'm having a look...


All times are GMT +2. The time now is 14:16.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.