line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::LinkEmbedder::Link::Video::Youtube; |
2
|
1
|
|
|
1
|
|
455
|
use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link::Text::HTML'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
has media_id => sub { shift->url->query->param('v') || '' }; |
5
|
0
|
|
|
0
|
1
|
|
sub provider_name {'YouTube'} |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub learn { |
8
|
0
|
|
|
0
|
1
|
|
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
|
1
|
|
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
|
1
|
|
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; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=encoding utf8 |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 NAME |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Mojolicious::Plugin::LinkEmbedder::Link::Video::Youtube - youtube.com link |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 DESCRIPTION |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
L |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This class inherit from L. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 media_id |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Returns the "v" query param value from L. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 provider_name |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 METHODS |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 learn |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 pretty_url |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Returns L without "eurl", "mode" and "search" query params. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 to_embed |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Returns the HTML code for an iframe embedding this movie. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHOR |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Marcus Ramberg |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |