コード例 #1
0
        public Form1(bool loggedIn)
        {
            InitializeComponent();
            Session.OnLoggedOut += Session_OnLoggedOut;
            LoggedIn             = loggedIn;
            AppConfig config = AppConfig.Load();

            Config     = config;
            configCtrl = new ConfigControl(config);
            if (config == null)
            {
                LoadConfig();
            }
            else
            {
                if (loggedIn)
                {
                    LoadMain();
                }
                else
                {
                    LoadLogin();
                }
            }
        }
コード例 #2
0
        static void DoConsole(string[] args)
        {
            nito.Do(() =>
            {
                var options = new Options();
                if (CommandLine.Parser.Default.ParseArguments(args, options))
                {
                    if (options.URL == null || options.URL.Length == 0)
                    {
                        Log.Error("Error: No URL specified");
                        return;
                    }

                    if (!Session.Login(options.Username, options.Password))
                    {
                        Log.Error("Error: Bad credentials");
                        return;
                    }

                    AppConfig config = AppConfig.Load();
                    if (config == null)
                    {
                        config = new AppConfig();
                    }

                    if (options.UseSftp != null)
                    {
                        config.sftpEnabled = options.UseSftp.Value;
                    }

                    if (options.LocalFolder != null)
                    {
                        config.localBaseFolder = options.LocalFolder;
                    }

                    if (options.SftpUsername != null)
                    {
                        config.sftpUsername = options.SftpUsername;
                    }

                    if (options.SftpPassword != null)
                    {
                        config.sftpPassword = options.SftpPassword;
                    }

                    if (options.SftpPort != null)
                    {
                        config.sftpPort = options.SftpPort.Value;
                    }

                    if (options.SftpServer != null)
                    {
                        config.sftpRemoteServer = options.SftpServer;
                    }

                    if (options.SftpKey != null)
                    {
                        config.sftpPrivateKeyPath = options.SftpKey;
                    }

                    if (options.SftpPath != null)
                    {
                        config.sftpRemoteServer = options.SftpPath;
                    }

                    config.spotifyBitrate = options.SpotifyBitrate;
                    config.lameBitrate    = options.LameBitrate;

                    if (options.Save == true)
                    {
                        config.Save();
                    }

                    Download(options.URL, config);
                }
            });
        }