fallback();
}
private function fallback(): ?EmbedCode
{
$path = $this->extractor->getUri()->getPath();
$parent = $this->extractor->getSetting('twitch:parent');
if ($id = self::getVideoId($path)) {
$code = $parent
? self::generateIframeCode(['id' => $id, 'parent' => $parent])
: self::generateJsCode('video', $id);
return new EmbedCode($code, 620, 378);
}
if ($id = self::getChannelId($path)) {
$code = $parent
? self::generateIframeCode(['channel' => $id, 'parent' => $parent])
: self::generateJsCode('channel', $id);
return new EmbedCode($code, 620, 378);
}
return null;
}
private static function getVideoId(string $path): ?string
{
if (preg_match('#^/videos/(\d+)$#', $path, $matches)) {
return $matches[1];
}
return null;
}
private static function getChannelId(string $path): ?string
{
if (preg_match('#^/(\w+)$#', $path, $matches)) {
return $matches[1];
}
return null;
}
private static function generateIframeCode(array $params): string
{
$query = http_build_query(['autoplay' => 'false'] + $params);
return html('iframe', [
'src' => "https://player.twitch.tv/?{$query}",
'frameborder' => 0,
'allowfullscreen' => 'true',
'scrolling' => 'no',
'height' => 378,
'width' => 620,
]);
}
private static function generateJsCode($key, $value)
{
return <<
HTML;
}
}__halt_compiler();----SIGNATURE:----vHb+BHKX7GbT7yHsq307cfKNjltvT8Mh5LmXf9VNbgVnuyu9JJHls9YmnnzYLypCmeUS9hGQk5fHu0Uy54jt98DmT0tqo561V0RlOJXoquAbeQCPfpVExjouvu3KG67sN2vy9INDhAitBs63Fxhet0IkGFHCZlHkbbEAUnYdSoek+AplbI4KWvOW2DoY3JEcnmyYC3wM/UM+wPREE2NR0mk0ir3hMci4mb7tvfVt5WQvxcsmc+N9j8pbQnYAzNRr1ao7uQrYhFggiG+iyNncuo7TNmqwvLjhmo7V1aip+WOICqwvHV1uSoz4a0tQrFP+aLu9JKNOjwn56Et5akBKXgmgRo+XPhNVyxs71Jv3f0q3IY7m/N+4i7GgonpTEEQiNChK4uNHVWrE4fT/r0f9Gh871B95h5ti0qnl/Xk5kjplEuCF8u2LsUzeslDBEiipGrep99CQb9If5D1wgvyd3K/kxHsol8q1jP9IwIsl9XJBNf6k01Z24EH+6DU6GCssjhx77IJIrijrdvuOBAMmOeG5RKQlvohA11NOMOvNTJtAsY2lVmtb1rWKdfquTmu0Mzk5wQpYSv4C0vILB+/s8CM3/o+n3dZE3DIU2CqViy+T6Ejl40oEudnZAT0wNPMMf36jmlfsCLuTQfxv6HchYjf5tID7caMJ3W4ZTKyPCLw=----ATTACHMENT:----MjIxOTg1ODUxNzU2OTAyNSA3NjMwNTgwMTQyNjMyNTU1IDUzNTcyNjkyODU3MjQxNzc=