Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            var version = Assembly.GetExecutingAssembly().GetName().Version;

            // Title
            C.Write("| ");
            CC.Write(ConsoleColor.Cyan, "Spotify-Downloader Handler");
            C.WriteLine($" v{version.Major}.{version.Minor}.{version.Build}");

            C.Write("| ");
            C.Write("Repository: ");
            CC.WriteLine(ConsoleColor.White, "https://github.com/Silverfeelin/spotdl-handler");
            C.Write("| ");
            C.Write("Powered by Spotify-Downloader: ");
            CC.WriteLine(ConsoleColor.White, "https://github.com/ritiek/spotify-downloader");

            //C.WriteLine("");

            try
            {
                _manager = new ConfigurationManager();

                // Configure
                if (args.Length == 0 || args.Any(a => a == "--configure"))
                {
                    _manager.Configure();
                    _manager.Save();
                    Exit(); return;
                }

                // Run
                Run(args);
            }
            catch (Exception exc)
            {
                CC.WriteLine(ConsoleColor.Red, $"Unhandled exception:\n{exc}");
                C.WriteLine("Press Enter to exit...");
                C.ReadLine();
                Environment.Exit(1);
            }

            Exit();
        }
Exemplo n.º 2
0
        private static bool ValidateDirectory(Config config)
        {
            var directory = config.Output.Directory;

            if (string.IsNullOrWhiteSpace(directory))
            {
                CC.WriteLine(ConsoleColor.Red, "Output directory not configured. Please run the application without any arguments to configure settings.");
                return(false);
            }
            if (!Directory.Exists(directory))
            {
                CC.Write(ConsoleColor.Red, "Output directory ");
                CC.Write(ConsoleColor.Yellow, directory);
                CC.Write(ConsoleColor.Red, " does not exist. Please run the application without any arguments to configure settings.");
                return(false);
            }

            return(true);
        }