nyaa.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. $nyaa_url = "https://nyaa.si/?q=$query";
  3. function get_nyaa_results($response)
  4. {
  5. global $config;
  6. $xpath = get_xpath($response);
  7. $results = array();
  8. foreach($xpath->query("//tbody/tr") as $result)
  9. {
  10. $name = $xpath->evaluate(".//td[@colspan='2']//a[not(contains(@class, 'comments'))]/@title", $result)[0]->textContent;
  11. $centered = $xpath->evaluate(".//td[@class='text-center']", $result);
  12. $magnet = $xpath->evaluate(".//a[2]/@href", $centered[0])[0]->textContent;
  13. $magnet_without_tracker = explode("&tr=", $magnet)[0];
  14. $magnet = $magnet_without_tracker . $config->bittorent_trackers;
  15. $size = $centered[1]->textContent;
  16. $seeders = $centered[3]->textContent;
  17. $leechers = $centered[4]->textContent;
  18. array_push($results,
  19. array (
  20. "name" => htmlspecialchars($name),
  21. "seeders" => (int) $seeders,
  22. "leechers" => (int) $leechers,
  23. "magnet" => htmlspecialchars($magnet),
  24. "size" => htmlspecialchars($size),
  25. "source" => "nyaa.si"
  26. )
  27. );
  28. }
  29. return $results;
  30. }
  31. ?>