|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Rutube.php |
|
4
|
|
|
* |
|
5
|
|
|
* @package Providers |
|
6
|
|
|
* @author dotzero <[email protected]> |
|
7
|
|
|
* @link http://www.dotzero.ru/ |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Embera\Providers; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* The Rutube.ru Provider |
|
14
|
|
|
*/ |
|
15
|
|
|
class Rutube extends \Embera\Adapters\Service |
|
16
|
|
|
{ |
|
17
|
|
|
/** inline {@inheritdoc} */ |
|
18
|
|
|
protected $apiUrl = 'http://rutube.ru/api/oembed/?format=json'; |
|
19
|
|
|
|
|
20
|
|
|
/** inline {@inheritdoc} */ |
|
21
|
2 |
|
protected function validateUrl() |
|
22
|
|
|
{ |
|
23
|
2 |
|
$this->url->stripWWW(); |
|
24
|
2 |
|
$this->url->stripQueryString(); |
|
25
|
|
|
|
|
26
|
2 |
|
return (preg_match('~\/video\/([a-z0-9]{25,})~i', $this->url)); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** inline {@inheritdoc} */ |
|
30
|
2 |
|
protected function normalizeUrl() |
|
31
|
|
|
{ |
|
32
|
2 |
|
$this->url->stripQueryString(); |
|
33
|
|
|
|
|
34
|
2 |
|
if (preg_match('~\/video\/([a-z0-9]{25,})~i', $this->url, $matches)) { |
|
35
|
2 |
|
$this->url = new \Embera\Url('http://rutube.ru/video/' . $matches['1'] . '/'); |
|
36
|
2 |
|
} |
|
37
|
2 |
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** inline {@inheritdoc} */ |
|
40
|
|
|
public function fakeResponse() |
|
41
|
|
|
{ |
|
42
|
|
|
preg_match('~\/video\/([a-z0-9]{25,})~i', $this->url, $matches); |
|
43
|
|
|
|
|
44
|
|
|
return array( |
|
45
|
|
|
'type' => 'video', |
|
46
|
|
|
'provider_name' => 'Rutube', |
|
47
|
|
|
'provider_url' => 'http://rutube.ru', |
|
48
|
|
|
'title' => 'Unknown title', |
|
49
|
|
|
'html' => '<iframe src="//rutube.ru/video/embed/' . $matches['1'] . '" width="{width}" height="{height}" frameborder="0" title="" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>', |
|
50
|
|
|
); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|