mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-15 09:42:56 -07:00
This commit is contained in:
parent
c03c11c3e7
commit
b323db1864
3 changed files with 50 additions and 19 deletions
|
@ -162,8 +162,10 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
if (content.viewGroup.Equals(PlexMediaType.Episode.ToString(), StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
Logger.LogInformation("Found some episodes, this must be a recently added sync");
|
||||
var count = 0;
|
||||
foreach (var epInfo in content.Metadata)
|
||||
{
|
||||
count++;
|
||||
var grandParentKey = epInfo.grandparentRatingKey;
|
||||
// Lookup the rating key
|
||||
var showMetadata = await PlexApi.GetMetadata(servers.PlexAuthToken, servers.FullUri, grandParentKey);
|
||||
|
@ -174,7 +176,27 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
}
|
||||
|
||||
await ProcessTvShow(servers, show, contentToAdd, recentlyAddedSearch, processedContent);
|
||||
if (contentToAdd.Any())
|
||||
{
|
||||
await Repo.AddRange(contentToAdd, false);
|
||||
if (recentlyAddedSearch)
|
||||
{
|
||||
foreach (var plexServerContent in contentToAdd)
|
||||
{
|
||||
processedContent.Add(plexServerContent.Id);
|
||||
}
|
||||
}
|
||||
contentToAdd.Clear();
|
||||
}
|
||||
if (count > 200)
|
||||
{
|
||||
await Repo.SaveChangesAsync();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Save just to make sure we don't leave anything hanging
|
||||
await Repo.SaveChangesAsync();
|
||||
|
||||
await EpisodeSync.ProcessEpsiodes(content.Metadata, allEps);
|
||||
}
|
||||
|
@ -182,11 +204,32 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
{
|
||||
// Process Shows
|
||||
Logger.LogInformation("Processing TV Shows");
|
||||
var count = 0;
|
||||
foreach (var show in content.Metadata ?? new Metadata[] { })
|
||||
{
|
||||
count++;
|
||||
await ProcessTvShow(servers, show, contentToAdd, recentlyAddedSearch, processedContent);
|
||||
|
||||
if (contentToAdd.Any())
|
||||
{
|
||||
await Repo.AddRange(contentToAdd, false);
|
||||
if (recentlyAddedSearch)
|
||||
{
|
||||
foreach (var plexServerContent in contentToAdd)
|
||||
{
|
||||
processedContent.Add(plexServerContent.Id);
|
||||
}
|
||||
}
|
||||
contentToAdd.Clear();
|
||||
}
|
||||
if (count > 200)
|
||||
{
|
||||
await Repo.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
await Repo.SaveChangesAsync();
|
||||
}
|
||||
if (content.viewGroup.Equals(PlexMediaType.Movie.ToString(), StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
Logger.LogInformation("Processing Movies");
|
||||
|
@ -464,21 +507,6 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
show.title);
|
||||
}
|
||||
}
|
||||
|
||||
if (contentToAdd.Count > 500 || recentlyAdded)
|
||||
{
|
||||
await Repo.AddRange(contentToAdd);
|
||||
foreach (var plexServerContent in contentToAdd)
|
||||
{
|
||||
contentProcessed.Add(plexServerContent.Id);
|
||||
}
|
||||
contentToAdd.Clear();
|
||||
}
|
||||
|
||||
if (contentToAdd.Any())
|
||||
{
|
||||
await Repo.AddRange(contentToAdd);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Ombi.Store.Repository
|
|||
Task<T> Find(object key);
|
||||
IQueryable<T> GetAll();
|
||||
Task<T> FirstOrDefaultAsync(Expression<Func<T, bool>> predicate);
|
||||
Task AddRange(IEnumerable<T> content);
|
||||
Task AddRange(IEnumerable<T> content, bool save = true);
|
||||
Task<T> Add(T content);
|
||||
Task DeleteRange(IEnumerable<T> req);
|
||||
Task Delete(T request);
|
||||
|
|
|
@ -35,11 +35,14 @@ namespace Ombi.Store.Repository
|
|||
return await _db.FirstOrDefaultAsync(predicate);
|
||||
}
|
||||
|
||||
public async Task AddRange(IEnumerable<T> content)
|
||||
public async Task AddRange(IEnumerable<T> content, bool save = true)
|
||||
{
|
||||
_db.AddRange(content);
|
||||
if (save)
|
||||
{
|
||||
await _ctx.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<T> Add(T content)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue