Youtube Downloader (youtube-dl) Helper Script

Youtube Downloader (youtube-dl) Helper Script

5 Comments on Youtube Downloader (youtube-dl) Helper Script

Introduction
I have created a very simple script to help with downloading Youtube videos. The script will display a list of available formats, ask what format you would like to download and correctly name the file that is being downloaded.

The Script

#!/bin/bash
echo "youtube-dl helper"
echo "================="
echo -n "video to download: "
read video
echo "getting video filename..."
filename=$(youtube-dl --get-filename -o "%(title)s.%(ext)s" $video)
echo "getting available video formats..."
youtube-dl -F $video
echo "file to download is '"$filename"'..."
echo -n "video format: "
read format
echo "downloading video..."
youtube-dl -v -f $format -o "%(title)s.%(ext)s" $video
echo "download complete."

Installation
You need to install youtube-dl which downloads the Youtube video. The script above just helps in the use of youtube-dl.

sudo apt-get install youtube-dl

Simply create a text file anywhere and copy the above script contents to the file. When the file has been saved, right click the file and select “Allow executing file as a program” in permissions. The following command will also change the file permission to executable

chmod +x <filename>

Usage
Run the script by dragging and dropping the script in a terminal window and pressing enter. It will ask you for the video you would like to download. Enter the whole URL or just the video code.
example…

https://www.youtube.com/watch?v=gWiMZkntIbk
or
gWiMZkntIbk

After enter has been pressed it will gather information like the title to display an example of the file name and a list of available file formats. When the list of available formats has been displayed enter the corresponding number displayed on the left side of the format you would like to download. After enter has been pressed the file will be downloaded to the current directory.

youtube-dl-helper

Let me know in the comments below if you find this helpful.

About the author:

Bill Payne started working as a paid professional software developer at the young age of 12 years old developing simple games and other applications for pre-packaged computers. Bill has since developed software for many industries such as direct sales and the the stock market. Bill has now started sharing his many years of software development experience through a blog on the MPSHouse website and one on one lessons.

5 Comments

  1. jezra  - 30 September , 2013 - 2:11 pm
    Reply /

    Thank you.
    This is a very handy script.

    • bill  - 30 September , 2013 - 5:23 pm
      Reply /

      You are welcome… If at least one person found this small and simple script handy, it was worth posting it :)

  2. dru8274  - 2 October , 2013 - 1:17 pm
    Reply /

    Thanks for the script – nice work :-)

  3. Raksi  - 8 October , 2013 - 11:28 pm
    Reply /

    Good job. Thanks.

  4. Filip  - 16 February , 2014 - 10:16 pm
    Reply /

    Great script, here is a tip i used:
    open terminal and write:
    1. gedit ~/.bashrc
    2. at the end of file add:
    dl_youtubevideo() {
    here paste all the script content
    }
    3. save and exit
    4. source ~/.bashrc
    5. start the script by typing dl_youtubevideo

Leave a comment

Back to Top