private async Task _process(Guid entryId, string audioUrl, bool forceReprocess = false) { var audioExists = !string.IsNullOrEmpty(audioUrl) && await _fileUtils.CheckFileExists(audioUrl.Split('/')[0], audioUrl.Split('/')[1]); if (!audioExists || forceReprocess) { //TODO: This is all largely a duplicate of ProcessEntryJob, should call into that... Log($"_process: Missing audio for: {entryId}"); var localFile = Path.Combine(Path.GetTempPath(), $"{System.Guid.NewGuid()}.mp3"); var processed = await _processor.DownloadAudio(entryId, localFile); if (processed) { Log($"_process: Processed: {entryId}"); Log($"_process: Uploading audio for: {entryId}"); var uploaded = await _uploadService.UploadAudio(entryId, localFile); if (!uploaded) { LogError($"Error uploading audio from {entryId}"); } Log($"_process: Generating waveform for: {entryId}"); var(dat, json, png) = await _waveFormGenerator.GenerateWaveformLocalFile(localFile); if (!File.Exists(json)) { LogError($"_process: Error json does not exist {json}"); } else { Log($"_process: Uploading waveform for: {entryId}"); var result = await _fileUploader.UploadFile( json, _waveformStorageSettings.ContainerName, $"{entryId}.json", "application/x-binary", null); Log($"_process: Uploaded waveform for: {entryId}\n\tResult: {result}"); } Log($"_process: Completed processing of: {entryId}"); } else { LogError($"_process: Unable to process podcast entry: {entryId}"); } } else { Log($"_process: Audio exists, not processing"); } }
public async Task <bool> Execute(Guid entryId, string cacheFile, PerformContext context) { _setContext(context); Log($"Starting Upload Job for {entryId} - {cacheFile}"); if (File.Exists(cacheFile)) { return(await _uploadProcessService.UploadAudio(entryId, cacheFile)); } else { context.WriteLine($"Failed to cache remote file {cacheFile}"); return(false); } }