1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2025-01-01 12:54:21 +00:00

Catching HTTP Errors when adding movies from a list.

This commit is contained in:
Leonardo Galli 2017-04-08 13:50:18 +02:00
parent cb596488f2
commit b4bb8875d3

View file

@ -729,39 +729,47 @@ private static MediaCoverTypes MapCoverType(string coverType)
public Movie MapMovieToTmdbMovie(Movie movie) public Movie MapMovieToTmdbMovie(Movie movie)
{ {
Movie newMovie = movie; try
if (movie.TmdbId > 0) {
{ Movie newMovie = movie;
newMovie = GetMovieInfo(movie.TmdbId); if (movie.TmdbId > 0)
} {
else if (movie.ImdbId.IsNotNullOrWhiteSpace()) newMovie = GetMovieInfo(movie.TmdbId);
{ }
newMovie = GetMovieInfo(movie.ImdbId); else if (movie.ImdbId.IsNotNullOrWhiteSpace())
} {
else newMovie = GetMovieInfo(movie.ImdbId);
{ }
var yearStr = ""; else
if (movie.Year > 1900) {
{ var yearStr = "";
yearStr = $" {movie.Year}"; if (movie.Year > 1900)
} {
newMovie = SearchForNewMovie(movie.Title + yearStr).FirstOrDefault(); yearStr = $" {movie.Year}";
} }
newMovie = SearchForNewMovie(movie.Title + yearStr).FirstOrDefault();
}
if (newMovie == null) if (newMovie == null)
{ {
_logger.Warn("Couldn't map movie {0} to a movie on The Movie DB. It will not be added :(", movie.Title); _logger.Warn("Couldn't map movie {0} to a movie on The Movie DB. It will not be added :(", movie.Title);
return null; return null;
} }
newMovie.Path = movie.Path; newMovie.Path = movie.Path;
newMovie.RootFolderPath = movie.RootFolderPath; newMovie.RootFolderPath = movie.RootFolderPath;
newMovie.ProfileId = movie.ProfileId; newMovie.ProfileId = movie.ProfileId;
newMovie.Monitored = movie.Monitored; newMovie.Monitored = movie.Monitored;
newMovie.MovieFile = movie.MovieFile; newMovie.MovieFile = movie.MovieFile;
newMovie.MinimumAvailability = movie.MinimumAvailability; newMovie.MinimumAvailability = movie.MinimumAvailability;
return newMovie; return newMovie;
}
catch (Exception ex)
{
_logger.Warn(ex, "Couldn't map movie {0} to a movie on The Movie DB. It will not be added :(", movie.Title);
return null;
}
} }
} }
} }