mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-14 09:12:57 -07:00
Fixed ##1492 and finished the episode searcher for #1464
This commit is contained in:
parent
d7f0f61ece
commit
9ed6fd09a4
5 changed files with 38 additions and 37 deletions
|
@ -5,6 +5,7 @@ namespace Ombi.Api.Plex.Models
|
||||||
public class Mediacontainer
|
public class Mediacontainer
|
||||||
{
|
{
|
||||||
public int size { get; set; }
|
public int size { get; set; }
|
||||||
|
public int totalSize { get; set; }
|
||||||
public bool allowSync { get; set; }
|
public bool allowSync { get; set; }
|
||||||
public string identifier { get; set; }
|
public string identifier { get; set; }
|
||||||
public string mediaTagPrefix { get; set; }
|
public string mediaTagPrefix { get; set; }
|
||||||
|
|
|
@ -90,17 +90,17 @@ namespace Ombi.DependencyInjection
|
||||||
services.AddEntityFrameworkSqlite().AddDbContext<OmbiContext>();
|
services.AddEntityFrameworkSqlite().AddDbContext<OmbiContext>();
|
||||||
|
|
||||||
services.AddScoped<IOmbiContext, OmbiContext>();
|
services.AddScoped<IOmbiContext, OmbiContext>();
|
||||||
services.AddTransient<ISettingsRepository, SettingsJsonRepository>();
|
services.AddScoped<ISettingsRepository, SettingsJsonRepository>();
|
||||||
services.AddTransient<ISettingsResolver, SettingsResolver>();
|
services.AddScoped<ISettingsResolver, SettingsResolver>();
|
||||||
services.AddTransient<IPlexContentRepository, PlexContentRepository>();
|
services.AddScoped<IPlexContentRepository, PlexContentRepository>();
|
||||||
services.AddTransient<INotificationTemplatesRepository, NotificationTemplatesRepository>();
|
services.AddScoped<INotificationTemplatesRepository, NotificationTemplatesRepository>();
|
||||||
|
|
||||||
services.AddTransient<ITvRequestRepository, TvRequestRepository>();
|
services.AddScoped<ITvRequestRepository, TvRequestRepository>();
|
||||||
services.AddTransient<IMovieRequestRepository, MovieRequestRepository>();
|
services.AddScoped<IMovieRequestRepository, MovieRequestRepository>();
|
||||||
services.AddTransient<IAuditRepository, AuditRepository>();
|
services.AddScoped<IAuditRepository, AuditRepository>();
|
||||||
services.AddTransient<IApplicationConfigRepository, ApplicationConfigRepository>();
|
services.AddScoped<IApplicationConfigRepository, ApplicationConfigRepository>();
|
||||||
services.AddTransient<ITokenRepository, TokenRepository>();
|
services.AddScoped<ITokenRepository, TokenRepository>();
|
||||||
services.AddTransient(typeof(ISettingsService<>), typeof(SettingsService<>));
|
services.AddScoped(typeof(ISettingsService<>), typeof(SettingsService<>));
|
||||||
}
|
}
|
||||||
public static void RegisterServices(this IServiceCollection services)
|
public static void RegisterServices(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
|
|
@ -83,10 +83,10 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the episodes
|
|
||||||
await GetEpisodes(settings, section);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the episodes
|
||||||
|
await GetEpisodes(settings, section);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -99,17 +99,17 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
var ResultCount = 50;
|
var ResultCount = 50;
|
||||||
var episodes = await _api.GetAllEpisodes(settings.PlexAuthToken, settings.FullUri, section.key, currentPosition, ResultCount);
|
var episodes = await _api.GetAllEpisodes(settings.PlexAuthToken, settings.FullUri, section.key, currentPosition, ResultCount);
|
||||||
|
|
||||||
_log.LogInformation(LoggingEvents.PlexEpisodeCacher, $"Total Epsiodes found for {episodes.MediaContainer.librarySectionTitle} = {episodes.MediaContainer.size}");
|
_log.LogInformation(LoggingEvents.PlexEpisodeCacher, $"Total Epsiodes found for {episodes.MediaContainer.librarySectionTitle} = {episodes.MediaContainer.totalSize}");
|
||||||
|
|
||||||
await ProcessEpsiodes(episodes);
|
await ProcessEpsiodes(episodes);
|
||||||
currentPosition += ResultCount;
|
currentPosition += ResultCount;
|
||||||
|
|
||||||
while (currentPosition < episodes.MediaContainer.size)
|
while (currentPosition < episodes.MediaContainer.totalSize)
|
||||||
{
|
{
|
||||||
var ep = await _api.GetAllEpisodes(settings.PlexAuthToken, settings.FullUri, section.key, currentPosition,
|
var ep = await _api.GetAllEpisodes(settings.PlexAuthToken, settings.FullUri, section.key, currentPosition,
|
||||||
ResultCount);
|
ResultCount);
|
||||||
await ProcessEpsiodes(ep);
|
await ProcessEpsiodes(ep);
|
||||||
_log.LogInformation(LoggingEvents.PlexEpisodeCacher, $"Processed {ResultCount} more episodes. Total Remaining {currentPosition - episodes.MediaContainer.size}");
|
_log.LogInformation(LoggingEvents.PlexEpisodeCacher, $"Processed {ResultCount} more episodes. Total Remaining {currentPosition - episodes.MediaContainer.totalSize}");
|
||||||
currentPosition += ResultCount;
|
currentPosition += ResultCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,9 +128,9 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
{
|
{
|
||||||
EpisodeNumber = episode.index,
|
EpisodeNumber = episode.index,
|
||||||
SeasonNumber = episode.parentIndex,
|
SeasonNumber = episode.parentIndex,
|
||||||
GrandparentKey = episode.grandparentKey,
|
GrandparentKey = episode.grandparentRatingKey,
|
||||||
ParentKey = episode.parentKey,
|
ParentKey = episode.parentRatingKey,
|
||||||
Key = episode.key,
|
Key = episode.ratingKey,
|
||||||
Title = episode.title
|
Title = episode.title
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,11 @@ namespace Ombi.Settings.Settings
|
||||||
return new T();
|
return new T();
|
||||||
}
|
}
|
||||||
result.Content = DecryptSettings(result);
|
result.Content = DecryptSettings(result);
|
||||||
return string.IsNullOrEmpty(result.Content) ? null : JsonConvert.DeserializeObject<T>(result.Content, SerializerSettings.Settings);
|
var obj = string.IsNullOrEmpty(result.Content) ? null : JsonConvert.DeserializeObject<T>(result.Content, SerializerSettings.Settings);
|
||||||
|
|
||||||
|
var model = obj;
|
||||||
|
|
||||||
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SaveSettings(T model)
|
public bool SaveSettings(T model)
|
||||||
|
@ -67,10 +71,10 @@ namespace Ombi.Settings.Settings
|
||||||
|
|
||||||
var modified = model;
|
var modified = model;
|
||||||
modified.Id = entity.Id;
|
modified.Id = entity.Id;
|
||||||
|
entity.Content = JsonConvert.SerializeObject(modified, SerializerSettings.Settings);
|
||||||
|
|
||||||
var globalSettings = new GlobalSettings { SettingsName = EntityName, Content = JsonConvert.SerializeObject(modified, SerializerSettings.Settings), Id = entity.Id };
|
entity.Content = EncryptSettings(entity);
|
||||||
globalSettings.Content = EncryptSettings(globalSettings);
|
Repo.Update(entity);
|
||||||
Repo.Update(globalSettings);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +89,7 @@ namespace Ombi.Settings.Settings
|
||||||
|
|
||||||
var settings = new GlobalSettings { SettingsName = EntityName, Content = JsonConvert.SerializeObject(newEntity, SerializerSettings.Settings) };
|
var settings = new GlobalSettings { SettingsName = EntityName, Content = JsonConvert.SerializeObject(newEntity, SerializerSettings.Settings) };
|
||||||
settings.Content = EncryptSettings(settings);
|
settings.Content = EncryptSettings(settings);
|
||||||
var insertResult = await Repo.InsertAsync(settings).ConfigureAwait(false);
|
var insertResult = await Repo.InsertAsync(settings);
|
||||||
|
|
||||||
return insertResult != null;
|
return insertResult != null;
|
||||||
}
|
}
|
||||||
|
@ -93,9 +97,10 @@ namespace Ombi.Settings.Settings
|
||||||
var modified = model;
|
var modified = model;
|
||||||
modified.Id = entity.Id;
|
modified.Id = entity.Id;
|
||||||
|
|
||||||
var globalSettings = new GlobalSettings { SettingsName = EntityName, Content = JsonConvert.SerializeObject(modified, SerializerSettings.Settings), Id = entity.Id };
|
entity.Content = JsonConvert.SerializeObject(modified, SerializerSettings.Settings);
|
||||||
globalSettings.Content = EncryptSettings(globalSettings);
|
|
||||||
await Repo.UpdateAsync(globalSettings).ConfigureAwait(false);
|
entity.Content = EncryptSettings(entity);
|
||||||
|
await Repo.UpdateAsync(entity);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,33 +37,27 @@ namespace Ombi.Store.Repository
|
||||||
public IEnumerable<GlobalSettings> GetAll()
|
public IEnumerable<GlobalSettings> GetAll()
|
||||||
{
|
{
|
||||||
|
|
||||||
var page = Db.Settings.ToList();
|
var page = Db.Settings.AsNoTracking().ToList();
|
||||||
return page;
|
return page;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<GlobalSettings>> GetAllAsync()
|
public async Task<IEnumerable<GlobalSettings>> GetAllAsync()
|
||||||
{
|
{
|
||||||
var page = await Db.Settings.ToListAsync();
|
var page = await Db.Settings.AsNoTracking().ToListAsync();
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlobalSettings Get(string pageName)
|
public GlobalSettings Get(string pageName)
|
||||||
{
|
{
|
||||||
var entity = Db.Settings.FirstOrDefault(x => x.SettingsName == pageName);
|
var entity = Db.Settings.AsNoTracking().FirstOrDefault(x => x.SettingsName == pageName);
|
||||||
if (entity == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException($"The setting {pageName} does not exist");
|
|
||||||
}
|
|
||||||
Db.Entry(entity).Reload();
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<GlobalSettings> GetAsync(string settingsName)
|
public async Task<GlobalSettings> GetAsync(string settingsName)
|
||||||
{
|
{
|
||||||
|
|
||||||
var obj = await Db.Settings.FirstOrDefaultAsync(x => x.SettingsName == settingsName);
|
var obj = await Db.Settings.AsNoTracking().FirstOrDefaultAsync(x => x.SettingsName == settingsName);
|
||||||
if (obj != null) Db.Entry(obj).Reload();
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +69,7 @@ namespace Ombi.Store.Repository
|
||||||
|
|
||||||
public async Task UpdateAsync(GlobalSettings entity)
|
public async Task UpdateAsync(GlobalSettings entity)
|
||||||
{
|
{
|
||||||
|
Db.Update(entity);
|
||||||
await Db.SaveChangesAsync();
|
await Db.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue