Browse Source

fix emby scanning (#1201)

pull/1203/head
Jason Dove 3 years ago committed by GitHub
parent
commit
4c67965b50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      ErsatzTV/Services/EmbyService.cs
  2. 19
      ErsatzTV/Services/ScannerService.cs

19
ErsatzTV/Services/EmbyService.cs

@ -50,9 +50,6 @@ public class EmbyService : BackgroundService
case SynchronizeEmbyMediaSources synchronizeEmbyMediaSources: case SynchronizeEmbyMediaSources synchronizeEmbyMediaSources:
requestTask = SynchronizeSources(synchronizeEmbyMediaSources, cancellationToken); requestTask = SynchronizeSources(synchronizeEmbyMediaSources, cancellationToken);
break; break;
case SynchronizeEmbyLibraries synchronizeEmbyLibraries:
requestTask = SynchronizeLibraries(synchronizeEmbyLibraries, cancellationToken);
break;
default: default:
throw new NotSupportedException($"Unsupported request type: {request.GetType().Name}"); throw new NotSupportedException($"Unsupported request type: {request.GetType().Name}");
} }
@ -105,20 +102,4 @@ public class EmbyService : BackgroundService
error.Value); error.Value);
}); });
} }
private async Task SynchronizeLibraries(SynchronizeEmbyLibraries request, CancellationToken cancellationToken)
{
using IServiceScope scope = _serviceScopeFactory.CreateScope();
IMediator mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
Either<BaseError, Unit> result = await mediator.Send(request, cancellationToken);
result.BiIter(
_ => _logger.LogInformation(
"Successfully synchronized Emby libraries for source {MediaSourceId}",
request.EmbyMediaSourceId),
error => _logger.LogWarning(
"Unable to synchronize Emby libraries for source {MediaSourceId}: {Error}",
request.EmbyMediaSourceId,
error.Value));
}
} }

19
ErsatzTV/Services/ScannerService.cs

@ -53,6 +53,9 @@ public class ScannerService : BackgroundService
case ISynchronizeJellyfinLibraryById synchronizeJellyfinLibraryById: case ISynchronizeJellyfinLibraryById synchronizeJellyfinLibraryById:
requestTask = SynchronizeJellyfinLibrary(synchronizeJellyfinLibraryById, cancellationToken); requestTask = SynchronizeJellyfinLibrary(synchronizeJellyfinLibraryById, cancellationToken);
break; break;
case SynchronizeEmbyLibraries synchronizeEmbyLibraries:
requestTask = SynchronizeLibraries(synchronizeEmbyLibraries, cancellationToken);
break;
case ISynchronizeEmbyLibraryById synchronizeEmbyLibraryById: case ISynchronizeEmbyLibraryById synchronizeEmbyLibraryById:
requestTask = SynchronizeEmbyLibrary(synchronizeEmbyLibraryById, cancellationToken); requestTask = SynchronizeEmbyLibrary(synchronizeEmbyLibraryById, cancellationToken);
break; break;
@ -224,6 +227,22 @@ public class ScannerService : BackgroundService
} }
} }
private async Task SynchronizeLibraries(SynchronizeEmbyLibraries request, CancellationToken cancellationToken)
{
using IServiceScope scope = _serviceScopeFactory.CreateScope();
IMediator mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
Either<BaseError, Unit> result = await mediator.Send(request, cancellationToken);
result.BiIter(
_ => _logger.LogInformation(
"Successfully synchronized Emby libraries for source {MediaSourceId}",
request.EmbyMediaSourceId),
error => _logger.LogWarning(
"Unable to synchronize Emby libraries for source {MediaSourceId}: {Error}",
request.EmbyMediaSourceId,
error.Value));
}
private async Task SynchronizeEmbyLibrary(ISynchronizeEmbyLibraryById request, CancellationToken cancellationToken) private async Task SynchronizeEmbyLibrary(ISynchronizeEmbyLibraryById request, CancellationToken cancellationToken)
{ {
using IServiceScope scope = _serviceScopeFactory.CreateScope(); using IServiceScope scope = _serviceScopeFactory.CreateScope();

Loading…
Cancel
Save