Keeping with the "self-built apps," I'm going to show you how to build your own YouTube downloader. Sure you could use applications like TubeSock, but where's the fun in that? This application will download the YouTube flash video from a pasted link, and all with a little AppleScript. Continue reading to learn how to build the YouTube downloader.
Building the script
Just copy the following script into the Script Editor.app (/Applications/AppleScript/Script Editor.app):
set pageURL to display dialog "Enter the URL of the YouTube video's page:" default answer ""
set AppleScript's text item delimiters to "?v="
set v_id to item 2 of text items of text returned of pageURL
set pageURL to "http://www.youtube.com/v/" & v_id
set locationURL to do shell script "curl -I " & pageURL & " | grep ^Location | grep -o 'video_id=.*'"
set AppleScript's text item delimiters to "&t="
set t_id to item 2 of text items of locationURL
set downloadURL to "http://youtube.com/get_video?video_id=" & v_id & "&t=" & t_id
open location downloadURL
Saving the script
Let's save this AppleScript as an AppleScript application. To do this, just click File > Save. Type in a name for your appliction and choose "Application Bundle" from the "Format" drop-down box.

Running the script
To run the YouTube downloader, double-click on the AppleScript application that you just created. When the script starts, it will display a dialog asking you for a YouTube URL (this is the URL that you copy from the address bar, not from the YouTube embed). Paste the URL and click "OK." The application will then start running and run a couple background processes -- in about 1-2 minutes (depending on internet connection / Mac speed) your default browser will begin downloading a file named "get_video.flv."
Once the download has finished, you can convert the flash video into something that you can look at natively. I recommend a free application called iSquint -- you can drop the flash video onto the iSquint app and convert it into numerous formats including iPod and Apple TV.
Additional notes
- This script was designed to work on Mac OS X Tiger / Leopard.
- While this script was designed and tested to work with Safari 3.0 and Firefox, it can be used with other browsers; however, if you are experiencing difficulties with your default browser, try Safari or Firefox













Reader Comments (Page 1 of 1)
5-12-2008 @ 8:18AM
The Tuesday Night Tech Show said...
The only downside to this is that you have to convert it at the end; there is a nice Firefox greasemonkey extension that you can install that gives you a new link that downloads the actual MP4 of the video instead; no conversion needed and better quality!
----------------------
Free iPhone-Only Ringtones
ringtoneyouriphone.blogspot.com
Reply
5-12-2008 @ 8:45AM
Macskeeball said...
Indeed, and there is also a bookmarklet (Javascript stored as a bookmark, with the ability to act on the current page) available, for those who don't use Firefox. http://googlesystem.blogspot.com/2008/04/download-youtube-videos-as-mp4-files.html
5-12-2008 @ 9:00AM
Tom said...
If you install perian (free) you can view FLV files through quicktime
5-12-2008 @ 8:25AM
Luigi193 said...
I prefer just going + option + A and option clicking on the file directly...
Reply
5-12-2008 @ 8:26AM
Dinesh said...
very nice!
Thanks! This will save me the trouble of going through another site to download the FLV!
Reply
5-12-2008 @ 8:42AM
Ryan Humphreys said...
You can use a bookmarklet to download the MP4 directly from YouTube. Just create a bookmark with this as the URL:
javascript:if%20(document.getElementById('download-youtube-video')==null%20&&%20!!(document.location.href.match(/http:\/\/[a-zA-Z\.]*youtube\.com\/watch/)))%20{var%20yt_mp4_path='http://www.youtube.com/get_video?fmt=18&video_id='+swfArgs['video_id']+'&t='+swfArgs['t'];%20var%20div_embed=document.getElementById('watch-embed-div');div_embed.innerHTML=div_embed.innerHTML+'%3Cbr%20/%3E%20%3Cspan%20id=\'download-youtube-video\'%3E%3Ca%20href=\''+yt_mp4_path+'\'%3EDownload%20as%20MP4%3C/a%3E%20'+%20%20((navigator.userAgent.indexOf('Safari')!=-1)?'(control-click%20and%20select%20%3Ci%3EDownload%20linked%20file%20as%3C/i%3E)':('(right-click%20and%20select%20%3Ci%3ESave%20'+%20(navigator.appName=='Microsoft%20Internet%20Explorer'?'target':'link')%20+'%20as)%3C/i%3E'))+'%3C/span%3E';}void(0);
Then when you are on YouTube and want to download a video, click the bookmarklet and underneath the video info will appear a link saying Download as MP4. Then just Command-click on the link and choose Download Linked File As...
And there you have it, an iPod ready MP4 of the YouTube video. Hope this helps!
Reply
5-12-2008 @ 10:17AM
Queco Jones said...
That works but, the file always ends up saved with a ".html" extension added to it (no matter what I name it)... any idea on how to avoid that?
TIA,
PS: Thanks! :)
5-12-2008 @ 10:13AM
Queco Jones said...
@Ryan Humphreys: That works but, the file always ends up saved with a ".html" extension added to it (no matter what I name it)... any idea on how to avoid that?
TIA,
PS: Thanks! :)
Reply
5-12-2008 @ 10:22AM
Ryan Humphreys said...
Just change the .html extension to .mp4 and that should work. :D
5-12-2008 @ 1:40PM
mark said...
If you change the last "set" of the script to the following, you can automatically download .mp4 versions of the videos if they are available.
set downloadURL to "http://youtube.com/get_video?video_id=" & v_id & "&t=" & t_id & "&fmt=18"
Reply
5-18-2008 @ 2:14PM
Javier said...
Can someone help me by teaching me how I can download the video from Tudou.com?
It is a China version of Youtube. It's got my fav astrology programs, I'm like dying to keep all of them!! =p
http://www.tudou.com/programs/view/G9AlwaVFR74/
Reply
5-21-2008 @ 6:56AM
Matthew Dunlop said...
I tried the script a couple of times the other day (with a nice bit of Automater to automatically put it in an iTunes format using iSquint) but it now keeps bring up an error message and highlights this line---
set locationURL to do shell script "curl -I " & pageURL & " | grep ^Location | grep -o 'video_id=.*'"
Can someone help me here?
I tried it just normally in applescript but it does the same thing!
Help me please I want Youtube videos on mY iPod Touch offline!
Reply
5-25-2008 @ 11:37PM
youtube downloader said...
Here is a great tutorial about how to download youtube videos fast and easily,http://www.ehow.com/video_2287260_handle-youtube-downloader.html,it's really worth reading.
Reply
7-01-2008 @ 9:22PM
download youtube said...
i use this, i cant find better
http://www.indonesiaindonesia.com/downloadvideos/
Reply