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

  • By
    Write Simple, Elegant and Maintainable Media Queries with Sass

    I spent a few months experimenting with different approaches for writing simple, elegant and maintainable media queries with Sass. Each solution had something that I really liked, but I couldn't find one that covered everything I needed to do, so I ventured into creating my...

  • By
    Create a CSS Cube

    CSS cubes really showcase what CSS has become over the years, evolving from simple color and dimension directives to a language capable of creating deep, creative visuals.  Add animation and you've got something really neat.  Unfortunately each CSS cube tutorial I've read is a bit...

Incredible Demos

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!