HowTo: Download YouTube videos (the easy way)

25 01 2010

Update: The Adobe Flash Player used to cache the .flv video files in the /tmp directory, so one could just copy the file from the directory after it was completely loaded and with the browser tab still active (!important).

This has changed. The Adobe Flash Player now deletes the file after it finished caching and keeps a so calles handle on it. Liori explains this very clearly and I blockquote the how to. Thanks!

Now we need to use two tools. First is lsof, which shows all opened handles by all processes. The key knowledge is that the deleted file is still created as /tmp/Flash*. Lets find the handle:

lsof|grep Flash

firefox-b 23220 liori 83u REG 254,0 10565348 929 /tmp/FlashXXQCq4K0 (deleted)

I added lsof’s header to make it clearer. Note that funny (deleted) remark—when you check the contents of /tmp, you won’t see that file! We’re interested in the PID and the FD number. FD is the opened handle’s number, and PID is an identifier used to distinguish different programs.

Second tool is the /proc filesystem. This is a special directory existing on all commonly used Linux installations. It contains data about running system: driver settings, process list, diagnostic information. What’s most interesting is that it contains files representing all opened file handles. In our case (PID=23220 and FD=83) the handle representing our deleted file is /proc/23220/fd/83. Again, if you just try to list that directory, you will only see a broken symlink. But what if you do this?

cat /proc/23220/fd/83 >video.flv
…you’ll get the contents of the deleted file!

This technique is of course not only useful to grab videos downloaded by your flash plugin. Any time you delete a file, but realize that it is still opened by some program, you can recover it.

This is the old post quoting FRuMMaGe on Ubuntuforums

Many people have been asking how to download youtube videos, and kept being pointed to useless software which will do it for them.

Here is the easy way:

Step 1: Find the video you want to download and wait for it to completely finish loading.

Step 2: Minimize your browser (do NOT close it, some browsers delete the temp directory upon closing), and navigate to the directory /tmp

Step 3: Drag the flash file onto your desktop. Voila!

This definitely works with firefox, and probably most other browsers aswell. Enjoy!




One response

25 01 2010

in ubuntu flash videos when they load 100% can be found at /tmp folder.
also you can use a firefox plugin Video (DownloadHelper or 1-Click YouTube Video Download)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: