From b70ed720c5b8e87bb71ad6277e466b2ffc208962 Mon Sep 17 00:00:00 2001 From: Leonardo Galli Date: Tue, 6 Jun 2017 20:02:40 +0200 Subject: [PATCH] Fix error when we get invalid datetime from our api. --- .../MetadataSource/SkyHook/SkyHookProxy.cs | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 4defaa6a1..0bb3edf36 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net; @@ -556,20 +556,28 @@ namespace NzbDrone.Core.MetadataSource.SkyHook 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.release_date.IsNotNullOrWhiteSpace()) + { + 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.physical_release.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;