diff --git a/app/Console/Commands/SearxInstances.php b/app/Console/Commands/SearxInstances.php index cd7f63779c61071ba074eb11bbcbe4e8e52eaa1a..bc4c0667ac9deac0bcc14bc736f9b7bf0542a669 100644 --- a/app/Console/Commands/SearxInstances.php +++ b/app/Console/Commands/SearxInstances.php @@ -45,15 +45,29 @@ class SearxInstances extends Command curl_close($ch); $response = json_decode($response); if($response !== null){ - $f = fopen('storage/instances.txt', 'w'); + $instances = []; foreach($response->instances as $instance => $data) { - if(!isset($data->{'error'}) && $data->{'network_type'} !== 'tor') { - fwrite($f, $instance . "\n"); + if(!isset($data->{'error'}) && + $data->{'network_type'} !== 'tor' && + isset($data->{'timing'}->{'search_go'}) && + isset($data->{'timing'}->{'search_go'}->{'all'}) && + isset($data->{'timing'}->{'search_go'}->{'all'}->{'median'}) && + $data->{'timing'}->{'search_go'}->{'all'}->{'median'} <= 1.8) { + try{ + $opensearch = file_get_contents($instance . 'opensearch.xml'); + if(!str_contains($opensearch, 'SyndicationRight')) { + $instances[] = $instance; + } + }catch(\Exception $e) { + + } } } + $f = fopen('storage/instances.txt', 'w'); + fwrite($f, implode("\n", $instances)); fclose($f); } else { echo "Unable to locate file. Check https://searx.space/data/instances.json for more info\n"; } } -} +} \ No newline at end of file