我正在使用exec
php函数来运行以mp3格式抓取YouTube视频的脚本(使用youtube-dl
)。
在这个脚本的最后我做了echo
,这是我想要的结果。
但是当我启动我的php页面时,输出由youtbe-dl
所做的所有内容组成。像那样:
[youtube] zTkS9SvhHUI: Downloading webpage
[youtube] zTkS9SvhHUI: Downloading video info webpage
[youtube] zTkS9SvhHUI: Extracting video information
[youtube] zTkS9SvhHUI: Downloading js player en_US-vflgFv_Kx
[youtube] zTkS9SvhHUI: Downloading js player en_US-vflgFv_Kx
[download] Destination: /var/www/xxx/mp3dl/Kaskade - Whatever Ft KOLAJ (NEUS Remix).webm
[download] 0.0% of 3.84MiB at 10.17KiB/s ETA 06:26
[download] 0.1% of 3.84MiB at 30.44KiB/s ETA 02:09
[. . .]
[download] 100.0% of 3.84MiB at 4.01MiB/s ETA 00:00
[download] 100% of 3.84MiB in 00:00
[ffmpeg] Destination: /var/www/xxx/mp3dl/Kaskade - Whatever Ft KOLAJ (NEUS Remix).mp3
Deleting original file /var/www/xxx/mp3dl/Kaskade - Whatever Ft KOLAJ (NEUS Remix).webm (pass -k to keep)
/var/www/xxx/mp3dl/Kaskade - Whatever Ft KOLAJ (NEUS Remix).mp3
我唯一需要的是:
/var/www/xxx/mp3dl/Kaskade - Whatever Ft KOLAJ (NEUS Remix).mp3
我该怎么做?有什么我不明白的吗?
编辑:有我的PHP代码:
$url = htmlspecialchars($_POST['url']);
$choice1 = $_POST['choice1'];
$output = exec('sh scripts/ytdlmp3_direct.sh "'.$url.'"');
if(isset($_POST['action'])){
if(empty($url)) {
print("<div class='card-panel yellow'>Please add a URL</div>") ;
} else {
if($choice1 == "download") {
print $output;
} elseif($choice1 == "store") {
print "Soon";
}
}
}
谢谢! 〜昆汀
答案 0 :(得分:1)