Fix error when we get invalid datetime from our api.

pull/2/head
Leonardo Galli 8 years ago
parent cff4578c66
commit b70ed720c5

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
@ -556,20 +556,28 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
imdbMovie.Title = result.title; imdbMovie.Title = result.title;
imdbMovie.TitleSlug = Parser.Parser.ToUrlSlug(result.title); imdbMovie.TitleSlug = Parser.Parser.ToUrlSlug(result.title);
if (result.release_date.IsNotNullOrWhiteSpace()) try
{ {
imdbMovie.InCinemas = DateTime.Parse(result.release_date); if (result.release_date.IsNotNullOrWhiteSpace())
imdbMovie.Year = imdbMovie.InCinemas.Value.Year; {
} imdbMovie.InCinemas = DateTime.Parse(result.release_date);
imdbMovie.Year = imdbMovie.InCinemas.Value.Year;
}
if (result.physical_release.IsNotNullOrWhiteSpace()) if (result.physical_release.IsNotNullOrWhiteSpace())
{
imdbMovie.PhysicalRelease = DateTime.Parse(result.physical_release);
if (result.physical_release_note.IsNotNullOrWhiteSpace())
{ {
imdbMovie.PhysicalReleaseNote = result.physical_release_note; 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; var now = DateTime.Now;

Loading…
Cancel
Save