File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ declare (strict_types = 1 );
3+
4+ namespace Embed \Adapters \Tidal \Detectors ;
5+
6+ use Embed \Detectors \Code as Detector ;
7+ use Embed \EmbedCode ;
8+ use function Embed \html ;
9+
10+ class Code extends Detector
11+ {
12+ public function detect (): ?EmbedCode
13+ {
14+ return parent ::detect ()
15+ ?: $ this ->fallback ();
16+ }
17+
18+ private function fallback (): ?EmbedCode
19+ {
20+ $ uri = $ this ->extractor ->getUri ();
21+
22+ if (!preg_match ('{^/playlist/(?P<uuid>[0-9a-fA-F\-]{36})$} ' , $ uri ->getPath (), $ matches )) {
23+ return NULL ;
24+ }
25+
26+ $ html = html ('iframe ' , [
27+ 'src ' => 'https://embed.tidal.com/playlists/ ' . $ matches ['uuid ' ] . '?disableAnalytics=true ' ,
28+ 'allow ' => 'encrypted-media ' ,
29+ 'allowfullscreen ' => 'allowfullscreen ' ,
30+ 'frameborder ' => '0 ' ,
31+ 'style ' => 'width:100%;height:352px ' ,
32+ ]);
33+
34+ return new EmbedCode ($ html , null , 352 );
35+ }
36+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ class Extractor extends Base
1010 public function createCustomDetectors (): array
1111 {
1212 return [
13+ 'code ' => new Detectors \Code ($ this ),
1314 'providerName ' => new Detectors \ProviderName ($ this ),
1415 ];
1516 }
You can’t perform that action at this time.
0 commit comments