Putting Google Video onto Your iPod
Subject:   Upgraded script
Date:   2006-01-29 14:17:09
From:   menkhaf
After browsing and finding a link for the "Fear of Girls" D&D documentary, , I got annoyed with the flash-based viewer, and couldn't immediately get the sound to work, I decided to update your script a bit.
The script now has no need for the external un-escape program, and automatically finds the title of the video and saves the video as $TITLE.flv unless you specify another filename as a second optional variable.
As it is my first real bash script (hooray), and feedback is appreciated.


# Filename: googlevid

# Google video downloader.
# 2006, Rune Juhl Jacobsen,
# Based on script by Erica Sadun,

# For readability

# Check the input
if [ -z $URL ]; then
echo -e "Error: You need to specify a URL.\n\n"
echo -e "Google video downloader\n\nUsage:\n ./googlevid URL [filename]"
exit 0

# Get the source
SOURCE=`curl -s "$URL"`
# Determine the title of the video
TITLE=`echo $SOURCE | sed "s/ - Google Video<\/title>.*//" | sed "s/.*<title>//"`
# Determine the URL of the actual video
VIDURL=`echo $SOURCE | sed "s/autoPlay=true.*/autoPlay=true/" | sed "s/.*videoUrl=//" | grep`
# Unescape the URL
VIDURL=`echo $VIDURL | sed "s/%3A/:/g" | sed "s/%2F/\//g" | sed "s/%3F/?/g" | sed "s/%3D/=/g" | sed "s/%26/\&/g"`
# Determine the filename to save the video as
if [ -z $FILENAME ]; then

curl "$VIDURL" > "$FILENAME"
echo "File has been output to \"$FILENAME\""
exit 0