line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::YouTube::Info; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
212855
|
use 5.008; |
|
4
|
|
|
|
|
31
|
|
4
|
4
|
|
|
4
|
|
23
|
use strict; |
|
4
|
|
|
|
|
19
|
|
|
4
|
|
|
|
|
93
|
|
5
|
4
|
|
|
4
|
|
15
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
254
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = qw( |
10
|
|
|
|
|
|
|
Exporter |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT = qw( |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
4
|
|
21
|
use Carp; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
198
|
|
19
|
4
|
|
|
4
|
|
2052
|
use Data::Dumper; |
|
4
|
|
|
|
|
22369
|
|
|
4
|
|
|
|
|
197
|
|
20
|
4
|
|
|
4
|
|
1389
|
use LWP::Simple; |
|
4
|
|
|
|
|
219896
|
|
|
4
|
|
|
|
|
27
|
|
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 https://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%7Chttps%3A%2F%2Fv14.lscache1.c.youtube.com%2Fvideoplayback%3Fip%3D131.0.0. .. |
51
|
|
|
|
|
|
|
# $info->{fmt_stream_map} # e.g.: 22%7Chttps%3A%2F%2Fv14.lscache1.c.youtube.com%2Fvideoplayback%3Fip%3D131.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
|
251
|
my ($class, $id) = @_; |
69
|
|
|
|
|
|
|
|
70
|
2
|
|
|
|
|
4
|
my $self = {}; |
71
|
2
|
|
33
|
|
|
9
|
$self->{_id} = $id || croak "no VIDEO_ID given!"; |
72
|
2
|
|
|
|
|
6
|
bless($self, $class); |
73
|
|
|
|
|
|
|
|
74
|
2
|
|
|
|
|
5
|
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
|
441
|
my ($self) = @_; |
86
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
8
|
my $id = $self->{_id}; |
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
4
|
my $info_url = "https://youtube.com/get_video_info?video_id=$id"; |
90
|
|
|
|
|
|
|
|
91
|
1
|
50
|
|
|
|
4
|
my $video_info = get($info_url) |
92
|
|
|
|
|
|
|
or croak "no get at $info_url - $!"; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# e.g.: fexp=907911%2C914091%2C911606&url_encoded_fmt_stream_map=url%3Dhttps .. |
95
|
1
|
|
|
|
|
824433
|
my %video_info = split /[=&]/, $video_info; |
96
|
1
|
|
|
|
|
15
|
$self->{info} = \%video_info; |
97
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
15
|
return $self->{info}; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |