2 #KISS YouTube video downloader
5 echo "Harvie's automatic YouTube downloader";
6 echo " Now go and watch something on YouTube...";
12 echo Downloading captured video to
"$VIDFILE" ...
;
13 if [[ -a "$VIDFILE" ]]; then
14 echo File
"$VIDFILE" already exists
!
16 curl
--url "$DLURL" -o "$VIDFILE" --location -s 2> /dev
/null
&& echo "->" "$VIDFILE" complete
! &
17 # wget "$DLURL" -O "$VIDFILE" 2> /dev/null && echo "->" "$VIDFILE" complete! &
18 echo Download started
at background
!
22 #remove "-p" option for ngrep to download videos wieved from other computers...
23 ngrep $@
-p port
80 |
while read line
; do
25 if [[ "$line" =~
"GET /get_video\?video_id=(.*)&t=(.*) HTTP" ]]; then
26 DLURL
="http://www.youtube.com/get_video?video_id=${BASH_REMATCH[1]}&t=${BASH_REMATCH[2]}";
27 WURL
="http://www.youtube.com/watch?v=${BASH_REMATCH[1]}"
29 echo ---------------------------------------------------;
31 echo Captured video download URL
: "$DLURL";
32 echo Captured video watch URL
: "$WURL";
33 echo Getting video info...
;
35 curl
"$WURL" 2> /dev
/null |
grep "<title>" |
while read iline
; do
36 if [[ "$iline " =~
"<title>YouTube - (.*)</title>" ]]; then
37 VIDTITLE
=$
( echo "${BASH_REMATCH[1]}" );
38 echo Captured video title
: "$VIDTITLE";
39 download_video
"$DLURL" "$VIDTITLE";