使用php exec运行youtube-dl

我正在尝试使用PHP exec()以JSON格式获取视频详细信息
我的CentOS服务器上安装了youtube-dl
通过youtube-dl -J <VideoURL> / SSH运行Terminal很好。
我的test.php脚本返回空白页:(

echo exec("youtube-dl -J <VideoURL>");
//Installed via pip

//OR

echo exec("python /home/site/youtube-dl -J <VideoURL>");
//Downloaded as file named youtube-dl
如果我像这样测试,则启用

exec

if(function_exists('exec')) {
    echo "exec is enabled";
}
服务器未

IP被YouTube阻止,因为我能够通过终端成功运行命令

shellingnie 回答:使用php exec运行youtube-dl

通过在我的test.php文件中执行以下操作,我就能实现您的目标

<?php

if(function_exists('shell_exec')) {
    header('Content-Type: application/json');
    echo shell_exec("youtube-dl -J https://www.youtube.com/watch?v=zGDzdps75ns");
}

?>
本文链接:https://www.f2er.com/3156976.html

大家都在问