Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }