2023-02-03 21:01:28 +00:00
|
|
|
<?php
|
2023-04-11 19:40:17 +00:00
|
|
|
$nyaa_url = "https://nyaa.si/?q=$query";
|
2023-02-03 21:01:28 +00:00
|
|
|
|
2023-04-11 19:40:17 +00:00
|
|
|
function get_nyaa_results($response)
|
|
|
|
{
|
|
|
|
try {
|
2023-02-03 21:01:28 +00:00
|
|
|
global $config;
|
|
|
|
$xpath = get_xpath($response);
|
|
|
|
$results = array();
|
|
|
|
|
2023-04-11 19:40:17 +00:00
|
|
|
foreach ($xpath->query("//tbody/tr") as $result) {
|
2023-02-03 21:01:28 +00:00
|
|
|
$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;
|
2023-04-11 19:40:17 +00:00
|
|
|
$size = $centered[1]->textContent;
|
|
|
|
$seeders = $centered[3]->textContent;
|
|
|
|
$leechers = $centered[4]->textContent;
|
2023-02-03 21:01:28 +00:00
|
|
|
|
2023-04-11 19:40:17 +00:00
|
|
|
array_push(
|
|
|
|
$results,
|
|
|
|
array(
|
2023-02-03 21:01:28 +00:00
|
|
|
"name" => htmlspecialchars($name),
|
|
|
|
"seeders" => (int) $seeders,
|
|
|
|
"leechers" => (int) $leechers,
|
|
|
|
"magnet" => htmlspecialchars($magnet),
|
|
|
|
"size" => htmlspecialchars($size),
|
|
|
|
"source" => "nyaa.si"
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $results;
|
2023-04-11 19:40:17 +00:00
|
|
|
} catch (Error $e) {
|
|
|
|
return array();
|
2023-02-03 21:01:28 +00:00
|
|
|
}
|
2023-04-11 19:40:17 +00:00
|
|
|
}
|
|
|
|
?>
|