sukebei.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. $sukebei_url = "https://sukebei.nyaa.si/?q=$query";
  3. function get_sukebei_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_node = $xpath->evaluate(".//td[@colspan='2']//a[not(contains(@class, 'comments'))]/@title", $result);
  11. if ($name_node->length > 0) {
  12. $name = $name_node[0]->textContent;
  13. } else {
  14. $name = "";
  15. }
  16. $centered = $xpath->evaluate(".//td[@class='text-center']", $result);
  17. $magnet_node = $xpath->evaluate(".//a[2]/@href", $centered[0]);
  18. if ($magnet_node->length > 0) {
  19. $magnet = $magnet_node[0]->textContent;
  20. $magnet_without_tracker = explode("&tr=", $magnet)[0];
  21. $magnet = $magnet_without_tracker . $config->bittorent_trackers;
  22. } else {
  23. $magnet = "";
  24. }
  25. $size = $centered[1]->textContent;
  26. $seeders = $centered[3]->textContent;
  27. $leechers = $centered[4]->textContent;
  28. array_push($results,
  29. array (
  30. "name" => htmlspecialchars($name),
  31. "seeders" => (int) $seeders,
  32. "leechers" => (int) $leechers,
  33. "magnet" => htmlspecialchars($magnet),
  34. "size" => htmlspecialchars($size),
  35. "source" => "sukebei.nyaa.si"
  36. )
  37. );
  38. }
  39. return $results;
  40. }
  41. ?>