line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::YouTube::Info; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
104105
|
use 5.008; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
165
|
|
4
|
4
|
|
|
4
|
|
20
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
701
|
|
5
|
4
|
|
|
4
|
|
26
|
use warnings; |
|
4
|
|
|
|
|
29
|
|
|
4
|
|
|
|
|
342
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = qw( |
10
|
|
|
|
|
|
|
Exporter |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT = qw( |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
4
|
|
19
|
use Carp; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
457
|
|
19
|
4
|
|
|
4
|
|
4413
|
use Data::Dumper; |
|
4
|
|
|
|
|
63433
|
|
|
4
|
|
|
|
|
314
|
|
20
|
4
|
|
|
4
|
|
3555
|
use LWP::Simple; |
|
4
|
|
|
|
|
373400
|
|
|
4
|
|
|
|
|
41
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 NAME |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
WWW::YouTube::Info - gain info on YouTube video by VIDEO_ID |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 Perhaps a little code snippet? |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
#!/usr/bin/perl |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use strict; |
33
|
|
|
|
|
|
|
use warnings; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use WWW::YouTube::Info; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# id taken from YouTube video URL |
38
|
|
|
|
|
|
|
my $id = 'foobar'; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $yt = WWW::YouTube::Info->new($id); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $info = $yt->get_info(); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# hash reference holds values gained via http://youtube.com/get_video_info?video_id=foobar |
45
|
|
|
|
|
|
|
# $info->{title} # e.g.: Foo+bar+-+%27Foobar%27 |
46
|
|
|
|
|
|
|
# $info->{author} # e.g.: foobar |
47
|
|
|
|
|
|
|
# $info->{keywords} # e.g.: Foo%2Cbar%2CFoobar |
48
|
|
|
|
|
|
|
# $info->{length_seconds} # e.g.: 60 |
49
|
|
|
|
|
|
|
# $info->{fmt_map} # e.g.: 22%2F1280x720%2F9%2F0%2F115%2C35%2F854x480%2F9%2F0%2F115%2C34%2F640x360%2F9%2 .. |
50
|
|
|
|
|
|
|
# $info->{fmt_url_map} # e.g.: 22%7Chttp%3A%2F%2Fv14.lscache1.c.youtube.com%2Fvideoplayback%3Fip%3D131.0.0.0 .. |
51
|
|
|
|
|
|
|
# $info->{fmt_stream_map} # e.g.: 22%7Chttp%3A%2F%2Fv14.lscache1.c.youtube.com%2Fvideoplayback%3Fip%3D131.0.0.0 .. |
52
|
|
|
|
|
|
|
# .. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Remark: |
55
|
|
|
|
|
|
|
# You might want to check $info->{status} before further workout, |
56
|
|
|
|
|
|
|
# as some videos have copyright issues indicated, for instance, by |
57
|
|
|
|
|
|
|
# $info->{status} ne 'ok'. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 DESCRIPTION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
I guess its pretty much self-explanatory .. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 METHODS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub new { |
68
|
2
|
|
|
2
|
0
|
142
|
my ($class, $id) = @_; |
69
|
|
|
|
|
|
|
|
70
|
2
|
|
|
|
|
5
|
my $self = {}; |
71
|
2
|
|
33
|
|
|
14
|
$self->{_id} = $id || croak "no VIDEO_ID given!"; |
72
|
2
|
|
|
|
|
6
|
bless($self, $class); |
73
|
|
|
|
|
|
|
|
74
|
2
|
|
|
|
|
6
|
return $self; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 get_info |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
See synopsis for how/what/why. You might also want to use L .. |
80
|
|
|
|
|
|
|
Croaks if C fails. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub get_info { |
85
|
1
|
|
|
1
|
1
|
659
|
my ($self) = @_; |
86
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
6
|
my $id = $self->{_id}; |
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
4
|
my $info_url = "http://youtube.com/get_video_info?video_id=$id"; |
90
|
|
|
|
|
|
|
|
91
|
1
|
50
|
|
|
|
6
|
my $video_info = get($info_url) |
92
|
|
|
|
|
|
|
or croak "no get at $info_url - $!"; |
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
723897
|
my @info = split /&/, $video_info; |
95
|
|
|
|
|
|
|
|
96
|
1
|
|
|
|
|
6
|
for ( @info ) { |
97
|
57
|
|
|
|
|
152
|
my ($key, $value) = split /=/; |
98
|
57
|
|
|
|
|
172
|
$self->{info}->{$key} = $value; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
1
|
|
|
|
|
15
|
return $self->{info}; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |