Esempio n. 1
0
        public static void Main(string[] args)
        {
            string folderName = null;

            if (Environment.GetCommandLineArgs().Length > 1)
            {
                folderName = Environment.GetCommandLineArgs()[1];
            }

            var settings = Arguments.Parse <SubSyncSettings>(args);

            var subtitleExtensions = settings.SubtitleExt;
            var languages          = settings.Languages;
            var input = folderName;

            var version           = GetVersion();
            var logger            = new ConsoleLogger();
            var videoIgnoreFilter = new VideoIgnoreFilter(ReadVideoIgnoreList());
            var videoSyncList     = new VideoSyncList();

            using (var fallbackSubtitleProvider = new FallbackSubtitleProvider(
                       videoSyncList,
                       new OpenSubtitles(languages, new FileBasedCredentialsProvider("opensubtitle.auth", logger), logger)))
            //new Subscene(languages)))
            {
                var resultReporter        = new QueueProcessReporter();
                var subSyncWorkerProvider = new WorkerProvider(logger, subtitleExtensions, fallbackSubtitleProvider, resultReporter);
                var subSyncWorkerQueue    = new WorkerQueue(settings, subSyncWorkerProvider, resultReporter);

                using (var mediaWatcher = new SubtitleSynchronizer(
                           logger, videoSyncList, subSyncWorkerQueue, resultReporter, videoIgnoreFilter, settings))
                {
                    logger.WriteLine("╔════════════════════════════════════════════╗");
                    logger.WriteLine("║   @whi@SubSync v" + version.PadRight(30 - version.Length) + "@gray@         ║");
                    logger.WriteLine("║   --------------------------------------   ║");
                    logger.WriteLine("║   Copyright (c) 2018 zerratar\\@gmail.com    ║");
                    logger.WriteLine("╚════════════════════════════════════════════╝");
                    logger.WriteLine("");
                    logger.WriteLine("  Following folder and its subfolders being watched");
                    logger.WriteLine($"    @whi@{input} @gray@");
                    logger.WriteLine("");
                    logger.WriteLine("  You may press @green@'r' @gray@ to register the SubSync in the windows folder context menu.");
                    logger.WriteLine("  You may press @green@'u' @gray@ to unregister the SubSync from the windows folder context menu.");
                    logger.WriteLine("  You may press @green@'q' @gray@at any time to quit.");
                    logger.WriteLine("");

                    if (settings.MinimummDelayBetweenRequests > 0)
                    {
                        logger.WriteLine($"  @yel@Request delay: @red@{settings.MinimummDelayBetweenRequests}ms @yel@activated.");
                        logger.WriteLine($"  @yel@All requests will be run in sequential order and may take a lot longer to sync.");
                        logger.WriteLine("");
                    }

                    logger.WriteLine(" ───────────────────────────────────────────────────── ");
                    logger.WriteLine("");

                    mediaWatcher.Start();
                    ConsoleKeyInfo ck;
                    while ((ck = Console.ReadKey(true)).Key != ConsoleKey.Q)
                    {
                        if (ck.Key == ConsoleKey.R)
                        {
                            RegisterOnContextMenu();
                            Console.WriteLine("Context menu item registered!");
                        }

                        if (ck.Key == ConsoleKey.U)
                        {
                            UnregisterOnContextMenu();
                            Console.WriteLine("Context menu item unregistered!");
                        }

                        if (ck.Key == ConsoleKey.A)
                        {
                            mediaWatcher.SyncAll();
                        }
                        System.Threading.Thread.Sleep(10);
                    }
                }
            }
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            var settings = Arguments.Parse <SubSyncSettings>(args);

            //// ugly workaround for ending backslashes with single/double-quotes. Seem to be a bug in the dotnet!
            //if (!string.IsNullOrEmpty(settings.Input) && (settings.Input.EndsWith("\"") || settings.Input.EndsWith("'")))
            //{
            //    settings.Input = settings.Input.Substring(0, settings.Input.Length - 1);
            //}

            var subtitleExtensions = settings.SubtitleExt;
            var languages          = settings.Languages;
            var input = settings.Input;

            var version           = GetVersion();
            var logger            = new ConsoleLogger();
            var videoIgnoreFilter = new VideoIgnoreFilter(ReadVideoIgnoreList());
            var videoSyncList     = new VideoSyncList();

            using (var fallbackSubtitleProvider = new FallbackSubtitleProvider(
                       videoSyncList,
                       new OpenSubtitles(languages, new FileBasedCredentialsProvider("opensubtitle.auth", logger), logger),
                       new Subscene(languages)))
            {
                var resultReporter        = new QueueProcessReporter();
                var subSyncWorkerProvider = new WorkerProvider(logger, subtitleExtensions, fallbackSubtitleProvider, resultReporter);
                var subSyncWorkerQueue    = new WorkerQueue(settings, subSyncWorkerProvider, resultReporter);

                using (var mediaWatcher = new SubtitleSynchronizer(
                           logger, videoSyncList, subSyncWorkerQueue, resultReporter, videoIgnoreFilter, settings))
                {
                    logger.WriteLine("╔════════════════════════════════════════════╗");
                    logger.WriteLine("║   @whi@SubSync v" + version.PadRight(30 - version.Length) + "@gray@         ║");
                    logger.WriteLine("║   --------------------------------------   ║");
                    logger.WriteLine("║   Copyright (c) 2018 zerratar\\@gmail.com    ║");
                    logger.WriteLine("╚════════════════════════════════════════════╝");
                    logger.WriteLine("");
                    logger.WriteLine("  Following folder and its subfolders being watched");
                    logger.WriteLine($"    @whi@{input} @gray@");
                    logger.WriteLine("");
                    logger.WriteLine("  You may press @green@'q' @gray@at any time to quit.");
                    logger.WriteLine("");

                    if (settings.MinimummDelayBetweenRequests > 0)
                    {
                        logger.WriteLine($"  @yel@Request delay: @red@{settings.MinimummDelayBetweenRequests}ms @yel@activated.");
                        logger.WriteLine($"  @yel@All requests will be run in sequential order and may take a lot longer to sync.");
                        logger.WriteLine("");
                    }

                    logger.WriteLine(" ───────────────────────────────────────────────────── ");
                    logger.WriteLine("");

                    mediaWatcher.Start();
                    ConsoleKeyInfo ck;
                    while ((ck = Console.ReadKey(true)).Key != ConsoleKey.Q)
                    {
                        if (ck.Key == ConsoleKey.A)
                        {
                            mediaWatcher.SyncAll();
                        }
                        System.Threading.Thread.Sleep(10);
                    }
                }
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var input              = "./";
            var videoExtensions    = ParseList("*.avi;*.mp4;*.mkv;*.mpeg;*.flv;*.webm");
            var subtitleExtensions = ParseList("*.srt;*.txt;*.sub;*.idx;*.ssa;*.ass");
            var languages          = ParseList("english");

            if (args.Length > 0 && !string.IsNullOrEmpty(args[0]))
            {
                input = args[0];
            }

            if (args.Length > 1 && !string.IsNullOrEmpty(args[1]))
            {
                languages = ParseList(args[1]);
            }

            if (args.Length > 2 && !string.IsNullOrEmpty(args[2]))
            {
                videoExtensions = ParseList(args[2]);
            }

            var version = GetVersion();
            var logger  = new ConsoleLogger();

            using (var fallbackSubtitleProvider = new FallbackSubtitleProvider(
                       new OpenSubtitles(languages, new FileBasedCredentialsProvider("opensubtitle.auth", logger)),
                       new Subscene(languages)))
            {
                var resultReporter        = new QueueProcessReporter();
                var subSyncWorkerProvider = new WorkerProvider(logger, subtitleExtensions, fallbackSubtitleProvider, resultReporter);
                var subSyncWorkerQueue    = new WorkerQueue(subSyncWorkerProvider, resultReporter);

                using (var mediaWatcher = new SubtitleSynchronizer(logger, subSyncWorkerQueue, resultReporter, input, videoExtensions, subtitleExtensions))
                {
                    logger.WriteLine("╔════════════════════════════════════════════╗");
                    logger.WriteLine("║   @whi@SubSync v" + version.PadRight(30 - version.Length) + "@gray@         ║");
                    logger.WriteLine("║   --------------------------------------   ║");
                    logger.WriteLine("║   Copyright (c) 2018 zerratar\\@gmail.com    ║");
                    logger.WriteLine("╚════════════════════════════════════════════╝");
                    logger.WriteLine("");
                    logger.WriteLine("  Following folder and its subfolders being watched");
                    logger.WriteLine($"    @whi@{input} @gray@");
                    logger.WriteLine("");
                    logger.WriteLine("  You may press @green@'q' @gray@at any time to quit.");
                    logger.WriteLine("");
                    logger.WriteLine(" ───────────────────────────────────────────────────── ");
                    logger.WriteLine("");

                    mediaWatcher.Start();
                    ConsoleKeyInfo ck;
                    while ((ck = Console.ReadKey(true)).Key != ConsoleKey.Q)
                    {
                        if (ck.Key == ConsoleKey.A)
                        {
                            mediaWatcher.SyncAll();
                        }
                        System.Threading.Thread.Sleep(10);
                    }
                }
            }
        }