src/Helper.php
public static function getYoutubeInfo(string $videoId) : array
    {
        $info = file_get_contents(static::YOUTUBE_INFO_URL . $videoId);
        if (!$info || stripos($info, static::YOUTUBE_STATUS_FAIL) !== false) {
            throw new YoutubeException('Не удалось получить информацию о видеоролике');
        }

        $info = explode('&', $info);
        $newInfo = [];

        foreach ($info as $record) {
            $record = explode('=', $record);
            $newInfo[$record[0]] = urldecode($record[1]);
        }

        $sources = explode(',', $newInfo[static::YOUTUBE_URL_ENCODED]);
        foreach ($sources as &$source) {
            $streams = [];
            foreach (explode('&', $source) as $record) {
                $record = explode('=', $record);
                $streams[$record[0]] = urldecode($record[1]);
            }

            $source = $streams;
        }

        unset($source);

        return [
            'title'   => str_replace('+', '', $newInfo[static::YOUTUBE_TITLE] ?? ''),
            'poster'  => str_replace(
                static::YOUTUBE_IMG_NAME,
                static::YOUTUBE_MAX_IMG_NAME,
                $newInfo[static::YOUTUBE_THUMBNAIL_URL] ?? ''
            ),
            'sources' => $sources,
        ];
    }
public static function getYoutubeInfo(string $videoId) : array
    {
        $info = file_get_contents(static::YOUTUBE_INFO_URL . $videoId);
        if (!$info || stripos($info, static::YOUTUBE_STATUS_FAIL) !== false) {
            throw new YoutubeException('Не удалось получить информацию о видеоролике');
        }

        $info = explode('&', $info);
        $newInfo = [];

        foreach ($info as $record) {
            $record = explode('=', $record);
            $newInfo[$record[0]] = urldecode($record[1]);
        }

        $sources = explode(',', $newInfo[static::YOUTUBE_URL_ENCODED]);
        foreach ($sources as &$source) {
            $streams = [];
            foreach (explode('&', $source) as $record) {
                $record = explode('=', $record);
                $streams[$record[0]] = urldecode($record[1]);
            }

            $source = $streams;
        }

        unset($source);

        return [
            'title'   => str_replace('+', '', $newInfo[static::YOUTUBE_TITLE] ?? ''),
            'poster'  => str_replace(
                static::YOUTUBE_IMG_NAME,
                static::YOUTUBE_MAX_IMG_NAME,
                $newInfo[static::YOUTUBE_THUMBNAIL_URL] ?? ''
            ),
            'sources' => $sources,
        ];
    }
Получить информацию о ролике с Youtube

@param string $videoId - иденетификатор видео

@return array

@throws HelperException