plex collection rework (#1503)
* start to rework plex collection scanning * sync plex collections to db * sync plex collection items * update changelog
This commit is contained in:
@@ -70,6 +70,10 @@ public class Worker : BackgroundService
|
||||
scanPlexCommand.AddOption(forceOption);
|
||||
scanPlexCommand.AddOption(deepOption);
|
||||
|
||||
var scanPlexCollectionsCommand = new Command("scan-plex-collections", "Scan Plex collections");
|
||||
scanPlexCollectionsCommand.AddArgument(mediaSourceIdArgument);
|
||||
scanPlexCollectionsCommand.AddOption(forceOption);
|
||||
|
||||
var scanEmbyCommand = new Command("scan-emby", "Scan an Emby library");
|
||||
scanEmbyCommand.AddArgument(libraryIdArgument);
|
||||
scanEmbyCommand.AddOption(forceOption);
|
||||
@@ -124,6 +128,24 @@ public class Worker : BackgroundService
|
||||
await mediator.Send(scan, context.GetCancellationToken());
|
||||
}
|
||||
});
|
||||
|
||||
scanPlexCollectionsCommand.SetHandler(
|
||||
async context =>
|
||||
{
|
||||
if (IsScanningEnabled())
|
||||
{
|
||||
bool force = context.ParseResult.GetValueForOption(forceOption);
|
||||
SetProcessPriority(force);
|
||||
|
||||
int mediaSourceId = context.ParseResult.GetValueForArgument(mediaSourceIdArgument);
|
||||
|
||||
using IServiceScope scope = _serviceScopeFactory.CreateScope();
|
||||
IMediator mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
|
||||
|
||||
var scan = new SynchronizePlexCollections(mediaSourceId, force);
|
||||
await mediator.Send(scan, context.GetCancellationToken());
|
||||
}
|
||||
});
|
||||
|
||||
scanEmbyCommand.SetHandler(
|
||||
async context =>
|
||||
@@ -202,6 +224,7 @@ public class Worker : BackgroundService
|
||||
var rootCommand = new RootCommand();
|
||||
rootCommand.AddCommand(scanLocalCommand);
|
||||
rootCommand.AddCommand(scanPlexCommand);
|
||||
rootCommand.AddCommand(scanPlexCollectionsCommand);
|
||||
rootCommand.AddCommand(scanEmbyCommand);
|
||||
rootCommand.AddCommand(scanEmbyCollectionsCommand);
|
||||
rootCommand.AddCommand(scanJellyfinCommand);
|
||||
|
||||
Reference in New Issue
Block a user