This commit is contained in:
@@ -50,43 +50,43 @@ public class ImageFoundRequestHandler implements RequestHandler {
|
|||||||
Map.of("fileId",fileId)));
|
Map.of("fileId",fileId)));
|
||||||
});
|
});
|
||||||
|
|
||||||
// String searchResponseYandex;
|
String searchResponseYandex;
|
||||||
String searchResponseGoogle;
|
// String searchResponseGoogle;
|
||||||
// List<YandexSearchResponse.ImageResult> allYandexImages = new ArrayList<>();
|
List<YandexSearchResponse.ImageResult> allYandexImages = new ArrayList<>();
|
||||||
List<YandexSearchResponse.ImageResult> allGoogleImages = new ArrayList<>();
|
// List<YandexSearchResponse.ImageResult> allGoogleImages = new ArrayList<>();
|
||||||
List<YandexSearchResponse.ImageResult> allUniqueImages;
|
List<YandexSearchResponse.ImageResult> allUniqueImages;
|
||||||
boolean hasTimeout = false;
|
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 {
|
// try {
|
||||||
// searchResponseYandex = searchImageService.searchReverseByPublicUrl(fileEntity, "yandex_reverse_image",
|
// searchResponseGoogle = searchImageService.searchReverseByPublicUrl(fileEntity, "google_lens",
|
||||||
// "visual_matches");
|
// "exact_matches");
|
||||||
// log.info("searchResponseYandex OK");
|
// log.info("searchResponseGoogle OK,{}", searchResponseGoogle);
|
||||||
// allYandexImages = searchImageService.getAllImagesWithoutPagination(
|
// allGoogleImages = searchImageService.getAllImagesWithoutPagination(
|
||||||
// searchResponseYandex, "visual_matches");
|
// searchResponseGoogle, "exact_matches");
|
||||||
|
//
|
||||||
// } catch (TimeoutException e) {
|
// } catch (TimeoutException e) {
|
||||||
// log.warn("Yandex search timeout for file {}", fileId);
|
// log.warn("Google search timeout for file {}", fileId);
|
||||||
// hasTimeout = true;
|
// hasTimeout = true;
|
||||||
// } catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
// log.error("Yandex search failed for file {}", fileId, 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);
|
||||||
|
}
|
||||||
|
|
||||||
// allUniqueImages = searchImageService.removeDuplicateUrls(allYandexImages, allGoogleImages);
|
// allUniqueImages = searchImageService.removeDuplicateUrls(allYandexImages, allGoogleImages);
|
||||||
allUniqueImages = allGoogleImages;
|
// allUniqueImages = allGoogleImages;
|
||||||
// allUniqueImages = allYandexImages;
|
allUniqueImages = allYandexImages;
|
||||||
log.info("allUniqueImages OK: {} images", allUniqueImages.size());
|
log.info("allUniqueImages OK: {} images", allUniqueImages.size());
|
||||||
|
|
||||||
tariffInfoService.writeOffTokens(fileEntity.getUserId(), TariffConstants.TOKEN_VALUE_FOR_SEARCH);
|
tariffInfoService.writeOffTokens(fileEntity.getUserId(), TariffConstants.TOKEN_VALUE_FOR_SEARCH);
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ public class SearchImageService {
|
|||||||
private final OkHttpClient googleHttpClient;
|
private final OkHttpClient googleHttpClient;
|
||||||
|
|
||||||
public SearchImageService() {
|
public SearchImageService() {
|
||||||
Proxy proxy = new Proxy(Proxy.Type.HTTP,
|
// Proxy proxy = new Proxy(Proxy.Type.HTTP,
|
||||||
new InetSocketAddress("193.46.217.94", 3128));
|
// new InetSocketAddress("193.46.217.94", 3128));
|
||||||
|
|
||||||
this.yandexHttpClient = new OkHttpClient.Builder()
|
this.yandexHttpClient = new OkHttpClient.Builder()
|
||||||
.proxy(proxy)
|
// .proxy(proxy)
|
||||||
.connectTimeout(35, TimeUnit.SECONDS)
|
.connectTimeout(35, TimeUnit.SECONDS)
|
||||||
.writeTimeout(35, TimeUnit.SECONDS)
|
.writeTimeout(35, TimeUnit.SECONDS)
|
||||||
.readTimeout(35, TimeUnit.SECONDS)
|
.readTimeout(35, TimeUnit.SECONDS)
|
||||||
@@ -47,7 +47,7 @@ public class SearchImageService {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
this.googleHttpClient = new OkHttpClient.Builder()
|
this.googleHttpClient = new OkHttpClient.Builder()
|
||||||
.proxy(proxy)
|
// .proxy(proxy)
|
||||||
.connectTimeout(35, TimeUnit.SECONDS)
|
.connectTimeout(35, TimeUnit.SECONDS)
|
||||||
.writeTimeout(35, TimeUnit.SECONDS)
|
.writeTimeout(35, TimeUnit.SECONDS)
|
||||||
.readTimeout(35, TimeUnit.SECONDS)
|
.readTimeout(35, TimeUnit.SECONDS)
|
||||||
|
|||||||
Reference in New Issue
Block a user