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 savvy but she relies on me to make 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 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!


  • 9 Mind-Blowing Canvas Demos

    The <canvas> element has been a revelation for the visual experts among our ranks.  Canvas provides the means for incredible and efficient animations with the added bonus of no Flash; these developers can flash their awesome JavaScript skills instead.  Here are nine unbelievable canvas demos that…

  • How to Create a Twitter Card
  • Advanced CSS Tables II &#8211; Using Mootools JavaScript For Alternate Row Colors
  • MooTools 1.2 Image Protector: dwProtector

    Image protection is a hot topic on the net these days, and why shouldn’t it be? If you spent two hours designing an awesome graphic, would you want it ripped of in matter of seconds? Hell no! That’s why I’ve created an image…



Source link
thanks you RSS link
( https://davidwalsh.name/-bash-)

LEAVE A REPLY

Please enter your comment!
Please enter your name here