Skip to content

Instantly share code, notes, and snippets.

@malikkurosaki
Created March 7, 2018 10:11
Show Gist options
  • Save malikkurosaki/6db376fc77dfd153ec45e1b06e630b43 to your computer and use it in GitHub Desktop.
Save malikkurosaki/6db376fc77dfd153ec45e1b06e630b43 to your computer and use it in GitHub Desktop.
download youtube video to server
<?php
preg_match("/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:m\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed)\/))([^\?&\"'>]+)/","https://www.youtube.com/watch?v=W8drxRl1fiY",$gtlk);
//echo $gtlk[1];
$fg = file_get_contents("https://www.youtube.com/get_video_info?video_id=".$gtlk[1]."&cpn=CouQulsSRICzWn5E&eurl&el=adunit");
$xp = explode(",",$fg);
parse_str($xp[0],$rst);
$url = $rst['url_encoded_fmt_stream_map'];
parse_str($url,$hasil);
echo $judul = $rst['title']; //get title
echo "<br><hr>";
echo $urlvid = $hasil['url']; // get url
file_put_contents($judul."satu.3gp",fopen($urlvid,'r'));
echo "sukses";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment