private async Task <bool> ProcessPoster(IPosterImageOwner imageOwner) { if (string.IsNullOrEmpty(imageOwner.PosterPath) || !string.IsNullOrEmpty(imageOwner.PosterBlurHash)) { return(false); } var tempFile = _tempFileService.GetFilename("download", ".jpg"); var downloaded = await _detailsApi.DownloadImage(342, imageOwner.PosterPath, tempFile); if (!downloaded) { return(false); } await _dispatcher.Dispatch(new SetImageCommand <IPosterImageOwner>(imageOwner, tempFile, $"{Guid.NewGuid()}.jpg")); return(true); }
private async Task <string> SaveTempImage(string imageExtension, Stream imageStream, CancellationToken cancellationToken) { var tempFile = _tempFileService.GetFilename("image_upload", imageExtension); await using var outputStream = File.OpenWrite(tempFile); await imageStream.CopyToAsync(outputStream, cancellationToken); return(tempFile); }
public async Task <string> Handle(CreateSnapshotCommand @event, CancellationToken cancellationToken = default) { var tempFile = _tempFileService.GetFilename("generated", ".png"); var analysis = await FFProbe.AnalyseAsync(@event.InputVideoFilePath); await FFMpeg.SnapshotAsync(@event.InputVideoFilePath, tempFile, new Size(@event.Width, @event.Height), analysis !.Duration * @event.SeekPercentage); return(tempFile); }