-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added support for Shopshare Provider
- Loading branch information
Showing
5 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# [Shopshare](https://shopshare.tv|shopshare.tv) | ||
|
||
Shopshare Provider | ||
|
||
## Implementation Details | ||
|
||
- Provider | ||
Name: Shopshare | ||
- Documentation: NONE | ||
- HTTPS support: YES | ||
- Fake Response: NO | ||
- Oembed Params: maxwidth , maxheight | ||
- Supported Hosts: shopshare.tv | ||
- Responsive response: NO | ||
- Collections: DefaultProviderCollection | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* Shopshare.php | ||
* | ||
* @package Embera | ||
* @author Michael Pratt <yo@michael-pratt.com> | ||
* @link http://www.michael-pratt.com/ | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Embera\Provider; | ||
|
||
use Embera\Url; | ||
|
||
/** | ||
* Shopshare Provider | ||
* | ||
* @link https://shopshare.tv|shopshare.tv | ||
*/ | ||
class Shopshare extends ProviderAdapter implements ProviderInterface | ||
{ | ||
/** inline {@inheritdoc} */ | ||
protected $endpoint = 'https://shopshare.tv/api/shopcast/oembed'; | ||
|
||
/** inline {@inheritdoc} */ | ||
protected static $hosts = [ | ||
'shopshare.tv' | ||
]; | ||
|
||
/** inline {@inheritdoc} */ | ||
protected $allowedParams = [ 'maxwidth', 'maxheight' ]; | ||
|
||
/** inline {@inheritdoc} */ | ||
protected $httpsSupport = true; | ||
|
||
/** inline {@inheritdoc} */ | ||
protected $responsiveSupport = false; | ||
|
||
/** inline {@inheritdoc} */ | ||
public function validateUrl(Url $url) | ||
{ | ||
return (bool) (preg_match('~shopshare\.tv/(shopboard|shopcast)/([^/]+)~i', (string) $url)); | ||
} | ||
|
||
/** inline {@inheritdoc} */ | ||
public function normalizeUrl(Url $url) | ||
{ | ||
$url->convertToHttps(); | ||
$url->removeQueryString(); | ||
$url->removeLastSlash(); | ||
|
||
return $url; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/** | ||
* ShopshareTest.php | ||
* | ||
* @package Embera | ||
* @author Michael Pratt <yo@michael-pratt.com> | ||
* @link http://www.michael-pratt.com/ | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Embera\Provider; | ||
|
||
use Embera\ProviderTester; | ||
|
||
/** | ||
* Test the Shopshare Provider | ||
*/ | ||
final class ShopshareTest extends ProviderTester | ||
{ | ||
protected $tasks = [ | ||
'valid_urls' => [ | ||
'https://shopshare.tv/shopcast/U2hvcGNhc3Q6NzExNA==', | ||
'https://shopshare.tv/shopboard/TG9va2Jvb2s6ODQwOQ==', | ||
], | ||
'invalid_urls' => [ | ||
'https://shopshare.tv', | ||
], | ||
]; | ||
|
||
public function testProvider() | ||
{ | ||
$this->validateProvider('Shopshare', [ 'width' => 480, 'height' => 270]); | ||
} | ||
} |