The easiest way to download YouTube videos is to use youtube-dl.

To install it using Debian based distribution like Ubuntu use command:

$ sudo apt-get install youtube-dl

Example usage:

$ youtube-dl
[youtube] Setting language
[youtube] O5D1O7eb_H4: Downloading video webpage
[youtube] O5D1O7eb_H4: Downloading video info webpage
[youtube] O5D1O7eb_H4: Extracting video information
[download] Destination: O5D1O7eb_H4.flv
[download] 100.0% of 124.37M at   87.78k/s ETA 00:00