开发者

How can I download youtube videos php?

I am looking for anyway to download video from youtube ... Of course I used and tried all codes and scripts , all of them are failure ...

Therefore I want开发者_Go百科 the new code that help me ...


Use an external tool for that. youtube-dl comes to mind, and is simple to utilize from within PHP:

$url = escapeshellcmd($url);
exec("youtube-dl $url -O /tmp/video.flv");


<?php
 // The YouTube ID
 $key = "Ct5KJKBI9kc";
 // Get all info for video
 $output = file_get_contents('http://www.youtube.com/get_video_info?&video_id='.$key);
 // Parse data to eg.(&id=var)
 parse_str($output);
 // Get Quality map of video an set array
if(isset($url_encoded_fmt_stream_map)) {
 $my_formats_array = explode(',',$url_encoded_fmt_stream_map);
} 
 // Set Array & Vars
 $avail_formats[] = '';
 $i = 0;
 // Break up array to create download links to quality
 foreach($my_formats_array as $format) {
 parse_str($format);
echo "<a download='". $title .".mp4' href='".$avail_formats[$i]['url'] = urldecode($url) . '&signature=' . $sig."'>". $title .".mp4</a> Quality - ".$quality."<br>"; $i++; } ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜