refinements
This commit is contained in:
parent
0abb7cfe17
commit
03316dd265
|
@ -45,6 +45,7 @@ public class PlexCommandLauncher {
|
|||
String plexRefreshURL = getPlexRefreshURL(plexPathToRefresh);
|
||||
if (plexRefreshURL==null) return;
|
||||
try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
|
||||
|
||||
HttpUriRequest httpGET = RequestBuilder.get()
|
||||
.setUri(new URI(plexRefreshURL))
|
||||
.addParameter("path", plexPathToRefresh)
|
||||
|
@ -68,11 +69,13 @@ public class PlexCommandLauncher {
|
|||
|
||||
public Document retrieveSectionsInfo() {
|
||||
try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
|
||||
String plexSectionsURL = getPlexSectionsURL();
|
||||
HttpUriRequest httpGET = RequestBuilder.get()
|
||||
.setUri(new URI(getPlexSectionsURL()))
|
||||
.setUri(new URI(plexSectionsURL))
|
||||
.addParameter("X-Plex-Token", config.getConfig(PLEX_TOKEN))
|
||||
.build();
|
||||
try (CloseableHttpResponse httpResponse = httpclient.execute(httpGET)) {
|
||||
|
||||
final HttpEntity entity = httpResponse.getEntity();
|
||||
if (entity != null) {
|
||||
try (InputStream inputStream = entity.getContent()) {
|
||||
|
|
|
@ -8,6 +8,7 @@ import tv.mangrana.utils.rest.APIInterface;
|
|||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* For more information, visit: <a href="https://radarr.video/docs/api/#/Movie/get_api_v3_movie">...</a>
|
||||
|
@ -30,9 +31,20 @@ public interface RadarrAPIInterface extends APIInterface {
|
|||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
MovieResource getMovieById(@PathParam("id") int movieId, @QueryParam("apikey") String apikey);
|
||||
|
||||
@GET
|
||||
@Path("/movie")
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
List<MovieResource> movieLookupByTMDBid(@QueryParam("tmdbId") int tmdbId, @QueryParam("apikey") String apikey);
|
||||
|
||||
|
||||
@POST
|
||||
@Path("/command")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
void refreshMoviesCommand(RefreshMoviesCommand command, @QueryParam("apikey") String apikey);
|
||||
|
||||
@PUT
|
||||
@Path("/movie/{id}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
void updateMovie(MovieResource movie, @PathParam("id") int movieId, @QueryParam("apikey") String apikey);
|
||||
|
||||
}
|
|
@ -6,6 +6,8 @@ import tv.mangrana.radarr.api.schema.movie.MovieResource;
|
|||
import tv.mangrana.radarr.api.schema.queue.QueueResourcePagingResource;
|
||||
import tv.mangrana.utils.rest.APIProxyBuilderSingleton;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static tv.mangrana.config.CommonConfigFileLoader.CommonProjectConfiguration.RADARR_API_HOST;
|
||||
import static tv.mangrana.config.CommonConfigFileLoader.CommonProjectConfiguration.RADARR_API_KEY;
|
||||
import static tv.mangrana.utils.Output.log;
|
||||
|
@ -30,6 +32,10 @@ public class RadarrApiGateway {
|
|||
return movie;
|
||||
}
|
||||
|
||||
public List<MovieResource> movieLookupByTMDBid (int tmdbId) {
|
||||
return proxy.movieLookupByTMDBid(tmdbId, apiKey);
|
||||
}
|
||||
|
||||
public void removeQueueItem(int itemId) {
|
||||
proxy.removeQueueItem(itemId, false, apiKey);
|
||||
log("removed item from queue successfully: "+itemId);
|
||||
|
@ -40,4 +46,8 @@ public class RadarrApiGateway {
|
|||
log("refreshed movie with id "+movieId);
|
||||
}
|
||||
|
||||
public void updateMovie(MovieResource movie){
|
||||
proxy.updateMovie(movie, movie.getId(), apiKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package tv.mangrana.sonarr.api.client.gateway;
|
||||
|
||||
import tv.mangrana.sonarr.api.schema.history.SonarrHistory;
|
||||
import tv.mangrana.sonarr.api.schema.series.SonarrSerie;
|
||||
import tv.mangrana.sonarr.api.schema.command.RefreshSerieCommand;
|
||||
import tv.mangrana.sonarr.api.schema.history.SonarrHistory;
|
||||
import tv.mangrana.sonarr.api.schema.queue.SonarrQueue;
|
||||
import tv.mangrana.sonarr.api.schema.series.SonarrSerie;
|
||||
import tv.mangrana.utils.rest.APIInterface;
|
||||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* For more information, visit: <a href="https://github.com/Sonarr/Sonarr/wiki/API">official Documentation</a>
|
||||
|
@ -31,6 +32,11 @@ public interface SonarrAPIInterface extends APIInterface {
|
|||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
SonarrSerie getSerieById(@PathParam("id") Integer idSerie, @QueryParam("apikey") String apikey);
|
||||
|
||||
@GET
|
||||
@Path("/series")
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
List<SonarrSerie> serieLookupByTVDBid(@QueryParam("tvdbId") int tvdbId, @QueryParam("apikey") String apikey);
|
||||
|
||||
@POST
|
||||
@Path("/command")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
|
@ -50,4 +56,10 @@ public interface SonarrAPIInterface extends APIInterface {
|
|||
@QueryParam("pageSize") int pageSize, @QueryParam("page") int page,
|
||||
@QueryParam("apikey") String apikey);
|
||||
|
||||
@PUT
|
||||
@Path("/series/{id}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
void updateSerie(SonarrSerie serie, @PathParam("id") int serieId, @QueryParam("apikey") String apikey);
|
||||
|
||||
|
||||
}
|
|
@ -9,6 +9,8 @@ import tv.mangrana.utils.EasyLogger;
|
|||
import tv.mangrana.utils.Output;
|
||||
import tv.mangrana.utils.rest.APIProxyBuilderSingleton;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static tv.mangrana.config.CommonConfigFileLoader.CommonProjectConfiguration.SONARR_API_HOST;
|
||||
import static tv.mangrana.config.CommonConfigFileLoader.CommonProjectConfiguration.SONARR_API_KEY;
|
||||
|
||||
|
@ -44,6 +46,18 @@ public class SonarrApiGateway {
|
|||
return serie;
|
||||
}
|
||||
|
||||
public SonarrSerie getSerieByTvdb(Integer tvDbId) {
|
||||
SonarrSerie serie = null;
|
||||
try {
|
||||
List<SonarrSerie> serieOutput = proxy.serieLookupByTVDBid(tvDbId, apiKey);
|
||||
serie = serieOutput.get(0);
|
||||
logger.nLog("retrieved serie from sonarr with tvdbId "+tvDbId);
|
||||
} catch (Exception e) {
|
||||
logger.nHLog("Error while getSerieByTvdb: {0}", e.getMessage());
|
||||
}
|
||||
return serie;
|
||||
}
|
||||
|
||||
public void refreshSerie(Integer seriesId) {
|
||||
proxy.refreshSeriesCommand(new RefreshSerieCommand(seriesId), apiKey);
|
||||
log("sent Refresh command to Sonarr for the serie with id "+seriesId);
|
||||
|
@ -53,6 +67,10 @@ public class SonarrApiGateway {
|
|||
return proxy.getHistory("date", "desc", 200, 1, apiKey);
|
||||
}
|
||||
|
||||
public void updateSerie(SonarrSerie series){
|
||||
proxy.updateSerie(series, series.getId(), apiKey);
|
||||
}
|
||||
|
||||
private void log (String msg) {
|
||||
Output.log("SonarrApiGateway: "+msg);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue