Skip to content

Commit

Permalink
Fixed #1133
Browse files Browse the repository at this point in the history
Do not show shows that we do not ahve any information for.
  • Loading branch information
tidusjar committed Feb 17, 2017
1 parent 7412528 commit d6684eb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 19 deletions.
10 changes: 2 additions & 8 deletions Ombi.Api/ApiRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

using System;
using System.IO;
using System.Net;
using System.Xml.Serialization;
using Newtonsoft.Json;
using NLog;
Expand Down Expand Up @@ -76,14 +77,7 @@ public IRestResponse Execute(IRestRequest request, Uri baseUri)
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;
}

Expand Down
31 changes: 20 additions & 11 deletions Ombi.Api/TvMazeApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -90,21 +91,29 @@ public TvMazeShow ShowLookupByTheTvDbId(int theTvDbId)
};
request.AddUrlSegment("id", theTvDbId.ToString());
request.AddHeader("Content-Type", "application/json");
try
{
var result = Api.Execute(request, new Uri(Uri));
var obj = JsonConvert.DeserializeObject<TvMazeShow>(result.Content);

var obj = Api.Execute<TvMazeShow>(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<TvMazeSeasons> GetSeasons(int id)
Expand Down
17 changes: 17 additions & 0 deletions Ombi.UI/Modules/SearchModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ private async Task<Response> ProcessShows(ShowSearchType type)
{
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
{
Expand Down Expand Up @@ -466,6 +471,12 @@ private async Task<Response> ProcessShows(ShowSearchType type)
{
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"),
Expand Down Expand Up @@ -494,6 +505,12 @@ private async Task<Response> ProcessShows(ShowSearchType type)
{
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"),
Expand Down

0 comments on commit d6684eb

Please sign in to comment.