diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexEpisodeCacher.cs b/src/Ombi.Schedule/Jobs/Plex/PlexEpisodeCacher.cs index 74628f2e4..a7570e2d5 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexEpisodeCacher.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexEpisodeCacher.cs @@ -3,17 +3,14 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Hangfire; -using Hangfire.Common; using Microsoft.Extensions.Logging; using Ombi.Api.Plex; using Ombi.Api.Plex.Models; -using Ombi.Api.Plex.Models.Server; using Ombi.Core.Settings; using Ombi.Core.Settings.Models.External; using Ombi.Helpers; using Ombi.Store.Entities; using Ombi.Store.Repository; -using Serilog; namespace Ombi.Schedule.Jobs.Plex { @@ -98,26 +95,26 @@ namespace Ombi.Schedule.Jobs.Plex private async Task GetEpisodes(PlexServers settings, Directory section) { - - // Get the first 50 var currentPosition = 0; - var ResultCount = 50; - var episodes = await _api.GetAllEpisodes(settings.PlexAuthToken, settings.FullUri, section.key, currentPosition, ResultCount); + var resultCount = settings.EpisodeBatchSize == 0 ? 50 : settings.EpisodeBatchSize; + var episodes = await _api.GetAllEpisodes(settings.PlexAuthToken, settings.FullUri, section.key, currentPosition, resultCount); var currentData = _repo.GetAllEpisodes(); _log.LogInformation(LoggingEvents.PlexEpisodeCacher, $"Total Epsiodes found for {episodes.MediaContainer.librarySectionTitle} = {episodes.MediaContainer.totalSize}"); await ProcessEpsiodes(episodes, currentData); - currentPosition += ResultCount; + currentPosition += resultCount; while (currentPosition < episodes.MediaContainer.totalSize) { var ep = await _api.GetAllEpisodes(settings.PlexAuthToken, settings.FullUri, section.key, currentPosition, - ResultCount); + resultCount); await ProcessEpsiodes(ep, currentData); - _log.LogInformation(LoggingEvents.PlexEpisodeCacher, $"Processed {ResultCount} more episodes. Total Remaining {currentPosition - episodes.MediaContainer.totalSize}"); - currentPosition += ResultCount; + _log.LogInformation(LoggingEvents.PlexEpisodeCacher, $"Processed {resultCount} more episodes. Total Remaining {episodes.MediaContainer.totalSize - currentPosition}"); + currentPosition += resultCount; } + // we have now finished. + await _repo.SaveChangesAsync(); } private async Task ProcessEpsiodes(PlexContainer episodes, IQueryable currentEpisodes) diff --git a/src/Ombi.Settings/Settings/Models/External/PlexSettings.cs b/src/Ombi.Settings/Settings/Models/External/PlexSettings.cs index 79a70c2f6..e708b694a 100644 --- a/src/Ombi.Settings/Settings/Models/External/PlexSettings.cs +++ b/src/Ombi.Settings/Settings/Models/External/PlexSettings.cs @@ -18,6 +18,8 @@ namespace Ombi.Core.Settings.Models.External public string PlexAuthToken { get; set; } public string MachineIdentifier { get; set; } + public int EpisodeBatchSize { get; set; } + public List PlexSelectedLibraries { get; set; } = new List(); } public class PlexSelectedLibraries diff --git a/src/Ombi.Store/Repository/IRepository.cs b/src/Ombi.Store/Repository/IRepository.cs index db5f3fc15..17b9d5d17 100644 --- a/src/Ombi.Store/Repository/IRepository.cs +++ b/src/Ombi.Store/Repository/IRepository.cs @@ -16,6 +16,7 @@ namespace Ombi.Store.Repository Task AddRange(IEnumerable content); Task DeleteRange(IEnumerable req); Task Delete(T request); + Task SaveChangesAsync(); IIncludableQueryable Include( IQueryable source, Expression> navigationPropertyPath) diff --git a/src/Ombi.Store/Repository/Repository.cs b/src/Ombi.Store/Repository/Repository.cs index 4900430f1..90861e36b 100644 --- a/src/Ombi.Store/Repository/Repository.cs +++ b/src/Ombi.Store/Repository/Repository.cs @@ -60,6 +60,11 @@ namespace Ombi.Store.Repository await _ctx.SaveChangesAsync(); } + public async Task SaveChangesAsync() + { + return await _ctx.SaveChangesAsync(); + } + public IIncludableQueryable Include( IQueryable source, Expression> navigationPropertyPath) where TEntity : class diff --git a/src/Ombi/.vscode/launch.json b/src/Ombi/.vscode/launch.json new file mode 100644 index 000000000..fc2680094 --- /dev/null +++ b/src/Ombi/.vscode/launch.json @@ -0,0 +1,46 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceRoot}/bin/Debug/netcoreapp2.0/Ombi.dll", + "args": [], + "cwd": "${workspaceRoot}", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart", + "launchBrowser": { + "enabled": true, + "args": "${auto-detect-url}", + "windows": { + "command": "cmd.exe", + "args": "/C start ${auto-detect-url}" + }, + "osx": { + "command": "open" + }, + "linux": { + "command": "xdg-open" + } + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceRoot}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/src/Ombi/.vscode/tasks.json b/src/Ombi/.vscode/tasks.json new file mode 100644 index 000000000..80a8042dc --- /dev/null +++ b/src/Ombi/.vscode/tasks.json @@ -0,0 +1,16 @@ +{ + "version": "0.1.0", + "command": "dotnet", + "isShellCommand": true, + "args": [], + "tasks": [ + { + "taskName": "build", + "args": [ + "${workspaceRoot}/Ombi.csproj" + ], + "isBuildCommand": true, + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/src/Ombi/ClientApp/app/interfaces/IPlex.ts b/src/Ombi/ClientApp/app/interfaces/IPlex.ts index d8ce4ed06..7125ae4bc 100644 --- a/src/Ombi/ClientApp/app/interfaces/IPlex.ts +++ b/src/Ombi/ClientApp/app/interfaces/IPlex.ts @@ -32,7 +32,14 @@ export interface IDirectory { export interface IPlexServerViewModel { success: boolean; message: string; - servers: IPlexServerResponse; + servers: IPlexServerResult; +} + +export interface IPlexServerResult { + friendlyName: string; + machineIdentifier: string; + identifier: string; + server: IPlexServerResponse[]; } export interface IPlexServerResponse { diff --git a/src/Ombi/ClientApp/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/app/interfaces/ISettings.ts index 3710eb229..fd13a4290 100644 --- a/src/Ombi/ClientApp/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/ISettings.ts @@ -45,6 +45,7 @@ export interface IPlexServer extends IExternalSettings { enableEpisodeSearching: boolean; plexAuthToken: string; machineIdentifier: string; + episodeBatchSize: number; plexSelectedLibraries: IPlexLibrariesSettings[]; } diff --git a/src/Ombi/ClientApp/app/settings/plex/plex.component.html b/src/Ombi/ClientApp/app/settings/plex/plex.component.html index 3dd8ac7d7..e90948635 100644 --- a/src/Ombi/ClientApp/app/settings/plex/plex.component.html +++ b/src/Ombi/ClientApp/app/settings/plex/plex.component.html @@ -1,4 +1,10 @@  +
+
+ Advanced + +
+
Plex Configuration @@ -34,21 +40,24 @@
- +
- +
- +
@@ -59,33 +68,24 @@
-
- +
- +
- +
@@ -100,16 +100,20 @@
- +


-
+ +
- @@ -128,7 +132,9 @@ Note: if nothing is selected, we will monitor all libraries
- +
@@ -142,6 +148,14 @@
+
+ +
+ +
+
+
-
-
- +
+
+ +
-
\ No newline at end of file diff --git a/src/Ombi/ClientApp/app/settings/plex/plex.component.ts b/src/Ombi/ClientApp/app/settings/plex/plex.component.ts index 19b9417d1..761a07a12 100644 --- a/src/Ombi/ClientApp/app/settings/plex/plex.component.ts +++ b/src/Ombi/ClientApp/app/settings/plex/plex.component.ts @@ -22,6 +22,8 @@ export class PlexComponent implements OnInit, OnDestroy { private subscriptions = new Subject(); + public advanced = false; + constructor(private settingsService: SettingsService, private notificationService: NotificationService, private plexService: PlexService, @@ -38,6 +40,7 @@ export class PlexComponent implements OnInit, OnDestroy { .takeUntil(this.subscriptions) .subscribe(x => { if (x.success) { + debugger; this.loadedServers = x; this.serversButton = true; this.notificationService.success("Loaded", "Found the servers! Please select one!");