summaryrefslogtreecommitdiff
path: root/classes/urlhelper.php
diff options
context:
space:
mode:
authorkdan <[email protected]>2021-05-11 11:05:20 +0300
committerkdan <[email protected]>2021-05-11 11:05:20 +0300
commit2ccf0e50a25086bb81155492ee9ebd1ac755c035 (patch)
tree7ad648695adb52632a08f9958176c339f5dbba5e /classes/urlhelper.php
parentacf0e0d266add0566e41b28946ee73fa01022255 (diff)
parentb2f888e3868c3703819e8acc1519e44d57a53259 (diff)
Merge branch 'master' into master
Diffstat (limited to 'classes/urlhelper.php')
-rw-r--r--classes/urlhelper.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/classes/urlhelper.php b/classes/urlhelper.php
index 46d80a0e6..edfb2ad73 100644
--- a/classes/urlhelper.php
+++ b/classes/urlhelper.php
@@ -487,4 +487,26 @@ class UrlHelper {
}
}
+ public static function url_to_youtube_vid($url) {
+ $url = str_replace("youtube.com", "youtube-nocookie.com", $url);
+
+ $regexps = [
+ "/\/\/www\.youtube-nocookie\.com\/v\/([\w-]+)/",
+ "/\/\/www\.youtube-nocookie\.com\/embed\/([\w-]+)/",
+ "/\/\/www\.youtube-nocookie\.com\/watch?v=([\w-]+)/",
+ "/\/\/youtu.be\/([\w-]+)/",
+ ];
+
+ foreach ($regexps as $re) {
+ $matches = [];
+
+ if (preg_match($re, $url, $matches)) {
+ return $matches[1];
+ }
+ }
+
+ return false;
+ }
+
+
}