From a361e8a0d73803ed6f21f0c9f9d708aca598d830 Mon Sep 17 00:00:00 2001 From: Darkalfx Date: Sun, 22 Mar 2020 16:09:47 -0400 Subject: [PATCH] Fixed a bug when searching by tmdb id --- Requestrr.WebApi/ClientApp/package.json | 2 +- .../src/components/Footers/AdminFooter.jsx | 2 +- .../src/components/Footers/AuthFooter.jsx | 2 +- .../Discord/DiscordHelpWorkFlow.cs | 2 +- .../DownloadClients/Radarr/Radarr.cs | 29 +++++++++++++++---- .../Movies/MovieRequestingWorkflow.cs | 4 +-- 6 files changed, 30 insertions(+), 11 deletions(-) diff --git a/Requestrr.WebApi/ClientApp/package.json b/Requestrr.WebApi/ClientApp/package.json index e9d49815..d16da63e 100644 --- a/Requestrr.WebApi/ClientApp/package.json +++ b/Requestrr.WebApi/ClientApp/package.json @@ -1,6 +1,6 @@ { "name": "Requestrr", - "version": "1.0.6", + "version": "1.0.7", "description": "Requestrr is a server designed to faciliate the request of media through chat applications.", "main": "index.js", "author": "Darkalfx", diff --git a/Requestrr.WebApi/ClientApp/src/components/Footers/AdminFooter.jsx b/Requestrr.WebApi/ClientApp/src/components/Footers/AdminFooter.jsx index b3376eb8..8de6ab85 100644 --- a/Requestrr.WebApi/ClientApp/src/components/Footers/AdminFooter.jsx +++ b/Requestrr.WebApi/ClientApp/src/components/Footers/AdminFooter.jsx @@ -29,7 +29,7 @@ class Footer extends React.Component {
© {new Date().getFullYear()}{" "} - Requestrr (v1.0.6) + Requestrr (v1.0.7)
diff --git a/Requestrr.WebApi/ClientApp/src/components/Footers/AuthFooter.jsx b/Requestrr.WebApi/ClientApp/src/components/Footers/AuthFooter.jsx index fe0fd705..068369cd 100644 --- a/Requestrr.WebApi/ClientApp/src/components/Footers/AuthFooter.jsx +++ b/Requestrr.WebApi/ClientApp/src/components/Footers/AuthFooter.jsx @@ -31,7 +31,7 @@ class AuthFooter extends React.Component {
© {new Date().getFullYear()}{" "} - Requestrr (v1.0.6) + Requestrr (v1.0.7)
diff --git a/Requestrr.WebApi/RequestrrBot/ChatClients/Discord/DiscordHelpWorkFlow.cs b/Requestrr.WebApi/RequestrrBot/ChatClients/Discord/DiscordHelpWorkFlow.cs index 84d087cc..eea352ea 100644 --- a/Requestrr.WebApi/RequestrrBot/ChatClients/Discord/DiscordHelpWorkFlow.cs +++ b/Requestrr.WebApi/RequestrrBot/ChatClients/Discord/DiscordHelpWorkFlow.cs @@ -45,7 +45,7 @@ public async Task HandleHelpAsync() if (!string.IsNullOrWhiteSpace(_discordSettings.MovieCommand)) { messageBuilder.AppendLine($"**{_discordSettings.CommandPrefix}{_discordSettings.MovieCommand}**"); - messageBuilder.AppendLine($"**{_discordSettings.CommandPrefix}{_discordSettings.MovieCommand} tmdbid**"); + messageBuilder.AppendLine($"**{_discordSettings.CommandPrefix}{_discordSettings.MovieCommand} tmdb**"); } messageBuilder.AppendLine($"**{_discordSettings.CommandPrefix}help**"); diff --git a/Requestrr.WebApi/RequestrrBot/DownloadClients/Radarr/Radarr.cs b/Requestrr.WebApi/RequestrrBot/DownloadClients/Radarr/Radarr.cs index 0571aae9..27b961b8 100644 --- a/Requestrr.WebApi/RequestrrBot/DownloadClients/Radarr/Radarr.cs +++ b/Requestrr.WebApi/RequestrrBot/DownloadClients/Radarr/Radarr.cs @@ -171,14 +171,33 @@ public async Task SearchMovieAsync(int theMovieDbId) { try { - var response = await HttpGetAsync($"{BaseURL}/movie/lookup/tmdb?tmdbId={theMovieDbId}"); - await response.ThrowIfNotSuccessfulAsync("RadarrMovieLookupByTmdbId failed", x => x.error); + var response = await HttpGetAsync($"{BaseURL}/movie"); + await response.ThrowIfNotSuccessfulAsync("RadarrGetAllMovies failed", x => x.error); var jsonResponse = await response.Content.ReadAsStringAsync(); - var jsonMovie = JsonConvert.DeserializeObject(jsonResponse); + var allRadarrMoviesJson = JsonConvert.DeserializeObject>(jsonResponse).ToArray(); + + var foundMovieJson = allRadarrMoviesJson.FirstOrDefault(x => x.tmdbId == theMovieDbId); + + response = await HttpGetAsync($"{BaseURL}/movie/lookup/tmdb?tmdbId={theMovieDbId}"); + await response.ThrowIfNotSuccessfulAsync("RadarrMovieLookupByTmdbId failed", x => x.error); + + jsonResponse = await response.Content.ReadAsStringAsync(); + var movieFoundByIdJson = JsonConvert.DeserializeObject(jsonResponse); + + if (foundMovieJson != null) + { + if (movieFoundByIdJson.tmdbId == theMovieDbId) + { + foundMovieJson.images = movieFoundByIdJson.images; + } + } + else + { + foundMovieJson = movieFoundByIdJson; + } - var convertedMovie = Convert(jsonMovie); - return convertedMovie?.TheMovieDbId == theMovieDbId.ToString() ? convertedMovie : null; + return foundMovieJson != null ? Convert(foundMovieJson) : null; } catch (System.Exception ex) { diff --git a/Requestrr.WebApi/RequestrrBot/Movies/MovieRequestingWorkflow.cs b/Requestrr.WebApi/RequestrrBot/Movies/MovieRequestingWorkflow.cs index 0a73704c..3e665950 100644 --- a/Requestrr.WebApi/RequestrrBot/Movies/MovieRequestingWorkflow.cs +++ b/Requestrr.WebApi/RequestrrBot/Movies/MovieRequestingWorkflow.cs @@ -60,9 +60,9 @@ public async Task> SearchMoviesAsync(string movieName) { IReadOnlyList movies = Array.Empty(); - if (movieName.Trim().ToLower().StartsWith("tmdbid")) + if (movieName.Trim().ToLower().StartsWith("tmdb")) { - var theMovieDbIdTextValue = movieName.ToLower().Split("tmdbid")[1]?.Trim(); + var theMovieDbIdTextValue = movieName.ToLower().Split("tmdb")[1]?.Trim(); if (int.TryParse(theMovieDbIdTextValue, out var theMovieDbId)) {