From f3896ed543c5e026ee114fa37e243a01c71322a7 Mon Sep 17 00:00:00 2001 From: sysadminstory Date: Wed, 9 Aug 2023 17:35:35 +0200 Subject: [PATCH] [ImgsedBridge] Add detectParameters feature to the bridge (#3604) The bridge can detect the most common profile variation URL of instagram.com or imgsed.com websites to extract the username. --- bridges/ImgsedBridge.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/bridges/ImgsedBridge.php b/bridges/ImgsedBridge.php index 1555c578..5fe3eee8 100644 --- a/bridges/ImgsedBridge.php +++ b/bridges/ImgsedBridge.php @@ -256,4 +256,30 @@ HTML, } return parent::getName(); } + + public function detectParameters($url) + { + $params = [ + 'post' => 'on', + 'story' => 'on', + 'tagged' => 'on' + ]; + $regex = '/^http(s|):\/\/((www\.|)(instagram.com)\/([a-zA-Z0-9_\.]{1,30})\/(reels\/|tagged\/|) +|(www\.|)(imgsed.com)\/(stories\/|tagged\/|)([a-zA-Z0-9_\.]{1,30})\/)/'; + if (preg_match($regex, $url, $matches) > 0) { + // Extract detected domain using the regex + $domain = $matches[8] ?? $matches[4]; + if ($domain == 'imgsed.com') { + $params['u'] = $matches[10]; + return $params; + } else if ($domain == 'instagram.com') { + $params['u'] = $matches[5]; + return $params; + } else { + return null; + } + } else { + return null; + } + } }