line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Video::Embed::Site::Youtube; |
2
|
11
|
|
|
11
|
|
7681
|
use Moo; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
69
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
with 'HTML::Video::Embed::Module'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub _build_domain_reg{ |
7
|
11
|
|
|
11
|
|
441
|
return qr/youtube\.com/; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub _build_validate_reg{ |
11
|
1
|
|
|
1
|
|
485
|
return qr|^([a-zA-Z0-9-_]{11})$|; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'timecode_reg' => ( |
15
|
|
|
|
|
|
|
'is' => 'lazy', |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _build_timecode_reg{ |
19
|
2
|
|
|
2
|
|
1000
|
return qr/(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)/; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub process{ |
23
|
8
|
|
|
8
|
0
|
15
|
my ( $self, $embeder, $uri ) = @_; |
24
|
|
|
|
|
|
|
|
25
|
8
|
|
100
|
|
|
33
|
my ( $vid ) = ( $uri->query_param('v') || '' ) =~ m/${ \$self->validate_reg }/; |
|
8
|
|
|
|
|
438
|
|
26
|
|
|
|
|
|
|
|
27
|
8
|
|
|
|
|
262
|
return $self->_process( $embeder, $vid, $uri ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _process{ |
31
|
14
|
|
|
14
|
|
29
|
my ( $self, $embeder, $vid, $uri ) = @_; |
32
|
|
|
|
|
|
|
|
33
|
14
|
100
|
|
|
|
38
|
if ( $vid ){ |
34
|
10
|
|
100
|
|
|
51
|
my $timecode = $uri->query_param('t') || $uri->fragment || ''; |
35
|
10
|
|
|
|
|
661
|
$vid .= '?rel=0&html5=1'; |
36
|
10
|
100
|
66
|
|
|
35
|
if ( |
37
|
|
|
|
|
|
|
defined( $timecode ) |
38
|
10
|
|
|
|
|
211
|
&& ( my @time = $timecode =~ m/${ \$self->timecode_reg }/ ) |
39
|
|
|
|
|
|
|
){ |
40
|
6
|
|
|
|
|
113
|
my $start = 0; |
41
|
6
|
100
|
|
|
|
18
|
if ( $time[0] ){ |
42
|
|
|
|
|
|
|
#hours |
43
|
4
|
|
|
|
|
18
|
$start += 3600 * $time[0]; |
44
|
|
|
|
|
|
|
} |
45
|
6
|
100
|
|
|
|
19
|
if ( $time[1] ){ |
46
|
|
|
|
|
|
|
#mins |
47
|
5
|
|
|
|
|
11
|
$start += 60 * $time[1]; |
48
|
|
|
|
|
|
|
} |
49
|
6
|
50
|
|
|
|
20
|
if ( $time[2] ){ |
50
|
|
|
|
|
|
|
#seconds |
51
|
6
|
|
|
|
|
11
|
$start += $time[2]; |
52
|
|
|
|
|
|
|
} |
53
|
6
|
50
|
|
|
|
15
|
if ( $start ){ |
54
|
6
|
|
|
|
|
18
|
$vid .= "&start=${start}"; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
10
|
|
|
|
|
48
|
return qq||; |
|
10
|
|
|
|
|
178
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
4
|
|
|
|
|
24
|
return undef; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |