Skip to content

Commit

Permalink
feat: Added support for Trackspace
Browse files Browse the repository at this point in the history
  • Loading branch information
mpratt committed Apr 23, 2024
1 parent 2551891 commit 4e3ce7b
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 @@ -204,6 +204,7 @@ I try to support all the providers listed on [oembed.com](https://oembed.com).
- [TikTok](providers/TikTok.md)
- [Toornament](providers/Toornament.md)
- [TonicAudio](providers/TonicAudio.md)
- [Trackspace](providers/Trackspace.md)
- [TrinityAudio](providers/TrinityAudio.md)
- [Tumblr](providers/Tumblr.md)
- [Tuxx](providers/Tuxx.md)
Expand Down
17 changes: 17 additions & 0 deletions doc/providers/Trackspace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# [Trackspace](https://trackspace.upitup.com)

Trackspace Provider

## Implementation Details

- Provider
Name: Trackspace
- Documentation: NONE
- HTTPS support: YES
- Fake Response: NO
- Oembed Params: maxwidth , maxheight
- Supported Hosts: trackspace.upitup.com
- Responsive response: YES
- Collections: DefaultProviderCollection


56 changes: 56 additions & 0 deletions src/Embera/Provider/Trackspace.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* Trackspace.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;

/**
* Trackspace Provider
*
* @link https://trackspace.upitup.com
*/
class Trackspace extends ProviderAdapter implements ProviderInterface
{
/** inline {@inheritdoc} */
protected $endpoint = 'https://trackspace.upitup.com/oembed?format=json';

/** inline {@inheritdoc} */
protected static $hosts = [
'trackspace.upitup.com'
];

/** inline {@inheritdoc} */
protected $allowedParams = [ 'maxwidth', 'maxheight' ];

/** inline {@inheritdoc} */
protected $httpsSupport = true;

/** inline {@inheritdoc} */
protected $responsiveSupport = true;

/** inline {@inheritdoc} */
public function validateUrl(Url $url)
{
return (bool) (preg_match('~trackspace\.upitup\.com/(user|track)/([^/]+)~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 @@ -224,6 +224,7 @@ public function __construct(array $config = [])
'TikTok',
'Toornament',
'TonicAudio',
'Trackspace',
'TrinityAudio',
'Tumblr',
'Tuxx',
Expand Down
36 changes: 36 additions & 0 deletions tests/Embera/Provider/TrackspaceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* TrackspaceTest.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 Trackspace Provider
*/
final class TrackspaceTest extends ProviderTester
{
protected $tasks = [
'valid_urls' => [
'https://trackspace.upitup.com/track/17',
'https://trackspace.upitup.com/user/test-user-mrxme',
],
'invalid_urls' => [
'https://trackspace.upitup.com',
],
];

public function testProvider()
{
$this->validateProvider('Trackspace', [ 'width' => 480, 'height' => 270]);
}
}

0 comments on commit 4e3ce7b

Please sign in to comment.