Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements: Shorts video ID parsing support #186

Open
hasnat-we opened this issue Mar 18, 2023 · 1 comment
Open

Improvements: Shorts video ID parsing support #186

hasnat-we opened this issue Mar 18, 2023 · 1 comment

Comments

@hasnat-we
Copy link

@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().

@alaouy
Copy link
Owner

alaouy commented Mar 18, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants