diff --git a/QobuzDownloaderX/Form1.Designer.cs b/QobuzDownloaderX/Form1.Designer.cs index aa12452..b02b8a3 100644 --- a/QobuzDownloaderX/Form1.Designer.cs +++ b/QobuzDownloaderX/Form1.Designer.cs @@ -99,6 +99,8 @@ this.displaySecretButton = new System.Windows.Forms.Button(); this.profilePictureBox = new System.Windows.Forms.PictureBox(); this.logoutLabel = new System.Windows.Forms.Label(); + this.downloadLabelBG = new System.ComponentModel.BackgroundWorker(); + this.hiddenTextPanel = new System.Windows.Forms.Panel(); ((System.ComponentModel.ISupportInitialize)(this.albumArtPicBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.logoBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.profilePictureBox)).BeginInit(); @@ -337,9 +339,9 @@ this.label6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(88)))), ((int)(((byte)(92)))), ((int)(((byte)(102))))); this.label6.Location = new System.Drawing.Point(12, 70); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(132, 13); + this.label6.Size = new System.Drawing.Size(61, 13); this.label6.TabIndex = 49; - this.label6.Text = "Qobuz Album / Track Link"; + this.label6.Text = "Qobuz Link"; // // totalTracksTextbox // @@ -865,20 +867,29 @@ // // secretTextbox // - this.secretTextbox.Location = new System.Drawing.Point(352, 34); + this.secretTextbox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); + this.secretTextbox.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.secretTextbox.ForeColor = System.Drawing.Color.White; + this.secretTextbox.Location = new System.Drawing.Point(352, 35); + this.secretTextbox.Multiline = true; this.secretTextbox.Name = "secretTextbox"; + this.secretTextbox.ReadOnly = true; this.secretTextbox.Size = new System.Drawing.Size(209, 20); this.secretTextbox.TabIndex = 92; this.secretTextbox.Visible = false; // // displaySecretButton // + this.displaySecretButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(112)))), ((int)(((byte)(239))))); + this.displaySecretButton.FlatAppearance.BorderSize = 0; + this.displaySecretButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.displaySecretButton.ForeColor = System.Drawing.Color.White; this.displaySecretButton.Location = new System.Drawing.Point(243, 32); this.displaySecretButton.Name = "displaySecretButton"; this.displaySecretButton.Size = new System.Drawing.Size(103, 23); this.displaySecretButton.TabIndex = 93; this.displaySecretButton.Text = "Display appSecret"; - this.displaySecretButton.UseVisualStyleBackColor = true; + this.displaySecretButton.UseVisualStyleBackColor = false; this.displaySecretButton.Visible = false; this.displaySecretButton.Click += new System.EventHandler(this.displaySecretButton_Click); // @@ -903,12 +914,26 @@ this.logoutLabel.MouseLeave += new System.EventHandler(this.logoutLabel_MouseLeave); this.logoutLabel.MouseHover += new System.EventHandler(this.logoutLabel_MouseHover); // + // downloadLabelBG + // + this.downloadLabelBG.DoWork += new System.ComponentModel.DoWorkEventHandler(this.downloadLabelBG_DoWork); + // + // hiddenTextPanel + // + this.hiddenTextPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(88)))), ((int)(((byte)(92)))), ((int)(((byte)(102))))); + this.hiddenTextPanel.Location = new System.Drawing.Point(352, 55); + this.hiddenTextPanel.Name = "hiddenTextPanel"; + this.hiddenTextPanel.Size = new System.Drawing.Size(209, 1); + this.hiddenTextPanel.TabIndex = 87; + this.hiddenTextPanel.Visible = false; + // // QobuzDownloaderX // 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(938, 533); + this.Controls.Add(this.hiddenTextPanel); this.Controls.Add(this.logoutLabel); this.Controls.Add(this.profilePictureBox); this.Controls.Add(this.displaySecretButton); @@ -1061,6 +1086,8 @@ private System.Windows.Forms.Button displaySecretButton; private System.Windows.Forms.PictureBox profilePictureBox; private System.Windows.Forms.Label logoutLabel; + private System.ComponentModel.BackgroundWorker downloadLabelBG; + private System.Windows.Forms.Panel hiddenTextPanel; } } diff --git a/QobuzDownloaderX/Form1.cs b/QobuzDownloaderX/Form1.cs index c6498e0..e9be805 100644 --- a/QobuzDownloaderX/Form1.cs +++ b/QobuzDownloaderX/Form1.cs @@ -268,6 +268,10 @@ namespace QobuzDownloaderX output.Invoke(new Action(() => output.Text = String.Empty)); output.Invoke(new Action(() => output.AppendText("Failed to get streaming URL. Error information below.\r\n\r\n"))); output.Invoke(new Action(() => output.AppendText(getError))); + mp3Checkbox.Invoke(new Action(() => mp3Checkbox.Visible = true)); + flacLowCheckbox.Invoke(new Action(() => flacLowCheckbox.Visible = true)); + flacMidCheckbox.Invoke(new Action(() => flacMidCheckbox.Visible = true)); + flacHighCheckbox.Invoke(new Action(() => flacHighCheckbox.Visible = true)); downloadButton.Invoke(new Action(() => downloadButton.Enabled = true)); return; } @@ -276,6 +280,10 @@ namespace QobuzDownloaderX { // If the hash can't be verified. output.Invoke(new Action(() => output.AppendText("The hash can't be verified. Please retry.\r\n"))); + mp3Checkbox.Invoke(new Action(() => mp3Checkbox.Visible = true)); + flacLowCheckbox.Invoke(new Action(() => flacLowCheckbox.Visible = true)); + flacMidCheckbox.Invoke(new Action(() => flacMidCheckbox.Visible = true)); + flacHighCheckbox.Invoke(new Action(() => flacHighCheckbox.Visible = true)); downloadButton.Invoke(new Action(() => downloadButton.Enabled = true)); return; } @@ -306,6 +314,10 @@ namespace QobuzDownloaderX // If there's no selected path. MessageBox.Show("No path selected!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + mp3Checkbox.Invoke(new Action(() => mp3Checkbox.Visible = true)); + flacLowCheckbox.Invoke(new Action(() => flacLowCheckbox.Visible = true)); + flacMidCheckbox.Invoke(new Action(() => flacMidCheckbox.Visible = true)); + flacHighCheckbox.Invoke(new Action(() => flacHighCheckbox.Visible = true)); downloadButton.Invoke(new Action(() => downloadButton.Enabled = true)); return; } @@ -322,6 +334,10 @@ namespace QobuzDownloaderX #region Getting Type of URL private void getLinkTypeBG_DoWork(object sender, DoWorkEventArgs e) { + mp3Checkbox.Invoke(new Action(() => mp3Checkbox.Visible = false)); + flacLowCheckbox.Invoke(new Action(() => flacLowCheckbox.Visible = false)); + 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 == "") @@ -329,6 +345,10 @@ namespace QobuzDownloaderX // If there is NOT a saved path. output.Invoke(new Action(() => output.Text = String.Empty)); output.Invoke(new Action(() => output.AppendText("No path has been set! Remember to Choose a Folder!\r\n"))); + mp3Checkbox.Invoke(new Action(() => mp3Checkbox.Visible = true)); + flacLowCheckbox.Invoke(new Action(() => flacLowCheckbox.Visible = true)); + flacMidCheckbox.Invoke(new Action(() => flacMidCheckbox.Visible = true)); + flacHighCheckbox.Invoke(new Action(() => flacHighCheckbox.Visible = true)); downloadButton.Invoke(new Action(() => downloadButton.Enabled = true)); return; } @@ -353,11 +373,19 @@ namespace QobuzDownloaderX { downloadDiscogBG.RunWorkerAsync(); } + else if (linkType == "label") + { + downloadLabelBG.RunWorkerAsync(); + } else if (linkType == "playlist") { // Say what isn't available at the moment. output.Invoke(new Action(() => output.Text = String.Empty)); output.Invoke(new Action(() => output.AppendText("Downloading playlists or artists is not available right now. Maybe in the future. Sorry."))); + mp3Checkbox.Invoke(new Action(() => mp3Checkbox.Visible = true)); + flacLowCheckbox.Invoke(new Action(() => flacLowCheckbox.Visible = true)); + flacMidCheckbox.Invoke(new Action(() => flacMidCheckbox.Visible = true)); + flacHighCheckbox.Invoke(new Action(() => flacHighCheckbox.Visible = true)); downloadButton.Invoke(new Action(() => downloadButton.Enabled = true)); return; } @@ -366,6 +394,10 @@ namespace QobuzDownloaderX // Say what isn't available at the moment. output.Invoke(new Action(() => output.Text = String.Empty)); output.Invoke(new Action(() => output.AppendText("URL not understood. Is there a typo?"))); + mp3Checkbox.Invoke(new Action(() => mp3Checkbox.Visible = true)); + flacLowCheckbox.Invoke(new Action(() => flacLowCheckbox.Visible = true)); + flacMidCheckbox.Invoke(new Action(() => flacMidCheckbox.Visible = true)); + flacHighCheckbox.Invoke(new Action(() => flacHighCheckbox.Visible = true)); downloadButton.Invoke(new Action(() => downloadButton.Enabled = true)); return; } @@ -541,6 +573,10 @@ namespace QobuzDownloaderX output.Invoke(new Action(() => output.AppendText("ERROR: 404\r\n"))); output.Invoke(new Action(() => output.AppendText("Error message is \"No result matching given argument\"\r\n"))); output.Invoke(new Action(() => output.AppendText("This could mean either the link is invalid, or isn't available in the region you're downloading from (even if the account is in the correct region). If the latter is true, use a VPN for the region it's available in to download."))); + mp3Checkbox.Invoke(new Action(() => mp3Checkbox.Visible = true)); + flacLowCheckbox.Invoke(new Action(() => flacLowCheckbox.Visible = true)); + flacMidCheckbox.Invoke(new Action(() => flacMidCheckbox.Visible = true)); + flacHighCheckbox.Invoke(new Action(() => flacHighCheckbox.Visible = true)); downloadButton.Invoke(new Action(() => downloadButton.Enabled = true)); return; } @@ -567,8 +603,8 @@ namespace QobuzDownloaderX string decodedAlbumArtist = DecodeEncodedNonAsciiCharacters(unicodeAlbumArtist); albumArtist = decodedAlbumArtist; - albumArtist = albumArtist.Replace(@"\\", @"\").Replace(@"\/", @"/"); - var albumArtistPath = albumArtist.Replace(@"\", "-").Replace(@"/", "-").Replace("\"", "''").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-"); + albumArtist = albumArtist.Replace("\\\"", "\"").Replace(@"\\/", @"/").Replace(@"\\", @"\").Replace(@"\/", @"/"); + var albumArtistPath = albumArtist.Replace(@"\", "-").Replace(@"/", "-").Replace("\\\"", "-").Replace("\\\"", "-").Replace("\"", "-").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-"); // Display album artist in text box under cover art. albumArtistTextBox.Invoke(new Action(() => albumArtistTextBox.Text = albumArtist)); @@ -588,8 +624,8 @@ namespace QobuzDownloaderX string decodedPerformerName = DecodeEncodedNonAsciiCharacters(unicodePerformerName); performerName = decodedPerformerName; - performerName = performerName.Replace(@"\\", @"\").Replace(@"\/", @"/"); - var performerNamePath = performerName.Replace(@"\", "-").Replace(@"/", "-").Replace("\"", "''").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-"); + performerName = performerName.Replace("\\\"", "\"").Replace(@"\\/", @"/").Replace(@"\\", @"\").Replace(@"\/", @"/"); + var performerNamePath = performerName.Replace("\\\"", "-").Replace("\"", "-").Replace(@"\", "-").Replace(@"/", "-").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-"); // If name goes over 200 characters, limit it to 200 if (performerNamePath.Length > MaxLength) @@ -610,7 +646,7 @@ namespace QobuzDownloaderX string decodedComposerName = DecodeEncodedNonAsciiCharacters(unicodeComposerName); composerName = decodedComposerName; - composerName = composerName.Replace(@"\\", @"\").Replace(@"\/", @"/"); + composerName = composerName.Replace("\\\"", "\"").Replace(@"\\/", @"/").Replace(@"\\", @"\").Replace(@"\/", @"/"); // Album Name tag var albumNameLog = Regex.Match(trackRequest, "\"title\":\"(?.*?)\",\\\"").Groups; @@ -621,8 +657,8 @@ namespace QobuzDownloaderX string decodedAlbumName = DecodeEncodedNonAsciiCharacters(unicodeAlbumName); albumName = decodedAlbumName; - albumName = albumName.Replace(@"\\", @"\").Replace(@"\/", @"/"); - var albumNamePath = albumName.Replace(@"\", "-").Replace(@"/", "-").Replace("\"", "''").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-"); + albumName = albumName.Replace("\\\"", "\"").Replace(@"\\/", @"/").Replace(@"\\", @"\").Replace(@"\/", @"/"); + var albumNamePath = albumName.Replace("\\\"", "-").Replace("\"", "-").Replace(@"\", "-").Replace(@"/", "-").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-"); // Display album name in text box under cover art. albumTextBox.Invoke(new Action(() => albumTextBox.Text = albumName)); @@ -643,8 +679,8 @@ namespace QobuzDownloaderX string decodedTrackName = DecodeEncodedNonAsciiCharacters(unicodeTrackName); trackName = decodedTrackName; - trackName = trackName.Replace(@"\\", @"\").Replace(@"\/", @"/"); - var trackNamePath = trackName.Replace(@"\", "-").Replace(@"/", "-").Replace("\"", "''").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-"); + trackName = trackName.Replace("\\\"", "\"").Replace(@"\\/", @"/").Replace(@"\\", @"\").Replace(@"\/", @"/"); + var trackNamePath = trackName.Replace("\\\"", "-").Replace("\"", "-").Replace(@"\", "-").Replace(@"/", "-").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-"); // If name goes over 200 characters, limit it to 200 if (trackNamePath.Length > MaxLength) @@ -661,8 +697,8 @@ namespace QobuzDownloaderX string decodedVersionName = DecodeEncodedNonAsciiCharacters(unicodeVersionName); versionName = decodedVersionName; - versionName = versionName.Replace(@"\\", @"\").Replace(@"\/", @"/"); - var versionNamePath = versionName.Replace(@"\", "-").Replace(@"/", "-").Replace("\"", "''").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-"); + versionName = versionName.Replace("\\\"", "\"").Replace(@"\\/", @"/").Replace(@"\\", @"\").Replace(@"\/", @"/"); + var versionNamePath = versionName.Replace("\\\"", "-").Replace("\"", "-").Replace(@"\", "-").Replace(@"/", "-").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-"); // Genre tag var genreLog = Regex.Match(trackRequest, "\"genre\":{\"id\":(?.*?),\"color\":\"(?.*?)\",\"name\":\"(?.*?)\",\\\"").Groups; @@ -671,7 +707,7 @@ namespace QobuzDownloaderX // For converting unicode characters to ASCII string unicodeGenre = genre; string decodedGenre = DecodeEncodedNonAsciiCharacters(unicodeGenre); - genre = decodedGenre; + genre = decodedGenre.Replace("\\\"", "\"").Replace(@"\\/", @"/").Replace(@"\\", @"\").Replace(@"\/", @"/"); // Release Date tag, grabs the available "stream" date var releaseDateLog = Regex.Match(trackRequest, "\"release_date_stream\":\"(?.*?)\",\\\"").Groups; @@ -689,7 +725,7 @@ namespace QobuzDownloaderX string decodedCopyright = DecodeEncodedNonAsciiCharacters(unicodeCopyright); copyright = decodedCopyright; - copyright = copyright.Replace(@"\\", @"\").Replace(@"\/", @"/").Replace(@"\u2117", @"℗"); + copyright = copyright.Replace("\\\"", "\"").Replace(@"\\/", @"/").Replace(@"\\", @"\").Replace(@"\/", @"/").Replace(@"\u2117", @"℗"); // UPC tag var upcLog = Regex.Match(trackRequest, "\"upc\":\"(?.*?)\",\\\"").Groups; @@ -1412,6 +1448,10 @@ namespace QobuzDownloaderX output.Invoke(new Action(() => output.AppendText("Track Download ERROR. Information below.\r\n\r\n"))); output.Invoke(new Action(() => output.AppendText(error))); output.Invoke(new Action(() => output.AppendText("\r\n\r\nIf some tracks aren't available for streaming on the album you're trying to download, try to manually download the available tracks individually."))); + mp3Checkbox.Invoke(new Action(() => mp3Checkbox.Visible = true)); + flacLowCheckbox.Invoke(new Action(() => flacLowCheckbox.Visible = true)); + flacMidCheckbox.Invoke(new Action(() => flacMidCheckbox.Visible = true)); + flacHighCheckbox.Invoke(new Action(() => flacHighCheckbox.Visible = true)); downloadButton.Invoke(new Action(() => downloadButton.Enabled = true)); return; } @@ -1424,6 +1464,10 @@ namespace QobuzDownloaderX // Say that downloading is completed. output.Invoke(new Action(() => output.AppendText("\r\n\r\n"))); output.Invoke(new Action(() => output.AppendText("Downloading job completed! All downloaded files will be located in your chosen path."))); + mp3Checkbox.Invoke(new Action(() => mp3Checkbox.Visible = true)); + flacLowCheckbox.Invoke(new Action(() => flacLowCheckbox.Visible = true)); + flacMidCheckbox.Invoke(new Action(() => flacMidCheckbox.Visible = true)); + flacHighCheckbox.Invoke(new Action(() => flacHighCheckbox.Visible = true)); downloadButton.Invoke(new Action(() => downloadButton.Enabled = true)); } catch (Exception ex) @@ -1432,6 +1476,10 @@ namespace QobuzDownloaderX output.Invoke(new Action(() => output.Text = String.Empty)); output.Invoke(new Action(() => output.AppendText("Failed to download (First Phase). Error information below.\r\n\r\n"))); output.Invoke(new Action(() => output.AppendText(error))); + mp3Checkbox.Invoke(new Action(() => mp3Checkbox.Visible = true)); + flacLowCheckbox.Invoke(new Action(() => flacLowCheckbox.Visible = true)); + flacMidCheckbox.Invoke(new Action(() => flacMidCheckbox.Visible = true)); + flacHighCheckbox.Invoke(new Action(() => flacHighCheckbox.Visible = true)); downloadButton.Invoke(new Action(() => downloadButton.Enabled = true)); return; } @@ -1444,6 +1492,1115 @@ namespace QobuzDownloaderX output.Invoke(new Action(() => output.Text = String.Empty)); output.Invoke(new Action(() => output.AppendText("Artist Download ERROR. Information below.\r\n\r\n"))); output.Invoke(new Action(() => output.AppendText(error))); + mp3Checkbox.Invoke(new Action(() => mp3Checkbox.Visible = true)); + flacLowCheckbox.Invoke(new Action(() => flacLowCheckbox.Visible = true)); + flacMidCheckbox.Invoke(new Action(() => flacMidCheckbox.Visible = true)); + flacHighCheckbox.Invoke(new Action(() => flacHighCheckbox.Visible = true)); + downloadButton.Invoke(new Action(() => downloadButton.Enabled = true)); + return; + } + #endregion + } + + // For downloading "label" links [IN DEV] + private async void downloadLabelBG_DoWork(object sender, DoWorkEventArgs e) + { + #region If URL has "label" + string loc = folderBrowserDialog.SelectedPath; + + trackIdString = albumId; + + WebRequest artistwr = WebRequest.Create("https://www.qobuz.com/api.json/0.2/label/get?label_id=" + albumId + "&extra=albums%2Cfocus&offset=0&limit=999999999999&app_id=" + appid + "&user_auth_token=" + userAuth); + + // Empty output, then say Starting Downloads. + output.Invoke(new Action(() => output.Text = String.Empty)); + output.Invoke(new Action(() => output.AppendText("LABEL DOWNLOADS MAY HAVE SOME ERRORS, THIS IS A NEW FEATURE. IF YOU RUN INTO AN ISSUE, PLEASE REPORT IT ON GITHUB!\r\n"))); + output.Invoke(new Action(() => output.AppendText("Grabbing Album IDs...\r\n\r\n"))); + + try + { + WebResponse artistws = artistwr.GetResponse(); + StreamReader artistsr = new StreamReader(artistws.GetResponseStream()); + + string artistRequest = artistsr.ReadToEnd(); + + // Grab Label Name + var labelNameLog = Regex.Match(artistRequest, "\"name\":\"(?