<?php namespace Uiharu\Lookup; use RuntimeException; use Uiharu\Url; use Index\MediaType; use Index\Colour\{Colour,ColourRgb}; final class YouTubeLookupResult implements \Uiharu\ILookupResult { public function __construct( private Url $url, private string $videoId, private object $videoInfo, private array $urlQuery ) {} public function getUrl(): Url { return $this->url; } public function getObjectType(): string { return 'youtube:video'; } public function getYouTubeVideoId(): string { return $this->videoId; } public function getYouTubeVideoInfo(): object { return $this->videoInfo; } public function getYouTubeUrlQuery(): array { return $this->urlQuery; } public function hasYouTubeVideoStartTime(): bool { return isset($this->urlQuery['t']); } public function getYouTubeVideoStartTime(): string { return $this->urlQuery['t'] ?? ''; } public function hasYouTubePlayListId(): bool { return isset($this->urlQuery['list']); } public function getYouTubePlayListId(): string { return $this->urlQuery['list'] ?? ''; } public function hasYouTubePlayListIndex(): bool { return isset($this->urlQuery['index']); } public function getYouTubePlayListIndex(): string { return $this->urlQuery['index'] ?? ''; } public function hasMediaType(): bool { return false; } public function getMediaType(): MediaType { throw new RuntimeException('Unsupported'); } public function hasColour(): bool { return true; } public function getColour(): Colour { return ColourRgb::fromRawRgb(0xFF0000); } public function hasTitle(): bool { return !empty($this->videoInfo->items[0]->snippet->title); } public function getTitle(): string { return $this->videoInfo->items[0]->snippet->title; } public function hasSiteName(): bool { return true; } public function getSiteName(): string { return 'YouTube'; } public function hasDescription(): bool { return !empty($this->videoInfo->items[0]->snippet->description); } public function getDescription(): string { return $this->videoInfo->items[0]->snippet->description; } public function hasPreviewImage(): bool { return !empty($this->videoInfo->items[0]->snippet->thumbnails->medium->url); } public function getPreviewImage(): string { return $this->videoInfo->items[0]->snippet->thumbnails->medium->url; } }