From 0790a2e3019b5f605014543797206b7078bb08ea Mon Sep 17 00:00:00 2001 From: malbero Date: Tue, 18 Oct 2022 16:44:03 +0200 Subject: [PATCH] Include "shorts" in URL parser and add video id fallback --- src/Youtube.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Youtube.php b/src/Youtube.php index 2ad7500..f71c855 100644 --- a/src/Youtube.php +++ b/src/Youtube.php @@ -476,8 +476,12 @@ public static function parseVIdFromURL($youtube_url) $path = static::_parse_url_path($youtube_url); $videoId = substr($path, 7); } + if (strpos($youtube_url, 'shorts')) { + $path = static::_parse_url_path($youtube_url); + $videoId = substr($path, 8); + } if ($params = static::_parse_url_query($youtube_url)) { - $videoId = isset($params['v']) ? $params['v'] : null; + $videoId = isset($params['v']) ? $params['v'] : $videoId; } } elseif (strpos($youtube_url, 'youtu.be')) { $path = static::_parse_url_path($youtube_url);