public function getVideoByUrl(string $videoUrl): Video
	{
		$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);
	}
public function getVideoByUrl(string $videoUrl): Video
	{
		$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);
	}
public function getVideoByUrl ( string $ videoUrl ) : Video { $ 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 ) ; }
Fetches video data by youtube url
Fetches video data by youtube url