用户输入后如何在终端中读取歌曲名称并从 youtube 下载 mp3

How to read the name of song in terminal after user input and download mp3 from youtube

我尝试使用此代码并在命令行中将参数传递给带有脚本的文件,但它不起作用,它只读取我输入的内容而不下载 mp3。 我如何首先在命令行中输入歌曲名称,然后将此名称用于脚本并从 youtube 视频下载 mp3 歌曲? 也许不使用参数,只使用读取命令,然后在脚本中传递歌曲名称并从 youtube 视频下载 mp3。

curl -s " " | grep '<span class="title video-title "' | cut -d\> -f2 | cut -d\< -f1
curl -s " "  | grep "watch?" | cut -d\" -f4| while read video;
do youtube-dl -x --audio-format mp3 "http://www.youtube.com$video"/home/viacheslav/IdeaProjects/untitled/untitled/script
done

使用 ytsearch: 关键字在 YouTube 上搜索:

read -p 'Song name: ' SONG
youtube-dl -x --audio-format mp3 "ytsearch:$SONG"