This commit is contained in:
@@ -50,43 +50,43 @@ public class ImageFoundRequestHandler implements RequestHandler {
|
||||
Map.of("fileId",fileId)));
|
||||
});
|
||||
|
||||
// String searchResponseYandex;
|
||||
String searchResponseGoogle;
|
||||
// List<YandexSearchResponse.ImageResult> allYandexImages = new ArrayList<>();
|
||||
List<YandexSearchResponse.ImageResult> allGoogleImages = new ArrayList<>();
|
||||
String searchResponseYandex;
|
||||
// String searchResponseGoogle;
|
||||
List<YandexSearchResponse.ImageResult> allYandexImages = new ArrayList<>();
|
||||
// List<YandexSearchResponse.ImageResult> allGoogleImages = new ArrayList<>();
|
||||
List<YandexSearchResponse.ImageResult> allUniqueImages;
|
||||
boolean hasTimeout = false;
|
||||
//
|
||||
// try {
|
||||
// searchResponseGoogle = searchImageService.searchReverseByPublicUrl(fileEntity, "google_lens",
|
||||
// "exact_matches");
|
||||
// log.info("searchResponseGoogle OK,{}", searchResponseGoogle);
|
||||
// allGoogleImages = searchImageService.getAllImagesWithoutPagination(
|
||||
// searchResponseGoogle, "exact_matches");
|
||||
//
|
||||
// } catch (TimeoutException e) {
|
||||
// log.warn("Google search timeout for file {}", fileId);
|
||||
// hasTimeout = true;
|
||||
// } catch (IOException e) {
|
||||
// log.error("Google search failed for file {}", fileId, e);
|
||||
// }
|
||||
|
||||
try {
|
||||
searchResponseGoogle = searchImageService.searchReverseByPublicUrl(fileEntity, "google_lens",
|
||||
"exact_matches");
|
||||
log.info("searchResponseGoogle OK,{}", searchResponseGoogle);
|
||||
allGoogleImages = searchImageService.getAllImagesWithoutPagination(
|
||||
searchResponseGoogle, "exact_matches");
|
||||
|
||||
} catch (TimeoutException e) {
|
||||
log.warn("Google search timeout for file {}", fileId);
|
||||
hasTimeout = true;
|
||||
} catch (IOException e) {
|
||||
log.error("Google search failed for file {}", fileId, e);
|
||||
}
|
||||
|
||||
// try {
|
||||
// searchResponseYandex = searchImageService.searchReverseByPublicUrl(fileEntity, "yandex_reverse_image",
|
||||
// "visual_matches");
|
||||
// log.info("searchResponseYandex OK");
|
||||
// allYandexImages = searchImageService.getAllImagesWithoutPagination(
|
||||
// searchResponseYandex, "visual_matches");
|
||||
// } catch (TimeoutException e) {
|
||||
// log.warn("Yandex search timeout for file {}", fileId);
|
||||
// hasTimeout = true;
|
||||
// } catch (IOException e) {
|
||||
// log.error("Yandex search failed for file {}", fileId, e);
|
||||
// }
|
||||
try {
|
||||
searchResponseYandex = searchImageService.searchReverseByPublicUrl(fileEntity, "yandex_reverse_image",
|
||||
"visual_matches");
|
||||
log.info("searchResponseYandex OK");
|
||||
allYandexImages = searchImageService.getAllImagesWithoutPagination(
|
||||
searchResponseYandex, "visual_matches");
|
||||
} catch (TimeoutException e) {
|
||||
log.warn("Yandex search timeout for file {}", fileId);
|
||||
hasTimeout = true;
|
||||
} catch (IOException e) {
|
||||
log.error("Yandex search failed for file {}", fileId, e);
|
||||
}
|
||||
|
||||
// allUniqueImages = searchImageService.removeDuplicateUrls(allYandexImages, allGoogleImages);
|
||||
allUniqueImages = allGoogleImages;
|
||||
// allUniqueImages = allYandexImages;
|
||||
// allUniqueImages = allGoogleImages;
|
||||
allUniqueImages = allYandexImages;
|
||||
log.info("allUniqueImages OK: {} images", allUniqueImages.size());
|
||||
|
||||
tariffInfoService.writeOffTokens(fileEntity.getUserId(), TariffConstants.TOKEN_VALUE_FOR_SEARCH);
|
||||
|
||||
Reference in New Issue
Block a user