1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Fix error when we get invalid datetime from our api.

This commit is contained in:
Leonardo Galli 2017-06-06 20:02:40 +02:00
parent cff4578c66
commit b70ed720c5

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
@ -556,20 +556,28 @@ private Movie MapMovie(MovieResult result)
imdbMovie.Title = result.title;
imdbMovie.TitleSlug = Parser.Parser.ToUrlSlug(result.title);
if (result.release_date.IsNotNullOrWhiteSpace())
try
{
imdbMovie.InCinemas = DateTime.Parse(result.release_date);
imdbMovie.Year = imdbMovie.InCinemas.Value.Year;
}
if (result.physical_release.IsNotNullOrWhiteSpace())
{
imdbMovie.PhysicalRelease = DateTime.Parse(result.physical_release);
if (result.physical_release_note.IsNotNullOrWhiteSpace())
if (result.release_date.IsNotNullOrWhiteSpace())
{
imdbMovie.PhysicalReleaseNote = result.physical_release_note;
imdbMovie.InCinemas = DateTime.Parse(result.release_date);
imdbMovie.Year = imdbMovie.InCinemas.Value.Year;
}
if (result.physical_release.IsNotNullOrWhiteSpace())
{
imdbMovie.PhysicalRelease = DateTime.Parse(result.physical_release);
if (result.physical_release_note.IsNotNullOrWhiteSpace())
{
imdbMovie.PhysicalReleaseNote = result.physical_release_note;
}
}
}
catch (Exception ex)
{
_logger.Debug("Not a valid date time.");
}
var now = DateTime.Now;