mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-05-10 15:12:12 +00:00
Added URL handling to a few more existing info providers
This commit is contained in:
parent
10acc2e130
commit
24f0f0d23c
5 changed files with 115 additions and 19 deletions
|
|
@ -33,7 +33,7 @@ use App\Settings\InfoProviderSystem\LCSCSettings;
|
|||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
class LCSCProvider implements BatchInfoProviderInterface
|
||||
class LCSCProvider implements BatchInfoProviderInterface, URLHandlerInfoProviderInterface
|
||||
{
|
||||
|
||||
private const ENDPOINT_URL = 'https://wmsc.lcsc.com/ftps/wm';
|
||||
|
|
@ -452,4 +452,21 @@ class LCSCProvider implements BatchInfoProviderInterface
|
|||
ProviderCapabilities::FOOTPRINT,
|
||||
];
|
||||
}
|
||||
|
||||
public function getHandledDomains(): array
|
||||
{
|
||||
return ['lcsc.com'];
|
||||
}
|
||||
|
||||
public function getIDFromURL(string $url): ?string
|
||||
{
|
||||
//Input example: https://www.lcsc.com/product-detail/C258144.html?s_z=n_BC547
|
||||
//The part between the "C" and the ".html" is the unique ID
|
||||
|
||||
$matches = [];
|
||||
if (preg_match("#/product-detail/(\w+)\.html#", $url, $matches) > 0) {
|
||||
return $matches[1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue