Repeat Bash Prompts

By  on  

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!

Recent Features

Incredible Demos

  • By
    NSFW Blocker Using MooTools and CSS

    One of my guilty pleasures is scoping out the latest celebrity gossip from PerezHilton.com, DListed.com, and JoBlo.com. Unfortunately, these sites occasionally post NSFW pictures which makes checking these sites on lunch a huge gamble -- a trip to HR's office could be just a click away. Since...

  • By
    MooTools Documentation Search Favelet

    I'm going to share something with you that will blow your mind: I don't have the MooTools documentation memorized. I just don't. I visit the MooTools docs frequently to figure out the order of parameters of More classes and how best to use...

Discussion

  1. test
    
    
    • test

      adsadsad

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!