-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcouchpotato-yifi.php
73 lines (58 loc) · 2.26 KB
/
couchpotato-yifi.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
//header("Content-Type: text/plain; charset=utf-8");
header('Content-Type: application/json; charset=utf-8');
//$username = $_GET["username"];
//$passkey = $_GET["passkey"];
$imdbid = (isset($_GET["imdbid"]) ? $_GET["imdbid"] : "");
$search = (isset($_GET["search"]) ? urlencode($_GET["search"]) : "");;
$url = "https://yts.ag/api/v2/list_movies.json?query_term=".$imdbid."&quality=1080p";
$agent= 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
//print_r($url);
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$filename = realpath(dirname(__FILE__))."/run.log";
$log = fopen($filename, "a");
fwrite($log, date("Y-m-d\TH:i:sP")." - REQUEST: ".$actual_link."\n");
fwrite($log, date("Y-m-d\TH:i:sP")." - RESPONSE: ".$url."\n");
fclose($log);
try{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
$result=curl_exec($ch);
$result = json_decode($result, true);
//print_r($result);
if($result['data']['movie_count'] <= 0){
echo json_encode(array("error" => "not found"));
exit;
}
$response = array();
foreach($result['data']['movies'] as $row){
//var_dump($row);
$name = $row['title_english'].".".$row['year'].'.1080p.BluRay-[YTS.AG]';
$movie['release_name'] = $name;
$movie['torrent_id'] = $row['id'];
$movie['details_url'] = $row['url'];
$movie['imdb_id'] = $row['imdb_code'];
foreach($row['torrents'] as $torrent){
if($torrent['quality'] == '1080p'){
$movie['download_url'] = $torrent['url'];
$movie['freeleech'] = true;
$movie['type'] = 'movie';
$movie['size'] = round($torrent['size_bytes']/1024/1024,2);
$movie['leechers'] = $torrent['peers'];
$movie['seeders'] = $torrent['seeds'];
break;
}
}
array_push($response, $movie);
}
//print_r($response);
//print_r(json_encode(array("results"=>$response, "total_results"=>count($response))));
echo json_encode(array("results"=>$response, "total_results"=>count($response)),JSON_NUMERIC_CHECK);
} catch (Exception $e) {
echo "error: ". $e->getMessage();
}
?>