Google Plus

bash script to download and run youtube movies

Written by Mel Kham on . Posted in News

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

Mel Kham

Founder of Unixmen, Living in Amsterdam. Am working in my free time to help people to understand the Opensource and to explain them in easy way how to make the fist steps to the the light. Working day and night with my Co-founder Zinovsky to keep this website live even with less resources.

Like us on Facebook

This week Top Posts

Write for us

Recent Comments

SK

|

Yes i will. Keep visiting. Subscribe us to get daily updates. Thanks for the comment

Rakesh Vijayan

|

Hi SK

I am Rakesh vijayan thanks for your great work ,by your work I start to learn what is ldap , my request is will you make tutorial for ldap and samba pdc for us on ubuntu 12.04

Guest

|

It was a typo. Now its corrected. Thanks for pointing out.

Michael T

|

You shouldn’t be so stupid, in the first time.

PrestaShop

|

Hi! Thank you for this nice article. We’ve 130,000+ active stores, you forgot the “1″ ;-)

 
IDG Tech Network
Copyright © 2008-2013 Unixmen.com .
Maintained by Anblik .