1 | <?php namespace Arcanedev\EmbedVideo\Parsers; |
||
9 | class YoutubeParser extends AbstractParser |
||
10 | { |
||
11 | /* ----------------------------------------------------------------- |
||
12 | | Properties |
||
13 | | ----------------------------------------------------------------- |
||
14 | */ |
||
15 | /** |
||
16 | * The parser's URL patterns. |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $patterns = [ |
||
21 | '^(https?://)?(?:www\.)?youtu\.be/([0-9a-zA-Z-_]{11})?(?:(?:\S+)?(?:\?|&)t=([0-9hm]+s))?(?:\S+)?', |
||
22 | '^(https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com/(?:embed/|v/|watch\?v=|watch\?.+&v=))((?:\w|-){11})(?:(?:\S+)?(?:\?|&)t=([0-9hm]+s))?(?:\S+)?$' |
||
23 | ]; |
||
24 | |||
25 | /** |
||
26 | * Timestamp pattern and param. |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $timestamp = [ |
||
31 | 'pattern' => '^(?:https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com/)(?:\S+)?(?:(?:\S+)?(?:\?|&)t=(?:([0-9]+)h)?(?:([0-9]+)m)?(?:([0-9]+)s)?)$', |
||
32 | 'param' => 'start', |
||
33 | ]; |
||
34 | |||
35 | /* ----------------------------------------------------------------- |
||
36 | | Getters & Setters |
||
37 | | ----------------------------------------------------------------- |
||
38 | */ |
||
39 | /** |
||
40 | * Get the video id from cached matches. |
||
41 | * |
||
42 | * @return string |
||
43 | */ |
||
44 | 21 | public function videoId() |
|
48 | |||
49 | /** |
||
50 | * Get the default URL queries. |
||
51 | * |
||
52 | * @return array |
||
53 | */ |
||
54 | 30 | protected function defaultQueries() |
|
61 | |||
62 | /** |
||
63 | * Get the iframe pattern. |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | 21 | protected function getIframePattern() |
|
71 | |||
72 | /** |
||
73 | * Get the iframe replace. |
||
74 | * |
||
75 | * @return array |
||
76 | */ |
||
77 | 21 | protected function getIframeReplacer() |
|
84 | } |
||
85 |