Skip to content

Commit

Permalink
Fix exception caused by non-image results in Google reverse image search
Browse files Browse the repository at this point in the history
  • Loading branch information
d4n3436 committed Dec 28, 2023
1 parent ebf6a26 commit bb9e958
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Apis/Google/GoogleLensClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,16 @@ public async Task<IReadOnlyList<IGoogleLensResult>> ReverseImageSearchAsync(stri

var matches = data[8][0][12];

return matches.EnumerateArray().Select(x => new GoogleLensResult(
return matches
.EnumerateArray()
.Where(x => x[0].GetArrayLength() != 0)
.Select(x => new GoogleLensResult(
x[3].GetString()!,
x[5].GetString()!,
x[0][0].GetString()!,
x[7].GetString()!,
x[15][0].GetString()!)).ToArray();
x[15][0].GetString()!))
.ToArray();
}

private static JsonDocument ExtractDataPack(byte[] page, ReadOnlySpan<byte> callbackStart)
Expand Down

0 comments on commit bb9e958

Please sign in to comment.