Guest User

Download Flash Videos Linux

a guest
Mar 4th, 2012
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.82 KB | None | 0 0
  1. #!/bin/bash
  2.     export IFS=$'\n'         #Treat spaces as... spaces!
  3.  
  4. ddir=$HOME/Flashes           #Destination directory
  5. mkdir -p "$ddir" 2>/dev/null #...create it,eventually
  6.  
  7. pref="FlashDownload"         #Prefix name
  8. dp="$ddir"/"$pref"           #destdir/prefixname
  9.  
  10. for s in $(find /proc/*/fd/ -lname "/tmp/Flash*" 2>/dev/null); do
  11.   pt=$(readlink "$s"|cut -f 1 -d " ") #Get real flash name
  12.   d=$dp$(basename "$pt")              #FullPath/Prefix+RealFlashName
  13.  
  14.   if [ ! -f "$d" ]                    #Download if the file does not exists
  15.   then
  16.     p=$(echo "$s"|cut -d "/" -f 3)                 #get the pid
  17.     echo tailing "$s" to "$d" from pid $p
  18.     tail -n +0 --pid=$p --follow "$s" > "$d" &     #copy using tail
  19.       else
  20.     echo File "$pt" is downloaded/downloading      #...skip if the file exists
  21.   fi
  22. done
Add Comment
Please, Sign In to add comment