librex/engines/bittorrent/yts.php

46 lines
1.5 KiB
PHP
Raw Normal View History

2023-02-03 21:01:28 +00:00
<?php
$yts_url = "https://yts.mx/api/v2/list_movies.json?query_term=$query";
2023-02-03 21:01:28 +00:00
function get_yts_results($response)
{
try {
2023-02-03 21:01:28 +00:00
global $config;
$results = array();
$json_response = json_decode($response, true);
if ($json_response["status"] == "ok" && $json_response["data"]["movie_count"] != 0) {
foreach ($json_response["data"]["movies"] as $movie) {
$name = $movie["title"];
$name_encoded = urlencode($name);
2023-02-03 21:01:28 +00:00
foreach ($movie["torrents"] as $torrent) {
2023-02-03 21:01:28 +00:00
$hash = $torrent["hash"];
$seeders = $torrent["seeds"];
$leechers = $torrent["peers"];
$size = $torrent["size"];
2023-02-03 21:01:28 +00:00
$magnet = "magnet:?xt=urn:btih:$hash&dn=$name_encoded$config->bittorent_trackers";
2023-02-03 21:01:28 +00:00
array_push(
$results,
array(
2023-02-03 21:01:28 +00:00
"size" => htmlspecialchars($size),
"name" => htmlspecialchars($name),
"seeders" => htmlspecialchars($seeders),
"leechers" => htmlspecialchars($leechers),
"magnet" => htmlspecialchars($magnet),
"source" => "yts.mx"
)
);
}
2023-02-03 21:01:28 +00:00
}
}
return $results;
} catch (Error $e) {
return array();
2023-02-03 21:01:28 +00:00
}
}
?>