jellyfin and emby collection sync (#752)
* sync jellyfin and emby collections * update changelog
This commit is contained in:
@@ -61,6 +61,9 @@ public class EmbyService : BackgroundService
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException($"Unsupported request type: {request.GetType().Name}");
|
||||
case SynchronizeEmbyCollections synchronizeEmbyCollections:
|
||||
requestTask = SynchronizeEmbyCollections(synchronizeEmbyCollections, cancellationToken);
|
||||
break;
|
||||
}
|
||||
|
||||
await requestTask;
|
||||
@@ -165,4 +168,20 @@ public class EmbyService : BackgroundService
|
||||
request.EmbyLibraryId,
|
||||
error.Value));
|
||||
}
|
||||
|
||||
private async Task SynchronizeEmbyCollections(
|
||||
SynchronizeEmbyCollections 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.LogDebug("Done synchronizing emby collections"),
|
||||
error => _logger.LogWarning(
|
||||
"Unable to synchronize emby collections for source {MediaSourceId}: {Error}",
|
||||
request.EmbyMediaSourceId,
|
||||
error.Value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,11 @@ public class JellyfinService : BackgroundService
|
||||
case ISynchronizeJellyfinLibraryById synchronizeJellyfinLibraryById:
|
||||
requestTask = SynchronizeJellyfinLibrary(synchronizeJellyfinLibraryById, cancellationToken);
|
||||
break;
|
||||
case SynchronizeJellyfinCollections synchronizeJellyfinCollections:
|
||||
requestTask = SynchronizeJellyfinCollections(
|
||||
synchronizeJellyfinCollections,
|
||||
cancellationToken);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException($"Unsupported request type: {request.GetType().Name}");
|
||||
}
|
||||
@@ -165,4 +170,20 @@ public class JellyfinService : BackgroundService
|
||||
request.JellyfinLibraryId,
|
||||
error.Value));
|
||||
}
|
||||
|
||||
private async Task SynchronizeJellyfinCollections(
|
||||
SynchronizeJellyfinCollections 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.LogDebug("Done synchronizing jellyfin collections"),
|
||||
error => _logger.LogWarning(
|
||||
"Unable to synchronize jellyfin collections for source {MediaSourceId}: {Error}",
|
||||
request.JellyfinMediaSourceId,
|
||||
error.Value));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user