Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
Improve saucenao handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklul committed Mar 20, 2020
1 parent c13fd17 commit 5b4265e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -1099,15 +1099,23 @@ private function reverseSearchSaucenao($file)

$result = json_decode($output, true);

if (empty($output)) {
return ['error' => 'EmptyResult'];
}

$matches = [];
if (isset($result['header']['status'])) {
if ($result['header']['status'] === 0) {
foreach ($result['results'] as $this_result) {
if (isset($this_result['data']['ext_urls'])) {
if (isset($this_result['data']['ext_urls']) && (float)$this_result['header']['similarity'] >= 55) {
$matches[] = $this_result['data']['ext_urls'][0];
}
}

if (count($matches) === 0) {
return ['error' => 'NoResults'];
}

return $matches;
}

Expand Down

0 comments on commit 5b4265e

Please # to comment.