下载安装 youtube-dl
下载地址
php实现代码
public function youTuBeDlTool($template){
$string = ('youtube-dl ' . escapeshellarg($this->mp4_url) . ' -f 18 -o ' .escapeshellarg($template));
$descriptorspec = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout
2 => array("pipe", "w"), // stderr
);
$process = proc_open($string, $descriptorspec, $pipes);
$stdout = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[2]);
$ret = proc_close($process);
$result =[];
$result['status'] = $ret;
$result['errors'] = $stderr;
$result['web_url'] = $this->web_url;
$result['output'] = $template;
$result['command'] = $string;
return $result;
}
网友评论