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
|
@ -119,7 +119,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Logger.LogInformation("Starting to cache the content on server {0}", servers.Name);
|
Logger.LogInformation("Starting to cache the content on server {0}", servers.Name);
|
||||||
|
|
||||||
if (recentlyAddedSearch)
|
if (recentlyAddedSearch)
|
||||||
{
|
{
|
||||||
|
@ -162,8 +162,10 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
if (content.viewGroup.Equals(PlexMediaType.Episode.ToString(), StringComparison.CurrentCultureIgnoreCase))
|
if (content.viewGroup.Equals(PlexMediaType.Episode.ToString(), StringComparison.CurrentCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
Logger.LogInformation("Found some episodes, this must be a recently added sync");
|
Logger.LogInformation("Found some episodes, this must be a recently added sync");
|
||||||
|
var count = 0;
|
||||||
foreach (var epInfo in content.Metadata)
|
foreach (var epInfo in content.Metadata)
|
||||||
{
|
{
|
||||||
|
count++;
|
||||||
var grandParentKey = epInfo.grandparentRatingKey;
|
var grandParentKey = epInfo.grandparentRatingKey;
|
||||||
// Lookup the rating key
|
// Lookup the rating key
|
||||||
var showMetadata = await PlexApi.GetMetadata(servers.PlexAuthToken, servers.FullUri, grandParentKey);
|
var showMetadata = await PlexApi.GetMetadata(servers.PlexAuthToken, servers.FullUri, grandParentKey);
|
||||||
|
@ -174,18 +176,59 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
}
|
}
|
||||||
|
|
||||||
await ProcessTvShow(servers, show, contentToAdd, recentlyAddedSearch, processedContent);
|
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);
|
await EpisodeSync.ProcessEpsiodes(content.Metadata, allEps);
|
||||||
}
|
}
|
||||||
if (content.viewGroup.Equals(PlexMediaType.Show.ToString(), StringComparison.CurrentCultureIgnoreCase))
|
if (content.viewGroup.Equals(PlexMediaType.Show.ToString(), StringComparison.CurrentCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
// Process Shows
|
// Process Shows
|
||||||
Logger.LogInformation("Processing TV Shows");
|
Logger.LogInformation("Processing TV Shows");
|
||||||
|
var count = 0;
|
||||||
foreach (var show in content.Metadata ?? new Metadata[] { })
|
foreach (var show in content.Metadata ?? new Metadata[] { })
|
||||||
{
|
{
|
||||||
|
count++;
|
||||||
await ProcessTvShow(servers, show, contentToAdd, recentlyAddedSearch, processedContent);
|
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))
|
if (content.viewGroup.Equals(PlexMediaType.Movie.ToString(), StringComparison.CurrentCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
|
@ -464,21 +507,6 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
show.title);
|
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>
|
/// <summary>
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Ombi.Store.Repository
|
||||||
Task<T> Find(object key);
|
Task<T> Find(object key);
|
||||||
IQueryable<T> GetAll();
|
IQueryable<T> GetAll();
|
||||||
Task<T> FirstOrDefaultAsync(Expression<Func<T, bool>> predicate);
|
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<T> Add(T content);
|
||||||
Task DeleteRange(IEnumerable<T> req);
|
Task DeleteRange(IEnumerable<T> req);
|
||||||
Task Delete(T request);
|
Task Delete(T request);
|
||||||
|
|
|
@ -35,10 +35,13 @@ namespace Ombi.Store.Repository
|
||||||
return await _db.FirstOrDefaultAsync(predicate);
|
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);
|
_db.AddRange(content);
|
||||||
await _ctx.SaveChangesAsync();
|
if (save)
|
||||||
|
{
|
||||||
|
await _ctx.SaveChangesAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<T> Add(T content)
|
public async Task<T> Add(T content)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue