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