line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::LinkEmbedder::Link::Video::Youtube; |
2
|
1
|
|
|
1
|
|
2442
|
use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link::Text::HTML'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
has media_id => sub { shift->url->query->param('v') || '' }; |
5
|
0
|
|
|
0
|
0
|
|
sub provider_name {'YouTube'} |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub learn { |
8
|
0
|
|
|
0
|
0
|
|
my ($self, $c, $cb) = @_; |
9
|
|
|
|
|
|
|
|
10
|
0
|
0
|
|
|
|
|
return $self->SUPER::learn($c, $cb) unless $self->media_id; |
11
|
0
|
|
|
|
|
|
$self->$cb; |
12
|
0
|
|
|
|
|
|
$self; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub pretty_url { |
16
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
17
|
0
|
|
|
|
|
|
my $url = $self->url->clone; |
18
|
0
|
|
|
|
|
|
my $query = $url->query; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
$query->remove('eurl'); |
21
|
0
|
|
|
|
|
|
$query->remove('mode'); |
22
|
0
|
|
|
|
|
|
$query->remove('search'); |
23
|
0
|
|
|
|
|
|
$url; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub to_embed { |
27
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
28
|
0
|
0
|
|
|
|
|
my $media_id = $self->media_id or return $self->SUPER::to_embed; |
29
|
0
|
|
|
|
|
|
my $query = Mojo::Parameters->new; |
30
|
0
|
|
|
|
|
|
my %args = @_; |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
$query->param(autoplay => 1) if $args{autoplay}; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
0
|
|
|
|
$args{width} ||= $self->DEFAULT_VIDEO_WIDTH; |
35
|
0
|
|
0
|
|
|
|
$args{height} ||= $self->DEFAULT_VIDEO_HEIGHT; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$self->_iframe( |
38
|
|
|
|
|
|
|
src => "//www.youtube.com/embed/$media_id?$query", |
39
|
|
|
|
|
|
|
class => 'link-embedder video-youtube', |
40
|
|
|
|
|
|
|
width => $args{width}, |
41
|
|
|
|
|
|
|
height => $args{height} |
42
|
0
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |