yts.php 1.5 KB

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