added 1337x to torrent results, fixed some css

This commit is contained in:
hnhx 2022-07-15 15:50:23 +02:00
parent 6959df8579
commit 57bfb483ba
7 changed files with 72 additions and 8 deletions

View File

@ -0,0 +1,34 @@
<?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"
)
);
}
return $results;
}
?>

View File

@ -0,0 +1,15 @@
<?php
require "../../misc/tools.php";
$config = require "../../config.php";
$url = $_REQUEST["url"];
$response = request($url);
$xpath = get_xpath($response);
$magnet = $xpath->query("//main/div/div/div/div/div/ul/li/a/@href")[0]->textContent;
$magnet_without_tracker = explode("&tr=", $magnet)[0];
$magnet = $magnet_without_tracker . $config->bittorent_trackers;
header("Location: $magnet")
?>

View File

@ -9,6 +9,7 @@
require "engines/bittorrent/nyaa.php";
require "engines/bittorrent/yts.php";
require "engines/bittorrent/torrentgalaxy.php";
require "engines/bittorrent/1337x.php";
$query = urlencode($query);
@ -17,7 +18,8 @@
$rutor_url,
$nyaa_url,
$yts_url,
$torrentgalaxy_url
$torrentgalaxy_url,
$_1337x_url
);
$mh = curl_multi_init();
@ -57,6 +59,9 @@
case 4:
$results = array_merge($results, get_torrentgalaxy_results($response));
break;
case 5:
$results = array_merge($results, get_1337x_results($response));
break;
}
}

View File

@ -3,7 +3,7 @@
<title>LibreX</title>
</head>
<body>
<form class="search-container" action="search.php" method="post" enctype="multipart/form-data" autocomplete="off">
<form class="search-container" action="search.php" method="get" autocomplete="off">
<h1>Libre<span class="X">X</span></h1>
<input type="text" name="q"/>
<input type="hidden" name="p" value="0"/>

View File

@ -130,7 +130,7 @@
function print_next_page_button($text, $page, $query, $type)
{
echo "<form class=\"page\" action=\"search.php\" target=\"_top\" method=\"post\" enctype=\"multipart/form-data\" autocomplete=\"off\">";
echo "<form class=\"page\" action=\"search.php\" target=\"_top\" method=\"get\" autocomplete=\"off\">";
echo "<input type=\"hidden\" name=\"p\" value=\"" . $page . "\" />";
echo "<input type=\"hidden\" name=\"q\" value=\"$query\" />";
echo "<input type=\"hidden\" name=\"type\" value=\"$type\" />";

View File

@ -3,7 +3,7 @@
<title> <?php echo $_REQUEST["q"]; ?> - LibreX</title>
</head>
<body>
<form class="sub-search-container" method="post" enctype="multipart/form-data" autocomplete="off">
<form class="sub-search-container" method="get" autocomplete="off">
<a href="./"><img class="logo" src="static/images/librex.png" alt="librex logo"></a>
<input type="text" name="q"
<?php
@ -22,7 +22,7 @@
<br>
<?php
$type = isset($_REQUEST["type"]) ? (int) $_REQUEST["type"] : 0;
echo "<input type=\"hidden\" name=\"type\" value=\"$type\"/>";
echo "<button class=\"hide\" name=\"type\" value=\"$type\"/></button>";
?>
<button type="submit" class="hide"></button>
<input type="hidden" name="p" value="0">

View File

@ -37,7 +37,7 @@ a:hover, .text-result-wrapper h2:hover {
.search-container {
text-align: center;
margin-top:15%;
margin-top: 230px;
}
.search-container h1 {
@ -154,12 +154,12 @@ a:hover, .text-result-wrapper h2:hover {
.text-result-container,
#time,
.next-page-button-wrapper {
margin-left:10%;
margin-left: 200px;
}
.text-result-container
{
margin-bottom:100px;
margin-bottom: 100px;
}
.special-result-container {
@ -360,4 +360,14 @@ a:hover, .text-result-wrapper h2:hover {
.search-container h1 {
font-size: 55px;
}
.search-container {
margin-top: 10%;
}
.text-result-container,
#time,
.next-page-button-wrapper {
margin-left: 40px;
}
}