diff --git a/src/main/java/tv/mangrana/plex/url/PlexCommandLauncher.java b/src/main/java/tv/mangrana/plex/url/PlexCommandLauncher.java
index 933ae39..6e04560 100644
--- a/src/main/java/tv/mangrana/plex/url/PlexCommandLauncher.java
+++ b/src/main/java/tv/mangrana/plex/url/PlexCommandLauncher.java
@@ -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()) {
diff --git a/src/main/java/tv/mangrana/radarr/api/client/gateway/RadarrAPIInterface.java b/src/main/java/tv/mangrana/radarr/api/client/gateway/RadarrAPIInterface.java
index d584e55..5c33079 100644
--- a/src/main/java/tv/mangrana/radarr/api/client/gateway/RadarrAPIInterface.java
+++ b/src/main/java/tv/mangrana/radarr/api/client/gateway/RadarrAPIInterface.java
@@ -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: ...
@@ -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 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);
+
}
\ No newline at end of file
diff --git a/src/main/java/tv/mangrana/radarr/api/client/gateway/RadarrApiGateway.java b/src/main/java/tv/mangrana/radarr/api/client/gateway/RadarrApiGateway.java
index 6758e49..c7770f5 100644
--- a/src/main/java/tv/mangrana/radarr/api/client/gateway/RadarrApiGateway.java
+++ b/src/main/java/tv/mangrana/radarr/api/client/gateway/RadarrApiGateway.java
@@ -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 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);
+ }
+
}
diff --git a/src/main/java/tv/mangrana/sonarr/api/client/gateway/SonarrAPIInterface.java b/src/main/java/tv/mangrana/sonarr/api/client/gateway/SonarrAPIInterface.java
index 0529d04..1e41aff 100644
--- a/src/main/java/tv/mangrana/sonarr/api/client/gateway/SonarrAPIInterface.java
+++ b/src/main/java/tv/mangrana/sonarr/api/client/gateway/SonarrAPIInterface.java
@@ -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: official Documentation
@@ -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 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);
+
+
}
\ No newline at end of file
diff --git a/src/main/java/tv/mangrana/sonarr/api/client/gateway/SonarrApiGateway.java b/src/main/java/tv/mangrana/sonarr/api/client/gateway/SonarrApiGateway.java
index 807d8b0..fa672d2 100644
--- a/src/main/java/tv/mangrana/sonarr/api/client/gateway/SonarrApiGateway.java
+++ b/src/main/java/tv/mangrana/sonarr/api/client/gateway/SonarrApiGateway.java
@@ -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 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);
}