Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Improvements: Shorts video ID parsing support  #186

@hasnat-we

Description

@hasnat-we

@alaouy Thanks for this awesome plugin. We need to support new YouTube shorts.

I am using following for only parsing ID and everything is working fine including shorts videos.

    /**
     * @param string|null $url
     * @return string|null
     */
    public static function getYouTubeVideoIDFromUrl(?string $url)
    {
        // See https://stackoverflow.com/a/71006865/3501553

        preg_match('/(youtu.*be.*)\/(watch\?v=|embed\/|v|shorts|)(.*?((?=[&#?])|$))/', $url, $matches);

        return ($matches[3] ?? null);
    }

I hope we can use this logic in \Alaouy\Youtube\Youtube::parseVidFromURL().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions