[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.
This commit is contained in:
sysadminstory 2023-08-09 17:35:35 +02:00 committed by GitHub
parent b86ee5778b
commit f3896ed543
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 0 deletions

View File

@ -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;
}
}
}