mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
Fixed an issue for #1951
This commit is contained in:
parent
acac2c3675
commit
b015b101ed
1 changed files with 106 additions and 74 deletions
|
@ -30,6 +30,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Hangfire;
|
using Hangfire;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Ombi.Api.Plex;
|
using Ombi.Api.Plex;
|
||||||
using Ombi.Api.Plex.Models;
|
using Ombi.Api.Plex.Models;
|
||||||
|
@ -81,7 +82,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
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");
|
Logger.LogInformation("Starting EP Cacher");
|
||||||
|
@ -187,6 +188,8 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
Logger.LogInformation("New show {0}, so add it", show.title);
|
Logger.LogInformation("New show {0}, so add it", show.title);
|
||||||
|
@ -220,9 +223,31 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
item.TvDbId = providerIds.TheTvDb;
|
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);
|
item.Seasons.ToList().AddRange(seasonsContent);
|
||||||
|
|
||||||
contentToAdd.Add(item);
|
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
|
// Let's check if we have this movie
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
var existing = await Repo.GetFirstContentByCustom(x => x.Title == movie.title
|
var existing = await Repo.GetFirstContentByCustom(x => x.Title == movie.title
|
||||||
&& x.ReleaseYear == movie.year.ToString()
|
&& x.ReleaseYear == movie.year.ToString()
|
||||||
&& x.Type == PlexMediaTypeEntity.Movie);
|
&& x.Type == PlexMediaTypeEntity.Movie);
|
||||||
|
@ -282,6 +309,11 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
}
|
}
|
||||||
contentToAdd.Add(item);
|
contentToAdd.Add(item);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.LogError(LoggingEvents.PlexContentCacher, e, "Exception when adding new Movie {0}", movie.title);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (contentToAdd.Count > 500)
|
if (contentToAdd.Count > 500)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue