Youtube Downloader (youtube-dl) Helper Script

28 September , 2013 Bill Bash Programming

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

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."

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>

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.

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.


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

bash, how to, linux, media, programming,

5 Responses to “Youtube Downloader (youtube-dl) Helper Script”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Powered by WordPress. Designed by elogi.