[ create a new paste ] login | about

Link: http://codepad.org/na2W7aPf    [ raw code | fork ]

Plain Text, pasted on Oct 31:
#/bin/bash

# Simple script to find flash video files that are stored in memory (as they are no longer stored on disk cache).
# Thankfully, due to the way *nix handles files, a file stored in memory or cache does not get deleted straight away
# if an open program still has a hold of it.
#
# To use, simply start playing the flash file in your browser, and run this script.
# It will attempt to find all flash files that are open, play them, and offer to save.
# Whilst playing, press 'q' (if in mplayer) or just exit out the media player program to view the next video (if any).
# Make sure the file is fully buffered (downloaded) in the browser if you want to save the full stream.
#
# BTC: 1GEEKqKUf4WwdsQuRd3wjHVYHA8NxUg1rU :)

# Set media player to use (i.e. vlc/cvlc/gnome-mplayer/mplayer). Default is mplayer.
mediaPlayer=mplayer

numFiles="$(stat -c %N /proc/*/fd/* 2>&1|awk -F[\`\'] '/Flash/{print$2}' |wc |awk '{print $1}')"
echo "Found $numFiles potential flash files"

if [ $numFiles -ne 0 ]; then
	echo -n "-> Play files? y/n: "
	read ans
	if [ "$ans" == "y" ]; then
		counter=1
		while [ $counter -le $numFiles ]; do
			currentFile=$(stat -c %N /proc/*/fd/* 2>&1|awk -F[\`\'] '/Flash/{print$2}' |head -n $counter |tail -n 1)
			echo -e "\n-> Playing $currentFile"
			echo "-> Press q for next file"
			$mediaPlayer "$currentFile" > /dev/null 2>&1
			echo -n "-> Save this video? y/n: "
			read ans
			if [ "$ans" == "y" ]; then
				path="/home/$(whoami)/"
				echo -n "-> Enter file name: $path"
				read path
				cp "$currentFile" "$path"
				echo "-* Saved to $path"
				if [ $counter -lt $numFiles ]; then
					echo -n "-> Continue playing remaining videos? y/n: "
					read ans
					if [ "$ans" == "n" ]; then
						exit 0
					fi
				fi
			fi
		let counter=counter+1
		done
	fi
fi



Create a new paste based on this one


Comments: