Exemple #1
0
        public void transposeBy_one_minute()
        {
            sut.TransposeBy(TimeSpan.FromMinutes(1));

            Assert.That(sut.Subtitles[0].Begin, Is.EqualTo(new TimeSpan(0, 1, 30)));
            Assert.That(sut.Subtitles[1].Begin, Is.EqualTo(new TimeSpan(0, 2, 42)));
            Assert.That(sut.Subtitles[2].Begin, Is.EqualTo(new TimeSpan(0, 2, 53)));
            Assert.That(sut.Subtitles[3].Begin, Is.EqualTo(new TimeSpan(0, 3, 19)));
            Assert.That(sut.Subtitles[4].Begin, Is.EqualTo(new TimeSpan(0, 4, 55)));
            Assert.That(sut.Subtitles[5].Begin, Is.EqualTo(new TimeSpan(0, 6, 3)));
        }
Exemple #2
0
        static void Main(string[] args)
        {
            try
            {
                var options = new SubbedOptionParser(args);
                if (options.ActionVerb == Verbs.Help)
                {
                    options.WriteHelp();
                    return;
                }

                var                     parserFactory = new SubtitleParserFactory();
                ISubtitleParser         reader        = parserFactory.GetReaderFor(options.InputFile);
                IEnumerable <ISubtitle> subs          = reader.Read(options.InputFile);

                var subManager = new SubtitleManager(subs);

                switch (options.ActionVerb)
                {
                case Verbs.Extrapolate:
                    ISubtitle targetSub = subs.FirstOrDefault(options.SubtitleSelector);
                    subManager.Extrapolate(targetSub, options.TimeDiff);
                    break;

                case Verbs.StretchBy:
                    subManager.StretchBy(options.Factor);
                    break;

                case Verbs.TransposeBy:
                    subManager.TransposeBy(options.TimeDiff);
                    break;
                }

                subs = subManager.Subtitles;

                ISubtitleParser writer = parserFactory.GetWriterFor(options.OutputFile);
                writer.Write(subs, options.OutputFile);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }