烈焰重击
I'm sure you wont be surprised when I tell you it's my job to automate things in our my household. My wife is tech savvy but she relies on me to make tech matters easy for everyone; I guess it's flattering that she trusts me to do that. One easy task she's trusted me with is make it easy to grab music from YouTube so she can put it on her phone or rock to on AudioShield. I could probably point her to numerous sites that do that conversion but most are filled with disgusting ads and malware. Since I love , I set out to create a bash script my wife could use to download as much music as she wanted!
我敢肯定,当我告诉您将自己家里的东西自动化是我的工作时,您不会感到惊讶。 我的妻子精通技术,但是她依靠我来使每个人都可以轻松解决技术问题。 我猜她相信我能做到这一点很讨人喜欢。 她信任我的一项简单任务就是轻松从YouTube抓取音乐,以便将其放在手机上或放在AudioShield上。 我可能会指出她是进行转换的众多网站,但大多数网站都充满了令人恶心的广告和恶意软件。 由于我喜欢 ,因此我着手创建一个bash脚本,我的妻子可以使用该脚本下载所需的任意音乐!
Almost a decade ago I wrote about but even that's a bit annoying for most people. I could make a web interface but that seemed like too much I created a bash script to repeatedly ask for a YouTube link which to download and convert to MP3:
大约十年前,我写过一篇关于但这对大多数人来说还是有点烦人。 我可以创建一个Web界面,但这似乎太多了,我创建了一个bash脚本来反复询问要下载并转换为MP3的YouTube链接:
while true; do read -p "What is the YouTube link? " answer youtube-dl --extract-audio --audio-format mp3 $answerdone;
The script repeatedly asks for a YouTube link, downloads and converts to mp3, then asks for YouTube link again. I created a desktop shortcut for this script to make usage even easier. An easy script to make music download easy!
该脚本反复询问YouTube链接,下载并转换为mp3,然后再次询问YouTube链接。 我为此脚本创建了一个桌面快捷方式,以使使用更加容易。 一个简单的脚本,使音乐下载变得容易!
Of course the script could use some validation (i.e. that it's a link from YouTube) but I trust that we'll paste a valid link. The key takeaway is that while true; do ...done
will allow you to create repeated loop in a bash script!
当然,脚本可以使用一些验证(即,这是来自YouTube的链接),但是我相信我们会粘贴有效的链接。 关键要点是, while true; do ...done
while true; do ...done
将允许您在bash脚本中创建重复循环!
翻译自:
烈焰重击