Archive

Archive for September 16th, 2008

YouTube++ Download and Converter

September 15th, 2008

YouTube++ Download and Converter

you need: Perl, wget, ffmpeg and this script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl
use LWP::Simple;
print "YouTube++ (URL's to MP3's) By Albertux\n[http://albertux.ayalasoft.com]\n";
 
$total = @ARGV;
 
if ($total==0) {
 
	print "\nExample: ~\$ youtube\+\+ url1 url2 url3 ...\n";
 
} else {
 
	foreach(@ARGV) {
 
		$URL = $_;
		$aux = index($URL,"?v=");
		$a = substr $URL,$aux+3,11;
		$content = get($URL);
		@lines = split("\n",$content);
 
		foreach(@lines) {
			my $aux = index($_,"&t=");
			if ($aux > -1) { 
				$t = substr $_, $aux+3,32;
			}
		}
		system "wget -c -O \"$a.flv\" \"http://youtube.com/get_video?video_id=$a&t=$t\"";
		system "ffmpeg -i \"$a.flv\" -ab 128k \"$a.mp3\"";
	}
}
print "\nFeedback to: <albertoi7\@gmail.com>\n";

Example you have one file with urls of some videos (YouTubeUrls.txt):

http://www.youtube.com/watch?v=-j39ABZyzek
http://www.youtube.com/watch?v=5cGvzApDZKI
http://www.youtube.com/watch?v=w1mgEQTMVB8
...

This script download all flv files and convert to mp3.

youtube++ `cat YouTubeUrls.txt`

unix/linux, web ,