quasi-[OT] Adobe Flash

Patrick O'Callaghan pocallaghan at gmail.com
Sat Oct 23 22:51:48 UTC 2010


On Sat, 2010-10-23 at 14:28 -0700, suvayu ali wrote:
> On 23 October 2010 11:24, Marko Vojinovic <vvmarko at gmail.com> wrote:
> > Feel free to test it :-), and tell us the results. I can't myself, don't have
> > flash on this machine, need to wait until I get home.
> >
> > The script should be run while flash is downloading the movie, and it should
> > end on its own once done.
> >
> 
> Works as expected, but there is one catch. Since the plugin is run by
> the browser, it waits for the browser to quit. Which might be rather
> inconvenient. Maybe inotify is the way to go, or maybe the script
> could check whether the file descriptor is still open under the pid of
> the browser.

I tried it using inotifywait(1), but it never terminates, i.e. the flash
file persists even after the video has finished. I suspect it will stay
there till a new video starts or the flash plugin (i.e. the browser
process) dies.

This is my version in case anyone wants to play with it. I changed the
name to avoid clashing with Suvayu and Marko's efforts:

$ cat grab-flash
#!/bin/sh
# Grab Flash video while it's being downloaded
# Adapted from http://lists.fedoraproject.org/pipermail/users/2010-October/385463.html

case $# in
1)	out_file=$1 ;;
*)	echo Usage: grab-flash output
	exit -1 ;;
esac

pid=$(ps -fu `whoami`|egrep 'libflashplayer\.so'|egrep -om 1 -E '\<[0-9]+\>'|head -1);
fid=$(lsof -p $pid |egrep '/tmp/Flash'|egrep -om 1 -E '\<[0-9]+[a-z]\>'|tr -d 'a-z');
in_file=/proc/${pid}/fd/${fid}
tail -f -q --bytes=1G --pid=${pid} $in_file > $out_file &
inotifywait -e delete $in_file 2> /dev/null
sleep 5	# Wait for buffer to flush. Is this necessary?
kill $!

poc




More information about the users mailing list