Script for downloading Youtube videos
Forum: Programming and Scripting
Topic: Script for downloading Youtube videos
started by: curaga
Posted by curaga on June 26 2007,16:13Don't look at me like that, I know it isn't useful.
But I just read Advanced bash scripting guide and I had to try my skills on something.. So < here >'s a very much enhanced version of the one from nixcraft.
I added some looks, clarity, comments, help switch, ability to get urls from nearly unlimited number of args...
After download they can be watched with Mplayer or flash player, and edited with mencoder..
Try and comment it
Posted by WDef on June 26 2007,19:36Hey Curaga,
Not sure about this:
to test if the beginning of the argument string is http://
EDIT: forget it, what you have works. I wasn't looking at the double brackets.
Posted by u2musicmike on June 30 2007,15:36I couldn't get it working. I think it bombs out on the mktemp part. I tried another name for tmp and it got further along. Then it looked like error 303 on the wget. Oh well interesting script.
Posted by curaga on July 01 2007,05:44I didn't create it on DSL, so mktemp might be missing. Just replace it with a name..
Isn't error 303 just a redirection? I get something like that always, Youtube has 3 servers to balance traffic..
Posted by curaga on July 01 2007,06:19More detailed usage:
Go to the Youtube video page you wish to download. Like here's a video of DSL:
< http://www.youtube.com/watch?v=prjQ7MwuCWI >
Copy that url. Then open Aterm and start this script (youtubedl if you haven't renamed)
and when it asks for that url, paste it there..
Or call it as "youtubedl < http://www.youtube.com/watch?v=prjQ7MwuCWI" >
Posted by jpeters on July 04 2007,19:29I copied the script to a file called "rip" , and ran "rip [the youtube URL]"; produced a "wget --n invalid option" error. No doubt, I'm missing something obvious.
Usage: wget [-c|--continue] [-q|--quiet] [-O|--output-document file]
[--header 'header: value'] [-Y|--proxy on/off] [-P DIR] url
Posted by ^thehatsrule^ on July 04 2007,20:40That's probably due to the wget from busybox...
Posted by curaga on July 05 2007,08:52I did have full wget.. That seems the right solution for busybox version
Posted by jpeters on July 05 2007,19:50
Doesn't matter; the script doesn't work even with the full wget installed. I don't know much about mktemp, but I tried it with that and directing to a file 'mktp'
EDIT: Problem was those little single quotes around mktemp didn't copy correctly; things almost working, although:
Resolving youtube.com... 184.108.40.206, 220.127.116.11
Connecting to youtube.com[18.104.22.168]:80... connected.
HTTP request sent, awaiting response... 303 See Other
00:56:25 ERROR 303: See Other.
Posted by curaga on July 06 2007,08:24I had this fully working.. But I personally haven't tested on DSL.
Those aren't single quotes, those are "backquotes" meaning the output of that command will be there:
VAR=`mktemp` VAR will have the output of mktemp
VAR='mktemp' VAR will have "mktemp"
I'll edit it for DSL needs. The link will stay the same.
Posted by jpeters on July 06 2007,08:45With the backquotes, the variable $tmp was void. I guess I don't understand something.
Posted by curaga on July 06 2007,09:05I now updated it, as you see from the beginning comments ;)
Posted by jpeters on July 06 2007,09:24Looks the same; are you sure it linked?
Posted by curaga on July 06 2007,09:47See the
#edited to work better with DSL?
I just removed wgets -nv switch and made $tmp a stable name
Posted by jpeters on July 06 2007,10:07Same 303 errors. Maybe tomorrow...
Posted by curaga on July 06 2007,10:44error 303 is supposed to be there. I get it always. Maybe busybox wget exits on that, but full wget does as it should and redirects there?
Posted by lucky13 on July 06 2007,11:58The 303 error is there because of the php script (get_video.php) at youtube that redirects to their content subservers. You probably never get 303 errors in your browser, unless you encounter a site with broken redirection chains, because browser engines handle that in the background. With wget, probably regardless of "real" wget or busybox, you get raw output. The 303 error isn't related to the wget script, it's on youtube's server side.
Posted by jpeters on July 06 2007,16:12
Bottom line is an empty file. I've used apt-get's wget and the one that comes with gnu-utils.
Posted by u2musicmike on July 10 2007,15:59I never got this script working but I didn't try to run it as root. Maybe the php script isn't working anymore? Anyway I really don't download many youtube videos so I have been using this link to download: < http://www.kissyoutube.com/watch?v=prjQ7MwuCWI >
Does anyone know what program converts flv to divx?
Posted by curaga on July 10 2007,16:04mencoder
Posted by curaga on July 15 2007,07:04I just used this to get Jeff Buckley's Hallelujah. Still works fine, though this was not on DSL..
Posted by curaga on Sep. 18 2007,18:37Okay, Youtube changed their video downloading possibilities, in an attempt to prevent downloading their videos. So here's a new ver that can still download