Register
It is currently Wed Sep 03, 2014 1:00 am

Flash FLV rip.


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Thu Mar 08, 2012 1:03 pm   

Joined: Wed Mar 10, 2010 8:05 pm
Posts: 25
there's been a few people discussing this in various places, but I wrote a script I thought I'd share.

After a flash update some time ago, it started deleting the /tmp/Flash* video files so we couldn't just copy them. But this script restores them while they're still loaded in the browser... sort of. after your flash video is fully loaded, run the script and it'll appear in the same directory. it won't be *the* file that your browser is using, but it's the same file name just on a different inode. I don't fully understand how the kernel works with this, but meh. it works.

Code:
#!/bin/bash

flashdir="/tmp/"
mkdir -p "$flashdir" 2>/dev/null

function get_files {
   stat /proc/$1/fd/* |
   grep 'Flash.* (deleted)' | # we're looking only for deleted flash files
   sed "s/.*File: \`\(.*\)' ->.*\(Flash[a-zA-Z0-9]*\).*/\1 \2/g" # prune out the proc/*/fd/* path as well as the deleted file path
}

function get_processes {
   ps ax |
   grep flash -i |
   grep -v grep | # not the grep process
   grep -v "$1" | # not the script process
   sed 's/^ *\([0-9]*\) .*/\1/g' # prune out the PID
}

processes=(`get_processes "$0"`) # put all flash processes in the array
for p in ${processes[@]} ; do
   files=(`get_files "$p"`) # put all files for this flash process in the array

   # restore the flash files...
   for (( i=0; $i < ${#files[@]}; i+=2 )); do
      if [[ ! -e "$flashdir/${files[$i+1]}" ]] ; then
         echo "--> copying \"${files[$i]}\" \"$flashdir/${files[$i+1]}\""
         cp "${files[$i]}" "$flashdir/${files[$i+1]}"
      else
         echo "--> already copied \"${files[$i]}\" \"$flashdir/${files[$i+1]}\""
      fi
   done
done


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP