Skip to content

Commit 8f574c5

Browse files
committed
addded suppport to cadenaser.com
1 parent 7173582 commit 8f574c5

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 Oscar Otero Marzoa
3+
Copyright (c) 2016 Oscar Otero Marzoa
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

src/Adapters/Cadenaser.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace Embed\Adapters;
4+
5+
use Embed\Utils;
6+
use Embed\Request;
7+
8+
/**
9+
* Adapter to get the embed code from play.cadenaser.com.
10+
*/
11+
class Cadenaser extends Webpage implements AdapterInterface
12+
{
13+
/**
14+
* {@inheritdoc}
15+
*/
16+
public static function check(Request $request)
17+
{
18+
return $request->isValid() && $request->match([
19+
'https?://play.cadenaser.com/audio/*',
20+
]);
21+
}
22+
23+
/**
24+
* {@inheritdoc}
25+
*/
26+
public function getCode()
27+
{
28+
$url = $this->request->createUrl();
29+
$url = $url->withPath('/widget/'.$url->getPath());
30+
31+
return Utils::iframe($url->getUrl(), $this->width, $this->height);
32+
}
33+
34+
/**
35+
* {@inheritdoc}
36+
*/
37+
public function getWidth()
38+
{
39+
return 620;
40+
}
41+
42+
/**
43+
* {@inheritdoc}
44+
*/
45+
public function getHeight()
46+
{
47+
return 100;
48+
}
49+
}

tests/CadenaserTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
class CadenaserTest extends TestCaseBase
4+
{
5+
public function testOne()
6+
{
7+
$this->assertEmbed(
8+
'http://play.cadenaser.com/audio/001RD010000004275766/',
9+
[
10+
'title' => "Debate electoral gallego, en 'Hoy por Hoy' | Cadena SER",
11+
'width' => 620,
12+
'height' => 100,
13+
'type' => 'rich',
14+
'code' => '<iframe src="http://play.cadenaser.com/widget/audio/001RD010000004275766/" frameborder="0" allowTransparency="true" style="border:none;overflow:hidden;width:620px;height:100px;"></iframe>',
15+
'providerName' => 'Hoy por hoy',
16+
]
17+
);
18+
}
19+
}

0 commit comments

Comments
 (0)