Advanced

Here's a couple of scripts for saving Youtube Flash Videos to your hard drive

Posted by tracyanne on · 16 comments
LXer Linux News; By Tracy Barlow
Mail this story
Print this story

I hope someone finds them useful.

Script1 locateallflashfiles.sh

#!/bin/bash

echo Please wait, searching for recent Flash Video Files

lsof | grep Flash | grep plugin-co > listallflashfiles.txt

while read line

do

./processflashfiles.sh $line

done < listallflashfiles.txt

echo Press any key to close this Terminal

read thekey

Script2 processflashfiles.sh

#!/bin/bash

string1=$4

string2=$9

echo Copying /proc/$2/fd/${string1//u/ } to /home/$3/Videos${string2///tmp/}.flv

cp /proc/$2/fd/${string1//u/ } /home/$3/Videos${string2///tmp/}.flv

  Nav
» Read more about:

» Get new stories by e-mail: nightly or as they are published

« Return to the newswire homepage

  Related stories
» More like this

Comments (16)

I see just two...

I see just two...
#!/bin/bash
#
# FLASHCOPY
#
# Will ieterate through all open copies flashplayer and copy flash video to the
# current folder (or specified directory) with the .flv extension added.
#
# USAGE:
#     flashcopy .  (copy to current directory)
#     flashcopy ~/Videos  (copying to a specified directory)
#
# This is done by finding all running copies of the flash player and looking at
# what files are opened by the process. If the file is a /tmp/Flash file 
# it is copied

args=("$@")

args=`echo $args | sed 's/[/]$//'`

pids=`eval pgrep -f flashplayer` for pid in $pids do lsoutput=$(lsof -p $pid | grep '/tmp/Flash[^ ]*')

IFS=$'n' for line in $lsoutput; do lsout1=`echo $line | awk '{print "/proc/" $2 "/fd/" $4}' | sed 's/[rwu]$//'` lsout2=`echo $line | awk '{print $9}' | awk -F '/' '{print $3}'`

if [ -n "$args" ];then if [ -d $args ]; then echo "Copying $lsout2 to $args/" eval "cp $lsout1 $args/$lsout2.flv" else echo "The directory "$args" doesn't exist" break fi else echo "Copying $lsout2" eval "cp $lsout1 $lsout2.flv" fi done

done
Nice. My preferred method of grabbing vids from youtube is to use Jdownloader. Copy url into it, pick which format(s) you want the vid in (vids often have a number of different formats available), let it rip.
@ElderGeek, believe it or not, after all these years, that was my first "serious" Bash script. I originally wrote an application in C# Mono that does the job, but wanted to see if I could do it as a bash script.
hehe. Oddly enough I don't think I've ever done a serious bash script...for anything more complex than simply a string of commands to run I usually go perl.
you might want to also check for mp4 files, as many websites' flashplayers use mp4s instead of flvs these days.

Had drive????

I the the one that crashed so it is what you had, or is it just the Boston version?
Definitely Bahstin, where you pahk your cah neah the had drive (the proper editorial authorities have been alerted).
Fixed..sorry about that.
Pardon my typos
Don't you mean "pahdon" my typos? :)
sorry, padon my typos
You are fogiven, TA.

lsof uninstalled ???!!

Sometimes I hate the distro I'm forced to use at work. (on a laptop I also use at home, of course)

no lsof, no privilege to install it.

d@mn.

Will try on another one.

Anyway thanks !
If they haven't thought to disallow running files from your home directory, copying a compatible version over to your home directory and running it will probably work. You can probably create a whole bin folder with useful files in that case. Now, the reaction of your IT department to finding such is a matter left to the reader's imagination.

Post a comment

A free account is needed to post. Write your comment here first: your text is kept in this browser while you sign up or log in, and is waiting for you when you come back.

Your message:
|||||
10
Markdown: **bold**, *italic*, [text](https://link), - lists, > quotes, $x^2$ for math. Formatting help

Sign up and post (it is free)  or  Log in and post