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:
parent
4d41243108
commit
7a816efc04
4 changed files with 29 additions and 39 deletions
|
|
@ -63,11 +63,22 @@ export const searchGooglePSE = async (query: string) => {
|
|||
title: item.title,
|
||||
url: item.link,
|
||||
content: item.snippet,
|
||||
img_src: item.pagemap?.cse_image?.[0]?.src,
|
||||
img_src: item.pagemap?.cse_image?.[0]?.src
|
||||
|| item.pagemap?.cse_thumbnail?.[0]?.src
|
||||
|| item.image?.thumbnailLink,
|
||||
...(item.pagemap?.videoobject?.[0] && {
|
||||
videoData: {
|
||||
duration: item.pagemap.videoobject[0].duration,
|
||||
embedUrl: item.pagemap.videoobject[0].embedurl
|
||||
}
|
||||
})
|
||||
}));
|
||||
|
||||
return { results, originalres };
|
||||
} catch (error) {
|
||||
throw new Error('Google PSE Error:', error.response?.data || error.message);
|
||||
const errorMessage = error.response?.data
|
||||
? JSON.stringify(error.response.data, null, 2)
|
||||
: error.message || 'Unknown error';
|
||||
throw new Error(`Google PSE Error: ${errorMessage}`);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue