From fea59de26b57a8922de1288d15c34968a75e39f4 Mon Sep 17 00:00:00 2001
From: Andrew Dolgov <noreply@fakecake.org>
Date: Fri, 7 May 2021 07:42:24 +0300
Subject: [PATCH] af_redditimgur: use core youtube vid helper

---
 plugins/af_redditimgur/init.php | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php
index b16b679af..3b4094b1b 100755
--- a/plugins/af_redditimgur/init.php
+++ b/plugins/af_redditimgur/init.php
@@ -425,13 +425,7 @@ class Af_RedditImgur extends Plugin {
 			}
 
 			$matches = array();
-			if (!$found && (preg_match("/youtube\.com\/v\/([\w-]+)/", $entry_href, $matches) ||
-				preg_match("/youtube\.com\/.*?[\&\?]v=([\w-]+)/", $entry_href, $matches) ||
-				preg_match("/youtube\.com\/embed\/([\w-]+)/", $entry_href, $matches) ||
-				preg_match("/youtube\.com\/watch\?v=([\w-]+)/", $entry_href, $matches) ||
-				preg_match("/\/\/youtu.be\/([\w-]+)/", $entry_href, $matches))) {
-
-				$vid_id = $matches[1];
+			if (!$found && $vid_id = UrlHelper::url_to_youtube_vid($entry_href)) {
 
 				Debug::log("Handling as youtube: $vid_id", Debug::LOG_VERBOSE);
 
-- 
GitLab