Improvements: Shorts video ID parsing support
Opened this issue · 1 comments
hasnat-we commented
@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 commented
@hasnat-we Yes absolutely, if you can include it in a PR I will happily
merge it ;)
…On Sat, Mar 18, 2023 at 3:49 PM Hasnat WE ***@***.***> wrote:
@alaouy <https://github.com/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().
—
Reply to this email directly, view it on GitHub
<#186>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXZOKK2BH22KE4I72WTPITW4XDNXANCNFSM6AAAAAAV7QMU44>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>