fix google pse

i tested everything, also tested if invalid api key and such and regression tested searxng which still works
This commit is contained in:
HadiCherkaoui
2025-02-28 09:13:11 +01:00
parent 4d41243108
commit 7a816efc04
4 changed files with 29 additions and 39 deletions

View File

@@ -45,22 +45,14 @@ async function performImageSearch(query: string) {
switch (searchEngine) {
case 'google': {
const googleResult = await searchGooglePSE(query);
images = googleResult.originalres
.map((result) => {
// Extract image URL from multiple possible locations in Google's response
const imageSrc = result.pagemap?.cse_image?.[0]?.src ||
result.pagemap?.cse_thumbnail?.[0]?.src ||
result.image?.thumbnailLink;
if (imageSrc && result.link && result.title) {
images.push({
img_src: imageSrc,
url: result.link,
images = googleResult.results.map((result) => {
if (result.img_src && result.url && result.title) {
return {
img_src: result.img_src,
url: result.url,
title: result.title,
// Add additional metadata if needed
source: result.displayLink,
fileFormat: result.fileFormat,
});
source: result.displayLink
};
}
})
.filter(Boolean);