Fixed an issue for #1951

pull/1955/head^2
tidusjar 7 years ago
parent acac2c3675
commit b015b101ed

@ -30,6 +30,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Hangfire;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Ombi.Api.Plex;
using Ombi.Api.Plex.Models;
@ -81,7 +82,7 @@ namespace Ombi.Schedule.Jobs.Plex
}
catch (Exception e)
{
Logger.LogWarning(LoggingEvents.Cacher, e, "Exception thrown when attempting to cache the Plex Content");
Logger.LogWarning(LoggingEvents.PlexContentCacher, e, "Exception thrown when attempting to cache the Plex Content");
}
Logger.LogInformation("Starting EP Cacher");
@ -187,6 +188,8 @@ namespace Ombi.Schedule.Jobs.Plex
}
}
else
{
try
{
Logger.LogInformation("New show {0}, so add it", show.title);
@ -220,9 +223,31 @@ namespace Ombi.Schedule.Jobs.Plex
item.TvDbId = providerIds.TheTvDb;
}
// Let's just double check to make sure we do not have it now we have some id's
var existingImdb = false;
var existingMovieDbId = false;
var existingTvDbId = false;
existingImdb = await Repo.GetAll().AnyAsync(x => x.ImdbId == item.ImdbId && x.Type == PlexMediaTypeEntity.Show);
existingMovieDbId = await Repo.GetAll().AnyAsync(x => x.TheMovieDbId == item.TheMovieDbId && x.Type == PlexMediaTypeEntity.Show);
existingTvDbId = await Repo.GetAll().AnyAsync(x => x.TvDbId == item.TvDbId && x.Type == PlexMediaTypeEntity.Show);
if (existingImdb || existingTvDbId || existingMovieDbId)
{
// We already have it!
continue;
}
item.Seasons.ToList().AddRange(seasonsContent);
contentToAdd.Add(item);
}
catch (Exception e)
{
Logger.LogError(LoggingEvents.PlexContentCacher, e, "Exception when adding tv show {0}", show.title);
}
}
}
}
@ -233,6 +258,8 @@ namespace Ombi.Schedule.Jobs.Plex
{
// Let's check if we have this movie
try
{
var existing = await Repo.GetFirstContentByCustom(x => x.Title == movie.title
&& x.ReleaseYear == movie.year.ToString()
&& x.Type == PlexMediaTypeEntity.Movie);
@ -282,6 +309,11 @@ namespace Ombi.Schedule.Jobs.Plex
}
contentToAdd.Add(item);
}
catch (Exception e)
{
Logger.LogError(LoggingEvents.PlexContentCacher, e, "Exception when adding new Movie {0}", movie.title);
}
}
}
if (contentToAdd.Count > 500)
{

Loading…
Cancel
Save