merge.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. function get_merged_torrent_results($query)
  3. {
  4. require "engines/bittorrent/thepiratebay.php";
  5. require "engines/bittorrent/rutor.php";
  6. require "engines/bittorrent/nyaa.php";
  7. require "engines/bittorrent/yts.php";
  8. $results = array_merge(get_thepiratebay_results($query),
  9. get_rutor_results($query),
  10. get_nyaa_results($query),
  11. get_yts_results($query));
  12. $seeders = array_column($results, "seeders");
  13. array_multisort($seeders, SORT_DESC, $results);
  14. return $results;
  15. }
  16. function print_merged_torrent_results($results)
  17. {
  18. echo "<div class=\"text-result-container\">";
  19. if (!empty($results))
  20. {
  21. foreach($results as $result)
  22. {
  23. $source = $result["source"];
  24. $name = $result["name"];
  25. $magnet = $result["magnet"];
  26. $seeders = $result["seeders"];
  27. $leechers = $result["leechers"];
  28. $size = $result["size"];
  29. echo "<div class=\"text-result-wrapper\">";
  30. echo "<a href=\"$magnet\">";
  31. echo "$source";
  32. echo "<h2>$name</h2>";
  33. echo "</a>";
  34. echo "<span>SE: <span style=\"color:#50fa7b\">$seeders</span> - ";
  35. echo "LE: <span style=\"color:#ff79c6\">$leechers</span> - ";
  36. echo "$size</span>";
  37. echo "</div>";
  38. }
  39. }
  40. else
  41. echo "<p>There are no results. Please try different keywords!</p>";
  42. echo "</div>";
  43. }
  44. ?>