php 中 youtube-dl的使用

2019-08-28  本文已影响0人  顶尖少爷

下载安装 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;
    }

上一篇 下一篇

猜你喜欢

热点阅读