I see just two...

Story: Here's a couple of scripts for saving Youtube Flash Videos to your hard driveTotal Replies: 5
Author Content
D

Sep 06, 2011
10:11 AM EDT
I see just two...
ElderGeek

Sep 06, 2011
10:27 AM EDT
#!/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
techiem2

Sep 06, 2011
5:46 PM EDT
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.
tracyanne

Sep 06, 2011
5:54 PM EDT
@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.
techiem2

Sep 06, 2011
5:56 PM EDT
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.
patrokov

Sep 06, 2011
8:05 PM EDT
you might want to also check for mp4 files, as many websites' flashplayers use mp4s instead of flvs these days.

Posting in this forum is limited to members of the group: [ForumMods, SITEADMINS, MEMBERS.]

Becoming a member of LXer is easy and free. Join Us!