YoutubeダウンロードURL生成β Perl

基礎となるプログラムです。
先日紹介したダウンロードの方法をPerlにて最小限に表現してみました。

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
32
33
34
35
#!/usr/bin/perl
#########################################
#ソフト名:YoutubeダウンロードURL生成β
#作成日:2009/11/5
#作者:ORBIT
#著作権:ORBIT SPACEへ帰属します。
#########################################
 
 
#LWPモジュールを使用する
use LWP;
 
print"YoutubetURLn>";
$Target = <stdin>;
 
#正規表現にてURLの情報を取得
$Target =~ /http://(.*)/watch?v=(w*)/;
my $host = $1;
my $id = $2;
 
#取得した情報からURLを生成
 
#HTMLの取得
my $soce = LWP::UserAgent->new->request(
        HTTP::Request->new(GET => "$URL"))->content;
 
        #TOKENの取得を行う
        $soce =~ /.*token=(.*)&thumbnail_url=.*/;
        my $t = $1;
 
#TOKENを出力
print"$tn";
#Downlad可能なURLを出力
print'http://youtube.com/get_video?video_id='."$id".'&t='."$tn";

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(Spamcheck Enabled)

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)