示例#1
0
        public void SplitSrt()
        {
            var srtItems = SrtHandler.ReadSrt(new System.IO.FileStream(@"C:\Users\Adrian\Downloads\jack\CD5\CD5.srt", System.IO.FileMode.Open));

            uint groupNumber = 1;
            var  from        = TimeSpan.MinValue;
            var  group       = srtItems.GroupBy(f =>
            {
                if (from < f.From)
                {
                    from = f.From;
                    return(groupNumber);
                }
                else
                {
                    from = TimeSpan.MinValue;
                    return(++groupNumber);
                }
            });

            foreach (var g in group)
            {
                var srtItemsFiltered = g.Where(s => s.From > new TimeSpan(0, 0, 0, 40, 0));

                SrtHandler.WriteSrt(srtItemsFiltered, new System.IO.FileStream(string.Format(@"C:\Users\Adrian\Downloads\jack\CD5\Jack{0}.srt", g.Key), System.IO.FileMode.Create));
            }
        }
示例#2
0
        public void ShiftSrt()
        {
            const string filePath = @"C:\Users\Adrian\Downloads\Rick and Morty S01E04  M. Night Shaym-Aliens! (Uncensored) (1920x1080) [Phr0stY].srt";
            var          srtItems = SrtHandler.ReadSrt(new System.IO.FileStream(filePath, System.IO.FileMode.Open));

            SrtHandler.ShiftSrt(srtItems, 1000);
            SrtHandler.WriteSrt(srtItems, new System.IO.FileStream(filePath, System.IO.FileMode.Create));
        }
示例#3
0
        public void ShiftWithMultiplierSrt()
        {
            const string filePath = @"C:\Users\Adrian\Downloads\The Last Unicorn 1080p.srt";
            var          srtItems = SrtHandler.ReadSrt(new System.IO.FileStream(filePath, System.IO.FileMode.Open));

            SrtHandler.ShiftSrt(srtItems, 23.976024m / 24.000384m, 0);
            SrtHandler.WriteSrt(srtItems, new System.IO.FileStream(filePath, System.IO.FileMode.Create));
        }
示例#4
0
        public void ShiftSrtNumber()
        {
            const string filePath = @"C:\Users\Adrian\Downloads\jack\CD5\S03E07 Jack and the Creature.srt";
            const uint   number   = 919;

            var srtItems = SrtHandler.ReadSrt(new System.IO.FileStream(filePath, System.IO.FileMode.Open));

            SrtHandler.ShiftSrtAfterNumber(srtItems, number, 0 * 60 * 1000 + 1 * 1000);
            SrtHandler.WriteSrt(srtItems, new System.IO.FileStream(filePath, System.IO.FileMode.Create));
        }
示例#5
0
        public void ShiftSrtFrom()
        {
            uint seconds = 75 * 60 + 45;
            int  shift   = -1800;

            var srtItems = SrtHandler.ReadSrt(new System.IO.FileStream(@"C:\Users\Adrian\Downloads\Expanse\S01E09E10.srt", System.IO.FileMode.Open));

            SrtHandler.ShiftSrtAfterFrom(srtItems, seconds * 1000, shift);
            SrtHandler.WriteSrt(srtItems, new System.IO.FileStream(@"C:\Users\Adrian\Downloads\Expanse\The.Expanse.S01E09E10.Anubis-Leviathan.erwacht.German.Dubbed.DD51.DL.2160p.AmazonUHD.x264-NIMA4K.srt", System.IO.FileMode.Create));
        }
示例#6
0
        public void ReplacePointsWithCommas()
        {
            const string filePath = @"Z:\Shared\Videos\Samurai Jack\S03\S03E01 Chicken Jack.srt";
            var          srtItems = SrtHandler.ReadSrt(new System.IO.FileStream(filePath, System.IO.FileMode.Open));

            srtItems.ToList().ForEach(s =>
            {
                if (!s.Text.Contains('.'))
                {
                    return;
                }

                var indexOfPoint = s.Text.IndexOf('.');

                if (s.Text.Length < indexOfPoint + 2)
                {
                    return;
                }

                var indexOfFirstLetterOfNextSentence = s.Text[indexOfPoint + 1] == '\r' && (s.Text.Length > indexOfPoint + 3) ? indexOfPoint + 3 : indexOfPoint + 2;
                var firstLetterOfNextSentence        = s.Text[indexOfFirstLetterOfNextSentence];
                if (!(firstLetterOfNextSentence >= 97 && firstLetterOfNextSentence <= 122))
                {
                    return;
                }

                var textFixed           = s.Text.ToCharArray();
                textFixed[indexOfPoint] = ',';
                var stringFixed         = new string(textFixed);

                System.Diagnostics.Debug.WriteLine(s.Text);
                System.Diagnostics.Debug.WriteLine(stringFixed);

                s.Text = stringFixed;
            });

            SrtHandler.WriteSrt(srtItems, new System.IO.FileStream(filePath, System.IO.FileMode.Create));
        }