Change limit to 100, use shikimoriId as main identifier
This commit is contained in:
@@ -74,7 +74,7 @@ public class SearchResource {
|
|||||||
@Path("/id/{id}")
|
@Path("/id/{id}")
|
||||||
public KodikResponse findByKodikId(@PathParam("id") String id) throws ServiceUnavailableException {
|
public KodikResponse findByKodikId(@PathParam("id") String id) throws ServiceUnavailableException {
|
||||||
try {
|
try {
|
||||||
Response<KodikResponse> response = kodikAPI.findByKodikID(tokenProvider.getKodikToken(), id, 1, 1)
|
Response<KodikResponse> response = kodikAPI.findByKodikID(tokenProvider.getKodikToken(), id, 100, 1)
|
||||||
.execute();
|
.execute();
|
||||||
if (!response.isSuccessful()) {
|
if (!response.isSuccessful()) {
|
||||||
LOG.errorv("failed find by kodik id {0}, response code {1}, message {2}", id,
|
LOG.errorv("failed find by kodik id {0}, response code {1}, message {2}", id,
|
||||||
@@ -92,7 +92,7 @@ public class SearchResource {
|
|||||||
@Path("/shikimori/{id}")
|
@Path("/shikimori/{id}")
|
||||||
public KodikResponse findByShikimoriId(@PathParam("id") String id) throws ServiceUnavailableException {
|
public KodikResponse findByShikimoriId(@PathParam("id") String id) throws ServiceUnavailableException {
|
||||||
try {
|
try {
|
||||||
Response<KodikResponse> response = kodikAPI.findByShikimoriID(tokenProvider.getKodikToken(), id, 1, 1)
|
Response<KodikResponse> response = kodikAPI.findByShikimoriID(tokenProvider.getKodikToken(), id, 100, 1)
|
||||||
.execute();
|
.execute();
|
||||||
if (!response.isSuccessful()) {
|
if (!response.isSuccessful()) {
|
||||||
LOG.errorv("failed find by shikimori id {0}, response code {1}, message {2}", id,
|
LOG.errorv("failed find by shikimori id {0}, response code {1}, message {2}", id,
|
||||||
@@ -110,7 +110,7 @@ public class SearchResource {
|
|||||||
@Path("/kinopoisk/{id}")
|
@Path("/kinopoisk/{id}")
|
||||||
public KodikResponse findByKinopoiskId(@PathParam("id") String id) throws ServiceUnavailableException {
|
public KodikResponse findByKinopoiskId(@PathParam("id") String id) throws ServiceUnavailableException {
|
||||||
try {
|
try {
|
||||||
Response<KodikResponse> response = kodikAPI.findByKinopoiskID(tokenProvider.getKodikToken(), id, 1, 1)
|
Response<KodikResponse> response = kodikAPI.findByKinopoiskID(tokenProvider.getKodikToken(), id, 100, 1)
|
||||||
.execute();
|
.execute();
|
||||||
if (!response.isSuccessful()) {
|
if (!response.isSuccessful()) {
|
||||||
LOG.errorv("failed find by kinopoisk id {0}, response code {1}, message {2}", id,
|
LOG.errorv("failed find by kinopoisk id {0}, response code {1}, message {2}", id,
|
||||||
@@ -128,7 +128,8 @@ public class SearchResource {
|
|||||||
@Path("/imdb/{id}")
|
@Path("/imdb/{id}")
|
||||||
public KodikResponse findByImdbId(@PathParam("id") String id) throws ServiceUnavailableException {
|
public KodikResponse findByImdbId(@PathParam("id") String id) throws ServiceUnavailableException {
|
||||||
try {
|
try {
|
||||||
Response<KodikResponse> response = kodikAPI.findByImdbID(tokenProvider.getKodikToken(), id, 1, 1).execute();
|
Response<KodikResponse> response = kodikAPI.findByImdbID(tokenProvider.getKodikToken(), id, 100, 1)
|
||||||
|
.execute();
|
||||||
if (!response.isSuccessful()) {
|
if (!response.isSuccessful()) {
|
||||||
LOG.errorv("failed find by imdb id {0}, response code {1}, message {2}", id,
|
LOG.errorv("failed find by imdb id {0}, response code {1}, message {2}", id,
|
||||||
response.code(), response.message());
|
response.code(), response.message());
|
||||||
|
|||||||
@@ -51,18 +51,14 @@ public class KodikSearchFilterService {
|
|||||||
return result != null && ALLOWED_TYPES.contains(result.type);
|
return result != null && ALLOWED_TYPES.contains(result.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isUnique(KodikResponse.Result result, Set<String> seenIds) {
|
|
||||||
return seenIds.add(identifier(result));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String identifier(KodikResponse.Result result) {
|
public String identifier(KodikResponse.Result result) {
|
||||||
if (result == null)
|
if (result == null)
|
||||||
return "null-0";
|
return "null-0";
|
||||||
|
|
||||||
String primaryId = Arrays.asList(
|
String primaryId = Arrays.asList(
|
||||||
|
result.shikimoriId,
|
||||||
result.kinopoiskId,
|
result.kinopoiskId,
|
||||||
result.imdbId,
|
result.imdbId,
|
||||||
result.shikimoriId,
|
|
||||||
result.worldartLink).stream()
|
result.worldartLink).stream()
|
||||||
.filter(id -> id != null && !id.isBlank())
|
.filter(id -> id != null && !id.isBlank())
|
||||||
.findFirst()
|
.findFirst()
|
||||||
|
|||||||
Reference in New Issue
Block a user