Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
Fixed a bug when searching by tmdb id
Browse files Browse the repository at this point in the history
  • Loading branch information
darkalfx committed Mar 22, 2020
1 parent d4e63e2 commit a361e8a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Requestrr.WebApi/ClientApp/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Footer extends React.Component {
<Col xl="6">
<div className="copyright text-center text-xl-left text-muted">
© {new Date().getFullYear()}{" "}
Requestrr (v1.0.6)
Requestrr (v1.0.7)
</div>
</Col>
</Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AuthFooter extends React.Component {
<Col xl="6">
<div className="copyright text-center text-xl-left text-muted">
© {new Date().getFullYear()}{" "}
Requestrr (v1.0.6)
Requestrr (v1.0.7)
</div>
</Col>
</Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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**");
Expand Down
29 changes: 24 additions & 5 deletions Requestrr.WebApi/RequestrrBot/DownloadClients/Radarr/Radarr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,33 @@ public async Task<Movie> 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<JSONMovie>(jsonResponse);
var allRadarrMoviesJson = JsonConvert.DeserializeObject<List<JSONMovie>>(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<JSONMovie>(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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public async Task<IReadOnlyList<Movie>> SearchMoviesAsync(string movieName)
{
IReadOnlyList<Movie> movies = Array.Empty<Movie>();

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))
{
Expand Down

0 comments on commit a361e8a

Please sign in to comment.