Skip to content

Commit dd5fc57

Browse files
committed
tests, removed old adapters, fixes, etc
1 parent 6605f39 commit dd5fc57

36 files changed

+265
-266
lines changed

demo/index.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,8 @@ function getResolverOption($name, $default = null)
173173
$options['oembedParameters'] = $options['oembedParameters'] ? json_decode($options['oembedParameters'], true) : array();
174174
}
175175

176-
$resolverOptions = isset($_GET['resolver']) ? (array) $_GET['resolver'] : array();
177-
178-
Embed\Request::setResolverConfig($resolverOptions);
179-
180-
$url = new Embed\Request($_GET['url']);
181-
$info = Embed\Embed::create($url, $options);
176+
$request = new Embed\Request(new Embed\Url($_GET['url'], null, isset($_GET['resolver']) ? (array) $_GET['resolver'] : null));
177+
$info = Embed\Embed::create($request, $options);
182178
?>
183179

184180
<?php if (empty($info)): ?>
@@ -301,7 +297,7 @@ function getResolverOption($name, $default = null)
301297
<td>
302298
<ul>
303299
<?php
304-
foreach ($url->getRequestInfo() as $name => $value) {
300+
foreach ($request->getRequestInfo() as $name => $value) {
305301
if (is_array($value)) {
306302
$value = print_r($value, true);
307303
}
@@ -319,7 +315,7 @@ function getResolverOption($name, $default = null)
319315
<tr>
320316
<th>Content</th>
321317
<td>
322-
<pre><?php echo htmlspecialchars($url->getContent(), ENT_IGNORE); ?></pre>
318+
<pre><?php echo htmlspecialchars($request->getContent(), ENT_IGNORE); ?></pre>
323319
</td>
324320
</tr>
325321
</table>

src/Adapters/Adapter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public function __construct(Request $request, array $options = null)
6161

6262
$this->initProviders($request);
6363

64-
if ($request->getUrl() !== $this->url) {
65-
$this->initProviders($request->createSubRequest($this->url));
64+
if ($request->url->getUrl() !== $this->url) {
65+
$this->initProviders($request->createRequest($this->url));
6666
}
6767
}
6868

@@ -142,7 +142,7 @@ public function getUrlFromProviders($name)
142142
*/
143143
public function getTitle()
144144
{
145-
return $this->getFromProviders('title') ?: $this->request->getUrl();
145+
return $this->getFromProviders('title') ?: $this->request->url->getUrl();
146146
}
147147

148148
/**
@@ -158,7 +158,7 @@ public function getDescription()
158158
*/
159159
public function getUrl()
160160
{
161-
return $this->getUrlFromProviders('url') ?: $this->request->getUrl();
161+
return $this->getUrlFromProviders('url') ?: $this->request->url->getUrl();
162162
}
163163

164164
/**

src/Adapters/Cadenaser.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/Adapters/Facebook.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected function initProviders(Request $request)
8383

8484
if (($id = $this->getId($request->getStartingUrl()))) {
8585
if ($this->options['facebookAccessToken']) {
86-
$api = $request->createSubRequest('https://graph.facebook.com/'.$id);
86+
$api = $request->createRequest('https://graph.facebook.com/'.$id);
8787
$api->setParameter('access_token', $this->options['facebookAccessToken']);
8888

8989
if ($json = $api->getJsonContent()) {

src/Adapters/File.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class File extends Adapter implements AdapterInterface
1313
{
1414
private static $contentTypes = array(
1515
'video/ogg' => array('video', 'videoHtml'),
16+
'application/ogg' => array('video', 'videoHtml'),
1617
'video/ogv' => array('video', 'videoHtml'),
1718
'video/webm' => array('video', 'videoHtml'),
1819
'video/mp4' => array('video', 'videoHtml'),
@@ -98,8 +99,8 @@ public function getImages()
9899
public function getProviderIcons()
99100
{
100101
return array(
101-
$this->request->getAbsolute('/favicon.ico'),
102-
$this->request->getAbsolute('/favicon.png'),
102+
$this->request->url->getAbsolute('/favicon.ico'),
103+
$this->request->url->getAbsolute('/favicon.png'),
103104
);
104105
}
105106
}

src/Adapters/Giphy.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ public static function check(Request $request)
2424
*/
2525
public function getCode()
2626
{
27-
if (($id = $this->request->getDirectory(1))) {
28-
return Viewers::iframe('//giphy.com/embed/'.$id, $this->width.'px', $this->height.'px');
27+
if (($url = $this->providers['TwitterCards']->get('player'))) {
28+
$url = str_replace('/twitter/iframe', '?html5=true', $url);
29+
return Viewers::iframe($url, $this->width.'px', $this->height.'px');
2930
}
3031
}
3132
}

src/Adapters/Github.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected function initProviders(Request $request)
2929
parent::initProviders($request);
3030

3131
$this->api = new Provider();
32-
$api = $request->createSubRequest($request->getUrl().'.json');
32+
$api = $request->createRequest($request->url->getUrl().'.json');
3333

3434
if (($json = $api->getJsonContent())) {
3535
$this->api->set($json);

src/Adapters/Google.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static function check(Request $request)
2626
*/
2727
public function getCode()
2828
{
29-
$url = new Url($this->request->getUrl());
29+
$url = new Url($this->request->url->getUrl());
3030

3131
$url->setParameter('output', 'embed');
3232
$url->setParameter('s', '');

src/Adapters/Marca.php

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/Adapters/Mit.php

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ class Mit extends Webpage implements AdapterInterface
1515
public static function check(Request $request)
1616
{
1717
return $request->match(array(
18-
'http://media.mit.edu/video/view/*',
19-
'http://www.media.mit.edu/video/view/*',
18+
'http://video.mit.edu/watch/*',
2019
));
2120
}
2221

@@ -25,7 +24,25 @@ public static function check(Request $request)
2524
*/
2625
public function getCode()
2726
{
28-
return Viewers::iframe(str_replace('/video/view/', '/video/embed/', $this->getUrl()));
27+
$url = $this->getUrl();
28+
$url = preg_replace('|(/watch/[\w-]+)-([\d]+)|', '/embed/$2', $url);
29+
return Viewers::iframe($url, $this->getWidth(), $this->getHeight());
30+
}
31+
32+
/**
33+
* {@inheritDoc}
34+
*/
35+
public function getWidth()
36+
{
37+
return 600;
38+
}
39+
40+
/**
41+
* {@inheritDoc}
42+
*/
43+
public function getHeight()
44+
{
45+
return 337;
2946
}
3047

3148
/**
@@ -35,4 +52,12 @@ public function getProviderName()
3552
{
3653
return 'MIT Media Lab';
3754
}
55+
56+
/**
57+
* {@inheritDoc}
58+
*/
59+
public function getType()
60+
{
61+
return 'video';
62+
}
3863
}

0 commit comments

Comments
 (0)