Add kodik, imdb, shikimori, kinopoisk

This commit is contained in:
2026-02-15 02:48:02 +05:00
parent 2dab1a4016
commit bf08d0f4b7
2 changed files with 103 additions and 0 deletions

View File

@@ -18,4 +18,35 @@ public interface KodikAPI {
@Field("limit") int limit, @Field("limit") int limit,
@Field("with_material_data") int withMaterialData); @Field("with_material_data") int withMaterialData);
@FormUrlEncoded
@POST("search")
Call<KodikResponse> findByKodikID(
@Field("token") String token,
@Field("id") String id,
@Field("limit") int limit,
@Field("with_material_data") int withMaterialData);
@FormUrlEncoded
@POST("search")
Call<KodikResponse> findByShikimoriID(
@Field("token") String token,
@Field("shikimori_id") String shikimoriId,
@Field("limit") int limit,
@Field("with_material_data") int withMaterialData);
@FormUrlEncoded
@POST("search")
Call<KodikResponse> findByKinopoiskID(
@Field("token") String token,
@Field("kinopoisk_id") String kinopoiskId,
@Field("limit") int limit,
@Field("with_material_data") int withMaterialData);
@FormUrlEncoded
@POST("search")
Call<KodikResponse> findByImdbID(
@Field("token") String token,
@Field("imdb_id") String imdbId,
@Field("limit") int limit,
@Field("with_material_data") int withMaterialData);
} }

View File

@@ -15,6 +15,7 @@ import io.quarkiverse.retrofit.runtime.EnableRetrofit;
import jakarta.ws.rs.BadRequestException; import jakarta.ws.rs.BadRequestException;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.QueryParam; import jakarta.ws.rs.QueryParam;
import retrofit2.Response; import retrofit2.Response;
@@ -51,4 +52,75 @@ public class SearchResource {
} }
} }
@GET
@Path("/id/{id}")
public KodikResponse findByKodikId(@PathParam("id") String id) throws ServiceUnavailableException {
try {
Response<KodikResponse> response = kodikAPI.findByKodikID(tokenProvider.getKodikToken(), id, 1, 1)
.execute();
if (!response.isSuccessful()) {
LOG.errorv("failed find by kodik id {0}, response code {1}, message {2}", id,
response.code(), response.message());
throw new BadRequestException("bad response, code: " + response.code());
}
return searchFilterService.filter(response.body());
} catch (IOException e) {
LOG.warn("i/o error", e);
throw new ServiceUnavailableException("i/o error");
}
}
@GET
@Path("/shikimori/{id}")
public KodikResponse findByShikimoriId(@PathParam("id") String id) throws ServiceUnavailableException {
try {
Response<KodikResponse> response = kodikAPI.findByShikimoriID(tokenProvider.getKodikToken(), id, 1, 1)
.execute();
if (!response.isSuccessful()) {
LOG.errorv("failed find by shikimori id {0}, response code {1}, message {2}", id,
response.code(), response.message());
throw new BadRequestException("bad response, code: " + response.code());
}
return searchFilterService.filter(response.body());
} catch (IOException e) {
LOG.warn("i/o error", e);
throw new ServiceUnavailableException("i/o error");
}
}
@GET
@Path("/kinopoisk/{id}")
public KodikResponse findByKinopoiskId(@PathParam("id") String id) throws ServiceUnavailableException {
try {
Response<KodikResponse> response = kodikAPI.findByKinopoiskID(tokenProvider.getKodikToken(), id, 1, 1)
.execute();
if (!response.isSuccessful()) {
LOG.errorv("failed find by kinopoisk id {0}, response code {1}, message {2}", id,
response.code(), response.message());
throw new BadRequestException("bad response, code: " + response.code());
}
return searchFilterService.filter(response.body());
} catch (IOException e) {
LOG.warn("i/o error", e);
throw new ServiceUnavailableException("i/o error");
}
}
@GET
@Path("/imdb/{id}")
public KodikResponse findByImdbId(@PathParam("id") String id) throws ServiceUnavailableException {
try {
Response<KodikResponse> response = kodikAPI.findByImdbID(tokenProvider.getKodikToken(), id, 1, 1).execute();
if (!response.isSuccessful()) {
LOG.errorv("failed find by imdb id {0}, response code {1}, message {2}", id,
response.code(), response.message());
throw new BadRequestException("bad response, code: " + response.code());
}
return searchFilterService.filter(response.body());
} catch (IOException e) {
LOG.warn("i/o error", e);
throw new ServiceUnavailableException("i/o error");
}
}
} }