-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathapp.php
51 lines (44 loc) · 1.5 KB
/
app.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
<?php
require "./vendor/autoload.php";
use JonnyW\PhantomJs\Client;
$video = $_GET['id'];
if($video == ''){
echo "Where is the media ID?"; //https://openload.co/embed/7zLUwKrlQqCk (The ID is "7zLUwKrlQqCk" in this case)
exit();
}else{
$client = Client::getInstance();
if(strpos($video, '.') !== False){
$video = explode('.', $video)[0];
}
$request = $client->getMessageFactory()->createRequest("https://openload.co/embed/$video", 'GET');
$response = $client->getMessageFactory()->createResponse();
$client->send($request, $response);
if($response->getStatus() === 200) {
$openload = $response->getContent();
if(strpos($openload, 'We are sorry!') !== False){
echo json_encode(array('error' => '404', 'msg' => 'File not found'));
exit();
}
$openload = explode('<span id="streamurl">', $openload)[1];
$file = 'https://openload.co/stream/'.explode('</span>', $openload)[0].'?mime=true';
$headers = get_headers($file,1);
//Final Args
$filename = explode('?', end(explode('/',$headers['Location'])))[0];
$file = explode('?', $headers['Location'])[0];
$size = $headers['Content-Length'];
//Download Code
set_time_limit(0);
header('Content-Type: video/mp4');
header('Content-Length: '.$size);
$f = fopen($file, "rb");
while (!feof($f)) {
echo fread($f, 8*1024);
flush();
ob_flush();
}
exit();
}else{
echo json_encode(array('error' => $response->getStatus(), 'msg' => 'Server error'));
exit();
}
}