line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::LinkEmbedder::Link::Video::Youtube; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Mojolicious::Plugin::LinkEmbedder::Link::Video::Youtube - youtube.com link |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
L |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This class inherit from L. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
404
|
use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link::Text::HTML'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head2 media_id |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Returns the "v" query param value from L. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 provider_name |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has media_id => sub { shift->url->query->param('v') || '' }; |
28
|
0
|
|
|
0
|
1
|
|
sub provider_name {'YouTube'} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 METHODS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 learn |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub learn { |
37
|
0
|
|
|
0
|
1
|
|
my ($self, $c, $cb) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
return $self->SUPER::learn($c, $cb) unless $self->media_id; |
40
|
0
|
|
|
|
|
|
$self->$cb; |
41
|
0
|
|
|
|
|
|
$self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 pretty_url |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Returns L without "eurl", "mode" and "search" query params. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub pretty_url { |
51
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
52
|
0
|
|
|
|
|
|
my $url = $self->url->clone; |
53
|
0
|
|
|
|
|
|
my $query = $url->query; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$query->remove('eurl'); |
56
|
0
|
|
|
|
|
|
$query->remove('mode'); |
57
|
0
|
|
|
|
|
|
$query->remove('search'); |
58
|
0
|
|
|
|
|
|
$url; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 to_embed |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Returns the HTML code for an iframe embedding this movie. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub to_embed { |
68
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
69
|
0
|
0
|
|
|
|
|
my $media_id = $self->media_id or return $self->SUPER::to_embed; |
70
|
0
|
|
|
|
|
|
my $query = Mojo::Parameters->new; |
71
|
0
|
|
|
|
|
|
my %args = @_; |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
$query->param(autoplay => 1) if $args{autoplay}; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
0
|
|
|
|
$args{width} ||= $self->DEFAULT_VIDEO_WIDTH; |
76
|
0
|
|
0
|
|
|
|
$args{height} ||= $self->DEFAULT_VIDEO_HEIGHT; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
$self->_iframe( |
79
|
|
|
|
|
|
|
src => "//www.youtube.com/embed/$media_id?$query", |
80
|
|
|
|
|
|
|
class => 'link-embedder video-youtube', |
81
|
|
|
|
|
|
|
width => $args{width}, |
82
|
|
|
|
|
|
|
height => $args{height} |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 AUTHOR |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Marcus Ramberg |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |