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 @@ -50,9 +50,6 @@ public class EmbyService : BackgroundService
case SynchronizeEmbyMediaSources synchronizeEmbyMediaSources:
requestTask = SynchronizeSources(synchronizeEmbyMediaSources, cancellationToken);
break;
case SynchronizeEmbyLibraries synchronizeEmbyLibraries:
requestTask = SynchronizeLibraries(synchronizeEmbyLibraries, cancellationToken);
break;
default:
throw new NotSupportedException($"Unsupported request type: {request.GetType().Name}");
}
@ -105,20 +102,4 @@ public class EmbyService : BackgroundService @@ -105,20 +102,4 @@ public class EmbyService : BackgroundService
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 @@ -53,6 +53,9 @@ public class ScannerService : BackgroundService
case ISynchronizeJellyfinLibraryById synchronizeJellyfinLibraryById:
requestTask = SynchronizeJellyfinLibrary(synchronizeJellyfinLibraryById, cancellationToken);
break;
case SynchronizeEmbyLibraries synchronizeEmbyLibraries:
requestTask = SynchronizeLibraries(synchronizeEmbyLibraries, cancellationToken);
break;
case ISynchronizeEmbyLibraryById synchronizeEmbyLibraryById:
requestTask = SynchronizeEmbyLibrary(synchronizeEmbyLibraryById, cancellationToken);
break;
@ -224,6 +227,22 @@ public class ScannerService : BackgroundService @@ -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)
{
using IServiceScope scope = _serviceScopeFactory.CreateScope();

Loading…
Cancel
Save