-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.php
68 lines (51 loc) · 1.59 KB
/
index.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
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
if (isset($_REQUEST['video-url'])) {
include('other_php_files/functions.php');
include('other_php_files/arrays.php');
include('classes/VideoGetterClass.php');
$video_link = $_REQUEST['video-url'];
if (!isValidURL($video_link) || empty($video_link)) {
$result = array(
'status' => 'error',
'message' => 'Not a valid URL'
);
header('Content-Type: application/json');
echo json_encode($result);
die();
}
$url_host = parse_url($video_link)['host'];
if (in_array($url_host, $facebookHosts)) {
VideoGetterClass::getFacebookVideoInfoByParsing($video_link);
}
elseif (in_array($url_host, $instagramHosts)) {
VideoGetterClass::getInstagramVideoInfoByParsing($video_link);
}
elseif (in_array($url_host, $dailymotionHosts)) {
VideoGetterClass::getDailymotionVideoInfoByParsing($video_link);
}
else{
$youtube_dl_provided_json = shell_exec("youtube-dl --skip-download --dump-single-json --no-warnings " .$video_link. " 2>&1");
if (isJSON($youtube_dl_provided_json)) {
$url_host = parse_url($video_link)['host'];
if (in_array($url_host, $facebookHosts)) {
VideoGetterClass::getFacebookVideoInfoByParsing($video_link);
}
else{
$youtube_dl_provided_json_decoded_array = json_decode($youtube_dl_provided_json, true);
VideoGetterClass::getVideoInfo($youtube_dl_provided_json_decoded_array);
}
}
else{
http_response_code(410);
die('Invalid json provided from youtube-dl.');
}
}
}
else{
http_response_code(406);
die('Required valid video url.');
}
?>