-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
142 additions
and
1 deletion.
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
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,29 @@ | ||
<?php | ||
|
||
namespace spicyweb\embeddedassets\adapters\ipcamlive; | ||
|
||
use spicyweb\embeddedassets\adapters\default\Extractor as BaseExtractor; | ||
use spicyweb\embeddedassets\adapters\ipcamlive\detectors\Code; | ||
use spicyweb\embeddedassets\adapters\ipcamlive\detectors\ProviderName; | ||
use spicyweb\embeddedassets\adapters\ipcamlive\detectors\ProviderUrl; | ||
use spicyweb\embeddedassets\adapters\ipcamlive\detectors\Type; | ||
|
||
/** | ||
* Embed extractor class for IPCamLive. | ||
* | ||
* @package spicyweb\embeddedassets\adapters\ipcamlive | ||
* @author Spicy Web <[email protected]> | ||
* @since 5.3.0 | ||
*/ | ||
class Extractor extends BaseExtractor | ||
{ | ||
public function createCustomDetectors(): array | ||
{ | ||
return [ | ||
'code' => new Code($this), | ||
'providerName' => new ProviderName($this), | ||
'providerUrl' => new ProviderUrl($this), | ||
'type' => new Type($this), | ||
] + parent::createCustomDetectors(); | ||
} | ||
} |
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,32 @@ | ||
<?php | ||
|
||
namespace spicyweb\embeddedassets\adapters\ipcamlive\detectors; | ||
|
||
use craft\helpers\Html; | ||
use Embed\Detectors\Code as BaseCodeDetector; | ||
use Embed\EmbedCode; | ||
|
||
/** | ||
* Embed code detector class for IPCamLive. | ||
* | ||
* @package spicyweb\embeddedassets\adapters\ipcamlive\detectors | ||
* @author Spicy Web <[email protected]> | ||
* @since 5.3.0 | ||
*/ | ||
class Code extends BaseCodeDetector | ||
{ | ||
public function detect(): ?EmbedCode | ||
{ | ||
$uri = $this->extractor->getUri(); | ||
|
||
if ($uri->getPath() !== '/player/player.php') { | ||
return null; | ||
} | ||
|
||
$iframe = Html::tag('iframe', '', [ | ||
'src' => (string)$uri, | ||
]); | ||
|
||
return new EmbedCode(htmlspecialchars_decode($iframe, ENT_QUOTES | ENT_HTML5)); | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace spicyweb\embeddedassets\adapters\ipcamlive\detectors; | ||
|
||
use Embed\Detectors\ProviderName as BaseProviderNameDetector; | ||
|
||
/** | ||
* Embed provider name detector class for IPCamLive. | ||
* | ||
* @package spicyweb\embeddedassets\adapters\ipcamlive\detectors | ||
* @author Spicy Web <[email protected]> | ||
* @since 5.3.0 | ||
*/ | ||
class ProviderName extends BaseProviderNameDetector | ||
{ | ||
public function detect(): string | ||
{ | ||
return 'IPCamLive'; | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
namespace spicyweb\embeddedassets\adapters\ipcamlive\detectors; | ||
|
||
use Embed\Detectors\ProviderUrl as BaseProviderUrlDetector; | ||
use Psr\Http\Message\UriInterface; | ||
|
||
/** | ||
* Embed provider URL detector class for IPCamLive. | ||
* | ||
* @package spicyweb\embeddedassets\adapters\ipcamlive\detectors | ||
* @author Spicy Web <[email protected]> | ||
* @since 5.3.0 | ||
*/ | ||
class ProviderUrl extends BaseProviderUrlDetector | ||
{ | ||
public function detect(): UriInterface | ||
{ | ||
return $this->extractor->resolveUri('https://www.ipcamlive.com/'); | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
|
||
namespace spicyweb\embeddedassets\adapters\ipcamlive\detectors; | ||
|
||
use Embed\Detectors\Detector; | ||
|
||
/** | ||
* Embed type detector class for IPCamLive. | ||
* | ||
* @package spicyweb\embeddedassets\adapters\ipcamlive\detectors | ||
* @author Spicy Web <[email protected]> | ||
* @since 5.3.0 | ||
*/ | ||
class Type extends Detector | ||
{ | ||
public function detect(): ?string | ||
{ | ||
return $this->extractor->getUri()->getPath() === '/player/player.php' | ||
? 'rich' | ||
: 'link'; | ||
} | ||
} |
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