mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
Added a bit better error handling around the request builder when requesting TV shows
This commit is contained in:
parent
6b49e23a77
commit
1cb2431ed1
1 changed files with 8 additions and 3 deletions
|
@ -12,16 +12,19 @@ using Ombi.Helpers;
|
|||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
using Ombi.Store.Repository.Requests;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Ombi.Core.Helpers
|
||||
{
|
||||
public class TvShowRequestBuilder
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public TvShowRequestBuilder(ITvMazeApi tvApi, IMovieDbApi movApi)
|
||||
public TvShowRequestBuilder(ITvMazeApi tvApi, IMovieDbApi movApi, ILogger<TvShowRequestBuilder> logger)
|
||||
{
|
||||
TvApi = tvApi;
|
||||
MovieDbApi = movApi;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
private ITvMazeApi TvApi { get; }
|
||||
|
@ -45,6 +48,7 @@ namespace Ombi.Core.Helpers
|
|||
{
|
||||
if (result.Name.Equals(ShowInfo.name, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
_logger.LogInformation($"Found matching MovieDb entry for show name {ShowInfo.name}");
|
||||
TheMovieDbRecord = result;
|
||||
var showIds = await MovieDbApi.GetTvExternals(result.Id);
|
||||
ShowInfo.externals.imdb = showIds.imdb_id;
|
||||
|
@ -237,18 +241,19 @@ namespace Ombi.Core.Helpers
|
|||
|
||||
public TvShowRequestBuilder CreateNewRequest(TvRequestViewModel tv)
|
||||
{
|
||||
_logger.LogInformation($"Building Request for {ShowInfo.name} with Provider ID {TheMovieDbRecord?.Id ?? 0}");
|
||||
NewRequest = new TvRequests
|
||||
{
|
||||
Overview = ShowInfo.summary.RemoveHtml(),
|
||||
PosterPath = PosterPath,
|
||||
Title = ShowInfo.name,
|
||||
ReleaseDate = FirstAir,
|
||||
ExternalProviderId = TheMovieDbRecord.Id,
|
||||
ExternalProviderId = TheMovieDbRecord?.Id ?? 0,
|
||||
Status = ShowInfo.status,
|
||||
ImdbId = ShowInfo.externals?.imdb ?? string.Empty,
|
||||
TvDbId = tv.TvDbId,
|
||||
ChildRequests = new List<ChildRequests>(),
|
||||
TotalSeasons = tv.Seasons.Count(),
|
||||
TotalSeasons = tv.Seasons?.Count ?? 0,
|
||||
Background = BackdropPath
|
||||
};
|
||||
NewRequest.ChildRequests.Add(ChildRequest);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue