bash script to download and run youtube movies

by
Share this Article: Facebook0Google+0Twitter1LinkedIn1Reddit0StumbleUpon0

i was looking in google  and  found  a wondefull script  to  download  movies  from youtube   and  run it  in your  terminal  Linux script  is  downloading  the  IF  of  the  movies  and will name it  downfile  and run it  with VLC player (orginal  script  was  working  with totem media  player)

 

edit  empty  file  and  put  in :

 

 

 

 

{codecitation}

#!/bin/bash

#

#  Source  Author: Finnbarr P. Murphy.

#    Date: september 17th, 2010

#

#

echo  -n “Enter the YouTube ID to copy: “

read ID

[[ -z $ID ]] && exit 1

TMP=/var/tmp/yt.$$

#QUIET=”-q”

QUIET=”–progress=bar”

WGET=/usr/bin/wget

SED=/bin/sed

TR=/usr/bin/tr

$WGET ${QUIET} -O ${TMP} “http://www.youtube.com/watch?v=${ID}”

[[ $? > 0 ]] && exit 2

VIDEOFILE=$($SED -n “/fmt_url_map/{s/['"|]/n/g;p}” ${TMP} |

$SED -n ‘/^fmt_url_map/,/videoplayback/p’ |

$SED -e :a -e ‘$q;N;5,$D;ba’ | $TR -d ‘n’ |

$SED -e ‘s/(.*),(.){1,3}/1/’)

rm -f $TMP

echo -n “Downloading video ….”

# download video to file named “downfile”. Change as necessary

$WGET ${QUIET} -O downfile “${VIDEOFILE}”

[[ $? > 0 ]] &&  {

echo “ERROR: Download failed”

exit 3

}

echo ” Done”
# play the video using VLC mediaplayer. Change as necessary

vlc  downfile
exit 0{/codecitation}

save and exit
do chmod +x the file
run the file with ./file and put the id of the youtube movie like xmXUD86DlhA
the script with start to download and watch the movie from http://www.youtube.com/watch?v=xmXUD86DlhA

 

enjoy

For questions please refer to our Q/A forum at : http://ask.unixmen.com/


Share this Article: Facebook0Google+0Twitter1LinkedIn1Reddit0StumbleUpon0