forked from nguyenhung1903/GET-VIDEO-YOUTUBE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GET VIDEO YOUTUBE.php
169 lines (164 loc) · 4.75 KB
/
GET VIDEO YOUTUBE.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!--
/* ======================================================
* @name GET YOUTUBE DOWNLOAD
* @version 0.0.2
* @author Nguyễn Hưng
* @copyright 2018 by TheStudySmart
* @FB fb.com/TheStudySmart
* @FB Me fb.com/NguyenHung1903
* @Website itlearning.me
* @Contact [email protected]
* @note Product not public, please don't share public
* ======================================================*/
-->
<?php
function getVideoid($url)
{
/*===============================================================================================
* Hỗ trợ get link:
*===============================================================================================
* http://youtu.be/XXXXXXXXXXX
* http://www.youtube.com/?v=XXXXXXXXXXX
* http://www.youtube.com/?v=XXXXXXXXXXX&feature=player_embedded
* http://www.youtube.com/watch?v=XXXXXXXXXXX
* http://www.youtube.com/watch?v=XXXXXXXXXXX&feature=player_embedded
* http://www.youtube.com/v/XXXXXXXXXXX
* http://www.youtube.com/e/XXXXXXXXXXX
* http://www.youtube.com/embed/XXXXXXXXXXX
* http://www.youtube.com/watch?t=40s&v=XXXXXXXXXXX
* https://www.youtube.com/watch?v=XXXXXXXXXXX&list=xxxxxxxx#t=xx
*================================================================================================*/
$video_id = false;
$url = parse_url($url);
if (strcasecmp($url['host'], 'youtu.be') === 0){
$video_id = substr($url['path'], 1);
}elseif (strcasecmp($url['host'], 'www.youtube.com') === 0){
if (isset($url['query'])){
parse_str($url['query'], $url['query']);
if (isset($url['query']['v'])){
$video_id = $url['query']['v'];
}
}
if ($video_id == false){
$url['path'] = explode('/', substr($url['path'], 1));
if (in_array($url['path'][0], array('e', 'embed', 'v'))){
$video_id = $url['path'][1];
}
}
}else{
return false;
}
return $video_id;
}?>
<?php
if (isset($_POST["sub"])){
if ($_POST["link"] != null){$Fulllink = $_POST["link"];}
$id = getVideoId($Fulllink);
}?>
<title>GET VIDEO YOUTUBE</title>
<body>
<center>
<p><b>-------------------------------------[GET VIDEO YOUTUBE]-------------------------------------</b></p>
<form method="post">
<input type="url" value="<?php if (isset($Fulllink)) echo $Fulllink;?>" name="link">
<input type="submit" value="GET" name="sub">
</form>
<?php if (isset($Fulllink)) echo "<iframe width='560' height='315' src='https://www.youtube-nocookie.com/embed/".$id."?rel=0&controls=0' frameborder='0' allow='autoplay; encrypted-media' allowfullscreen></iframe><br><br>";
?>
<?php
/*GET Link from Youtube*/
if (isset($_POST["sub"]))
if ($_POST["link"] != null){
parse_str(file_get_contents('http://www.youtube.com/get_video_info?video_id='.$id), $video_data);
$streams = $video_data['url_encoded_fmt_stream_map'];
$streams = explode(',',$streams);
$quly = 1;
foreach ($streams as $streamdata) {
parse_str($streamdata,$streamdata);
foreach ($streamdata as $key => $value) {
if ($key == "url") {
$value = urldecode($value);
$link = $value;
}
if ($key == "quality"){
$quality = $value;
if ($quality == "hd720"){
$quality = "720p";
$quly = $quly+ 1;
} elseif ($quality == "medium"){
$quality = "480p";
$quly = $quly+ 1;
if ($quly == 4){
$quality = "360p";
}
}
}
}
if ($quality == "720p" or $quality == "480p" or $quality == "360p"){
echo "<a href ='".$link."' target = '_blank'>".$quality."</a>  ";
}
}
echo "<br>";
}
/*GET Link from Youtube*/
?>
<footer>
<p><b>------------------------------[ Code by Sokoda Haraki ( Nguyễn Hưng ) ]------------------------------</b></p>
</footer>
<style type="text/css" media="screen">
a{
-webkit-transition: 0.3s;
}
a:link, a:visited {
border: 2px solid white;
color: white;
padding: 14px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
}
body{
background-color: Black;
margin-top:10%;
}
a:hover {
transition: 0.3s;
background-color: white;
color:black;
}
a:active{
background-color: #eeeeee;
color:black;
}
input[type = url]{
width: 540px;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
border: 2px solid white;
background-color: Black;
color: white;
}
input[type = submit]{
width: 80px;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
border: 2px solid white;
background-color: Black;
color: white;
}
input[type = submit]:hover{
transition: 0.3s;
background-color: white;
color:black;
}
iframe{
border: 2px solid white;
}
p{
color:white;
}
</style>
</center>
</body>