2022-02-25 16:26:15 -03:00
|
|
|
<?php
|
|
|
|
function get_nyaa_results($query)
|
|
|
|
{
|
2022-03-11 06:04:36 -03:00
|
|
|
global $config;
|
2022-02-25 16:26:15 -03:00
|
|
|
|
|
|
|
$url = "https://nyaa.si/?q=$query";
|
|
|
|
$response = request($url);
|
|
|
|
$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];
|
2022-03-11 06:04:36 -03:00
|
|
|
$magnet = $magnet_without_tracker . $config->bittorent_trackers;
|
2022-02-25 16:26:15 -03:00
|
|
|
$size = $centered[1]->textContent;
|
|
|
|
$seeders = $centered[3]->textContent;
|
|
|
|
$leechers = $centered[4]->textContent;
|
|
|
|
|
|
|
|
array_push($results,
|
|
|
|
array (
|
|
|
|
"name" => $name,
|
|
|
|
"seeders" => (int) $seeders,
|
|
|
|
"leechers" => (int) $leechers,
|
|
|
|
"magnet" => $magnet,
|
|
|
|
"size" => $size,
|
|
|
|
"source" => "nyaa.si"
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
?>
|