Beispiel #1
0
        public static ISubtitle GetSubtitleFromFile(string fileName)
        {
            var subtitleCreator = new SubtitleCreator();

            var subtitlePath   = SubtitleFolderPath + fileName;
            var subtitleStream = File.OpenRead(subtitlePath);
            var subtitle       = subtitleCreator.CreateFromFile(subtitleStream);

            return(subtitle);
        }
Beispiel #2
0
        public void PerformAction()
        {
            var subtitleCreator = new SubtitleCreator();
            var subtitle        = subtitleCreator.CreateFromFile(File.OpenRead(_sourceFile));

            if (_timeOffset != 0)
            {
                Console.WriteLine("Offsetting your subtitle by " + _timeOffset + " seconds");

                var timeOffsetAction = new SubtitleTimeOffsetAction(TimeSpan.FromSeconds(_timeOffset), subtitle);
                timeOffsetAction.PerformAction();
            }

            if (!string.IsNullOrEmpty(_language))
            {
                var culture          = new CultureInfo(_language);
                var translatorAction = new SubtitleTranslatorAction(subtitle, culture);

                var reset = new ManualResetEvent(false);

                Console.WriteLine("Translating your subtitle to " + culture.EnglishName);
                Console.WriteLine("Please wait...");

                translatorAction.PerformAction(
                    () =>
                {
                    SaveSubtitleToOutput(subtitle, _destination);
                    reset.Set();
                });

                reset.WaitOne();
            }
            else
            {
                SaveSubtitleToOutput(subtitle, _destination);
            }
        }