Repeat Bash Prompts
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 youtube-dl, I set out to create a bash script my wife could use to download as much music as she wanted!
Almost a decade ago I wrote about using a text file to download with youtube-dl 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:
while true; do read -p "What is the YouTube link? " answer youtube-dl --extract-audio --audio-format mp3 $answer done;
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!
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!