From d6684eb1de29728da255571ae652a6a04efd404e Mon Sep 17 00:00:00 2001 From: tidusjar Date: Fri, 17 Feb 2017 22:11:37 +0000 Subject: [PATCH] Fixed #1133 Do not show shows that we do not ahve any information for. --- Ombi.Api/ApiRequest.cs | 10 ++-------- Ombi.Api/TvMazeApi.cs | 31 ++++++++++++++++++++----------- Ombi.UI/Modules/SearchModule.cs | 17 +++++++++++++++++ 3 files changed, 39 insertions(+), 19 deletions(-) diff --git a/Ombi.Api/ApiRequest.cs b/Ombi.Api/ApiRequest.cs index a27d4af28..2de72101d 100644 --- a/Ombi.Api/ApiRequest.cs +++ b/Ombi.Api/ApiRequest.cs @@ -27,6 +27,7 @@ using System; using System.IO; +using System.Net; using System.Xml.Serialization; using Newtonsoft.Json; using NLog; @@ -76,14 +77,7 @@ namespace Ombi.Api var client = new RestClient { BaseUrl = baseUri }; var response = client.Execute(request); - - if (response.ErrorException != null) - { - Log.Error(response.ErrorException); - var message = "Error retrieving response. Check inner details for more info."; - throw new ApiRequestException(message, response.ErrorException); - } - + return response; } diff --git a/Ombi.Api/TvMazeApi.cs b/Ombi.Api/TvMazeApi.cs index 5bb534990..4330a3d1e 100644 --- a/Ombi.Api/TvMazeApi.cs +++ b/Ombi.Api/TvMazeApi.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Newtonsoft.Json; using NLog; using Ombi.Api.Models.Tv; using RestSharp; @@ -90,21 +91,29 @@ namespace Ombi.Api }; request.AddUrlSegment("id", theTvDbId.ToString()); request.AddHeader("Content-Type", "application/json"); + try + { + var result = Api.Execute(request, new Uri(Uri)); + var obj = JsonConvert.DeserializeObject(result.Content); - var obj = Api.Execute(request, new Uri(Uri)); - - var episodes = EpisodeLookup(obj.id).ToList(); + var episodes = EpisodeLookup(obj.id).ToList(); - foreach (var e in episodes) - { - obj.Season.Add(new TvMazeCustomSeason + foreach (var e in episodes) { - SeasonNumber = e.season, - EpisodeNumber = e.number - }); + obj.Season.Add(new TvMazeCustomSeason + { + SeasonNumber = e.season, + EpisodeNumber = e.number + }); + } + + return obj; } - - return obj; + catch (Exception e) + { + Log.Error(e); + return null; + } } public List GetSeasons(int id) diff --git a/Ombi.UI/Modules/SearchModule.cs b/Ombi.UI/Modules/SearchModule.cs index f11e41b55..2d4a12d49 100644 --- a/Ombi.UI/Modules/SearchModule.cs +++ b/Ombi.UI/Modules/SearchModule.cs @@ -437,6 +437,11 @@ namespace Ombi.UI.Modules { var show = anticipatedShow.Show; var theTvDbId = int.Parse(show.Ids.Tvdb.ToString()); + var result = TvApi.ShowLookupByTheTvDbId(theTvDbId); + if (result == null) + { + continue; + } var model = new SearchTvShowViewModel { @@ -466,6 +471,12 @@ namespace Ombi.UI.Modules { var show = watched.Show; var theTvDbId = int.Parse(show.Ids.Tvdb.ToString()); + var result = TvApi.ShowLookupByTheTvDbId(theTvDbId); + if (result == null) + { + continue; + } + var model = new SearchTvShowViewModel { FirstAired = show.FirstAired?.ToString("yyyy-MM-ddTHH:mm:ss"), @@ -494,6 +505,12 @@ namespace Ombi.UI.Modules { var show = watched.Show; var theTvDbId = int.Parse(show.Ids.Tvdb.ToString()); + var result = TvApi.ShowLookupByTheTvDbId(theTvDbId); + if (result == null) + { + continue; + } + var model = new SearchTvShowViewModel { FirstAired = show.FirstAired?.ToString("yyyy-MM-ddTHH:mm:ss"),