Download Youtube (really, any Flash)

To download youtube videos (or any other flash file) while using Firefox the process used to be ultra-simple - look under /tmp and copy the /tmp/Fl* files. So long as you left the youtube page open in firefox and so long as the download of the video was complete you could copy the file. As soon as you close that tab in the browser the file was deleted.

More recently the files are created within the .mozilla directory (something like .mozilla/firefox/<your_profile_dir>/Cache/FlashXX<blah>) but these files are deleted as soon as the file download is complete - but the file is still cached on disk so...

Using some handy hints from http://dag.wieers.com/blog/undeleting-an-open-file-by-inode I've now done this by copying the deleted but still open files out of /proc - here's an example:

Find the firefox flash plugin process (not the main firefox process):

username@host:~$ ps auxwww | grep firefox
username    4095 16.8 10.3 600000 318068 ?       Sl   09:39  34:42 /usr/lib/firefox-3.6.18/firefox-bin
username    5287 18.6 11.2 1112724 348788 ?      Sl   11:49  14:07 /usr/lib/firefox-3.6.18/plugin-container /usr/lib/adobe-flashplugin/libflashplayer.so 4095 plugin true
username    8116  0.0  0.0   4012   776 pts/8    S+   13:05   0:00 grep firefox

Head into the /proc fd directory (in this case for PID 5287) for that process and look for flash files (note these are all deleted):

username@host:~$ cd /proc/5287/fd

username@host:/proc/5287/fd$ ls -l | grep Flash
lrwx------ 1 username groupname 64 2011-07-05 12:42 16 -> /tmp/FlashXXI1nhpt (deleted)
lrwx------ 1 username groupname 64 2011-07-05 12:42 24 -> /tmp/FlashXXXtOsi5 (deleted)
lrwx------ 1 username groupname 64 2011-07-05 12:42 25 -> /tmp/FlashXX6U0d1V (deleted)
lrwx------ 1 username groupname 64 2011-07-05 12:42 26 -> /tmp/FlashXX9MJa0Y (deleted)
lrwx------ 1 username groupname 64 2011-07-05 12:42 27 -> /tmp/FlashXXeua2gh (deleted)
lrwx------ 1 username groupname 64 2011-07-05 12:42 28 -> /tmp/FlashXXvdxsHK (deleted)
lrwx------ 1 username groupname 64 2011-07-05 12:42 29 -> /tmp/FlashXXeLFvHk (deleted)
lrwx------ 1 username groupname 64 2011-07-05 12:42 30 -> /tmp/FlashXX9Apo2a (deleted)
lrwx------ 1 username groupname 64 2011-07-05 12:42 31 -> /tmp/FlashXXgJO4Nh (deleted)
lrwx------ 1 username groupname 64 2011-07-05 12:42 32 -> /tmp/FlashXXx6KMAx (deleted)
lrwx------ 1 username groupname 64 2011-07-05 12:42 33 -> /tmp/FlashXXmDKY5Y (deleted)
lrwx------ 1 username groupname 64 2011-07-05 12:42 34 -> /tmp/FlashXXDoJ0DF (deleted)
lrwx------ 1 username groupname 64 2011-07-05 12:42 35 -> /tmp/FlashXX02zX8W (deleted)
lrwx------ 1 username groupname 64 2011-07-05 12:42 36 -> /tmp/FlashXXpsO5oq (deleted)
lrwx------ 1 username groupname 64 2011-07-05 12:42 37 -> /tmp/FlashXXeTVmh9 (deleted)
lrwx------ 1 username groupname 64 2011-07-05 12:42 38 -> /tmp/FlashXX10gs07 (deleted)
lrwx------ 1 username groupname 64 2011-07-05 12:42 39 -> /tmp/FlashXXiQUIvw (deleted)
lrwx------ 1 username groupname 64 2011-07-05 12:42 40 -> /tmp/FlashXXLV1MC7 (deleted)

By the time the files appear in this form (ie in /tmp and deleted) they appear to be complete downloads, so you could pull a bunch of flash downloads all at once and monitor this directory to check when things were complete. I also found that the numerical order of the file descriptors to be useful - they were in order of the downloads so pulling a series of flash videos it was possible to at least know the correct order).

Finally - cat each of these file descriptors into another file:

username@host:/proc/5287/fd$ ls -l | grep Flash | awk '{print $8}' | while read a ; do cat $a > /path/to/mycopy_${a}.flv ; done

At this point firefox tabs can be closed and you have copies of the flash files.

Once that's done - see Programming Notes/ExtractAudioFromFlash

BradsWiki: Programming Notes/DownloadYouTube (last edited 2011-07-05 03:57:34 by BradleyDean)