Archive for December, 2007

GetUTube: YouTube Video Downloader in Bash

December 24, 2007

Below is the script I wrote in hurry for a friend. Many of my friends wanted to download Videos from YouTube for later viewing but they always complained about available scripts or programs, so I decided to write my own quick and simple script which work as we want it ;).

I know below script does not have any comments or checks, but this is what I wrote in hurry.


#!/bin/bash

TMPFILE="/tmp/getutube.$$.data"

if [ "$1" == "" ]; then
echo "Please provide YouTube Video's Page URL"
fi

VIDEOID="${1#*v=}"

echo -n "Getting video URL..."
wget -O $TMPFILE $1
echo "DONE"

UGETURL="`grep video_id $TMPFILE|grep fullscreenUrl|head -1`"
rm -f $TMPFILE
URLPARAMS="${UGETURL#*/watch_fullscreen?}"
URLPARAMS="${URLPARAMS%\';}"
FILENAME="${URLPARAMS#*&title=}"

echo -n "Downloading Video..."
wget -O "${FILENAME}.flv" "http://www.youtube.com/get_video?$URLPARAMS"
echo "DONE"

Advertisements