Skip to content

Commit

Permalink
feat: Added support for Shopshare Provider
Browse files Browse the repository at this point in the history
  • Loading branch information
mpratt committed Apr 12, 2024
1 parent 540e7a3 commit 9bd050a
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/02-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ I try to support all the providers listed on [oembed.com](https://oembed.com).
- [ScribbleMaps](providers/ScribbleMaps.md)
- [Scribd](providers/Scribd.md)
- [SendToNews](providers/SendToNews.md)
- [Shopshare](providers/Shopshare.md)
- [Shoudio](providers/Shoudio.md)
- [ShowTheWay](providers/ShowTheWay.md)
- [Sketchfab](providers/Sketchfab.md)
Expand Down
17 changes: 17 additions & 0 deletions doc/providers/Shopshare.md
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


56 changes: 56 additions & 0 deletions src/Embera/Provider/Shopshare.php
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ public function __construct(array $config = [])
'ScribbleMaps',
'Scribd',
'SendToNews',
'Shopshare',
'Shoudio',
'ShowTheWay',
'Sketchfab',
Expand Down
36 changes: 36 additions & 0 deletions tests/Embera/Provider/ShopshareTest.php
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]);
}
}

0 comments on commit 9bd050a

Please sign in to comment.