diff --git a/README.md b/README.md index ede3528..7a16aa7 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,11 @@ Made this simple slack/discord/telegram/matrix bot so I could access radarr, son ## Currently Supported API's -- [x] Radarr (v2) -- [ ] Radarr (v3) -- [ ] Sonarr (v2) +- [x] Radarr (v3) - [x] Sonarr (v3) - [x] Lidarr (v1) +- [x] ~~Radarr (v2) - no longer supported~~ +- [ ] ~~Sonarr (v2) - no plans to support~~ ## Currently Supported Chat Client's @@ -33,10 +33,10 @@ Made this simple slack/discord/telegram/matrix bot so I could access radarr, son - [x] Configurable value for max number of movies, shows, and artists per user - [x] Configurable command prefix (i.e., /help, $help, !help) - [x] Configurable value for url base for radarr, sonarr, and lidarr -- [x] Lookup torrents for movies and force download - [x] (discord/slack only) Thumbs up reaction will add search results - [x] User requests audited to local database\ - [x] Blacklist content by paths from showing up in searches +- [ ] Lookup torrents for movies and force download - [ ] Cancel/blacklist existing downloads - [ ] Episode/season search - [ ] Album/song search diff --git a/src/main/java/com/botdarr/api/DownloadsStrategy.java b/src/main/java/com/botdarr/api/DownloadsStrategy.java index 0171b08..097c4cb 100644 --- a/src/main/java/com/botdarr/api/DownloadsStrategy.java +++ b/src/main/java/com/botdarr/api/DownloadsStrategy.java @@ -12,7 +12,7 @@ import java.util.Collections; import java.util.List; -public abstract class DownloadsStrategy { +public abstract class DownloadsStrategy { public DownloadsStrategy(Api api, String url, ChatClientResponseBuilder chatClientResponseBuilder, @@ -57,7 +57,7 @@ public List parseContent(String response) { } chatClientResponses.add(chatClientResponse); } - if (tooManyDownloads) { + if (tooManyDownloads && !chatClientResponses.isEmpty()) { chatClientResponses = ListUtils.subList(chatClientResponses, MAX_DOWNLOADS_TO_SHOW); chatClientResponses.add(0, chatClientResponseBuilder.createInfoMessage("Too many downloads, limiting results to " + MAX_DOWNLOADS_TO_SHOW)); } diff --git a/src/main/java/com/botdarr/api/radarr/RadarrApi.java b/src/main/java/com/botdarr/api/radarr/RadarrApi.java index b90feb7..ef439c6 100644 --- a/src/main/java/com/botdarr/api/radarr/RadarrApi.java +++ b/src/main/java/com/botdarr/api/radarr/RadarrApi.java @@ -56,12 +56,7 @@ public ChatClientResponse getNewOrExistingItem(RadarrMovie lookupItem, RadarrMov @Override public boolean isPathBlacklisted(RadarrMovie item) { - for (String path : Config.getExistingItemBlacklistPaths()) { - if (item.getPath() != null && item.getPath().startsWith(path)) { - return true; - } - } - return false; + return RadarrApi.this.isPathBlacklisted(item); } }.lookup(search, findNew); } @@ -154,7 +149,7 @@ public String getApiToken() { } public List discover() { - return ConnectionHelper.makeGetRequest(this, RadarrUrls.DISCOVER_MOVIES, new ConnectionHelper.SimpleEntityResponseHandler>() { + return ConnectionHelper.makeGetRequest(this, RadarrUrls.DISCOVER_MOVIES, "&includeRecommendations=true", new ConnectionHelper.SimpleEntityResponseHandler>() { @Override public List onSuccess(String response) throws Exception { List recommendedMovies = new ArrayList<>(); @@ -178,13 +173,44 @@ public List onSuccess(String response) throws Exception { }); } - private DownloadsStrategy getDownloadsStrategy() { - return new DownloadsStrategy(this, RadarrUrls.DOWNLOAD_BASE, chatClientResponseBuilder, ContentType.MOVIE) { + private DownloadsStrategy getDownloadsStrategy() { + return new DownloadsStrategy(this, RadarrUrls.DOWNLOAD_BASE, chatClientResponseBuilder, ContentType.MOVIE) { @Override public ChatClientResponse getResponse(JsonElement rawElement) { RadarrQueue radarrQueue = new Gson().fromJson(rawElement, RadarrQueue.class); + RadarrMovie radarrMovie = RADARR_CACHE.getExistingMovieWithRadarrId(radarrQueue.getMovieId()); + if (radarrMovie == null) { + LOGGER.warn("Could not load radarr movie from cache for id " + radarrQueue.getMovieId() + " title=" + radarrQueue.getTitle()); + return null; + } + //the radarr queue title is the title of the actual download, instead of movie title + //so we get the real value here + radarrQueue.setTitle(radarrMovie.getTitle()); + if (isPathBlacklisted(radarrMovie)) { + //skip any radarr queue items tied to blacklisted content + return null; + } + return chatClientResponseBuilder.getMovieDownloadResponses(radarrQueue); } + + @Override + public List getContentDownloads() { + return ConnectionHelper.makeGetRequest( + RadarrApi.this, + RadarrUrls.DOWNLOAD_BASE, + new ConnectionHelper.SimpleMessageEmbedResponseHandler(chatClientResponseBuilder) { + @Override + public List onSuccess(String response) { + if (response == null || response.isEmpty() || response.equals("{}")) { + return new ArrayList<>(); + } + JsonParser parser = new JsonParser(); + JsonObject json = parser.parse(response).getAsJsonObject(); + return parseContent(json.get("records").toString()); + } + }); + } }; } @@ -306,6 +332,15 @@ public List onSuccess(String response) { }); } + private boolean isPathBlacklisted(RadarrMovie item) { + for (String path : Config.getExistingItemBlacklistPaths()) { + if (item.getPath() != null && item.getPath().startsWith(path)) { + return true; + } + } + return false; + } + private final ChatClientResponseBuilder chatClientResponseBuilder; private static final RadarrCache RADARR_CACHE = new RadarrCache(); public static final String ADD_MOVIE_COMMAND_FIELD_PREFIX = "Add movie command"; diff --git a/src/main/java/com/botdarr/api/radarr/RadarrCache.java b/src/main/java/com/botdarr/api/radarr/RadarrCache.java index 1e231c7..eb7ba54 100644 --- a/src/main/java/com/botdarr/api/radarr/RadarrCache.java +++ b/src/main/java/com/botdarr/api/radarr/RadarrCache.java @@ -8,12 +8,12 @@ public RadarrMovie getExistingMovie(long tmdbid) { return existingTmdbIdsToMovies.get(tmdbid); } - public boolean doesMovieExist(String title) { - return existingMovieTitlesToIds.containsKey(title.toLowerCase()); + public RadarrMovie getExistingMovieWithRadarrId(long radarrId) { + return existingRadarrMovieIdsToMovies.get(radarrId); } - public Long getMovieSonarrId(String title) { - return existingMovieTitlesToIds.get(title.toLowerCase()); + public boolean doesMovieExist(String title) { + return existingMovieTitlesToIds.containsKey(title.toLowerCase()); } public Collection getQualityProfiles() { @@ -23,6 +23,7 @@ public Collection getQualityProfiles() { public void add(RadarrMovie movie) { existingTmdbIdsToMovies.put(movie.getKey(), movie); existingMovieTitlesToIds.put(movie.getTitle().toLowerCase(), movie.getId()); + existingRadarrMovieIdsToMovies.put(movie.getId(), movie); } public void addProfile(RadarrProfile qualityProfile) { @@ -39,17 +40,21 @@ public void removeDeletedProfiles(List addUpdatedProfiles) { public void removeDeletedMovies(List addUpdatedMovies) { List existingMovieTitles = new ArrayList<>(); + List existingMovieIds = new ArrayList<>(); for (Long tmdbId : addUpdatedMovies) { RadarrMovie radarrMovie = existingTmdbIdsToMovies.get(tmdbId); if (radarrMovie != null) { existingMovieTitles.add(radarrMovie.getTitle().toLowerCase()); + existingMovieIds.add(radarrMovie.getId()); } } existingTmdbIdsToMovies.keySet().retainAll(addUpdatedMovies); existingMovieTitlesToIds.keySet().retainAll(existingMovieTitles); + existingRadarrMovieIdsToMovies.keySet().retainAll(existingMovieIds); } private Map existingProfiles = new ConcurrentHashMap<>(); private Map existingMovieTitlesToIds = new ConcurrentHashMap<>(); + private Map existingRadarrMovieIdsToMovies = new ConcurrentHashMap<>(); private Map existingTmdbIdsToMovies = new ConcurrentHashMap<>(); } diff --git a/src/main/java/com/botdarr/api/radarr/RadarrQueue.java b/src/main/java/com/botdarr/api/radarr/RadarrQueue.java index 7136cf0..1b8aa07 100644 --- a/src/main/java/com/botdarr/api/radarr/RadarrQueue.java +++ b/src/main/java/com/botdarr/api/radarr/RadarrQueue.java @@ -17,22 +17,10 @@ public void setTimeleft(String timeleft) { this.timeleft = timeleft; } - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - public RadarrQueueStatusMessages[] getStatusMessages() { return statusMessages; } - public void setStatusMessages(RadarrQueueStatusMessages[] statusMessages) { - this.statusMessages = statusMessages; - } - public RadarrProfileQualityItem getQuality() { return quality; } @@ -41,18 +29,22 @@ public void setQuality(RadarrProfileQualityItem quality) { this.quality = quality; } - public RadarrQueueMovie getRadarrQueueMovie() { - return movie; + public long getMovieId() { + return movieId; + } + + public String getTitle() { + return title; } - public void setRadarrQueueMovie(RadarrQueueMovie radarrQueueMovie) { - this.movie = radarrQueueMovie; + public void setTitle(String title) { + this.title = title; } private String status; private String timeleft; private RadarrProfileQualityItem quality; - private long id; private RadarrQueueStatusMessages[] statusMessages; - private RadarrQueueMovie movie; + private long movieId; + private String title; } diff --git a/src/main/java/com/botdarr/api/radarr/RadarrQueueMovie.java b/src/main/java/com/botdarr/api/radarr/RadarrQueueMovie.java deleted file mode 100644 index 671db54..0000000 --- a/src/main/java/com/botdarr/api/radarr/RadarrQueueMovie.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.botdarr.api.radarr; - -public class RadarrQueueMovie { - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - private String title; -} diff --git a/src/main/java/com/botdarr/api/radarr/RadarrQueuePage.java b/src/main/java/com/botdarr/api/radarr/RadarrQueuePage.java new file mode 100644 index 0000000..f19b1a5 --- /dev/null +++ b/src/main/java/com/botdarr/api/radarr/RadarrQueuePage.java @@ -0,0 +1,20 @@ +package com.botdarr.api.radarr; + +import java.util.List; + +public class RadarrQueuePage { + public List getRecords() { + return records; + } + + public void setRecords(List records) { + this.records = records; + } + + private Integer page; + private Integer pageSize; + private String sortKey; + private String sortDirection; + private Integer totalRecords; + private List records = null; +} diff --git a/src/main/java/com/botdarr/api/radarr/RadarrUrls.java b/src/main/java/com/botdarr/api/radarr/RadarrUrls.java index 43d3f3f..536a49c 100644 --- a/src/main/java/com/botdarr/api/radarr/RadarrUrls.java +++ b/src/main/java/com/botdarr/api/radarr/RadarrUrls.java @@ -1,17 +1,12 @@ package com.botdarr.api.radarr; public class RadarrUrls { - /** - * Specifically used as a post request for forcing a download for a specific release or getting existing available - * downloads for a release - */ - public static final String RELEASE_BASE = "release"; - + private static final String V3_BASE = "v3/"; /** * The base download(s) url for get, put, delete requests (which each do different things in radarr) * See https://github.com/Radarr/Radarr/wiki/API:Queue */ - public static final String DOWNLOAD_BASE = "queue"; + public static final String DOWNLOAD_BASE = V3_BASE + "queue"; /** * The base movie url for getting and adding movies (get, post requests) @@ -32,7 +27,7 @@ public class RadarrUrls { /** * The url for triggering gets requests in radarr to discover new movies */ - public static final String DISCOVER_MOVIES = "movies/discover/recommendations"; + public static final String DISCOVER_MOVIES = V3_BASE + "importlist/movie"; /** * The url base for adding, getting, deleting movie profiles diff --git a/src/main/java/com/botdarr/api/sonarr/SonarQueueEpisode.java b/src/main/java/com/botdarr/api/sonarr/SonarQueueEpisode.java index cc4b9d2..268361b 100644 --- a/src/main/java/com/botdarr/api/sonarr/SonarQueueEpisode.java +++ b/src/main/java/com/botdarr/api/sonarr/SonarQueueEpisode.java @@ -33,8 +33,13 @@ public void setOverview(String overview) { this.overview = overview; } + public long getSeriesId() { + return seriesId; + } + private int seasonNumber; private int episodeNumber; private String title; private String overview; + private long seriesId; } diff --git a/src/main/java/com/botdarr/api/sonarr/SonarrApi.java b/src/main/java/com/botdarr/api/sonarr/SonarrApi.java index 7555756..14e5329 100644 --- a/src/main/java/com/botdarr/api/sonarr/SonarrApi.java +++ b/src/main/java/com/botdarr/api/sonarr/SonarrApi.java @@ -68,12 +68,7 @@ public ChatClientResponse getNewOrExistingItem(SonarrShow lookupItem, SonarrShow @Override public boolean isPathBlacklisted(SonarrShow item) { - for (String path : Config.getExistingItemBlacklistPaths()) { - if (item.getPath() != null && item.getPath().startsWith(path)) { - return true; - } - } - return false; + return SonarrApi.this.isPathBlacklisted(item); } }.lookup(search, findNew); } @@ -198,6 +193,15 @@ public ChatClientResponse getResponse(JsonElement rawElement) { LOGGER.error("Series " + showQueue.getSonarrQueueShow().getTitle() + " missing episode info for id " + showQueue.getId()); return null; } + SonarrShow sonarrShow = SONARR_CACHE.getExistingShowFromSonarrId(showQueue.getEpisode().getSeriesId()); + if (sonarrShow == null) { + LOGGER.warn("Could not load sonarr show from cache for id " + showQueue.getEpisode().getSeriesId() + " title=" + showQueue.getSonarrQueueShow().getTitle()); + return null; + } + if (isPathBlacklisted(sonarrShow)) { + //TODO: log + return null; + } return chatClientResponseBuilder.getShowDownloadResponses(showQueue); } }; @@ -276,6 +280,15 @@ public boolean shouldSkipClass(Class aClass) { } }; + private boolean isPathBlacklisted(SonarrShow item) { + for (String path : Config.getExistingItemBlacklistPaths()) { + if (item.getPath() != null && item.getPath().startsWith(path)) { + return true; + } + } + return false; + } + private final ChatClientResponseBuilder chatClientResponseBuilder; private static final SonarrCache SONARR_CACHE = new SonarrCache(); public static final String ADD_SHOW_COMMAND_FIELD_PREFIX = "Add show command"; diff --git a/src/main/java/com/botdarr/api/sonarr/SonarrCache.java b/src/main/java/com/botdarr/api/sonarr/SonarrCache.java index 65fa95c..cf44e2f 100644 --- a/src/main/java/com/botdarr/api/sonarr/SonarrCache.java +++ b/src/main/java/com/botdarr/api/sonarr/SonarrCache.java @@ -5,15 +5,11 @@ public class SonarrCache { public SonarrShow getExistingShowFromTvdbId(long tvdbId) { - return existingTvdbIdsToMovies.get(tvdbId); + return existingTvdbIdsToShows.get(tvdbId); } - public SonarrShow getExistingShowFromTvrageId(long tvrageId) { - return existingTvrageIdsToMovies.get(tvrageId); - } - - public SonarrShow getExistingShowFromTvmazeId(long tvmazeId) { - return existingTvmazeIdsToMovies.get(tvmazeId); + public SonarrShow getExistingShowFromSonarrId(long sonarrId) { + return existingSonarrIdsToShows.get(sonarrId); } public boolean doesShowExist(String title) { @@ -21,10 +17,9 @@ public boolean doesShowExist(String title) { } public void add(SonarrShow show) { - existingTvdbIdsToMovies.put(show.getKey(), show); - existingTvrageIdsToMovies.put(show.getTvRageId(), show); - existingTvmazeIdsToMovies.put(show.getTvMazeId(), show); + existingTvdbIdsToShows.put(show.getKey(), show); existingShowTitlesToSonarrId.put(show.getTitle().toLowerCase(), show.getId()); + existingSonarrIdsToShows.put(show.getId(), show); } public Collection getQualityProfiles() { @@ -45,25 +40,21 @@ public void removeDeletedProfiles(List addUpdatedProfiles) { public void removeDeletedShows(List addUpdatedTvdbShowIds) { List existingShowTitles = new ArrayList<>(); - List existingTvRageIds = new ArrayList<>(); - List existingTvmazeIds = new ArrayList<>(); + List existingShowIds = new ArrayList<>(); for (Long tvdbId : addUpdatedTvdbShowIds) { - SonarrShow sonarrShow = existingTvdbIdsToMovies.get(tvdbId); + SonarrShow sonarrShow = existingTvdbIdsToShows.get(tvdbId); if (sonarrShow != null) { existingShowTitles.add(sonarrShow.getTitle().toLowerCase()); - existingTvRageIds.add(sonarrShow.getTvRageId()); - existingTvmazeIds.add(sonarrShow.getTvMazeId()); + existingShowIds.add(sonarrShow.getId()); } } existingShowTitlesToSonarrId.keySet().retainAll(existingShowTitles); - existingTvdbIdsToMovies.keySet().retainAll(addUpdatedTvdbShowIds); - existingTvrageIdsToMovies.keySet().retainAll(existingTvRageIds); - existingTvmazeIdsToMovies.keySet().retainAll(existingTvmazeIds); + existingTvdbIdsToShows.keySet().retainAll(addUpdatedTvdbShowIds); + existingSonarrIdsToShows.keySet().retainAll(existingShowIds); } private Map existingProfiles = new ConcurrentHashMap<>(); private Map existingShowTitlesToSonarrId = new ConcurrentHashMap<>(); - private Map existingTvdbIdsToMovies = new ConcurrentHashMap<>(); - private Map existingTvrageIdsToMovies = new ConcurrentHashMap<>(); - private Map existingTvmazeIdsToMovies = new ConcurrentHashMap<>(); + private Map existingTvdbIdsToShows = new ConcurrentHashMap<>(); + private Map existingSonarrIdsToShows = new ConcurrentHashMap<>(); } diff --git a/src/main/java/com/botdarr/clients/ChatClientType.java b/src/main/java/com/botdarr/clients/ChatClientType.java index 1bb66d4..4943dd0 100644 --- a/src/main/java/com/botdarr/clients/ChatClientType.java +++ b/src/main/java/com/botdarr/clients/ChatClientType.java @@ -321,8 +321,9 @@ public String getReadableName() { void initScheduling(ChatClient chatClient, List apis) { Scheduler scheduler = Scheduler.getScheduler(); - scheduler.initApiNotifications(apis, chatClient); + //make sure to always cache before doing any notifications scheduler.initApiCaching(apis); + scheduler.initApiNotifications(apis, chatClient); } public abstract void init() throws Exception; diff --git a/src/main/java/com/botdarr/clients/discord/DiscordResponseBuilder.java b/src/main/java/com/botdarr/clients/discord/DiscordResponseBuilder.java index 2c7a75f..f0c5f5a 100644 --- a/src/main/java/com/botdarr/clients/discord/DiscordResponseBuilder.java +++ b/src/main/java/com/botdarr/clients/discord/DiscordResponseBuilder.java @@ -117,7 +117,7 @@ public DiscordResponse getShowDownloadResponses(SonarrQueue showQueue) { @Override public DiscordResponse getMovieDownloadResponses(RadarrQueue radarrQueue) { EmbedBuilder embedBuilder = new EmbedBuilder(); - embedBuilder.setTitle(radarrQueue.getRadarrQueueMovie().getTitle()); + embedBuilder.setTitle(radarrQueue.getTitle()); embedBuilder.addField("Quality", radarrQueue.getQuality().getQuality().getName(), true); embedBuilder.addField("Status", radarrQueue.getStatus(), true); embedBuilder.addField("Time Left", radarrQueue.getTimeleft() == null ? "unknown" : radarrQueue.getTimeleft(), true); diff --git a/src/main/java/com/botdarr/clients/matrix/MatrixResponseBuilder.java b/src/main/java/com/botdarr/clients/matrix/MatrixResponseBuilder.java index cafed35..53a46d7 100644 --- a/src/main/java/com/botdarr/clients/matrix/MatrixResponseBuilder.java +++ b/src/main/java/com/botdarr/clients/matrix/MatrixResponseBuilder.java @@ -117,7 +117,7 @@ public MatrixResponse getShowDownloadResponses(SonarrQueue sonarrShow) { @Override public MatrixResponse getMovieDownloadResponses(RadarrQueue radarrQueue) { MatrixResponse matrixResponse = new MatrixResponse(); - matrixResponse.addContent("Title - " + radarrQueue.getRadarrQueueMovie().getTitle()); + matrixResponse.addContent("Title - " + radarrQueue.getTitle()); matrixResponse.addContent("Quality - " + radarrQueue.getQuality().getQuality().getName()); matrixResponse.addContent("Status - " + radarrQueue.getStatus()); matrixResponse.addContent("Time Left - " + (radarrQueue.getTimeleft() == null ? "unknown" : radarrQueue.getTimeleft()) + ""); diff --git a/src/main/java/com/botdarr/clients/slack/SlackResponseBuilder.java b/src/main/java/com/botdarr/clients/slack/SlackResponseBuilder.java index d49de46..bc78049 100644 --- a/src/main/java/com/botdarr/clients/slack/SlackResponseBuilder.java +++ b/src/main/java/com/botdarr/clients/slack/SlackResponseBuilder.java @@ -176,7 +176,7 @@ public SlackResponse getShowDownloadResponses(SonarrQueue showQueue) { public SlackResponse getMovieDownloadResponses(RadarrQueue radarrQueue) { SlackResponse slackResponse = new SlackResponse(); slackResponse.addBlock(SectionBlock.builder() - .text(MarkdownTextObject.builder().text("*Title* - " + radarrQueue.getRadarrQueueMovie().getTitle()).build()) + .text(MarkdownTextObject.builder().text("*Title* - " + radarrQueue.getTitle()).build()) .build()); slackResponse.addBlock(SectionBlock.builder() .text(MarkdownTextObject.builder().text("Quality - " + radarrQueue.getQuality().getQuality().getName()).build()) diff --git a/src/main/java/com/botdarr/clients/telegram/TelegramResponseBuilder.java b/src/main/java/com/botdarr/clients/telegram/TelegramResponseBuilder.java index 710ce00..472d0e1 100644 --- a/src/main/java/com/botdarr/clients/telegram/TelegramResponseBuilder.java +++ b/src/main/java/com/botdarr/clients/telegram/TelegramResponseBuilder.java @@ -118,7 +118,7 @@ public TelegramResponse getShowDownloadResponses(SonarrQueue showQueue) { @Override public TelegramResponse getMovieDownloadResponses(RadarrQueue radarrQueue) { List domContents = new ArrayList<>(); - domContents.add(b(radarrQueue.getRadarrQueueMovie().getTitle())); + domContents.add(b(radarrQueue.getTitle())); StringBuilder details = new StringBuilder(); details.append("Quality - " + radarrQueue.getQuality().getQuality().getName() + "\n"); details.append("Status - " + radarrQueue.getStatus() + "\n"); diff --git a/src/main/resources/version.txt b/src/main/resources/version.txt index 61fcc87..cdb98d2 100644 --- a/src/main/resources/version.txt +++ b/src/main/resources/version.txt @@ -1 +1 @@ -5.1.2 +5.1.3 diff --git a/src/test/java/com/botdarr/api/radarr/RadarrApiTests.java b/src/test/java/com/botdarr/api/radarr/RadarrApiTests.java index 428a6e8..9f7f77e 100644 --- a/src/test/java/com/botdarr/api/radarr/RadarrApiTests.java +++ b/src/test/java/com/botdarr/api/radarr/RadarrApiTests.java @@ -37,8 +37,9 @@ public void discover_existingMoviesNotReturned() { RadarrApi radarrApi = new RadarrApi(new TestResponseBuilder()); HttpRequest request = HttpRequest.request() .withMethod("GET") - .withPath("/api/movies/discover/recommendations") - .withQueryStringParameter("apiKey", "FSJDkjmf#$Kf3"); + .withPath("/api/v3/importlist/movie") + .withQueryStringParameter("apiKey", "FSJDkjmf#$Kf3") + .withQueryStringParameter("includeRecommendations", "true"); RadarrMovie expectedRadarrMovie = new RadarrMovie(); expectedRadarrMovie.setTitle("movie1"); @@ -67,8 +68,9 @@ public void discover_maxResults() { RadarrApi radarrApi = new RadarrApi(new TestResponseBuilder()); HttpRequest request = HttpRequest.request() .withMethod("GET") - .withPath("/api/movies/discover/recommendations") - .withQueryStringParameter("apiKey", "FSJDkjmf#$Kf3"); + .withPath("/api/v3/importlist/movie") + .withQueryStringParameter("apiKey", "FSJDkjmf#$Kf3") + .withQueryStringParameter("includeRecommendations", "true"); RadarrMovie[] radarrMovies = new RadarrMovie[40]; for (int i = 0; i < radarrMovies.length; i++) { @@ -211,7 +213,7 @@ public void downloads_noDownloadsFound() { RadarrApi radarrApi = new RadarrApi(new TestResponseBuilder()); HttpRequest request = HttpRequest.request() .withMethod("GET") - .withPath("/api/queue") + .withPath("/api/v3/queue") .withQueryStringParameter("apiKey", "FSJDkjmf#$Kf3"); //setup expected response in mock server @@ -219,7 +221,7 @@ public void downloads_noDownloadsFound() { .when(request) .respond(HttpResponse.response() .withStatusCode(200) - .withBody(new Gson().toJson(new RadarrQueue[] {}), MediaType.APPLICATION_JSON)); + .withBody(new Gson().toJson(new RadarrQueuePage()), MediaType.APPLICATION_JSON)); //trigger api CommandResponse commandResponse = new CommandResponse(radarrApi.downloads()); @@ -239,20 +241,21 @@ public void downloads_downloadsFound() { RadarrApi radarrApi = new RadarrApi(new TestResponseBuilder()); HttpRequest request = HttpRequest.request() .withMethod("GET") - .withPath("/api/queue") + .withPath("/api/v3/queue") .withQueryStringParameter("apiKey", "FSJDkjmf#$Kf3"); RadarrQueue radarrQueue = new RadarrQueue(); - radarrQueue.setId(1); radarrQueue.setTimeleft("05:00"); radarrQueue.setStatus("DOWNLOADING"); //setup expected response in mock server + RadarrQueuePage radarrQueuePage = new RadarrQueuePage(); + radarrQueuePage.setRecords(new ArrayList() {{add(radarrQueue);}}); mockServerRule.getClient() .when(request) .respond(HttpResponse.response() .withStatusCode(200) - .withBody(new Gson().toJson(new RadarrQueue[] {radarrQueue}), MediaType.APPLICATION_JSON)); + .withBody(new Gson().toJson(radarrQueuePage), MediaType.APPLICATION_JSON)); //trigger api CommandResponse commandResponse = new CommandResponse(radarrApi.downloads()); @@ -264,7 +267,6 @@ public void downloads_downloadsFound() { List testResponses = commandResponse.getMultipleChatClientResponses(); //only movie is downloading, verify all properties Assert.assertEquals(1, testResponses.size()); - Assert.assertEquals(1, testResponses.get(0).getRadarrQueue().getId()); Assert.assertEquals("05:00", testResponses.get(0).getRadarrQueue().getTimeleft()); Assert.assertEquals("DOWNLOADING", testResponses.get(0).getRadarrQueue().getStatus()); }