From 984bed19f2ece87796e0d9f7c4fdba54bd1a664f Mon Sep 17 00:00:00 2001 From: AiiR <22158489+ImAiiR@users.noreply.github.com> Date: Sun, 29 Mar 2020 01:39:50 -0400 Subject: [PATCH] 0.9.9.12 0.9.9.12 --- QobuzDownloaderX/App.config | 9 + QobuzDownloaderX/Form1.cs | 13 +- QobuzDownloaderX/LoginForm-v2.Designer.cs | 118 +++- QobuzDownloaderX/LoginForm-v2.cs | 631 ++++++++++++------ QobuzDownloaderX/LoginForm-v2.resx | 3 + QobuzDownloaderX/Properties/AssemblyInfo.cs | 4 +- .../Properties/Settings.Designer.cs | 36 + QobuzDownloaderX/Properties/Settings.settings | 9 + 8 files changed, 599 insertions(+), 224 deletions(-) diff --git a/QobuzDownloaderX/App.config b/QobuzDownloaderX/App.config index d866ebf..c9be9f4 100644 --- a/QobuzDownloaderX/App.config +++ b/QobuzDownloaderX/App.config @@ -100,6 +100,15 @@ .flac + + + + + + + + 0 + diff --git a/QobuzDownloaderX/Form1.cs b/QobuzDownloaderX/Form1.cs index 8ca435b..81eded7 100644 --- a/QobuzDownloaderX/Form1.cs +++ b/QobuzDownloaderX/Form1.cs @@ -65,7 +65,17 @@ namespace QobuzDownloaderX // Welcome the user after successful login. output.Invoke(new Action(() => output.Text = String.Empty)); output.Invoke(new Action(() => output.AppendText("Welcome " + displayName + "!\r\n"))); - output.Invoke(new Action(() => output.AppendText("Qobuz Account Type - " + accountType + "\r\n\r\n"))); + + // Show account type if user logged in normally. + if (accountType == null | accountType == "") + { + output.Invoke(new Action(() => output.AppendText("\r\n"))); + } + else + { + output.Invoke(new Action(() => output.AppendText("Qobuz Account Type - " + accountType + "\r\n\r\n"))); + } + output.Invoke(new Action(() => output.AppendText("Your user_auth_token has been set for this session!"))); // Get and display version number. @@ -354,6 +364,7 @@ namespace QobuzDownloaderX flacMidCheckbox.Invoke(new Action(() => flacMidCheckbox.Visible = false)); flacHighCheckbox.Invoke(new Action(() => flacHighCheckbox.Visible = false)); downloadButton.Invoke(new Action(() => downloadButton.Enabled = false)); + // Check if there's no selected path. if (folderBrowserDialog.SelectedPath == null | folderBrowserDialog.SelectedPath == "") { diff --git a/QobuzDownloaderX/LoginForm-v2.Designer.cs b/QobuzDownloaderX/LoginForm-v2.Designer.cs index bf72fd2..08f7f33 100644 --- a/QobuzDownloaderX/LoginForm-v2.Designer.cs +++ b/QobuzDownloaderX/LoginForm-v2.Designer.cs @@ -32,18 +32,23 @@ this.panel1 = new System.Windows.Forms.Panel(); this.disableLogin = new System.Windows.Forms.CheckBox(); this.verNumLabel2 = new System.Windows.Forms.Label(); + this.md5Button = new System.Windows.Forms.Button(); this.exitLabel = new System.Windows.Forms.Label(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.userAuthTokenTextbox = new System.Windows.Forms.TextBox(); this.loginButton = new System.Windows.Forms.Button(); this.panel3 = new System.Windows.Forms.Panel(); this.panel4 = new System.Windows.Forms.Panel(); this.emailTextbox = new System.Windows.Forms.TextBox(); this.passwordTextbox = new System.Windows.Forms.TextBox(); - this.md5Button = new System.Windows.Forms.Button(); this.loginText = new System.Windows.Forms.Label(); this.getSecretBG = new System.ComponentModel.BackgroundWorker(); this.loginBG = new System.ComponentModel.BackgroundWorker(); this.visableCheckbox = new System.Windows.Forms.CheckBox(); + this.altLoginLabel = new System.Windows.Forms.Label(); + this.altLoginTutLabel = new System.Windows.Forms.Label(); + this.userIdTextbox = new System.Windows.Forms.TextBox(); + this.altLoginBG = new System.ComponentModel.BackgroundWorker(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); @@ -88,6 +93,23 @@ this.verNumLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.verNumLabel2.MouseMove += new System.Windows.Forms.MouseEventHandler(this.verNumLabel2_MouseMove); // + // md5Button + // + this.md5Button.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(112)))), ((int)(((byte)(239))))); + this.md5Button.Enabled = false; + this.md5Button.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); + this.md5Button.FlatAppearance.BorderSize = 2; + this.md5Button.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.md5Button.ForeColor = System.Drawing.Color.White; + this.md5Button.Location = new System.Drawing.Point(227, 122); + this.md5Button.Name = "md5Button"; + this.md5Button.Size = new System.Drawing.Size(43, 27); + this.md5Button.TabIndex = 9; + this.md5Button.Text = "MD5"; + this.md5Button.UseVisualStyleBackColor = false; + this.md5Button.Visible = false; + this.md5Button.Click += new System.EventHandler(this.md5Button_Click); + // // exitLabel // this.exitLabel.AutoSize = true; @@ -114,6 +136,22 @@ this.pictureBox1.TabStop = false; this.pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove); // + // userAuthTokenTextbox + // + this.userAuthTokenTextbox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); + this.userAuthTokenTextbox.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.userAuthTokenTextbox.Font = new System.Drawing.Font("Trebuchet MS", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.userAuthTokenTextbox.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(88)))), ((int)(((byte)(92)))), ((int)(((byte)(102))))); + this.userAuthTokenTextbox.Location = new System.Drawing.Point(12, 255); + this.userAuthTokenTextbox.Multiline = true; + this.userAuthTokenTextbox.Name = "userAuthTokenTextbox"; + this.userAuthTokenTextbox.Size = new System.Drawing.Size(237, 23); + this.userAuthTokenTextbox.TabIndex = 35; + this.userAuthTokenTextbox.Text = "user_auth_token"; + this.userAuthTokenTextbox.Visible = false; + this.userAuthTokenTextbox.Click += new System.EventHandler(this.userAuthTokenTextbox_Click); + this.userAuthTokenTextbox.Leave += new System.EventHandler(this.userAuthTokenTextbox_Leave); + // // loginButton // this.loginButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(112)))), ((int)(((byte)(239))))); @@ -136,7 +174,6 @@ this.panel3.Name = "panel3"; this.panel3.Size = new System.Drawing.Size(258, 1); this.panel3.TabIndex = 2; - this.panel3.Click += new System.EventHandler(this.panel3_Click); // // panel4 // @@ -145,7 +182,6 @@ this.panel4.Name = "panel4"; this.panel4.Size = new System.Drawing.Size(258, 1); this.panel4.TabIndex = 2; - this.panel4.Click += new System.EventHandler(this.panel4_Click); // // emailTextbox // @@ -171,34 +207,17 @@ this.passwordTextbox.Location = new System.Drawing.Point(12, 255); this.passwordTextbox.Multiline = true; this.passwordTextbox.Name = "passwordTextbox"; - this.passwordTextbox.Size = new System.Drawing.Size(209, 23); + this.passwordTextbox.Size = new System.Drawing.Size(237, 23); this.passwordTextbox.TabIndex = 8; this.passwordTextbox.Text = "Password"; this.passwordTextbox.Click += new System.EventHandler(this.passwordTextbox_Click); this.passwordTextbox.Leave += new System.EventHandler(this.passwordTextbox_Leave); // - // md5Button - // - this.md5Button.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(112)))), ((int)(((byte)(239))))); - this.md5Button.Enabled = false; - this.md5Button.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); - this.md5Button.FlatAppearance.BorderSize = 2; - this.md5Button.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.md5Button.ForeColor = System.Drawing.Color.White; - this.md5Button.Location = new System.Drawing.Point(227, 122); - this.md5Button.Name = "md5Button"; - this.md5Button.Size = new System.Drawing.Size(43, 27); - this.md5Button.TabIndex = 9; - this.md5Button.Text = "MD5"; - this.md5Button.UseVisualStyleBackColor = false; - this.md5Button.Visible = false; - this.md5Button.Click += new System.EventHandler(this.md5Button_Click); - // // loginText // this.loginText.Font = new System.Drawing.Font("Trebuchet MS", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.loginText.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(88)))), ((int)(((byte)(92)))), ((int)(((byte)(102))))); - this.loginText.Location = new System.Drawing.Point(12, 333); + this.loginText.Location = new System.Drawing.Point(12, 349); this.loginText.Name = "loginText"; this.loginText.Size = new System.Drawing.Size(258, 23); this.loginText.TabIndex = 30; @@ -223,12 +242,58 @@ this.visableCheckbox.UseVisualStyleBackColor = true; this.visableCheckbox.CheckedChanged += new System.EventHandler(this.visableCheckbox_CheckedChanged); // + // altLoginLabel + // + this.altLoginLabel.Font = new System.Drawing.Font("Trebuchet MS", 8.25F); + this.altLoginLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(88)))), ((int)(((byte)(92)))), ((int)(((byte)(102))))); + this.altLoginLabel.Location = new System.Drawing.Point(12, 326); + this.altLoginLabel.Name = "altLoginLabel"; + this.altLoginLabel.Size = new System.Drawing.Size(258, 20); + this.altLoginLabel.TabIndex = 32; + this.altLoginLabel.Text = "Can\'t login? Click here"; + this.altLoginLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.altLoginLabel.Click += new System.EventHandler(this.altLoginLabel_Click); + // + // altLoginTutLabel + // + this.altLoginTutLabel.AutoSize = true; + this.altLoginTutLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(88)))), ((int)(((byte)(92)))), ((int)(((byte)(102))))); + this.altLoginTutLabel.Location = new System.Drawing.Point(77, 180); + this.altLoginTutLabel.Name = "altLoginTutLabel"; + this.altLoginTutLabel.Size = new System.Drawing.Size(128, 13); + this.altLoginTutLabel.TabIndex = 33; + this.altLoginTutLabel.Text = "Click Here for Instructions"; + this.altLoginTutLabel.Visible = false; + this.altLoginTutLabel.Click += new System.EventHandler(this.altLoginTutLabel_Click); + // + // userIdTextbox + // + this.userIdTextbox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); + this.userIdTextbox.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.userIdTextbox.Font = new System.Drawing.Font("Trebuchet MS", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.userIdTextbox.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(88)))), ((int)(((byte)(92)))), ((int)(((byte)(102))))); + this.userIdTextbox.Location = new System.Drawing.Point(12, 199); + this.userIdTextbox.Multiline = true; + this.userIdTextbox.Name = "userIdTextbox"; + this.userIdTextbox.Size = new System.Drawing.Size(258, 23); + this.userIdTextbox.TabIndex = 9; + this.userIdTextbox.Text = "user_id"; + this.userIdTextbox.Visible = false; + this.userIdTextbox.Click += new System.EventHandler(this.userIdTextbox_Click); + this.userIdTextbox.Leave += new System.EventHandler(this.userIdTextbox_Leave); + // + // altLoginBG + // + this.altLoginBG.DoWork += new System.ComponentModel.DoWorkEventHandler(this.altLoginBG_DoWork); + // // LoginFrm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); - this.ClientSize = new System.Drawing.Size(282, 377); + this.ClientSize = new System.Drawing.Size(282, 392); + this.Controls.Add(this.altLoginTutLabel); + this.Controls.Add(this.altLoginLabel); this.Controls.Add(this.visableCheckbox); this.Controls.Add(this.loginText); this.Controls.Add(this.panel4); @@ -237,6 +302,8 @@ this.Controls.Add(this.emailTextbox); this.Controls.Add(this.loginButton); this.Controls.Add(this.panel1); + this.Controls.Add(this.userIdTextbox); + this.Controls.Add(this.userAuthTokenTextbox); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "LoginFrm"; @@ -267,5 +334,10 @@ private System.Windows.Forms.Label verNumLabel2; private System.Windows.Forms.CheckBox visableCheckbox; private System.Windows.Forms.CheckBox disableLogin; + private System.Windows.Forms.TextBox userAuthTokenTextbox; + private System.Windows.Forms.Label altLoginLabel; + private System.Windows.Forms.Label altLoginTutLabel; + private System.Windows.Forms.TextBox userIdTextbox; + private System.ComponentModel.BackgroundWorker altLoginBG; } } \ No newline at end of file diff --git a/QobuzDownloaderX/LoginForm-v2.cs b/QobuzDownloaderX/LoginForm-v2.cs index 80b36bd..76c425f 100644 --- a/QobuzDownloaderX/LoginForm-v2.cs +++ b/QobuzDownloaderX/LoginForm-v2.cs @@ -47,6 +47,9 @@ namespace QobuzDownloaderX public string appSecret { get; set; } public string appID { get; set; } + public string userID { get; set; } + public string userAuthToken { get; set; } + public string altLoginValue { get; set; } string errorLog = Path.GetDirectoryName(Application.ExecutablePath) + "\\Latest_Error.log"; string dllCheck = Path.GetDirectoryName(Application.ExecutablePath) + "\\taglib-sharp.dll"; @@ -163,83 +166,397 @@ namespace QobuzDownloaderX // Set saved settings to correct places. emailTextbox.Text = Settings.Default.savedEmail.ToString(); passwordTextbox.Text = Settings.Default.savedPassword.ToString(); + userIdTextbox.Text = Settings.Default.savedUserID.ToString(); + userAuthTokenTextbox.Text = Settings.Default.savedUserAuthToken.ToString(); + altLoginValue = Settings.Default.savedAltLoginValue.ToString(); + // Set alt login mode & label text based on saved value + if (altLoginValue == "0") + { + // Change alt login label text + altLoginLabel.Text = "Can't login? Click here"; + + // Hide alt login methods + altLoginTutLabel.Visible = false; + userIdTextbox.Visible = false; + userAuthTokenTextbox.Visible = false; + + // Unhide standard login methods + emailTextbox.Visible = true; + passwordTextbox.Visible = true; + } + else if (altLoginValue == "1") + { + // Change alt login label text + altLoginLabel.Text = "Login normally? Click here"; + + // Hide standard login methods + emailTextbox.Visible = false; + passwordTextbox.Visible = false; + + // Unhide alt login methods + altLoginTutLabel.Visible = true; + userIdTextbox.Visible = true; + userAuthTokenTextbox.Visible = true; + } + + // Set values for email textbox. if (emailTextbox.Text != "Email") { emailTextbox.ForeColor = Color.FromArgb(186, 186, 186); } - if (emailTextbox.Text == null | emailTextbox.Text == "") { emailTextbox.ForeColor = Color.FromArgb(88, 92, 102); emailTextbox.Text = "Email"; } + // Set values for user_id textbox. + if (userIdTextbox.Text != "user_id") + { + userIdTextbox.ForeColor = Color.FromArgb(186, 186, 186); + } + if (userIdTextbox.Text == null | userIdTextbox.Text == "") + { + userIdTextbox.ForeColor = Color.FromArgb(88, 92, 102); + userIdTextbox.Text = "user_id"; + } + + // Set values for password textbox. if (passwordTextbox.Text != "Password") { passwordTextbox.PasswordChar = '*'; passwordTextbox.UseSystemPasswordChar = false; passwordTextbox.ForeColor = Color.FromArgb(186, 186, 186); } - if (passwordTextbox.Text == null | passwordTextbox.Text == "") { passwordTextbox.ForeColor = Color.FromArgb(88, 92, 102); passwordTextbox.UseSystemPasswordChar = true; passwordTextbox.Text = "Password"; } + + // Set values for user_auth_token textbox. + if (userAuthTokenTextbox.Text != "user_auth_token") + { + userAuthTokenTextbox.PasswordChar = '*'; + userAuthTokenTextbox.UseSystemPasswordChar = false; + userAuthTokenTextbox.ForeColor = Color.FromArgb(186, 186, 186); + } + if (userAuthTokenTextbox.Text == null | userAuthTokenTextbox.Text == "") + { + userAuthTokenTextbox.ForeColor = Color.FromArgb(88, 92, 102); + userAuthTokenTextbox.UseSystemPasswordChar = true; + userAuthTokenTextbox.Text = "user_auth_token"; + } } private void loginButton_Click(object sender, EventArgs e) { - if (emailTextbox.Text == "Email" | emailTextbox.Text == null | emailTextbox.Text == "") + // Hide alt login label until job is finished or failed + altLoginLabel.Visible = false; + + // If logging in normally (email & password) + if (altLoginValue == "0") { - // If there's no email typed in. - loginText.Invoke(new Action(() => loginText.Text = "No email, please input email first.")); - return; - } - - if (passwordTextbox.Text == "Password") - { - // If there's no password typed in. - loginText.Invoke(new Action(() => loginText.Text = "No password typed, please input password first.")); - return; - } - - string plainTextPW = passwordTextbox.Text; - - var passMD5CheckLog = Regex.Match(plainTextPW, "(?^[0-9a-f]{32}$)").Groups; - var passMD5Check = passMD5CheckLog[1].Value; - - if (passMD5Check == null | passMD5Check == "") - { - // Generate the MD5 hash using the string created above. - using (MD5 md5PassHash = MD5.Create()) + #region Normal Login + if (emailTextbox.Text == "Email" | emailTextbox.Text == null | emailTextbox.Text == "") { - string hashedPW = GetMd5Hash(md5PassHash, plainTextPW); + // If there's no email typed in. + loginText.Invoke(new Action(() => loginText.Text = "No email, please input email first.")); + return; + } - if (VerifyMd5Hash(md5PassHash, plainTextPW, hashedPW)) + if (passwordTextbox.Text == "Password") + { + // If there's no password typed in. + loginText.Invoke(new Action(() => loginText.Text = "No password typed, please input password first.")); + return; + } + + string plainTextPW = passwordTextbox.Text; + + var passMD5CheckLog = Regex.Match(plainTextPW, "(?^[0-9a-f]{32}$)").Groups; + var passMD5Check = passMD5CheckLog[1].Value; + + if (passMD5Check == null | passMD5Check == "") + { + // Generate the MD5 hash using the string created above. + using (MD5 md5PassHash = MD5.Create()) { - // If the MD5 hash is verified, proceed to get the streaming URL. - passwordTextbox.Text = hashedPW; - } - else - { - // If the hash can't be verified. - loginText.Invoke(new Action(() => loginText.Text = "Hashing failed. Please retry.")); - return; + string hashedPW = GetMd5Hash(md5PassHash, plainTextPW); + + if (VerifyMd5Hash(md5PassHash, plainTextPW, hashedPW)) + { + // If the MD5 hash is verified, proceed to get the streaming URL. + passwordTextbox.Text = hashedPW; + } + else + { + // If the hash can't be verified. + loginText.Invoke(new Action(() => loginText.Text = "Hashing failed. Please retry.")); + return; + } } } + + // Save info locally to be used on next launch. + Settings.Default.savedEmail = emailTextbox.Text; + Settings.Default.savedPassword = passwordTextbox.Text; + Settings.Default.savedAltLoginValue = altLoginValue; + Settings.Default.Save(); + + loginText.Text = "Getting App ID and Secret..."; + loginButton.Enabled = false; + getSecretBG.RunWorkerAsync(); + #endregion + } + // If logging in the alternate way (user_id & user_auth_token) + else + { + #region Alt Login + if (userIdTextbox.Text == "user_id" | userIdTextbox.Text == null | userIdTextbox.Text == "") + { + // If there's no email typed in. + loginText.Invoke(new Action(() => loginText.Text = "No user_id, please input user_id first.")); + return; + } + + if (userAuthTokenTextbox.Text == "user_auth_token") + { + // If there's no password typed in. + loginText.Invoke(new Action(() => loginText.Text = "No user_auth_token typed, please input user_auth_token first.")); + return; + } + + // Set user_id & user_auth_token to login. + userID = userIdTextbox.Text; + userAuthToken = userAuthTokenTextbox.Text; + + // Save info locally to be used on next launch. + Settings.Default.savedUserID = userIdTextbox.Text; + Settings.Default.savedUserAuthToken = userAuthTokenTextbox.Text; + Settings.Default.savedAltLoginValue = altLoginValue; + Settings.Default.Save(); + + loginText.Text = "Getting App ID and Secret..."; + loginButton.Enabled = false; + getSecretBG.RunWorkerAsync(); + #endregion + } + } + + private void getSecretBG_DoWork(object sender, DoWorkEventArgs e) + { + getSecretBG.WorkerSupportsCancellation = true; + + WebClient bundleURLClient = new WebClient(); + string bundleHTML = bundleURLClient.DownloadString("https://play.qobuz.com/login"); + + // Grab link to bundle.js + var bundleLog = Regex.Match(bundleHTML, "