yts.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. $yts_url = "https://yts.mx/api/v2/list_movies.json?query_term=$query";
  3. function get_yts_results($response)
  4. {
  5. global $config;
  6. $results = array();
  7. $json_response = json_decode($response, true);
  8. if ($json_response["status"] == "ok" && $json_response["data"]["movie_count"] != 0)
  9. {
  10. foreach ($json_response["data"]["movies"] as $movie)
  11. {
  12. $name = $movie["title"];
  13. $name_encoded = urlencode($name);
  14. foreach ($movie["torrents"] as $torrent)
  15. {
  16. $hash = $torrent["hash"];
  17. $seeders = $torrent["seeds"];
  18. $leechers = $torrent["peers"];
  19. $size = $torrent["size"];
  20. $magnet = "magnet:?xt=urn:btih:$hash&dn=$name_encoded$config->bittorent_trackers";
  21. array_push($results,
  22. array (
  23. "size" => htmlspecialchars($size),
  24. "name" => htmlspecialchars($name),
  25. "seeders" => htmlspecialchars($seeders),
  26. "leechers" => htmlspecialchars($leechers),
  27. "magnet" => htmlspecialchars($magnet),
  28. "source" => "yts.mx"
  29. )
  30. );
  31. }
  32. }
  33. }
  34. return $results;
  35. }
  36. ?>