jellyfin and emby collection sync (#752)

* sync jellyfin and emby collections

* update changelog
This commit is contained in:
Jason Dove
2022-04-22 13:33:35 -05:00
committed by GitHub
parent e91ec98007
commit d67251bfa0
49 changed files with 9538 additions and 68 deletions
+19
View File
@@ -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));
}
}
+21
View File
@@ -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));
}
}