use engine request for torrent search
This commit is contained in:
parent
0bd726d897
commit
4941a6aa58
9 changed files with 268 additions and 308 deletions
|
@ -1,34 +1,39 @@
|
|||
<?php
|
||||
$_1337x_url = "https://1337x.to/search/$query/1/";
|
||||
|
||||
function get_1337x_results($response)
|
||||
{
|
||||
global $config;
|
||||
$xpath = get_xpath($response);
|
||||
$results = array();
|
||||
|
||||
foreach($xpath->query("//table/tbody/tr") as $result)
|
||||
{
|
||||
|
||||
$name = $xpath->evaluate(".//td[@class='coll-1 name']/a", $result)[1]->textContent;
|
||||
$magnet = "./engines/bittorrent/get_magnet_1337x.php?url=https://1337x.to" . $xpath->evaluate(".//td[@class='coll-1 name']/a/@href", $result)[1]->textContent;
|
||||
$size_unformatted = explode(" ", $xpath->evaluate(".//td[contains(@class, 'coll-4 size')]", $result)[0]->textContent);
|
||||
$size = $size_unformatted[0] . " " . preg_replace("/[0-9]+/", "", $size_unformatted[1]);
|
||||
$seeders = $xpath->evaluate(".//td[@class='coll-2 seeds']", $result)[0]->textContent;
|
||||
$leechers = $xpath->evaluate(".//td[@class='coll-3 leeches']", $result)[0]->textContent;
|
||||
|
||||
array_push($results,
|
||||
array (
|
||||
"name" => htmlspecialchars($name),
|
||||
"seeders" => (int) $seeders,
|
||||
"leechers" => (int) $leechers,
|
||||
"magnet" => htmlspecialchars($magnet),
|
||||
"size" => htmlspecialchars($size),
|
||||
"source" => "1337x.to"
|
||||
)
|
||||
);
|
||||
class _1337xRequest extends EngineRequest {
|
||||
public function get_request_url() {
|
||||
$query = urlencode($this->query);
|
||||
return "https://1337x.to/search/$query/1/";
|
||||
}
|
||||
|
||||
return $results;
|
||||
public function get_results() {
|
||||
$response = curl_multi_getcontent($this->ch);
|
||||
|
||||
$xpath = get_xpath($response);
|
||||
$results = array();
|
||||
|
||||
foreach($xpath->query("//table/tbody/tr") as $result)
|
||||
{
|
||||
|
||||
$name = $xpath->evaluate(".//td[@class='coll-1 name']/a", $result)[1]->textContent;
|
||||
$magnet = "./engines/bittorrent/get_magnet_1337x.php?url=https://1337x.to" . $xpath->evaluate(".//td[@class='coll-1 name']/a/@href", $result)[1]->textContent;
|
||||
$size_unformatted = explode(" ", $xpath->evaluate(".//td[contains(@class, 'coll-4 size')]", $result)[0]->textContent);
|
||||
$size = $size_unformatted[0] . " " . preg_replace("/[0-9]+/", "", $size_unformatted[1]);
|
||||
$seeders = $xpath->evaluate(".//td[@class='coll-2 seeds']", $result)[0]->textContent;
|
||||
$leechers = $xpath->evaluate(".//td[@class='coll-3 leeches']", $result)[0]->textContent;
|
||||
|
||||
array_push($results,
|
||||
array (
|
||||
"name" => htmlspecialchars($name),
|
||||
"seeders" => (int) $seeders,
|
||||
"leechers" => (int) $leechers,
|
||||
"magnet" => htmlspecialchars($magnet),
|
||||
"size" => htmlspecialchars($size),
|
||||
"source" => "1337x.to"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -4,68 +4,32 @@
|
|||
$this->query = $query;
|
||||
$this->page = $page;
|
||||
|
||||
// TODO make these engine requests
|
||||
require "engines/bittorrent/thepiratebay.php";
|
||||
require "engines/bittorrent/rutor.php";
|
||||
require "engines/bittorrent/nyaa.php";
|
||||
require "engines/bittorrent/yts.php";
|
||||
require "engines/bittorrent/torrentgalaxy.php";
|
||||
require "engines/bittorrent/1337x.php";
|
||||
require "engines/bittorrent/sukebei.php";
|
||||
|
||||
$query = urlencode($query);
|
||||
|
||||
$torrent_urls = array(
|
||||
$thepiratebay_url,
|
||||
$rutor_url,
|
||||
$nyaa_url,
|
||||
$yts_url,
|
||||
$torrentgalaxy_url,
|
||||
$_1337x_url,
|
||||
$sukebei_url
|
||||
$this->requests = array(
|
||||
new PirateBayRequest($query, $page, $mh, $config),
|
||||
new _1337xRequest($query, $page, $mh, $config),
|
||||
new NyaaRequest($query, $page, $mh, $config),
|
||||
new RutorRequest($query, $page, $mh, $config),
|
||||
new SukebeiRequest($query, $page, $mh, $config),
|
||||
new TorrentGalaxyRequest($query, $page, $mh, $config),
|
||||
new YTSRequest($query, $page, $mh, $config),
|
||||
);
|
||||
|
||||
$this->chs = array();
|
||||
|
||||
foreach ($torrent_urls as $url)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt_array($ch, $config->curl_settings);
|
||||
array_push($this->chs, $ch);
|
||||
curl_multi_add_handle($mh, $ch);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_results() {
|
||||
$query = urlencode($this->query);
|
||||
$results = array();
|
||||
for ($i=0; count($this->chs)>$i; $i++)
|
||||
{
|
||||
$response = curl_multi_getcontent($this->chs[$i]);
|
||||
|
||||
switch ($i)
|
||||
{
|
||||
case 0:
|
||||
$results = array_merge($results, get_thepiratebay_results($response));
|
||||
break;
|
||||
case 1:
|
||||
$results = array_merge($results, get_rutor_results($response));
|
||||
break;
|
||||
case 2:
|
||||
$results = array_merge($results, get_nyaa_results($response));
|
||||
break;
|
||||
case 3:
|
||||
$results = array_merge($results, get_yts_results($response));
|
||||
break;
|
||||
case 4:
|
||||
//$results = array_merge($results, get_torrentgalaxy_results($response));
|
||||
break;
|
||||
case 5:
|
||||
//$results = array_merge($results, get_1337x_results($response));
|
||||
break;
|
||||
case 6:
|
||||
$results = array_merge($results, get_sukebei_results($response));
|
||||
break;
|
||||
foreach ($this->requests as $request) {
|
||||
error_log($request->get_request_url());
|
||||
error_log( curl_getinfo($request->ch)['http_code'] );
|
||||
if ($request->successful()) {
|
||||
$results = array_merge($results, $request->get_results());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,30 +42,29 @@
|
|||
public static function print_results($results) {
|
||||
echo "<div class=\"text-result-container\">";
|
||||
|
||||
if (!empty($results))
|
||||
{
|
||||
foreach($results as $result)
|
||||
{
|
||||
$source = $result["source"];
|
||||
$name = $result["name"];
|
||||
$magnet = $result["magnet"];
|
||||
$seeders = $result["seeders"];
|
||||
$leechers = $result["leechers"];
|
||||
$size = $result["size"];
|
||||
|
||||
echo "<div class=\"text-result-wrapper\">";
|
||||
echo "<a href=\"$magnet\">";
|
||||
echo "$source";
|
||||
echo "<h2>$name</h2>";
|
||||
echo "</a>";
|
||||
echo "<span>SE: <span class=\"seeders\">$seeders</span> - ";
|
||||
echo "LE: <span class=\"leechers\">$leechers</span> - ";
|
||||
echo "$size</span>";
|
||||
echo "</div>";
|
||||
}
|
||||
}
|
||||
else
|
||||
if (empty($results)) {
|
||||
echo "<p>There are no results. Please try different keywords!</p>";
|
||||
return;
|
||||
}
|
||||
|
||||
foreach($results as $result) {
|
||||
$source = $result["source"];
|
||||
$name = $result["name"];
|
||||
$magnet = $result["magnet"];
|
||||
$seeders = $result["seeders"];
|
||||
$leechers = $result["leechers"];
|
||||
$size = $result["size"];
|
||||
|
||||
echo "<div class=\"text-result-wrapper\">";
|
||||
echo "<a href=\"$magnet\">";
|
||||
echo "$source";
|
||||
echo "<h2>$name</h2>";
|
||||
echo "</a>";
|
||||
echo "<span>SE: <span class=\"seeders\">$seeders</span> - ";
|
||||
echo "LE: <span class=\"leechers\">$leechers</span> - ";
|
||||
echo "$size</span>";
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
echo "</div>";
|
||||
}
|
||||
|
|
|
@ -1,35 +1,50 @@
|
|||
<?php
|
||||
$nyaa_url = "https://nyaa.si/?q=$query";
|
||||
class NyaaRequest extends EngineRequest {
|
||||
public $SOURCE = "nyaa.si";
|
||||
|
||||
function get_nyaa_results($response)
|
||||
{
|
||||
global $config;
|
||||
$xpath = get_xpath($response);
|
||||
$results = array();
|
||||
|
||||
foreach($xpath->query("//tbody/tr") as $result)
|
||||
{
|
||||
$name = $xpath->evaluate(".//td[@colspan='2']//a[not(contains(@class, 'comments'))]/@title", $result)[0]->textContent;
|
||||
$centered = $xpath->evaluate(".//td[@class='text-center']", $result);
|
||||
$magnet = $xpath->evaluate(".//a[2]/@href", $centered[0])[0]->textContent;
|
||||
$magnet_without_tracker = explode("&tr=", $magnet)[0];
|
||||
$magnet = $magnet_without_tracker . $config->bittorent_trackers;
|
||||
$size = $centered[1]->textContent;
|
||||
$seeders = $centered[3]->textContent;
|
||||
$leechers = $centered[4]->textContent;
|
||||
|
||||
array_push($results,
|
||||
array (
|
||||
"name" => htmlspecialchars($name),
|
||||
"seeders" => (int) $seeders,
|
||||
"leechers" => (int) $leechers,
|
||||
"magnet" => htmlspecialchars($magnet),
|
||||
"size" => htmlspecialchars($size),
|
||||
"source" => "nyaa.si"
|
||||
)
|
||||
);
|
||||
public function get_request_url() {
|
||||
return "https://$this->SOURCE/?q=" . urlencode($this->query);
|
||||
}
|
||||
|
||||
return $results;
|
||||
public function get_results() {
|
||||
$response = curl_multi_getcontent($this->ch);
|
||||
$xpath = get_xpath($response);
|
||||
$results = array();
|
||||
|
||||
foreach($xpath->query("//tbody/tr") as $result)
|
||||
{
|
||||
$name_node = $xpath->evaluate(".//td[@colspan='2']//a[not(contains(@class, 'comments'))]/@title", $result);
|
||||
if ($name_node->length > 0) {
|
||||
$name = $name_node[0]->textContent;
|
||||
} else {
|
||||
$name = "";
|
||||
}
|
||||
$centered = $xpath->evaluate(".//td[@class='text-center']", $result);
|
||||
$magnet_node = $xpath->evaluate(".//a[2]/@href", $centered[0]);
|
||||
if ($magnet_node->length > 0) {
|
||||
$magnet = $magnet_node[0]->textContent;
|
||||
$magnet_without_tracker = explode("&tr=", $magnet)[0];
|
||||
$magnet = $magnet_without_tracker . $this->config->bittorent_trackers;
|
||||
} else {
|
||||
$magnet = "";
|
||||
}
|
||||
$size = $centered[1]->textContent;
|
||||
$seeders = $centered[3]->textContent;
|
||||
$leechers = $centered[4]->textContent;
|
||||
|
||||
array_push($results,
|
||||
array (
|
||||
"name" => htmlspecialchars($name),
|
||||
"seeders" => (int) $seeders,
|
||||
"leechers" => (int) $leechers,
|
||||
"magnet" => htmlspecialchars($magnet),
|
||||
"size" => htmlspecialchars($size),
|
||||
"source" => $this->SOURCE
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,36 +1,39 @@
|
|||
<?php
|
||||
$rutor_url = "http://rutor.info/search/$query";
|
||||
|
||||
function get_rutor_results($response)
|
||||
{
|
||||
global $config;
|
||||
$xpath = get_xpath($response);
|
||||
$results = array();
|
||||
|
||||
|
||||
foreach($xpath->query("//table/tr[@class='gai' or @class='tum']") as $result)
|
||||
{
|
||||
$name = $xpath->evaluate(".//td/a", $result)[2]->textContent;
|
||||
$magnet = $xpath->evaluate(".//td/a/@href", $result)[1]->textContent;
|
||||
$magnet_without_tracker = explode("&tr=", $magnet)[0];
|
||||
$magnet = $magnet_without_tracker . $config->bittorent_trackers;
|
||||
$td = $xpath->evaluate(".//td", $result);
|
||||
$size = $td[count($td) == 5 ? 3 : 2]->textContent;
|
||||
$seeders = $xpath->evaluate(".//span", $result)[0]->textContent;
|
||||
$leechers = $xpath->evaluate(".//span", $result)[1]->textContent;
|
||||
|
||||
array_push($results,
|
||||
array (
|
||||
"name" => htmlspecialchars($name),
|
||||
"seeders" => (int) filter_var($seeders, FILTER_SANITIZE_NUMBER_INT),
|
||||
"leechers" => (int) filter_var($leechers, FILTER_SANITIZE_NUMBER_INT),
|
||||
"magnet" => htmlspecialchars($magnet),
|
||||
"size" => htmlspecialchars($size),
|
||||
"source" => "rutor.info"
|
||||
)
|
||||
);
|
||||
class RutorRequest extends EngineRequest {
|
||||
public function get_request_url() {
|
||||
return "http://rutor.info/search/" . urlencode($this->query);
|
||||
}
|
||||
|
||||
return $results;
|
||||
public function get_results() {
|
||||
$response = curl_multi_getcontent($this->ch);
|
||||
$xpath = get_xpath($response);
|
||||
$results = array();
|
||||
|
||||
|
||||
foreach($xpath->query("//table/tr[@class='gai' or @class='tum']") as $result)
|
||||
{
|
||||
$name = $xpath->evaluate(".//td/a", $result)[2]->textContent;
|
||||
$magnet = $xpath->evaluate(".//td/a/@href", $result)[1]->textContent;
|
||||
$magnet_without_tracker = explode("&tr=", $magnet)[0];
|
||||
$magnet = $magnet_without_tracker . $this->config->bittorent_trackers;
|
||||
$td = $xpath->evaluate(".//td", $result);
|
||||
$size = $td[count($td) == 5 ? 3 : 2]->textContent;
|
||||
$seeders = $xpath->evaluate(".//span", $result)[0]->textContent;
|
||||
$leechers = $xpath->evaluate(".//span", $result)[1]->textContent;
|
||||
|
||||
array_push($results,
|
||||
array (
|
||||
"name" => htmlspecialchars($name),
|
||||
"seeders" => (int) filter_var($seeders, FILTER_SANITIZE_NUMBER_INT),
|
||||
"leechers" => (int) filter_var($leechers, FILTER_SANITIZE_NUMBER_INT),
|
||||
"magnet" => htmlspecialchars($magnet),
|
||||
"size" => htmlspecialchars($size),
|
||||
"source" => "rutor.info"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,44 +1,6 @@
|
|||
<?php
|
||||
$sukebei_url = "https://sukebei.nyaa.si/?q=$query";
|
||||
|
||||
function get_sukebei_results($response)
|
||||
{
|
||||
global $config;
|
||||
$xpath = get_xpath($response);
|
||||
$results = array();
|
||||
|
||||
foreach($xpath->query("//tbody/tr") as $result)
|
||||
{
|
||||
$name_node = $xpath->evaluate(".//td[@colspan='2']//a[not(contains(@class, 'comments'))]/@title", $result);
|
||||
if ($name_node->length > 0) {
|
||||
$name = $name_node[0]->textContent;
|
||||
} else {
|
||||
$name = "";
|
||||
}
|
||||
$centered = $xpath->evaluate(".//td[@class='text-center']", $result);
|
||||
$magnet_node = $xpath->evaluate(".//a[2]/@href", $centered[0]);
|
||||
if ($magnet_node->length > 0) {
|
||||
$magnet = $magnet_node[0]->textContent;
|
||||
$magnet_without_tracker = explode("&tr=", $magnet)[0];
|
||||
$magnet = $magnet_without_tracker . $config->bittorent_trackers;
|
||||
} else {
|
||||
$magnet = "";
|
||||
}
|
||||
$size = $centered[1]->textContent;
|
||||
$seeders = $centered[3]->textContent;
|
||||
$leechers = $centered[4]->textContent;
|
||||
|
||||
array_push($results,
|
||||
array (
|
||||
"name" => htmlspecialchars($name),
|
||||
"seeders" => (int) $seeders,
|
||||
"leechers" => (int) $leechers,
|
||||
"magnet" => htmlspecialchars($magnet),
|
||||
"size" => htmlspecialchars($size),
|
||||
"source" => "sukebei.nyaa.si"
|
||||
)
|
||||
);
|
||||
}
|
||||
return $results;
|
||||
include "engines/bittorrent/nyaa.php";
|
||||
class SukebeiRequest extends NyaaRequest {
|
||||
public $SOURCE = "sukebei.nyaa.si";
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,44 +1,46 @@
|
|||
<?php
|
||||
class PirateBayRequest extends EngineRequest {
|
||||
public function get_request_url() {
|
||||
return "https://apibay.org/q.php?q=" . urlencode($this->query);
|
||||
}
|
||||
|
||||
$thepiratebay_url = "https://apibay.org/q.php?q=$query";
|
||||
public function get_results() {
|
||||
$response = curl_multi_getcontent($this->ch);
|
||||
$results = array();
|
||||
$json_response = json_decode($response, true);
|
||||
|
||||
function get_thepiratebay_results($response)
|
||||
{
|
||||
global $config;
|
||||
$results = array();
|
||||
$json_response = json_decode($response, true);
|
||||
if (empty($json_response))
|
||||
{
|
||||
return $results;
|
||||
}
|
||||
|
||||
foreach ($json_response as $response)
|
||||
{
|
||||
$size = human_filesize($response["size"]);
|
||||
$hash = $response["info_hash"];
|
||||
$name = $response["name"];
|
||||
$seeders = (int) $response["seeders"];
|
||||
$leechers = (int) $response["leechers"];
|
||||
|
||||
$magnet = "magnet:?xt=urn:btih:$hash&dn=$name" . $config->bittorent_trackers;
|
||||
|
||||
if ($name == "No results returned")
|
||||
break;
|
||||
|
||||
array_push($results,
|
||||
array (
|
||||
"size" => htmlspecialchars($size),
|
||||
"name" => htmlspecialchars($name),
|
||||
"seeders" => (int) htmlspecialchars($seeders),
|
||||
"leechers" => (int) htmlspecialchars($leechers),
|
||||
"magnet" => htmlspecialchars($magnet),
|
||||
"source" => "thepiratebay.org"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($json_response))
|
||||
{
|
||||
return $results;
|
||||
|
||||
}
|
||||
|
||||
foreach ($json_response as $response)
|
||||
{
|
||||
$size = human_filesize($response["size"]);
|
||||
$hash = $response["info_hash"];
|
||||
$name = $response["name"];
|
||||
$seeders = (int) $response["seeders"];
|
||||
$leechers = (int) $response["leechers"];
|
||||
|
||||
$magnet = "magnet:?xt=urn:btih:$hash&dn=$name" . $config->bittorent_trackers;
|
||||
|
||||
if ($name == "No results returned")
|
||||
break;
|
||||
|
||||
array_push($results,
|
||||
array (
|
||||
"size" => htmlspecialchars($size),
|
||||
"name" => htmlspecialchars($name),
|
||||
"seeders" => (int) htmlspecialchars($seeders),
|
||||
"leechers" => (int) htmlspecialchars($leechers),
|
||||
"magnet" => htmlspecialchars($magnet),
|
||||
"source" => "thepiratebay.org"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,34 +1,38 @@
|
|||
<?php
|
||||
$torrentgalaxy_url = "https://torrentgalaxy.to/torrents.php?search=$query#results";
|
||||
|
||||
function get_torrentgalaxy_results($response)
|
||||
{
|
||||
global $config;
|
||||
$xpath = get_xpath($response);
|
||||
$results = array();
|
||||
|
||||
foreach($xpath->query("//div[@class='tgxtablerow txlight']") as $result)
|
||||
{
|
||||
$name = $xpath->evaluate(".//div[contains(@class, 'clickable-row')]", $result)[0]->textContent;
|
||||
$magnet = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/a/@href", $result)[1]->textContent;
|
||||
$magnet_without_tracker = explode("&tr=", $magnet)[0];
|
||||
$magnet = $magnet_without_tracker . $config->bittorent_trackers;
|
||||
$size = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/span", $result)[0]->textContent;
|
||||
$seeders = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/span/font", $result)[1]->textContent;
|
||||
$leechers = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/span/font", $result)[2]->textContent;
|
||||
|
||||
array_push($results,
|
||||
array (
|
||||
"name" => htmlspecialchars($name),
|
||||
"seeders" => (int) $seeders,
|
||||
"leechers" => (int) $leechers,
|
||||
"magnet" => htmlspecialchars($magnet),
|
||||
"size" => htmlspecialchars($size),
|
||||
"source" => "torrentgalaxy.to"
|
||||
)
|
||||
);
|
||||
class TorrentGalaxyRequest extends EngineRequest {
|
||||
public function get_request_url() {
|
||||
$query = urlencode($this->query);
|
||||
return "https://torrentgalaxy.to/torrents.php?search=$query#results";
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
public function get_results() {
|
||||
$response = curl_multi_getcontent($this->ch);
|
||||
$xpath = get_xpath($response);
|
||||
$results = array();
|
||||
|
||||
foreach($xpath->query("//div[@class='tgxtablerow txlight']") as $result)
|
||||
{
|
||||
$name = $xpath->evaluate(".//div[contains(@class, 'clickable-row')]", $result)[0]->textContent;
|
||||
$magnet = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/a/@href", $result)[1]->textContent;
|
||||
$magnet_without_tracker = explode("&tr=", $magnet)[0];
|
||||
$magnet = $magnet_without_tracker . $this->config->bittorent_trackers;
|
||||
$size = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/span", $result)[0]->textContent;
|
||||
$seeders = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/span/font", $result)[1]->textContent;
|
||||
$leechers = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/span/font", $result)[2]->textContent;
|
||||
|
||||
array_push($results,
|
||||
array (
|
||||
"name" => htmlspecialchars($name),
|
||||
"seeders" => (int) $seeders,
|
||||
"leechers" => (int) $leechers,
|
||||
"magnet" => htmlspecialchars($magnet),
|
||||
"size" => htmlspecialchars($size),
|
||||
"source" => "torrentgalaxy.to"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,45 +1,47 @@
|
|||
<?php
|
||||
$yts_url = "https://yts.mx/api/v2/list_movies.json?query_term=$query";
|
||||
|
||||
function get_yts_results($response)
|
||||
{
|
||||
global $config;
|
||||
$results = array();
|
||||
$json_response = json_decode($response, true);
|
||||
|
||||
if ($json_response["status"] == "ok" && $json_response["data"]["movie_count"] != 0)
|
||||
{
|
||||
foreach ($json_response["data"]["movies"] as $movie)
|
||||
{
|
||||
$name = $movie["title"];
|
||||
$name_encoded = urlencode($name);
|
||||
|
||||
foreach ($movie["torrents"] as $torrent)
|
||||
{
|
||||
|
||||
$hash = $torrent["hash"];
|
||||
$seeders = $torrent["seeds"];
|
||||
$leechers = $torrent["peers"];
|
||||
$size = $torrent["size"];
|
||||
|
||||
$magnet = "magnet:?xt=urn:btih:$hash&dn=$name_encoded$config->bittorent_trackers";
|
||||
|
||||
array_push($results,
|
||||
array (
|
||||
"size" => htmlspecialchars($size),
|
||||
"name" => htmlspecialchars($name),
|
||||
"seeders" => htmlspecialchars($seeders),
|
||||
"leechers" => htmlspecialchars($leechers),
|
||||
"magnet" => htmlspecialchars($magnet),
|
||||
"source" => "yts.mx"
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
class YTSRequest extends EngineRequest {
|
||||
public function get_request_url() {
|
||||
return "https://yts.mx/api/v2/list_movies.json?query_term=" . urlencode($this->query);
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
||||
public function get_results() {
|
||||
$response = curl_multi_getcontent($this->ch);
|
||||
global $config;
|
||||
$results = array();
|
||||
$json_response = json_decode($response, true);
|
||||
|
||||
if ($json_response["status"] == "ok" && $json_response["data"]["movie_count"] != 0)
|
||||
{
|
||||
foreach ($json_response["data"]["movies"] as $movie)
|
||||
{
|
||||
$name = $movie["title"];
|
||||
$name_encoded = urlencode($name);
|
||||
|
||||
foreach ($movie["torrents"] as $torrent)
|
||||
{
|
||||
|
||||
$hash = $torrent["hash"];
|
||||
$seeders = $torrent["seeds"];
|
||||
$leechers = $torrent["peers"];
|
||||
$size = $torrent["size"];
|
||||
|
||||
$magnet = "magnet:?xt=urn:btih:$hash&dn=$name_encoded$config->bittorent_trackers";
|
||||
|
||||
array_push($results,
|
||||
array (
|
||||
"size" => htmlspecialchars($size),
|
||||
"name" => htmlspecialchars($name),
|
||||
"seeders" => htmlspecialchars($seeders),
|
||||
"leechers" => htmlspecialchars($leechers),
|
||||
"magnet" => htmlspecialchars($magnet),
|
||||
"source" => "yts.mx"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
return "";
|
||||
}
|
||||
|
||||
public function successful() {
|
||||
return curl_getinfo($this->ch)['http_code'] == '200';
|
||||
}
|
||||
|
||||
abstract function get_results();
|
||||
static public function print_results($results){}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue