Пример #1
0
        private static void PromptForPath()
        {
            Console.WriteLine("                         Welcome to demo of AutoPrompt APIs");
            Console.WriteLine("\n\n1. Demo of prompt with initial input:\n");
            var userInput1 = AutoPrompt.PromptForInput("Q: How do you feel? (Press backspce to edit)\nA: ", "Awesome");

            Console.WriteLine("User feels '" + userInput1 + "'");

            Console.WriteLine("\n\n2. Demo of prompt with options:\n");
            var userInput2 = AutoPrompt.PromptForInput("Q: Choose occupation (Press up/down arrow to choose, Backspace to edit)\nA: ", new string[] { "Engineer", "Scientist", "Salesman", "Manager", "TopManagement" });

            Console.WriteLine("Occupation selected: '" + userInput2 + "'");

            Console.WriteLine("\n\n3. Demo of prompt with options with edits disallowed :\n");
            var userInput3 = AutoPrompt.PromptForInput("Q: Choose sex (Press up/down arrow to choose)\nA: ", new string[] { "Male", "Female", "Others" }, false);

            Console.WriteLine("Occupation selected: '" + userInput3 + "'");

            Console.WriteLine("\n\n4. Demo of prompt with searchable options:\n");
            var userInput4 = AutoPrompt.PromptForInput_Searchable("Q: Choose city (Press up/down arrow or type name)\nA: ", new string[] { "New York City", "San Fransisco", "New Delhi", "Bangalore", "Tokyo" });

            Console.WriteLine("City selected: '" + userInput4 + "'");

            Console.WriteLine("\n\n5. Demo of prompt for password:\n");
            var userInput5 = AutoPrompt.GetPassword("Q: Enter password: "******"Password entered: '" + userInput5 + "'");

            Console.WriteLine("\n\n6. Demo of prompt for file/folder:\n");
            var userInput6 = AutoPrompt.GetPath("Q: Enter path of file:\n\tUp/down arrow to go through files in current directory.\n\t'\\' to step into directory\n\tBackspace to edit\n\tOr just type to go to nearest search match\n\nA: ");

            Console.WriteLine("Path entered: '" + userInput6 + "'");

            Console.ReadLine();
        }
Пример #2
0
        internal static async Task Main(string[] args)
        {
            var defaultCoursesDir = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                "Pluralsight", "courses");

            string coursesFolder;
            string dbPath;
            string outputFolder;

            do
            {
                coursesFolder = AutoPrompt
                                .PromptForInput("Pluralsight courses folder? Enter to accept default, backspace to change.\n ",
                                                defaultCoursesDir);
            }while (!Directory.Exists(coursesFolder));

            var defaultDbPath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                "Pluralsight", "pluralsight.db");

            do
            {
                dbPath = AutoPrompt
                         .PromptForInput("\nPluralsight.db path? Enter to accept default, backspace to change.\n",
                                         defaultDbPath);
            }while (!File.Exists(dbPath));

            var defaultOutputDir = Path.Combine(Directory.GetCurrentDirectory(), "output");

            do
            {
                outputFolder = AutoPrompt
                               .PromptForInput("\nOutput folder? Enter to accept default, backspace to change.\n",
                                               defaultOutputDir);
            }while (string.IsNullOrEmpty(outputFolder));

            if (!Directory.Exists(outputFolder))
            {
                Util.CreateDirectory(outputFolder);
            }

            Console.WriteLine("Courses folder: " + coursesFolder);
            Console.WriteLine("Output folder: " + outputFolder);

            _dbConn = new SQLiteConnection("Data Source=" + dbPath + ";Version=3;");
            _dbConn.Open();

            GetFolderToCourseMapping();

            string[] subDirs = Directory.GetDirectories(coursesFolder);

            if (subDirs.Length == 0)
            {
                Console.WriteLine("\nNo course found.");
            }

            Console.WriteLine("\nFound " + subDirs.Length + " course(s):\n");
            for (var i = 0; i < subDirs.Length; i++)
            {
                var dir = subDirs[i];
                Console.WriteLine($"{i + 1}. " + GetCourseTitle(Path.GetFileName(dir)) + "  (" + Path.GetFileName(dir) + ")");
            }

            var courseFolderId = AutoPrompt.PromptForInput("\nSelect course to decrypt: (Press up/down to choose.)\n",
                                                           Enumerable.Range(1, subDirs.Length).Select(i => i.ToString()).ToArray(),
                                                           false);

            var courseFolder = subDirs[Convert.ToInt32(courseFolderId) - 1];

            // System.Threading.Thread.Sleep(500);
            Console.WriteLine("\nStart decrypting the course? (Press any key to continue.)\n");
            Console.ReadKey();

            var dstCourseFolder = DecryptCourse(courseFolder, outputFolder);

            if (dstCourseFolder != null)
            {
                Console.WriteLine("\nMerge videos files with subtitles and chapters? (Press any key to continue.)\n");
                Console.ReadKey();

                var videoTransform = new VideosTransform();
                if (!videoTransform.ValidateFFmpeg())
                {
                    await videoTransform.DownloadFFmpegIfRequiredAsync();
                }

                videoTransform.ProcessCourse(dstCourseFolder);
            }

            Console.WriteLine("All done.\n\n");
            Console.WriteLine("Press any key to exit.\n");
            Console.ReadKey();
        }