Programming and Scripting :: Script for downloading Youtube videos



I just used this to get Jeff Buckley's Hallelujah. Still works fine, though this was not on DSL..
Okay, Youtube changed their video downloading possibilities, in an attempt to prevent downloading their videos. So here's a new ver that can still download :D

Quote
#!/bin/bash
# Script for downloading Youtube videos. Base was from nixcraft.org
# Edited by Curaga for my liking (Added ability for nearly unlimited URLs, help,
# comments, and ability to get urls from args)

case $1 in
-h | *help )
echo "Usage: ${0##*/} url1 url2.. or just ${0##*/} and type the urls"
exit 0 ;;
esac

ripurl="http://youtube.com/get_video.php?"
tmp=`mktemp`
touch $tmp.flv
mkdir -p ~/YouTube;cd ~/YouTube
url="not empty in da beginning"

until [ -z "$url" ]; do
if [ -n "$1" ] && [[ $1 = http://* ]]; then url=$1
elif [ -n "$1" ]; then echo "Not a valid url. http:// required."; exit 1; fi

if [ -z "$1" ]; then read -p "YouTube URL? Press enter to exit. " url; fi
if [ -z "$url" ]; then
rm $tmp
clear; echo -e "\n    Finished."
exit 0; fi

echo
echo ------------------------------------------------------------------------
echo -e "                  Now getting the page for analysis.\n"
wget -nv "$url" -O $tmp

uf=$ripurl`grep watch_fullscreen $tmp | sed "s;.*\(video_id.\+\)&title.*;\1;"`

nv=`grep 'h1 id="video_title"' $tmp | cut -d ">" -f 2 | cut -d "<" -f 1`

echo -e "\n\n  Title: $nv\n\n"

wget "$uf" -O $tmp.flv
echo "" > $tmp
newname=`echo $nv | sed 's;/;\/;g'`
mv "$tmp.flv" "$newname.flv"
echo -e "\n\n $HOME/Youtube/$newname.flv ready.\n"

shift
done


original here.