Download Youtube Videos Via Command Line (Cross Platform)
January 3rd, 2007 - By: Alex BaileyIf you don't want to slow your browser down with Firefox extensions, or you think you're a command line guru then check out youtube-dl. It's an open source script written in python. It'll work on any system capable of running python, including Windows, Linux, and Mac OS. There are a few handy options to name the video the name of the youtube title, simulate the download, and output no text (quite mode). It also currently supports user and passwords for videos dubbed inappropriate to users under 18 as well.

The file extension type of the downloaded video is an flv. To open it, I use the cross platform video player VLC. It'll also open in mplayer.
There really is no install directions for this script, but there are a few commands needed to get it working. Download the script, and name the file "youtube" without the quotes.
chmod 744 youtube (Make the file executable)
mv youtube /usr/bin (Optional, makes it so you don't have to type the direct path to the file each time)
youtube inserturlhere











1. ramunasg | January 4th, 2007 @ 8:35 AM |
+8
You can also convert flv to mpeg or other format if you have ffmpeg installed, like this:
ffmpeg -i downloaded.flv output.mpeg
2. Ryan | January 4th, 2007 @ 9:16 AM |
+3
I’ve been trying to figure something out like this for quite sometime. Thanks for sharing.
ffmpeg I knew about but this I guess I just didn’t spend enough time trying to research it.
Anyways, thanks again!
3. John | January 4th, 2007 @ 9:29 AM |
+2
chmod 744 will make the file only executable by its owner and readable by everyone (rwxr–r–), you probably meant 755 (rwxr-xr-x)
4. troy | January 4th, 2007 @ 9:30 AM |
+1
Is it possible that you guys can write a youtube video uploader? make my life a whole lot easier!
5. KyleGoetz | January 4th, 2007 @ 10:21 AM |
+0
As a suggestion for the next update, why not use the “re” module to grab the title of the video with this regular expression:
‘<title>YouTube - (?P<nameofvid>.+?)</title>’
6. vadi | January 4th, 2007 @ 10:43 AM |
+0
sexy product dude! thanx!
7. Jon | January 4th, 2007 @ 8:59 PM |
+1
Does this work on XBMC as well?
8. Lao | January 4th, 2007 @ 9:49 PM |
+0
Why am I getting a “invalid syntax” error from line 102 (do I need a title?)…….
I _do_ like this script, though!
9. JCMets4112 | January 5th, 2007 @ 8:31 AM |
+0
This is gonna sound like a really dumb question, but..
What does it mean to “download the script?” I have the Python interpreter. But by download the script..does it mean save the text to a notepad file? save the entire page as an HTML document? I’m a little new to this and I don’t really know what download the script actually means.
10. Alex Bailey | January 5th, 2007 @ 8:36 AM |
+0
[quote comment="5694"]This is gonna sound like a really dumb question, but..
What does it mean to “download the script?” I have the Python interpreter. But by download the script..does it mean save the text to a notepad file? save the entire page as an HTML document? I’m a little new to this and I don’t really know what download the script actually means.[/quote]
Open this link in your browser, and go to File > Save as. Save it as “youtube”. Then you need to download the python interpreter if your OS doesn’t come with it. (Windows doesn’t)
[quote]
Why am I getting a “invalid syntax†error from line 102 (do I need a title?)…….
I _do_ like this script, though!
[/quote]
What syntax are you using?
[quote]
Does this work on XBMC as well?
[/quote]
No idea, if it supports python and has internet it should.
11. Damon | February 6th, 2007 @ 8:18 PM |
+0
[quote comment="5648"]Why am I getting a “invalid syntax” error from line 102 (do I need a title?)…….
[/quote]
That’s likely because you are using a version of python less than 2.4. Python 2.4 or greater is required to run the script.
12. Savetube | February 9th, 2007 @ 7:41 AM |
+0
I use savetube.com to save any youtube video.
13. zephro | February 23rd, 2007 @ 3:23 AM |
+0
Nice. But, is there anything i can get thatl allow cmd to use this pythons script on a system WITHOUT having python installed?
I knoww that IMVU uses something for its python scripts :P
14. Alex Bailey | February 23rd, 2007 @ 7:45 AM |
+1
[quote comment="11406"]Nice. But, is there anything i can get thatl allow cmd to use this pythons script on a system WITHOUT having python installed?
I knoww that IMVU uses something for its python scripts :P[/quote]
No of course not :). You can use alternative things such as the “video downloader” extension for Firefox.
I wrote a tutorial about how to do this for my Free Music Videos Site. You can find it here:
Download Youtube Videos
15. Bay | May 25th, 2007 @ 3:42 AM |
+0
Why am I getting this error ?
File “./youtube”, line 97
title = ”.join((x in string.ascii_letters or x in string.digits) and x or ‘ ‘ for x in title)
Thanks for your help..
16. rajey | May 29th, 2007 @ 9:48 PM |
+1
i am getting invalid syntax.
17. Brian | June 20th, 2007 @ 2:25 PM |
+0
This seems quite complex. I prefer using ZillaTube. It downloads youtube videos quickly, plays them too.
zillatube.com
18. tomparker | February 22nd, 2008 @ 9:07 PM |
+0
DOES ANYONE KNOW WHERE I CAN DOWNLOAD A YOUTUBE VIDEO DOWNLOADER FOR A MACBOOK! I cant find one any where and this wont even download! please email me with a link it would be very much appreciated!
Leave a comment