public static async Task <Guid> ComputeSubtitle(string text) { FileContainer fileContainer = FileContainer.NewSubtitleContainer(); string outputfilePath = Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".vtt"); if (!IsValidVTT(text)) { return(fileContainer.ProgressToken); } try { await System.IO.File.WriteAllTextAsync(outputfilePath, text); fileContainer.SubtitleFileItem.SetOutputFilePath(outputfilePath); IpfsDaemon.Instance.Queue(fileContainer.SubtitleFileItem); } catch (Exception ex) { TempFileManager.SafeDeleteTempFile(outputfilePath); LogManager.AddSubtitleMessage(ex.ToString(), "Exception"); return(fileContainer.ProgressToken); } return(fileContainer.ProgressToken); }
public static async Task <Guid> ComputeSubtitle(string text) { FileContainer fileContainer = FileContainer.NewSubtitleContainer(); if (!IsValidVTT(text)) { fileContainer.SubtitleFileItem.IpfsProcess.SetErrorMessage("Not a valid WEBVTT file", "Not a valid WEBVTT file"); return(fileContainer.ProgressToken); } try { await File.WriteAllTextAsync(fileContainer.SubtitleFileItem.TempFilePath, text); fileContainer.SubtitleFileItem.ReplaceOutputPathWithTempPath(); IpfsDaemon.Instance.Queue(fileContainer.SubtitleFileItem); } catch (Exception ex) { LogManager.AddSubtitleMessage(LogLevel.Critical, "Exception non gérée", "Exception", ex); fileContainer.CancelAll("Exception non gérée"); fileContainer.CleanFilesIfEnd(); return(fileContainer.ProgressToken); } return(fileContainer.ProgressToken); }
public static async Task <Guid> ComputeSubtitle(string text) { FileContainer fileContainer = FileContainer.NewSubtitleContainer(); string outputfilePath = Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".vtt"); if (!IsValidVTT(text)) { fileContainer.SubtitleFileItem.IpfsProcess.SetErrorMessage("Not a valid WEBVTT file", "Not a valid WEBVTT file"); return(fileContainer.ProgressToken); } try { await File.WriteAllTextAsync(outputfilePath, text); fileContainer.SubtitleFileItem.SetOutputFilePath(outputfilePath); IpfsDaemon.Instance.Queue(fileContainer.SubtitleFileItem); } catch (Exception ex) { TempFileManager.SafeDeleteTempFile(outputfilePath); LogManager.AddSubtitleMessage(LogLevel.Critical, "Exception non gérée", "Exception", ex); return(fileContainer.ProgressToken); } return(fileContainer.ProgressToken); }