diff options
Diffstat (limited to 'librevideojs/processor.php')
-rw-r--r-- | librevideojs/processor.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/librevideojs/processor.php b/librevideojs/processor.php new file mode 100644 index 0000000..555a081 --- /dev/null +++ b/librevideojs/processor.php @@ -0,0 +1,21 @@ +<?php + +$yturllarge = "www.youtube.com"; +$yturlshort = 'youtu.be/'; + +if (strpos($url, $yturlshort) !== false || strpos($url, $yturllarge) !== 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 + } + } +} |