Register
It is currently Sat Aug 30, 2014 4:20 am

youtube.com video ripper


All times are UTC - 6 hours


Post new topic Reply to topic  [ 44 posts ]  Go to page Previous  1, 2
Author Message
 PostPosted: Sat Aug 25, 2007 11:17 pm   

Joined: Thu Aug 23, 2007 10:02 pm
Posts: 3
never mind, youtube-dl has been updated.
http://www.arrakis.es/~rggi3/youtube-dl/


Last edited by yeehawjared on Mon Aug 27, 2007 1:08 pm, edited 1 time in total.

Top
 Profile  
 PostPosted: Mon Aug 27, 2007 12:58 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 666
Location: Des Moines, Iowa
yeehawjared wrote:
is the script broken? I believe I'm doing everything correct, and have curl installed.

script:
Code:
#!/bin/bash
wget -c -S -O $2.flv http://youtube.com/get_video.php\?`curl -s $1 | grep player2.swf | cut -f2 -d? | cut -f1 -d"` && ffmpeg -i $2.flv -ab 56 -ar 22050 -b 500 -s 320x240 $2.mpg && exit 0


output:
Code:
root@jaredtop:/tmp# ./youtube.sh http://www.youtube.com/watch?v=0Sn7GmHHR14 lisa
--00:15:56--  http://youtube.com/get_video.php?v=1';
           => `lisa.flv'
Resolving youtube.com... 208.65.153.238, 208.65.153.251, 208.65.153.253
Connecting to youtube.com|208.65.153.238|:80... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 404 Not Found
  Date: Fri, 24 Aug 2007 04:15:54 GMT
  Server: Apache
  Cache-Control: no-cache
  Connection: close
  Content-Type: text/html; charset=utf-8
00:15:56 ERROR 404: Not Found.

root@jaredtop:/tmp#





HTTP/1.1 404 Not Found
MEANS your web page wasn't found........

perhaps trying
./youtube.sh "http://www.youtube.com/watch?v=0Sn7GmHHR14 lisa"

Notice the quotes......


Top
 Profile WWW  
 PostPosted: Mon Aug 27, 2007 1:06 pm   

Joined: Thu Aug 23, 2007 10:02 pm
Posts: 3
yup, forgot the quotes. :oops:


Top
 Profile  
 PostPosted: Mon Aug 27, 2007 1:08 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 666
Location: Des Moines, Iowa
I think normally it would work.....but looks like your url had a space in it which broke it i guess.

I should update the script, but just haven't bothered with it since i wrote it. I only wrote it so my son could download his favorite youtube vids quickly.


Top
 Profile WWW  
 PostPosted: Thu Aug 30, 2007 5:24 am   

Joined: Thu Aug 30, 2007 5:22 am
Posts: 1
Location: London
crouse wrote:
I think normally it would work.....but looks like your url had a space in it which broke it i guess.

I should update the script, but just haven't bothered with it since i wrote it. I only wrote it so my son could download his favorite youtube vids quickly.


Thanks for writing the script - I've gone through and updated it so it works with the youtube changes.

Cheers,

Alan.

Code:
#!/bin/bash
# by Crouse
# Program name ytr = YouTube.com Ripper
baseurl="http://youtube.com/get_video.php?"
mkdir -p ~/YouTube ;
mkdir -p ~/YouTube/tmp ;
cd ~/YouTube/tmp ;
read -p "What is the youtube.com url you want to rip ? " urltorip ;
read -p "What would you like to name the video (no spaces in the name) ? " nameofvideo ;
wget ${urltorip} -O urlsource.txt ;
grep "watch_fullscreen" urlsource.txt > url.info;
videourl=`sed "s;.*\(video_id.\+\)&title.*;\1;" url.info`;
fullurl=${baseurl}${videourl};
echo ${fullurl};
rm *;
wget ${fullurl};
mv * *.flv;
echo "Now converting the file to mpeg ... this can take awhile, please be patient" ;
ffmpeg -i *.flv -ab 56 -ar 22050 -b 500 -s 320x240 ${nameofvideo}.mpg;
mv *.mpg ../;
rm -Rf ~/YouTube/tmp;
exit


Top
 Profile  
 PostPosted: Thu Aug 30, 2007 7:07 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 666
Location: Des Moines, Iowa
Thanks skyphyr ;)


Top
 Profile WWW  
 PostPosted: Thu Nov 01, 2007 1:59 pm   

Joined: Thu Nov 01, 2007 1:52 pm
Posts: 1
Code:
#!/bin/bash
# by Crouse
# Program name ytr = YouTube.com Ripper
baseurl="http://youtube.com/get_video.php?"
mkdir -p ~/YouTube ;
mkdir -p ~/YouTube/tmp ;
cd ~/YouTube/tmp ;
read -p "What is the youtube.com url you want to rip ? " urltorip ;
read -p "What would you like to name the video (no spaces in the name) ? " nameofvideo ;
wget ${urltorip} -O urlsource.txt ;
grep "watch_fullscreen" urlsource.txt > url.info;
videourl=`sed "s;.*\(video_id.\+\)&title.*;\1;" url.info`;
fullurl=${baseurl}${videourl};
echo ${fullurl};
rm *;
wget ${fullurl};
mv * *.flv;
echo "Now converting the file to mp3 ... this shouldnt take long" ;
ffmpeg -i *.flv -ab 128 -ar 44100 ${nameofvideo}.mp3;
mv *.mp3 ../;
rm -Rf ~/YouTube/tmp;
exit


extract as mp3's.... eat that torrent....


Top
 Profile  
 PostPosted: Sat Nov 03, 2007 1:28 am   
Site Admin

Joined: Tue May 17, 2005 7:31 pm
Posts: 251
Location: Georgia
:lol:


Top
 Profile  
 PostPosted: Thu Nov 22, 2007 3:07 pm   

Joined: Thu Nov 22, 2007 2:57 pm
Posts: 1
First of all, thank you for the original bash script -- it was very helpful.

The original program didn't fit my needs perfectly so I revised this program a bit to include error checking and to use a temporary directory (with mktemp command) instead of ~/YouTube. Also, I made it accept command-line arguments instead of standard input allowing for easier automation. If it fails to convert the downloaded file to an mpg, it will notify the user save it as a .flv instead. All scratch work is done in a temporary directory which is removed before the program ends. Also, it rips the mpeg at 640x480 resolution. If you don't want this it is easy to change.

Usage:
ytr <youtube url> <output filename>

note: the filename should not have an extension



bash script: ytr
Code:
#!/bin/bash

# Program name ytr = YouTube.com Ripper
# originally by Crouse
# Revised by Jeshua Bratman
#
# http://bashscripts.org/viewtopic.php?t=210&start=25
#
#INPUT:  ytr <youtube url> <output filename without extension>
#OUTPUT: mpg file ripped from youtube url

##############################

#check arguments

if [[ $# < 2 ]]
then
    echo "usage: ytr <url> <output file>"
    exit;
fi

#url and output file arguments
URL=$1
OUTPUT=$2

#make a temporary directory
TMPDIR="`mktemp -d`"


##############################

#youtube url to download flv files
BASEURL="http://youtube.com/get_video.php?"

wget $URL -O $TMPDIR/urlsource  > /dev/null 2>&1
#check return value
if [[ $?  != "0" ]]
then
  echo "ERROR: Failed to read from url."
  rm -r $TMPDIR
  exit;
fi

grep "watch_fullscreen" $TMPDIR/urlsource > $TMPDIR/urlinfo;
#check return value
if [[ $?  != "0" ]]
then
  echo "ERROR: Failed to parse url's content. Are you sure this is a correct youtube video url?"
  rm -r $TMPDIR
  exit;
fi

videourl=`sed "s;.*\(video_id.\+\)&title.*;\1;" $TMPDIR/urlinfo`;
#check return value
if [[ $?  != "0" ]]
then
  echo "ERROR: Failed to parse url's content. Are you sure this is a correct youtube video url?"
  rm -r $TMPDIR
  exit;
fi

fullurl=${BASEURL}${videourl};

#download video
echo "Downloading video (this may take some time)..."
wget $fullurl -O $TMPDIR/temp.flv  > /dev/null 2>&1
if [[ $?  != "0" ]]
then
  echo "ERROR: Failed to download video."
  rm -r $TMPDIR
  exit;
fi

echo "done!"

echo "Converting flv to mpeg (this may take some time)... "
ffmpeg -i $TMPDIR/temp.flv -acodec copy -b 500 -s 640x480 ${OUTPUT}.mpg  > /dev/null 2>&1

if [[ $?  != "0" ]]
then
  echo "ERROR: Failed to convert video to mpg. Saving file as ${OUTPUT}.flv instead."
  mv $TMPDIR/temp.flv ${OUTPUT}.flv   
else
  echo "done!"
  echo "Download successful. Saved file as ${OUTPUT}.mpg"
fi


#remove temporary directory and exit
rm -r $TMPDIR
exit;



Now I'm happily downloading all the flight of the conchords music videos.

Hope this is useful,
Jeshua Bratman


Top
 Profile  
 PostPosted: Sat Nov 24, 2007 10:23 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 666
Location: Des Moines, Iowa
Thanks for sharing :) :)

and to think this all started out simply as a way for my son to download a couple youtube vids lol :)


Top
 Profile WWW  
 PostPosted: Fri Jan 25, 2008 4:49 am   

Joined: Wed Jun 27, 2007 11:07 pm
Posts: 2
Location: Colorado -- USA


Last edited by xinilux on Wed Dec 17, 2008 9:45 pm, edited 2 times in total.

Top
 Profile  
 PostPosted: Fri Feb 08, 2008 2:08 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 666
Location: Des Moines, Iowa
thank jbsnake........ he helped with that ;)


Top
 Profile WWW  
 PostPosted: Mon Feb 11, 2008 4:56 pm   

Joined: Mon Feb 11, 2008 4:51 pm
Posts: 1
If anyone would like to try it, a modification or two to Crouse's script:

Code:
#!/bin/bash
# by Crouse
# Program name ytr = YouTube.com Ripper
baseurl="http://youtube.com/get_video.php?"
mkdir -p ~/YouTube ;
mkdir -p ~/YouTube/tmp ;
cd ~/YouTube/tmp ;
read -p "What is the youtube.com url you want to rip ? " urltorip ;
read -p "What would you like to name the video (no spaces in the name) ? " nameofvideo ;
wget ${urltorip} -O urlsource.txt ;
grep "watch_fullscreen" urlsource.txt > url.info;
videourl=`sed "s;.*\(video_id.\+\)&title.*;\1;" url.info`;
fullurl=${baseurl}${videourl};
echo ${fullurl};
rm *;
wget ${fullurl};
mv * *.flv;
echo "Now converting the file to mpeg ... this can take awhile, please be patient" ;
tovid -in *.flv -out ${nameofvideo} -ffmpeg -half-dvd -ntsc -keepfiles;
mv *.mpg ../;
rm -Rf ~/YouTube/tmp;
exit


Top
 Profile  
 PostPosted: Fri Mar 14, 2008 10:27 pm   

Joined: Fri Mar 14, 2008 9:23 pm
Posts: 1
Hello,

Thanks for providing this script. However, I have been unable to get it to work. First, I have the sed call doesn't process at all. And 2nd, from what I have been able to piece together the resulting $fullurl doesn't download the any video (this is most likely due to Youtube changes.)

Also, I am running BSD Unix on OS X, so there is most likely some cross-platform issues. (So hard to tell, as the documentation seems somewhat sparse. }

First let me state, I am new to bash scripting, thus determining the intent was an excellent learning experience.

My url.info file looks like this:

var fullscreenUrl = '/watch_fullscreen?fs=1&vq=None&video_id=YsB_rnzBA08&l=448&sk=Mtaqj8HuPC8337H0ErPMcAC&fmt_map=&t=OEgsToPDskJXV7getH-j02to-K4UzVyF&hl=en&plid=AARIY3GwGbBRZZcpAAAAIAAQAAA&title=The Laughter, Part II: Reviewing the Fun';

The sed function has no effect text. I don't know why. Patients please as I step through the Sed line. I would appreciate to confirm my study.

videourl=`sed "s;.*\(video_id.\+\)&title.*;\1;" url.info`;

; = sed allows different command delineators.
.*\ = find all text up to video_id
\(video_id.\+\} = subpattern; all text from vid to end
&title.* = find all txt from &tit to end
replace 2nd match with subpattern.

Desired Result:
video_id=YsB_rnzBA08&l=448&sk=Mtaqj8HuPC8337H0ErPMcAC&fmt_map=&t=OEgsToPDskJXV7getH-j02to-K4UzVyF&hl=en&plid=AARIY3GwGbBRZZcpAAAAIAAQAAA

Actual result:
var fullscreenUrl = '/watch_fullscreen?fs=1&vq=None&video_id=YsB_rnzBA08&l=448&sk=Mtaqj8HuPC8337H0ErPMcAC&fmt_map=&t=OEgsToPDskJXV7getH-j02to-K4UzVyF&hl=en&plid=AARIY3GwGbBRZZcpAAAAIAAQAAA&title=The Laughter, Part II: Reviewing the Fun';


Any ideas on why the sed function is not processing properly? I would greatly appreciate any feedback. Having spent a good bit of time studying RE's and sed, and pulling apart this script, I am dying to know where the hiccup is!!!

George

DedannaRocks wrote:
If anyone would like to try it, a modification or two to Crouse's script:

Code:
#!/bin/bash
# by Crouse
# Program name ytr = YouTube.com Ripper
baseurl="http://youtube.com/get_video.php?"
mkdir -p ~/YouTube ;
mkdir -p ~/YouTube/tmp ;
cd ~/YouTube/tmp ;
read -p "What is the youtube.com url you want to rip ? " urltorip ;
read -p "What would you like to name the video (no spaces in the name) ? " nameofvideo ;
wget ${urltorip} -O urlsource.txt ;
grep "watch_fullscreen" urlsource.txt > url.info;
videourl=`sed "s;.*\(video_id.\+\)&title.*;\1;" url.info`;
fullurl=${baseurl}${videourl};
echo ${fullurl};
rm *;
wget ${fullurl};
mv * *.flv;
echo "Now converting the file to mpeg ... this can take awhile, please be patient" ;
tovid -in *.flv -out ${nameofvideo} -ffmpeg -half-dvd -ntsc -keepfiles;
mv *.mpg ../;
rm -Rf ~/YouTube/tmp;
exit


Top
 Profile  
 PostPosted: Fri Apr 04, 2008 5:36 pm   

Joined: Tue Apr 01, 2008 10:19 am
Posts: 49
Quote:
clive is a video extraction tool for user-uploaded video hosts such as Youtube, Google Video, Dailymotion, Guba and Metacafe. It can be chained with 3rd party tools for subsequent video re-encoding and playing and playing.


http://home.gna.org/clive

Written in python.

Archlinux package is in AUR


Top
 Profile  
 PostPosted: Sun Apr 13, 2008 4:54 am   
User avatar

Joined: Sun Apr 13, 2008 4:05 am
Posts: 37
Location: /dev/random
updated 2 lines version :)

Code:
#!/bin/bash
wget -c -S -O $2.flv http://youtube.com/get_video.php\?`curl -s $1 | grep watch_fullscreen | sed "s;.*\(video_id.\+\)&title.*;\1;" ` && ffmpeg -i $2.flv -ab 56 -ar 22050 -b 500 -s 320x240 $2.mpg && exit 0


example
./yourscript.sh http://www.youtube.com/watch?v=teMlv3ripSM monthy-argument-clinic


Top
 Profile  
 PostPosted: Sun May 25, 2008 5:33 am   

Joined: Sun May 25, 2008 5:22 am
Posts: 1
I played a bit with the script and added a function to demux the audio and save the result with the youtube title as a filename.

It's a nice script if you just want to play some music videos remotely ... however youtube's 64k audio stream won't make you happy ... ;)

Code:
#!/bin/bash

#
# YouTube Leech & Play Script
# eg. ./youtube.sh http://www.youtube.com/watch?v=UsAl3HsCXf0
#
# Remember: Install the sox package for 'play' and put yourself in the audio group!
#

YOUTUBE=$(curl -s $1 | grep watch_fullscreen)
VIDEOID=$(echo $YOUTUBE | sed "s!.*\(video_id.\+\)&title.*!\1!")
TITLE=$(echo $YOUTUBE | sed "s!.*&title=\(.*\)';!\1!" | sed 's!&[^;]*;!!g' | sed 's![^-a-zA-Z0-9 ]!!g' | sed 's! !_!g').mp3
TEMP=$(mktemp)

echo -e "Downloading $TITLE from YouTube ...\n"
curl -L http://youtube.com/get_video.php\?$VIDEOID > $TEMP

echo -e "Demuxing ... \n"
ffmpeg -i $TEMP $TITLE
rm $TEMP

echo -e "Playing ... \n"
play $TITLE

exit 0


Image


Top
 Profile  
 PostPosted: Tue Sep 21, 2010 1:26 pm   
User avatar

Joined: Fri Oct 03, 2008 5:48 pm
Posts: 8
Could this be modified/updated to download the higher quality mp4 and convert to mp3?


Top
 Profile  
 PostPosted: Wed Feb 23, 2011 4:20 pm   

Joined: Wed Feb 23, 2011 4:14 pm
Posts: 1
Some months ago, YouTube has changed something, and there isn't any "watch_fullscreen" phrase in the YouTube html page code, so the scripts didn't work. have you ideas what to do with that? have anybody working youtube downloading script? ; )


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 44 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: Yahoo [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP