Copy flashvideos to disk

So if you want to save flashvideos from certain websites, you can use this little script. Flash saves all his files in /tmp but deletes them instantly from the filesystem. No file is just deleted immediate from the disk while the application, which creates the file, is running. The file is still accessible through procfs. This script actualy just search for the flashplayer and copies the open file from procfs to your home directory.

A little shell magic and every open flashvideo in any browser is saved to your disk:

FPID=`/usr/bin/pgrep -f libflashplayer.so`
DATE=`date +%d%m%y`
VDIR="$HOME/video"

rc=1
count=1


while [ $rc -eq 1 ]
do
        mkdir $HOME/video/$DATE
        rc=$?
        if [ $rc -eq 1 ]
        then
                mkdir $VDIR/$DATE-$count
                rc=$?
                let count=count+1
        fi

done

CDIR=$VDIR/`ls -tr $HOME/video/|tail -1` 

for FD in `ls -l /proc/$FPID/fd/|grep deleted|awk '{print $9}'`
do
        cat /proc/$FPID/fd/$FD > $CDIR/$FD.flv
done