Download YouTube Videos The Light Way

by longtom & longtomjr

I have an oldish PC. Ok – it's an old brick. I know, I know. That means that downloading videos from the popular hosting sites like YouTube always meant use of quite a lot of resources. So, I was browsing around for a program that could do this cheaply in a terminal. I found youtube-dl.

I tried it and it worked very well. I figured out how to make sure the resolution I like is downloaded, the file name is the way I want it. etc.

Longtomjr felt it would be a lot cooler to make this easier to use with a bash script and zenity.

So this is what you need to do.

Download youtube-dl from here. Right click on the date and choose "Save Link As..." This will give you the most up-to-date version of youtube-dl, which is a Python script with no external dependencies (making it safe to use on your system, without fear of borking your installation).

Meanwhile, download longtomjr’s custom bash script, Youdl.sh, from here, or enter the following in your favorite text editor (saving it as youdl.sh):

#!/bin/bash

cd ~/Downloads

szAnswer=$(zenity --entry --text "Enter Link" --entry-text "link"); echo $szAnswer

szReso=$(zenity  --list  --text "Chose Resolution" --radiolist  --column "Pick" --column "Resolution" False "720" True "480" FALSE "360" FALSE "240");

echo $szReso

szSavePath=$(zenity --file-selection --directory);echo $szSavePath

cd $szSavePath

if [ $szReso == 720 ]  

then

~/bin/youtube-dl.py -l -f 45 $szAnswer

fi

if [ $szReso == 480 ]  

then

~/bin/youtube-dl.py -l -f 35 $szAnswer

fi

if [ $szReso == 360 ]  

then

~/bin/youtube-dl.py -l -f 34 $szAnswer

fi

if [ $szReso == 240 ]  

then

~/bin/youtube-dl.py -l -f 5 $szAnswer

fi

zenity --info --text "Session complete, press ok"

Create a folder /home/you/bin, and copy youtube-dl and Youdl.sh into /home/you/bin. Be sure that both files are marked to be run as an application.

At that point, I renamed youtube-dl to youtube-dl.py

Run Youdl.sh in a terminal. It will run without a terminal, but then you can't see the progress.

We decided to make a .desktop file in order to have it in the menu (PCLinuxOS LXDE).

If you would like something similar, here is the .desktop file. Alternatively, you can enter the following in your favorite text editor, and save it as YouTubeLight.desktop (or any other name that you wish to call it).

[Desktop Entry]
Name=YouTube downloader
GenericName=Download Manager
Comment=Simple Youtube Download Manager
Exec=/home/
longtom/bin/Youdl.sh
Icon=/home/
longtom/icons/YT_download.png
Encoding=UTF-8
Version=0.1
Type=Application
Terminal=true
StartupNotify=false
Categories=Utility;X-MandrivaLinux-System-FileTools;

Replace the red text with your username, and save it in /home/you/.local/share/applications/. (Thanks, Leiche!)

That's where we called it a day. It does what we wanted and then some. Maybe you will find some use for it, too.

We found that it works with:

YouTube.com.

YouTube.com playlists (playlist URLs in "view_play_list" form).

YouTube.com searches, using the special keyword "ytsearch" as a form of URL, as in "ytsearch:cute kittens". Do not forget the quotes if you want to include spaces in your search. Other variants are "ytsearchN" to download more than the first result, with N being a number, and "ytsearchall".

YouTube.com user videos, using user page URLs or the specifc "ytuser" keyword.

metacafe.com.

Google Video.

Google Video searches ("gvsearch" keyword).

Photobucket videos.

Yahoo! video.

Yahoo! video searches ("ybsearch" keyword).

Dailymotion.

DepositFiles.

blip.tv.

vimeo.

myvideo.de.

The Daily Show/Colbert Nation.

The Escapist.

A generic downloader that works in some sites.

There you go! Now you can join me and Junior in downloading YouTube videos (and videos from other streaming sites) the light way.