librex/engines/bittorrent/1337x.php

40 lines
1.6 KiB
PHP
Raw Normal View History

2023-02-03 21:01:28 +00:00
<?php
$_1337x_url = "https://1337x.tw/search/$query/1/";
function get_1337x_results($response)
{
try {
global $config;
$xpath = get_xpath($response);
$results = array();
2023-02-03 21:01:28 +00:00
foreach($xpath->query("//table/tbody/tr") as $result)
{
2023-02-03 21:01:28 +00:00
$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;
2023-02-03 21:01:28 +00:00
array_push($results,
array (
"name" => htmlspecialchars($name),
"seeders" => (int) $seeders,
"leechers" => (int) $leechers,
"magnet" => htmlspecialchars($magnet),
"size" => htmlspecialchars($size),
"source" => "1337x.tw"
)
);
}
2023-02-03 21:01:28 +00:00
return $results;
} catch (Error $e) {
return array();
}
2023-02-03 21:01:28 +00:00
}
?>