运行 youtube-dl 与 php exec
Running youtube-dl with php exec
我正在尝试使用 PHP exec()
JSON 获取视频详细信息
我的 CentOS 服务器上安装了 youtube-dl
。
运行 youtube-dl -J <VideoURL>
通过 SSH
/Terminal
就可以了。
我的 test.php
脚本 returns 空页 :(
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 阻止,因为我能够通过终端成功 运行 命令
通过在我的 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");
}
?>
我正在尝试使用 PHP exec()
JSON 获取视频详细信息
我的 CentOS 服务器上安装了 youtube-dl
。
运行 youtube-dl -J <VideoURL>
通过 SSH
/Terminal
就可以了。
我的 test.php
脚本 returns 空页 :(
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 阻止,因为我能够通过终端成功 运行 命令
通过在我的 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");
}
?>