mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 21:33:15 -07:00
Fixed the issue with the Recently Added Sync sometimes not working as expected
This commit is contained in:
parent
af2cceb6a8
commit
02f941767e
1 changed files with 18 additions and 11 deletions
|
@ -147,7 +147,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
|
|
||||||
private async Task<IEnumerable<int>> ProcessServer(PlexServers servers, bool recentlyAddedSearch)
|
private async Task<IEnumerable<int>> ProcessServer(PlexServers servers, bool recentlyAddedSearch)
|
||||||
{
|
{
|
||||||
var processedContent = new HashSet<int>();
|
var processedContent = new Dictionary<int,int>();
|
||||||
Logger.LogInformation("Getting all content from server {0}", servers.Name);
|
Logger.LogInformation("Getting all content from server {0}", servers.Name);
|
||||||
var allContent = await GetAllContent(servers, recentlyAddedSearch);
|
var allContent = await GetAllContent(servers, recentlyAddedSearch);
|
||||||
Logger.LogInformation("We found {0} items", allContent.Count);
|
Logger.LogInformation("We found {0} items", allContent.Count);
|
||||||
|
@ -175,7 +175,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
await ProcessTvShow(servers, show, contentToAdd, recentlyAddedSearch, processedContent);
|
await ProcessTvShow(servers, show, contentToAdd, processedContent);
|
||||||
if (contentToAdd.Any())
|
if (contentToAdd.Any())
|
||||||
{
|
{
|
||||||
await Repo.AddRange(contentToAdd, false);
|
await Repo.AddRange(contentToAdd, false);
|
||||||
|
@ -183,7 +183,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
{
|
{
|
||||||
foreach (var plexServerContent in contentToAdd)
|
foreach (var plexServerContent in contentToAdd)
|
||||||
{
|
{
|
||||||
processedContent.Add(plexServerContent.Id);
|
processedContent.Add(plexServerContent.Id, plexServerContent.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentToAdd.Clear();
|
contentToAdd.Clear();
|
||||||
|
@ -208,7 +208,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
foreach (var show in content.Metadata ?? new Metadata[] { })
|
foreach (var show in content.Metadata ?? new Metadata[] { })
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
await ProcessTvShow(servers, show, contentToAdd, recentlyAddedSearch, processedContent);
|
await ProcessTvShow(servers, show, contentToAdd, processedContent);
|
||||||
|
|
||||||
if (contentToAdd.Any())
|
if (contentToAdd.Any())
|
||||||
{
|
{
|
||||||
|
@ -217,7 +217,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
{
|
{
|
||||||
foreach (var plexServerContent in contentToAdd)
|
foreach (var plexServerContent in contentToAdd)
|
||||||
{
|
{
|
||||||
processedContent.Add(plexServerContent.Id);
|
processedContent.Add(plexServerContent.Id, plexServerContent.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentToAdd.Clear();
|
contentToAdd.Clear();
|
||||||
|
@ -299,7 +299,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
await Repo.AddRange(contentToAdd);
|
await Repo.AddRange(contentToAdd);
|
||||||
foreach (var c in contentToAdd)
|
foreach (var c in contentToAdd)
|
||||||
{
|
{
|
||||||
processedContent.Add(c.Id);
|
processedContent.Add(c.Id, c.Key);
|
||||||
}
|
}
|
||||||
contentToAdd.Clear();
|
contentToAdd.Clear();
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
await Repo.AddRange(contentToAdd);
|
await Repo.AddRange(contentToAdd);
|
||||||
foreach (var c in contentToAdd)
|
foreach (var c in contentToAdd)
|
||||||
{
|
{
|
||||||
processedContent.Add(c.Id);
|
processedContent.Add(c.Id, c.Key);
|
||||||
}
|
}
|
||||||
contentToAdd.Clear();
|
contentToAdd.Clear();
|
||||||
}
|
}
|
||||||
|
@ -321,14 +321,14 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
await Repo.AddRange(contentToAdd);
|
await Repo.AddRange(contentToAdd);
|
||||||
foreach (var c in contentToAdd)
|
foreach (var c in contentToAdd)
|
||||||
{
|
{
|
||||||
processedContent.Add(c.Id);
|
processedContent.Add(c.Id, c.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return processedContent;
|
return processedContent.Values;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ProcessTvShow(PlexServers servers, Metadata show, HashSet<PlexServerContent> contentToAdd, bool recentlyAdded, HashSet<int> contentProcessed)
|
private async Task ProcessTvShow(PlexServers servers, Metadata show, HashSet<PlexServerContent> contentToAdd, Dictionary<int,int> contentProcessed)
|
||||||
{
|
{
|
||||||
var seasonList = await PlexApi.GetSeasons(servers.PlexAuthToken, servers.FullUri,
|
var seasonList = await PlexApi.GetSeasons(servers.PlexAuthToken, servers.FullUri,
|
||||||
show.ratingKey);
|
show.ratingKey);
|
||||||
|
@ -397,6 +397,13 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Also make sure it's not already being processed...
|
||||||
|
var alreadyProcessed = contentProcessed.Select(x => x.Value).Any(x => x == show.ratingKey);
|
||||||
|
if (alreadyProcessed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// The ratingKey keeps changing...
|
// The ratingKey keeps changing...
|
||||||
//var existingContent = await Repo.GetByKey(show.ratingKey);
|
//var existingContent = await Repo.GetByKey(show.ratingKey);
|
||||||
if (existingContent != null)
|
if (existingContent != null)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue