blob: 579a1eeed00fadbec33d3d7caf3a8fcc46d7f589 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
<?php
$yturllarge = "www.youtube.com";
$ytmobile = "m.youtube.com";
$yturlshort = 'youtu.be/';
if (strpos($url, $yturlshort) !== false || strpos($url, $yturllarge) !== false || strpos($url, $ytmobile) !== false){
$link = $url;
$id = substr($link, -11); //Extract the youtube video ID
$format = "video/webm"; //the MIME type of the video. e.g. video/webm, etc.
parse_str(file_get_contents("https://youtube.com/get_video_info?video_id=".$id),$info); //decode the data
$streams = $info['url_encoded_fmt_stream_map'];
$streams = explode(',',$streams);
foreach($streams as $stream){
parse_str($stream,$data); //decode the stream
if(stripos($data['type'],$format) !== false){ //We've found the right stream with the correct format
$videoyt = $data['url']; //the video
}
}
}
|