LibreY- privacy respecting meta search engine |
git clone git://git.acid.vegas/LibreY.git |
Log | Files | Refs | Archive | README | LICENSE |
yts.php (1754B)
1 <?php 2 class YTSRequest extends EngineRequest { 3 public function get_request_url() { 4 return "https://yts.mx/api/v2/list_movies.json?query_term=" . urlencode($this->query); 5 } 6 7 public function parse_results($response) { 8 $response = curl_multi_getcontent($this->ch); 9 $results = array(); 10 $json_response = json_decode($response, true); 11 12 if ($json_response["status"] != "ok" || $json_response["data"]["movie_count"] == 0) 13 return $results; 14 15 foreach ($json_response["data"]["movies"] as $movie) 16 { 17 $name = $movie["title"]; 18 $name_encoded = urlencode($name); 19 20 foreach ($movie["torrents"] as $torrent) 21 { 22 23 $hash = $torrent["hash"]; 24 $seeders = $torrent["seeds"]; 25 $leechers = $torrent["peers"]; 26 $size = $torrent["size"]; 27 28 $magnet = "magnet:?xt=urn:btih:$hash&dn=$name_encoded" . $this->opts->bittorrent_trackers; 29 30 array_push($results, 31 array ( 32 "size" => htmlspecialchars($size), 33 "name" => htmlspecialchars($name), 34 "seeders" => htmlspecialchars($seeders), 35 "leechers" => htmlspecialchars($leechers), 36 "magnet" => htmlspecialchars($magnet), 37 "source" => "yts.mx" 38 ) 39 ); 40 } 41 } 42 43 return $results; 44 } 45 } 46 ?>