Add kodik, imdb, shikimori, kinopoisk
This commit is contained in:
@@ -18,4 +18,35 @@ public interface KodikAPI {
|
||||
@Field("limit") int limit,
|
||||
@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);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import io.quarkiverse.retrofit.runtime.EnableRetrofit;
|
||||
import jakarta.ws.rs.BadRequestException;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user