/**
* Fetches video data by youtube url
* @param string $videoUrl YouTube url
* @return Video
*/
public function getVideoByUrl($videoUrl)
{
$url = new Nette\Http\Url($videoUrl);
if (stripos($url->host, 'youtu.be') !== false) {
return $this->getVideo(trim($url->getPath(), '/'));
}
$videoId = $url->getQueryParameter('v');
if (stripos($url->host, 'youtube.com') === false || $videoId === null) {
throw new Nette\InvalidArgumentException('videoUrl must be valid youtube url.');
}
return $this->getVideo($videoId);
}