diff --git a/QobuzDownloaderX/Download/DownloadAlbum.cs b/QobuzDownloaderX/Download/DownloadAlbum.cs
index 1289376..db5f8cb 100644
--- a/QobuzDownloaderX/Download/DownloadAlbum.cs
+++ b/QobuzDownloaderX/Download/DownloadAlbum.cs
@@ -30,7 +30,7 @@ class DownloadAlbum
public Album QoAlbum = new Album();
public Item QoItem = new Item();
public QopenAPI.Stream QoStream = new QopenAPI.Stream();
-
+
public int paddedTrackLength { get; set; }
public int paddedDiscLength { get; set; }
@@ -45,27 +45,34 @@ class DownloadAlbum
public Item getTrackInfoLabels(string app_id, string track_id, string user_auth_token)
{
+ qbdlxForm._qbdlxForm.logger.Debug("Grabbing track info...");
try
{
// Grab album info with auth
getInfo.outputText = null;
getInfo.updateDownloadOutput("Getting Track Info...");
QoItem = QoService.TrackGetWithAuth(app_id, track_id, user_auth_token);
+ qbdlxForm._qbdlxForm.logger.Debug("Grabbed QoItem");
string album_id = QoItem.Album.Id;
+ qbdlxForm._qbdlxForm.logger.Info("Album ID: " + album_id);
QoAlbum = QoService.AlbumGetWithAuth(app_id, album_id, user_auth_token);
+ qbdlxForm._qbdlxForm.logger.Debug("Grabbed QoAlbum");
return QoItem;
}
- catch (Exception getAlbumInfoLabelsEx)
+ catch (Exception getTrackInfoLabelsEx)
{
- getInfo.updateDownloadOutput("\r\n" + getAlbumInfoLabelsEx.ToString());
- Console.WriteLine(getAlbumInfoLabelsEx);
+ qbdlxForm._qbdlxForm.logger.Error("Error occured during getTrackInfoLabels, error below:\r\n" + getTrackInfoLabelsEx);
+ getInfo.updateDownloadOutput("\r\n" + getTrackInfoLabelsEx.ToString());
+ Console.WriteLine(getTrackInfoLabelsEx);
return null;
}
}
public void downloadAlbum(string app_id, string album_id, string format_id, string audio_format, string user_auth_token, string app_secret, string downloadLocation, string artistTemplate, string albumTemplate, string trackTemplate, Album QoAlbum)
{
+ qbdlxForm._qbdlxForm.logger.Debug("Starting album download (downloadAlbum)");
// Clear output text from DownloadTrack to avoid text from previous downloads sticking around.
+ qbdlxForm._qbdlxForm.logger.Debug("Clearing output text");
downloadTrack.clearOutputText();
getInfo.outputText = null;
@@ -73,11 +80,15 @@ public void downloadAlbum(string app_id, string album_id, string format_id, stri
{
if (Settings.Default.streamableCheck == true)
{
+ qbdlxForm._qbdlxForm.logger.Debug("Steamable tag is set to false on Qobuz, and streamable check is enabled, skipping download");
getInfo.updateDownloadOutput("Release is not available for streaming.");
getInfo.updateDownloadOutput("\r\n" + "DOWNLOAD COMPLETE");
return;
}
- else { }
+ else
+ {
+ qbdlxForm._qbdlxForm.logger.Debug("Steamable tag is set to false on Qobuz, but streamable check is disabled, attempting download");
+ }
}
try
@@ -86,12 +97,16 @@ public void downloadAlbum(string app_id, string album_id, string format_id, stri
paddedDiscLength = padNumber.padTracks(QoAlbum);
downloadPath = downloadFile.createPath(downloadLocation, artistTemplate, albumTemplate, trackTemplate, null, null, paddedTrackLength, paddedDiscLength, QoAlbum, null, null);
+ qbdlxForm._qbdlxForm.logger.Debug("Download path: " + downloadPath);
try
{
+ qbdlxForm._qbdlxForm.logger.Debug("Downloading artwork...");
downloadFile.downloadArtwork(downloadPath, QoAlbum);
+ qbdlxForm._qbdlxForm.logger.Debug("Artwork download complete");
}
- catch {
+ catch (Exception artworkEx) {
+ qbdlxForm._qbdlxForm.logger.Error("Artwork download failed, error below:\r\n" + artworkEx);
Console.WriteLine("Unable to download artwork");
}
@@ -100,47 +115,55 @@ public void downloadAlbum(string app_id, string album_id, string format_id, stri
{
try
{
+ qbdlxForm._qbdlxForm.logger.Debug("Downloading track...");
downloadTrack.downloadTrack(app_id, album_id, format_id, audio_format, user_auth_token, app_secret, downloadLocation, artistTemplate, albumTemplate, trackTemplate, QoAlbum, QoService.TrackGetWithAuth(app_id, item.Id.ToString(), user_auth_token));
+ qbdlxForm._qbdlxForm.logger.Debug("Track download complete");
}
- catch (Exception downloadAlbumEx)
+ catch (Exception downloadTrackEx)
{
- getInfo.updateDownloadOutput("\r\n" + downloadAlbumEx);
- Console.WriteLine(downloadAlbumEx);
+ qbdlxForm._qbdlxForm.logger.Error("Track download failed, error below:\r\n" + downloadTrackEx);
+ getInfo.updateDownloadOutput("\r\n" + downloadTrackEx);
+ Console.WriteLine(downloadTrackEx);
return;
}
}
- // Delete image used for embedded artwork
+ // Delete image used for embedding artwork
try
{
+ qbdlxForm._qbdlxForm.logger.Debug("Deleting artwork used for embedding");
System.IO.File.Delete(downloadPath + qbdlxForm._qbdlxForm.embeddedArtSize + @".jpg");
}
catch
{
- Console.WriteLine("Unable to delete artwork");
+ qbdlxForm._qbdlxForm.logger.Warning("Unable to delete artwork used for embedding");
}
try
{
foreach (var goody in QoAlbum.Goodies)
{
+ qbdlxForm._qbdlxForm.logger.Debug("Goodies found, attempting to download...");
getInfo.updateDownloadOutput("Goodies found, attempting to download...");
if (goody.Url == null)
{
+ qbdlxForm._qbdlxForm.logger.Warning("No URL found for the goody, skipping");
Console.WriteLine("No goody URL, skipping");
getInfo.updateDownloadOutput(" No download URL found, skipping" + "\r\n");
}
else
{
+ qbdlxForm._qbdlxForm.logger.Debug("Downloading goody...");
Console.WriteLine("Downloading goody");
downloadFile.downloadGoody(downloadPath, QoAlbum, goody);
+ qbdlxForm._qbdlxForm.logger.Debug("Goody download complete");
getInfo.updateDownloadOutput(" DONE" + "\r\n");
}
}
}
catch
{
-
+ qbdlxForm._qbdlxForm.logger.Warning("No goodies found, or goodies failed to download");
}
//if (Settings.Default.fixMD5s == true)
@@ -154,9 +177,11 @@ public void downloadAlbum(string app_id, string album_id, string format_id, stri
// Say the downloading is finished when it's completed.
getInfo.outputText = qbdlxForm._qbdlxForm.downloadOutput.Text;
+ qbdlxForm._qbdlxForm.logger.Debug("All downloads completed!");
getInfo.updateDownloadOutput("\r\n" + "DOWNLOAD COMPLETE");
// JAM.S Post Template Export, not really useful for normal users.
+ qbdlxForm._qbdlxForm.logger.Debug("Writing a post template to post_template.txt");
var templateDate = DateTime.Parse(QoAlbum.ReleaseDateOriginal).ToString("MMMM d, yyyy");
File.WriteAllText("post_template.txt", String.Empty);
using (StreamWriter sw = File.AppendText("post_template.txt"))
@@ -188,16 +213,19 @@ public void downloadAlbum(string app_id, string album_id, string format_id, stri
sw.WriteLine("[spoiler=" + QoAlbum.Label.Name + " / " + QoAlbum.UPC + " / WEB]");
sw.WriteLine("[format=FLAC / Lossless (24bit/??kHz) / WEB]");
sw.WriteLine("Uploaded by [USER=2]@AiiR[/USER]");
+ sw.WriteLine("");
sw.WriteLine("DOWNLOAD");
sw.WriteLine("REPLACE THIS WITH URL");
sw.WriteLine("[/format]");
sw.WriteLine("[format=FLAC / Lossless / WEB]");
sw.WriteLine("Uploaded by [USER=2]@AiiR[/USER]");
+ sw.WriteLine("");
sw.WriteLine("DOWNLOAD");
sw.WriteLine("REPLACE THIS WITH URL");
sw.WriteLine("[/format]");
sw.WriteLine("[format=MP3 / 320 / WEB]");
sw.WriteLine("Uploaded by [USER=2]@AiiR[/USER]");
+ sw.WriteLine("");
sw.WriteLine("DOWNLOAD");
sw.WriteLine("REPLACE THIS WITH URL");
sw.WriteLine("[/format]");
@@ -211,6 +239,7 @@ public void downloadAlbum(string app_id, string album_id, string format_id, stri
}
catch (Exception downloadAlbumEx)
{
+ qbdlxForm._qbdlxForm.logger.Error("Error occured during downloadAlbum, error below:\r\n" + downloadAlbumEx);
Console.WriteLine(downloadAlbumEx);
return;
}
diff --git a/QobuzDownloaderX/Download/DownloadFile.cs b/QobuzDownloaderX/Download/DownloadFile.cs
index 4dfebbb..23e8099 100644
--- a/QobuzDownloaderX/Download/DownloadFile.cs
+++ b/QobuzDownloaderX/Download/DownloadFile.cs
@@ -32,14 +32,16 @@ public string createPath(string downloadLocation, string artistTemplate, string
{
if (QoPlaylist == null)
{
+ qbdlxForm._qbdlxForm.logger.Debug("Using non-playlist path");
artistTemplateConverted = renameTemplates.renameTemplates(artistTemplate, paddedTrackLength, paddedDiscLength, qbdlxForm._qbdlxForm.audio_format, QoAlbum, null, null);
albumTemplateConverted = renameTemplates.renameTemplates(albumTemplate, paddedTrackLength, paddedDiscLength, qbdlxForm._qbdlxForm.audio_format, QoAlbum, null, null);
downloadPath = Path.Combine(downloadLocation, artistTemplateConverted, albumTemplateConverted.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar);
-
+
return downloadPath;
}
else
{
+ qbdlxForm._qbdlxForm.logger.Debug("Using playlist path");
playlistTemplateConverted = renameTemplates.renameTemplates(playlistTemplate, paddedTrackLength, paddedDiscLength, qbdlxForm._qbdlxForm.audio_format, null, null, QoPlaylist);
downloadPath = Path.Combine(downloadLocation, playlistTemplateConverted.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar);
@@ -49,23 +51,26 @@ public string createPath(string downloadLocation, string artistTemplate, string
public void downloadStream(string streamUrl, string downloadPath, string filePath, string audio_format, Album QoAlbum, Item QoItem)
{
+ qbdlxForm._qbdlxForm.logger.Debug("Writing temp file to qbdlx-temp/qbdlx_downloading-" + QoItem.Id.ToString() + audio_format);
// Create a temp directory inside the exe location, to download files to.
- string tempFile = Path.Combine(@"qbdlx-temp", "qbdlx_downloading" + audio_format);
+ string tempFile = Path.Combine(@"qbdlx-temp", "qbdlx_downloading-" + QoItem.Id.ToString() + audio_format);
Directory.CreateDirectory(@"qbdlx-temp");
using (var client = new WebClient())
{
// Set path for downloaded artwork.
artworkPath = downloadPath + qbdlxForm._qbdlxForm.embeddedArtSize + @".jpg";
+ qbdlxForm._qbdlxForm.logger.Debug("Artwork path: " + artworkPath);
// Use secure connection
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
// Download to the temp directory that was made, and tag the file
- Console.WriteLine("Downloading");
+ qbdlxForm._qbdlxForm.logger.Debug("Downloading to temp file...");
Console.WriteLine(filePath);
if (QoAlbum.MediaCount > 1)
{
+ qbdlxForm._qbdlxForm.logger.Debug("More than 1 volume, using subfolders for each volume");
Directory.CreateDirectory(Path.GetDirectoryName(downloadPath + "CD " + QoItem.MediaNumber.ToString().PadLeft(paddingNumbers.padDiscs(QoAlbum), '0') + Path.DirectorySeparatorChar));
}
else
@@ -83,9 +88,11 @@ public void downloadStream(string streamUrl, string downloadPath, string filePat
}
}
+ qbdlxForm._qbdlxForm.logger.Debug("Starting file metadata tagging");
TagFile.WriteToFile(tempFile, artworkPath, QoAlbum, QoItem);
// Move the file with the full name (Zeta Long Paths to avoid MAX_PATH error)
+ qbdlxForm._qbdlxForm.logger.Debug("Moving temp file to - " + filePath);
ZetaLongPaths.ZlpIOHelper.MoveFile(tempFile, filePath);
}
}
@@ -98,15 +105,17 @@ public void downloadArtwork(string downloadPath, Album QoAlbum)
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
// Download cover art (600x600) to the download path
- Console.WriteLine("Downloading Cover Art");
+ qbdlxForm._qbdlxForm.logger.Debug("Downloading Cover Art");
Directory.CreateDirectory(Path.GetDirectoryName(downloadPath));
if (File.Exists(downloadPath + @"Cover.jpg") == false)
{
+ qbdlxForm._qbdlxForm.logger.Debug("Saved artwork Cover.jpg not found, downloading");
try { client.DownloadFile(QoAlbum.Image.Large.Replace("_600", "_" + qbdlxForm._qbdlxForm.savedArtSize), downloadPath + @"Cover.jpg"); } catch { Console.WriteLine("Failed to Download Cover Art"); }
}
if (File.Exists(downloadPath + qbdlxForm._qbdlxForm.embeddedArtSize + @".jpg") == false)
{
+ qbdlxForm._qbdlxForm.logger.Debug("Saved artwork for embedding not found, downloading");
try { client.DownloadFile(QoAlbum.Image.Large.Replace("_600", "_" + qbdlxForm._qbdlxForm.embeddedArtSize), downloadPath + qbdlxForm._qbdlxForm.embeddedArtSize + @".jpg"); } catch { Console.WriteLine("Failed to Download Cover Art"); }
}
}
@@ -119,8 +128,7 @@ public void downloadGoody(string downloadPath, Album QoAlbum, Goody QoGoody)
// Use secure connection
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
- // Download cover art (600x600) to the download path
- Console.WriteLine("Downloading Goody");
+ // Download goody to the download path
Directory.CreateDirectory(Path.GetDirectoryName(downloadPath));
client.DownloadFile(QoGoody.Url, downloadPath + QoAlbum.Title + " (" + QoGoody.Id + @").pdf");
}
diff --git a/QobuzDownloaderX/Download/DownloadTrack.cs b/QobuzDownloaderX/Download/DownloadTrack.cs
index fa9c2e5..1a8f742 100644
--- a/QobuzDownloaderX/Download/DownloadTrack.cs
+++ b/QobuzDownloaderX/Download/DownloadTrack.cs
@@ -165,7 +165,7 @@ public void downloadTrack(string app_id, string album_id, string format_id, stri
{
downloadPath = downloadFile.createPath(downloadLocation, artistTemplate, albumTemplate, trackTemplate, null, null, paddedTrackLength, paddedDiscLength, QoAlbum, QoItem, null);
- try { downloadFile.downloadArtwork(downloadPath, QoAlbum); } catch { Console.WriteLine("Failed to Download Cover Art"); }
+ try { downloadFile.downloadArtwork(downloadPath, QoAlbum); } catch { qbdlxForm._qbdlxForm.logger.Error("Failed to Download Cover Art"); }
string trackTemplateConverted = renameTemplates.renameTemplates(trackTemplate, paddedTrackLength, paddedDiscLength, audio_format, QoAlbum, QoItem, null);
diff --git a/QobuzDownloaderX/Download/FixMD5.cs b/QobuzDownloaderX/Download/FixMD5.cs
index 8905550..bbfeaed 100644
--- a/QobuzDownloaderX/Download/FixMD5.cs
+++ b/QobuzDownloaderX/Download/FixMD5.cs
@@ -17,16 +17,14 @@ class FixMD5
public void fixMD5(string filePath, string flacEXEPath)
{
- Console.WriteLine("Attempting to fix unset MD5...");
+ qbdlxForm._qbdlxForm.logger.Debug("Attempting to fix unset MD5...");
driveLetter = filePath.Substring(0, 2);
- Console.WriteLine("Drive letter - " + driveLetter);
- Console.WriteLine("File Path - " + filePath);
- Console.WriteLine("FLAC exe Path - " + flacEXEPath);
cmdText = "/C echo Fixing unset MD5s... & \"" + flacEXEPath + "\" -f8 \"" + filePath + "\"";
- Console.WriteLine("Commands - " + cmdText);
+ qbdlxForm._qbdlxForm.logger.Debug("Commands - " + cmdText);
try
{
+ qbdlxForm._qbdlxForm.logger.Debug("Running cmd to run ffmpeg command to fix MD5");
Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
@@ -34,12 +32,12 @@ public void fixMD5(string filePath, string flacEXEPath)
cmd.Start();
cmd.WaitForExit();
outputResult = "COMPLETE";
+ qbdlxForm._qbdlxForm.logger.Debug("MD5 has been fixed for file!");
}
catch (Exception fixMD5ex)
{
outputResult = "Failed";
- Console.WriteLine("Failed to fix MD5s");
- Console.WriteLine(fixMD5ex);
+ qbdlxForm._qbdlxForm.logger.Error("Failed to fix MD5s, error below:\r\n" + fixMD5ex);
}
}
}
diff --git a/QobuzDownloaderX/Download/GetInfo.cs b/QobuzDownloaderX/Download/GetInfo.cs
index bc3fffc..781cfc8 100644
--- a/QobuzDownloaderX/Download/GetInfo.cs
+++ b/QobuzDownloaderX/Download/GetInfo.cs
@@ -51,16 +51,16 @@ public Artist getArtistInfo(string app_id, string artist_id, string user_auth_to
{
try
{
- // Grab album info with auth
+ // Grab artist info with auth
outputText = null;
- Console.WriteLine("Getting Artist Info...");
+ qbdlxForm._qbdlxForm.logger.Debug("Getting artist Info...");
QoArtist = QoService.ArtistGetWithAuth(app_id, artist_id, user_auth_token);
return QoArtist;
}
catch (Exception getArtistInfoEx)
{
updateDownloadOutput("\r\n" + getArtistInfoEx.ToString());
- Console.WriteLine(getArtistInfoEx);
+ qbdlxForm._qbdlxForm.logger.Error("Failed to get artist info, error below:\r\n" + getArtistInfoEx);
return null;
}
}
@@ -69,16 +69,16 @@ public QopenAPI.Label getLabelInfo(string app_id, string label_id, string user_a
{
try
{
- // Grab album info with auth
+ // Grab label info with auth
outputText = null;
- Console.WriteLine("Getting Label Info...");
+ qbdlxForm._qbdlxForm.logger.Debug("Getting label Info...");
QoLabel = QoService.LabelGetWithAuth(app_id, label_id, "albums", 500, 0, user_auth_token);
return QoLabel;
}
catch (Exception getLabelInfoEx)
{
updateDownloadOutput("\r\n" + getLabelInfoEx.ToString());
- Console.WriteLine(getLabelInfoEx);
+ qbdlxForm._qbdlxForm.logger.Error("Failed to get label info, error below:\r\n" + getLabelInfoEx);
return null;
}
}
@@ -87,16 +87,16 @@ public Favorites getFavoritesInfo(string app_id, string user_id, string type, st
{
try
{
- // Grab album info with auth
+ // Grab favorites info with auth
outputText = null;
- Console.WriteLine("Getting Favorites Info...");
+ qbdlxForm._qbdlxForm.logger.Debug("Getting favorites Info...");
QoFavorites = QoService.FavoriteGetUserFavoritesWithAuth(app_id, user_id, type, 500, 0, user_auth_token);
return QoFavorites;
}
catch (Exception getFavoritesInfoEx)
{
updateDownloadOutput("\r\n" + getFavoritesInfoEx.ToString());
- Console.WriteLine(getFavoritesInfoEx);
+ qbdlxForm._qbdlxForm.logger.Error("Failed to get favorites info, error below:\r\n" + getFavoritesInfoEx);
return null;
}
}
@@ -105,9 +105,9 @@ public Item getTrackInfoLabels(string app_id, string track_id, string user_auth_
{
try
{
- // Grab album info with auth
+ // Grab track info with auth
outputText = null;
- Console.WriteLine("Getting Track Info...");
+ qbdlxForm._qbdlxForm.logger.Debug("Getting track Info...");
QoItem = QoService.TrackGetWithAuth(app_id, track_id, user_auth_token);
string album_id = QoItem.Album.Id;
QoAlbum = QoService.AlbumGetWithAuth(app_id, album_id, user_auth_token);
@@ -116,7 +116,7 @@ public Item getTrackInfoLabels(string app_id, string track_id, string user_auth_
catch (Exception getTrackInfoLabelsEx)
{
updateDownloadOutput("\r\n" + getTrackInfoLabelsEx.ToString());
- Console.WriteLine(getTrackInfoLabelsEx);
+ qbdlxForm._qbdlxForm.logger.Error("Failed to get track info, error below:\r\n" + getTrackInfoLabelsEx);
return null;
}
}
@@ -127,14 +127,14 @@ public Album getAlbumInfoLabels(string app_id, string album_id, string user_auth
{
// Grab album info with auth
outputText = null;
- Console.WriteLine("Getting Album Info...");
+ qbdlxForm._qbdlxForm.logger.Debug("Getting album Info...");
QoAlbum = QoService.AlbumGetWithAuth(app_id, album_id, user_auth_token);
return QoAlbum;
}
catch (Exception getAlbumInfoLabelsEx)
{
updateDownloadOutput("\r\n" + getAlbumInfoLabelsEx.ToString());
- Console.WriteLine(getAlbumInfoLabelsEx);
+ qbdlxForm._qbdlxForm.logger.Error("Failed to get album info, error below:\r\n" + getAlbumInfoLabelsEx);
return null;
}
}
@@ -143,16 +143,16 @@ public Playlist getPlaylistInfoLabels(string app_id, string playlist_id, string
{
try
{
- // Grab album info with auth
+ // Grab playlist info with auth
outputText = null;
- Console.WriteLine("Getting Playlist Info...");
+ qbdlxForm._qbdlxForm.logger.Debug("Getting playlist Info...");
QoPlaylist = QoService.PlaylistGetWithAuth(app_id, playlist_id, "tracks", 500, 0, user_auth_token);
return QoPlaylist;
}
catch (Exception getPlaylistInfoLabelsEx)
{
updateDownloadOutput("\r\n" + getPlaylistInfoLabelsEx.ToString());
- Console.WriteLine(getPlaylistInfoLabelsEx);
+ qbdlxForm._qbdlxForm.logger.Error("Failed to get playlist info, error below:\r\n" + getPlaylistInfoLabelsEx);
return null;
}
}
diff --git a/QobuzDownloaderX/Download/RenameTemplates.cs b/QobuzDownloaderX/Download/RenameTemplates.cs
index 6179c16..c10ff9e 100644
--- a/QobuzDownloaderX/Download/RenameTemplates.cs
+++ b/QobuzDownloaderX/Download/RenameTemplates.cs
@@ -20,6 +20,8 @@ public string GetSafeFilename(string filename)
public string renameTemplates(string template, int paddedTrackLength, int paddedDiscLength, string fileFormat, Album QoAlbum, Item QoItem, Playlist QoPlaylist)
{
+ qbdlxForm._qbdlxForm.logger.Debug("Renaming user template - " + template);
+
// Keep backslashes to be used to make new folders
if (template.Contains(Path.DirectorySeparatorChar))
{
@@ -105,7 +107,7 @@ public string renameTemplates(string template, int paddedTrackLength, int padded
}
}
-
+ qbdlxForm._qbdlxForm.logger.Debug("Template output - " + template.Replace("{backslash}", @"\").Replace("{forwardslash}", @"/"));
return template.Replace("{backslash}", @"\").Replace("{forwardslash}", @"/");
}
}
diff --git a/QobuzDownloaderX/Download/SearchPanelHelper.cs b/QobuzDownloaderX/Download/SearchPanelHelper.cs
new file mode 100644
index 0000000..01fda50
--- /dev/null
+++ b/QobuzDownloaderX/Download/SearchPanelHelper.cs
@@ -0,0 +1,247 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using QopenAPI;
+using QobuzDownloaderX.Properties;
+using QobuzDownloaderX.Download;
+using System.Reflection;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Diagnostics;
+
+namespace QobuzDownloaderX.Download
+{
+ public class SearchResultRow
+ {
+ public string ThumbnailUrl { get; set; }
+ public string Artist { get; set; }
+ public string Title { get; set; }
+ public bool Explicit { get; set; }
+ public string FormattedDuration { get; set; }
+ public string WebPlayerUrl { get; set; }
+ public string StoreUrl { get; set; }
+ public int TrackCount { get; set; }
+ public string ReleaseDate { get; set; }
+ public string FormattedQuality { get; set; }
+ }
+
+ class SearchPanelHelper
+ {
+ public Service QoService = new Service();
+ public User QoUser = new User();
+ public Item QoItem = new Item();
+ public SearchAlbumResult QoAlbumSearch = new SearchAlbumResult();
+ public SearchTrackResult QoTrackSearch = new SearchTrackResult();
+
+ public void PopulateTableAlbums(qbdlxForm mainForm, SearchAlbumResult QoAlbumSearch)
+ {
+ // Access the "items" array from the response
+ var albums = QoAlbumSearch.Albums.Items;
+
+ TableLayoutPanel searchResultsTablePanel = mainForm.searchResultsTablePanel;
+ searchResultsTablePanel.Controls.Clear();
+ searchResultsTablePanel.ColumnCount = 5; // Artwork, Artist, Title, Quality, Button
+ searchResultsTablePanel.RowCount = albums.Count(); // Set row count based on the number of albums
+ searchResultsTablePanel.AutoSize = true;
+
+ // Set ColumnStyles to define the size of each column
+ searchResultsTablePanel.ColumnStyles.Clear();
+ searchResultsTablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 70F)); // Artwork column
+ searchResultsTablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 200F)); // Artist name
+ searchResultsTablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 200F)); // Album title
+ searchResultsTablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 140F)); // Quality
+ searchResultsTablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 70F)); // Button column
+
+ int rowIndex = 0;
+
+ foreach (var album in albums)
+ {
+ // Add PictureBox for artwork
+ PictureBox artwork = new PictureBox();
+ artwork.SizeMode = PictureBoxSizeMode.StretchImage;
+ try { artwork.Load(album.Image.Large.ToString()); /* Using the thumbnail URL */ } catch { artwork.Image = Resources.qbdlx_new; /* Use QBDLX Icon as fallback */ }
+ artwork.Width = 65;
+ artwork.Height = 65;
+ artwork.Anchor = AnchorStyles.None; // Center both horizontally and vertically
+ searchResultsTablePanel.Controls.Add(artwork, 0, rowIndex);
+
+ // Add Label for artist name
+ System.Windows.Forms.Label artistName = new System.Windows.Forms.Label();
+ artistName.Text = album.Artist.Name.ToString();
+ artistName.AutoSize = true; // Disable auto-sizing to allow wrapping
+ /*artistName.MaximumSize = new Size(0, 0);*/ // Word-wrap if needed
+ artistName.TextAlign = ContentAlignment.MiddleCenter; // Center text horizontally and vertically
+ artistName.Anchor = AnchorStyles.None; // Center within the cell
+ artistName.ForeColor = Color.FromArgb(147, 147, 147); // Set text color
+ artistName.Font = new Font("Nirmala UI", 10F, FontStyle.Regular); // Set font size and style
+ searchResultsTablePanel.Controls.Add(artistName, 1, rowIndex);
+
+ // Add Label for album title
+ System.Windows.Forms.Label albumTitle = new System.Windows.Forms.Label();
+ albumTitle.Text = album.Title.ToString().TrimEnd();
+ if (album.Version != null) { albumTitle.Text = albumTitle.Text + " (" + album.Version + ")"; }
+ albumTitle.AutoSize = true;
+ /*albumTitle.MaximumSize = new Size(0, 0);*/ // Allow word-wrap
+ albumTitle.TextAlign = ContentAlignment.MiddleCenter; // Center text horizontally and vertically
+ albumTitle.Anchor = AnchorStyles.None; // Center within the cell
+ albumTitle.ForeColor = Color.FromArgb(147, 147, 147); // Set text color
+ albumTitle.Font = new Font("Nirmala UI", 10F, FontStyle.Regular); // Set font size and style
+ searchResultsTablePanel.Controls.Add(albumTitle, 2, rowIndex);
+
+ // Add Label for quality
+ System.Windows.Forms.Label qualityLabel = new System.Windows.Forms.Label();
+ qualityLabel.Text = album.MaximumBitDepth.ToString() + "bit/" + album.MaximumSamplingRate + "kHz";
+ qualityLabel.AutoSize = true;
+ qualityLabel.MaximumSize = new Size(0, 0); // Allow word-wrap
+ qualityLabel.TextAlign = ContentAlignment.MiddleCenter; // Center text horizontally and vertically
+ qualityLabel.Anchor = AnchorStyles.None; // Center within the cell
+
+ // Set text color
+ if (qualityLabel.Text.Contains("24bit"))
+ {
+ qualityLabel.ForeColor = Color.FromArgb(253, 202, 28);
+ }
+ else
+ {
+ qualityLabel.ForeColor = Color.FromArgb(147, 147, 147);
+ }
+
+ qualityLabel.Font = new Font("Nirmala UI", 10F, FontStyle.Regular); // Set font size and style
+ searchResultsTablePanel.Controls.Add(qualityLabel, 3, rowIndex);
+
+ // Add Button for selecting album ID
+ Button selectButton = new Button();
+ selectButton.Text = "GET";
+ selectButton.ForeColor = Color.FromArgb(147, 147, 147); // Set button text color
+ selectButton.BackColor = Color.FromArgb(13, 13, 13); // Set button background color
+ selectButton.Font = new Font("Nirmala UI", 8F, FontStyle.Regular); // Set font size and style
+ selectButton.FlatStyle = FlatStyle.Flat; // Set FlatStyle to Flat
+ selectButton.FlatAppearance.BorderSize = 0; // Set border size
+ selectButton.FlatAppearance.MouseOverBackColor = Color.FromArgb(18, 18, 18); // Set background color when hovering
+ selectButton.FlatAppearance.MouseDownBackColor = Color.FromArgb(25, 25, 25); // Set background color when clicked
+ string albumLink = "https://play.qobuz.com/album/" + album.Id.ToString(); // Store the album link
+ selectButton.Click += (sender, e) => SendURL(mainForm, albumLink);
+ selectButton.Anchor = AnchorStyles.None; // Center the button
+ searchResultsTablePanel.Controls.Add(selectButton, 4, rowIndex);
+
+ rowIndex++;
+ }
+ }
+
+ public void PopulateTableTracks(qbdlxForm mainForm, SearchTrackResult QoTrackSearch)
+ {
+ // Access the "items" array from the response
+ var tracks = QoTrackSearch.Tracks.Items;
+
+ TableLayoutPanel searchResultsTablePanel = mainForm.searchResultsTablePanel;
+ searchResultsTablePanel.Controls.Clear();
+ searchResultsTablePanel.ColumnCount = 5; // Artwork, Artist, Title, Quality, Button
+ searchResultsTablePanel.RowCount = tracks.Count(); // Set row count based on the number of albums
+ searchResultsTablePanel.AutoSize = true;
+
+ // Set ColumnStyles to define the size of each column
+ searchResultsTablePanel.ColumnStyles.Clear();
+ searchResultsTablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 70F)); // Artwork column
+ searchResultsTablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 200F)); // Artist name
+ searchResultsTablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 200F)); // Track title
+ searchResultsTablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 140F)); // Quality
+ searchResultsTablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 70F)); // Button column
+
+ int rowIndex = 0;
+
+ foreach (var track in tracks)
+ {
+ // Add PictureBox for artwork
+ PictureBox artwork = new PictureBox();
+ artwork.SizeMode = PictureBoxSizeMode.StretchImage;
+ try { artwork.Load(track.Album.Image.Large.ToString()); /* Using the thumbnail URL */ } catch { artwork.Image = Resources.qbdlx_new; /* Use QBDLX Icon as fallback */ }
+ artwork.Width = 65;
+ artwork.Height = 65;
+ artwork.Anchor = AnchorStyles.None; // Center both horizontally and vertically
+ searchResultsTablePanel.Controls.Add(artwork, 0, rowIndex);
+
+ // Add Label for artist name
+ System.Windows.Forms.Label artistName = new System.Windows.Forms.Label();
+ artistName.Text = track.Performer.Name.ToString();
+ artistName.AutoSize = true; // Disable auto-sizing to allow wrapping
+ /*artistName.MaximumSize = new Size(0, 0);*/ // Word-wrap if needed
+ artistName.TextAlign = ContentAlignment.MiddleCenter; // Center text horizontally and vertically
+ artistName.Anchor = AnchorStyles.None; // Center within the cell
+ artistName.ForeColor = Color.FromArgb(147, 147, 147); // Set text color
+ artistName.Font = new Font("Nirmala UI", 10F, FontStyle.Regular); // Set font size and style
+ searchResultsTablePanel.Controls.Add(artistName, 1, rowIndex);
+
+ // Add Label for track title
+ System.Windows.Forms.Label trackTitle = new System.Windows.Forms.Label();
+ trackTitle.Text = track.Title.ToString().TrimEnd();
+ if (track.Version != null) { trackTitle.Text = trackTitle.Text + " (" + track.Version + ")"; }
+ trackTitle.AutoSize = true;
+ /*trackTitle.MaximumSize = new Size(0, 0);*/ // Allow word-wrap
+ trackTitle.TextAlign = ContentAlignment.MiddleCenter; // Center text horizontally and vertically
+ trackTitle.Anchor = AnchorStyles.None; // Center within the cell
+ trackTitle.ForeColor = Color.FromArgb(147, 147, 147); // Set text color
+ trackTitle.Font = new Font("Nirmala UI", 10F, FontStyle.Regular); // Set font size and style
+ searchResultsTablePanel.Controls.Add(trackTitle, 2, rowIndex);
+
+ // Add Label for quality
+ System.Windows.Forms.Label qualityLabel = new System.Windows.Forms.Label();
+ qualityLabel.Text = track.MaximumBitDepth.ToString() + "bit/" + track.MaximumSamplingRate + "kHz";
+ qualityLabel.AutoSize = true;
+ qualityLabel.MaximumSize = new Size(0, 0); // Allow word-wrap
+ qualityLabel.TextAlign = ContentAlignment.MiddleCenter; // Center text horizontally and vertically
+ qualityLabel.Anchor = AnchorStyles.None; // Center within the cell
+
+ // Set text color
+ if (qualityLabel.Text.Contains("24bit"))
+ {
+ qualityLabel.ForeColor = Color.FromArgb(253, 202, 28);
+ }
+ else
+ {
+ qualityLabel.ForeColor = Color.FromArgb(147, 147, 147);
+ }
+
+ qualityLabel.Font = new Font("Nirmala UI", 10F, FontStyle.Regular); // Set font size and style
+ searchResultsTablePanel.Controls.Add(qualityLabel, 3, rowIndex);
+
+ // Add Button for selecting album ID
+ Button selectButton = new Button();
+ selectButton.Text = "GET";
+ selectButton.ForeColor = Color.FromArgb(147, 147, 147); // Set button text color
+ selectButton.BackColor = Color.FromArgb(13, 13, 13); // Set button background color
+ selectButton.Font = new Font("Nirmala UI", 8F, FontStyle.Regular); // Set font size and style
+ selectButton.FlatStyle = FlatStyle.Flat; // Set FlatStyle to Flat
+ selectButton.FlatAppearance.BorderSize = 0; // Set border size
+ selectButton.FlatAppearance.MouseOverBackColor = Color.FromArgb(18, 18, 18); // Set background color when hovering
+ selectButton.FlatAppearance.MouseDownBackColor = Color.FromArgb(25, 25, 25); // Set background color when clicked
+ string trackLink = "https://open.qobuz.com/track/" + track.Id.ToString(); // Store the track link
+ selectButton.Click += (sender, e) => SendURL(mainForm, trackLink);
+ selectButton.Anchor = AnchorStyles.None; // Center the button
+ searchResultsTablePanel.Controls.Add(selectButton, 4, rowIndex);
+
+ rowIndex++;
+ }
+ }
+
+ public void SendURL(qbdlxForm mainForm, string url)
+ {
+ try
+ {
+ // Send URL to the input textbox, and start download
+ mainForm.logger.Debug("Sending URL to download panel, and starting download");
+ TextBox inputTextbox = mainForm.inputTextbox;
+ inputTextbox.Text = url;
+ inputTextbox.ForeColor = Color.FromArgb(200, 200, 200);
+ mainForm.downloaderButton_Click(this, EventArgs.Empty);
+ mainForm.getLinkType();
+ }
+ catch (Exception ex)
+ {
+ mainForm.logger.Error("Error on SendURL (SearchPanelHelper). Error below:\r\n" + ex);
+ return;
+ }
+ }
+ }
+}
diff --git a/QobuzDownloaderX/Download/TagFile.cs b/QobuzDownloaderX/Download/TagFile.cs
index 108fa40..43751b4 100644
--- a/QobuzDownloaderX/Download/TagFile.cs
+++ b/QobuzDownloaderX/Download/TagFile.cs
@@ -22,6 +22,7 @@ public static void WriteToFile(string tempPath, string artworkPath, Album QoAlbu
if (tempPath.Contains(".flac"))
{
+ qbdlxForm._qbdlxForm.logger.Debug("FLAC detected, setting FLAC specific tags");
if (Settings.Default.yearTag == true) { customTagsFLAC.SetField("DATE", QoAlbum.ReleaseDateOriginal); } // Release Date (FLAC)
if (Settings.Default.isrcTag == true) { customTagsFLAC.SetField("ISRC", QoItem.ISRC); } // ISRC (FLAC)
if (Settings.Default.typeTag == true) { customTagsFLAC.SetField("MEDIATYPE", QoAlbum.ProductType.ToUpper()); } // Type of release (FLAC)
@@ -31,6 +32,7 @@ public static void WriteToFile(string tempPath, string artworkPath, Album QoAlbu
}
else
{
+ qbdlxForm._qbdlxForm.logger.Debug("Non-FLAC detected, setting MP3 specific tags");
TagLib.Id3v2.Tag mp3Tag = (TagLib.Id3v2.Tag)file.GetTag(TagTypes.Id3v2, true);
UserTextInformationFrame barcodeFrame = UserTextInformationFrame.Get(mp3Tag, "BARCODE", true);
@@ -44,14 +46,14 @@ public static void WriteToFile(string tempPath, string artworkPath, Album QoAlbu
if (Settings.Default.labelTag == true) { mp3Tag.SetTextFrame("TPUB", QoAlbum.Label.Name); } // Record Label (MP3)
if (Settings.Default.typeTag == true) { mp3Tag.SetTextFrame("TMED", QoAlbum.ProductType.ToUpper()); } // Type of release (MP3)
}
-
+ qbdlxForm._qbdlxForm.logger.Debug("Writing all other tags");
if (Settings.Default.trackTitleTag == true) { file.Tag.Title = QoItem.Title; } // Track Title
if (Settings.Default.artistTag == true) { file.Tag.Performers = new[] { QoItem.Performer.Name }; } // Track Artist
if (Settings.Default.albumArtistTag == true) { if (QoAlbum.Artist.Name != null) { file.Tag.AlbumArtists = new[] { QoAlbum.Artist.Name }; } } // Album Artist
if (Settings.Default.genreTag == true) { file.Tag.Genres = new[] { QoAlbum.Genre.Name }; } // Genre
if (Settings.Default.albumTag == true) { if (QoAlbum.Version == null) { file.Tag.Album = QoAlbum.Title; } else { file.Tag.Album = QoAlbum.Title.TrimEnd() + " (" + QoAlbum.Version + ")"; } } // Album Title
if (Settings.Default.trackTitleTag == true) { if (QoItem.Version == null) { file.Tag.Title = QoItem.Title; } else { file.Tag.Title = QoItem.Title.TrimEnd() + " (" + QoItem.Version + ")"; } } // Track Title
- if (Settings.Default.composerTag == true) { try { file.Tag.Composers = new[] { QoItem.Composer.Name }; } catch { } } // Track Composer
+ if (Settings.Default.composerTag == true) { try { file.Tag.Composers = new[] { QoItem.Composer.Name }; } catch { qbdlxForm._qbdlxForm.logger.Warning("Failed to write track composer, usually means it wasn't available"); } } // Track Composer
if (Settings.Default.trackTag == true) { file.Tag.Track = (uint)QoItem.TrackNumber; } // Track Number
if (Settings.Default.totalTracksTag == true) { file.Tag.TrackCount = (uint)(QoAlbum.TracksCount); } // Total Tracks
if (Settings.Default.discTag == true) { file.Tag.Disc = (uint)QoItem.MediaNumber; } // Disc Number
@@ -62,6 +64,7 @@ public static void WriteToFile(string tempPath, string artworkPath, Album QoAlbu
{
try
{
+ qbdlxForm._qbdlxForm.logger.Debug("Attempting to embed artwork");
// Define cover art to use for file(s)
TagLib.Id3v2.AttachedPictureFrame pic = new TagLib.Id3v2.AttachedPictureFrame();
pic.TextEncoding = TagLib.StringType.Latin1;
@@ -71,12 +74,16 @@ public static void WriteToFile(string tempPath, string artworkPath, Album QoAlbu
// Save cover art to file.
file.Tag.Pictures = new TagLib.IPicture[1] { pic };
+ qbdlxForm._qbdlxForm.logger.Debug("Artwork embed complete");
+ }
+ catch {
+ qbdlxForm._qbdlxForm.logger.Error("Unable to write embedded artwork");
}
- catch { }
}
// Save All Tags
file.Save();
+ qbdlxForm._qbdlxForm.logger.Debug("File tagging completed!");
}
}
}
diff --git a/QobuzDownloaderX/LoginForm/LoginForm.Designer.cs b/QobuzDownloaderX/LoginForm/LoginForm.Designer.cs
index b6551d0..b81b675 100644
--- a/QobuzDownloaderX/LoginForm/LoginForm.Designer.cs
+++ b/QobuzDownloaderX/LoginForm/LoginForm.Designer.cs
@@ -57,6 +57,7 @@ private void InitializeComponent()
this.appSecretTextbox = new System.Windows.Forms.TextBox();
this.appidTextbox = new System.Windows.Forms.TextBox();
this.updateButton = new System.Windows.Forms.Button();
+ this.topPanel = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.qbdlxPictureBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.emailIcon)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.passwordIcon)).BeginInit();
@@ -74,6 +75,7 @@ private void InitializeComponent()
this.qbdlxPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.qbdlxPictureBox.TabIndex = 28;
this.qbdlxPictureBox.TabStop = false;
+ this.qbdlxPictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.qbdlxPictureBox_MouseMove);
//
// versionNumber
//
@@ -426,6 +428,14 @@ private void InitializeComponent()
this.updateButton.Visible = false;
this.updateButton.Click += new System.EventHandler(this.updateButton_Click);
//
+ // topPanel
+ //
+ this.topPanel.Location = new System.Drawing.Point(-1, 0);
+ this.topPanel.Name = "topPanel";
+ this.topPanel.Size = new System.Drawing.Size(301, 18);
+ this.topPanel.TabIndex = 45;
+ this.topPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.topPanel_MouseMove);
+ //
// LoginForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -450,6 +460,7 @@ private void InitializeComponent()
this.Controls.Add(this.versionNumber);
this.Controls.Add(this.qbdlxPictureBox);
this.Controls.Add(this.exitButton);
+ this.Controls.Add(this.topPanel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
@@ -498,5 +509,6 @@ private void InitializeComponent()
private System.Windows.Forms.Label appSecretLabel;
private System.Windows.Forms.Label appidLabel;
private System.Windows.Forms.Button updateButton;
+ private System.Windows.Forms.Panel topPanel;
}
}
\ No newline at end of file
diff --git a/QobuzDownloaderX/LoginForm/LoginForm.cs b/QobuzDownloaderX/LoginForm/LoginForm.cs
index 17e758f..29f6fae 100644
--- a/QobuzDownloaderX/LoginForm/LoginForm.cs
+++ b/QobuzDownloaderX/LoginForm/LoginForm.cs
@@ -61,6 +61,9 @@ private void QobuzDownloaderX_FormClosing(Object sender, FormClosingEventArgs e)
public string newVersion { get; set; }
public string changes { get; set; }
+ // Create logger for this form
+ public Logger logger { get; set; }
+
public string username { get; set; }
public string password { get; set; }
public string user_auth_token { get; set; }
@@ -71,6 +74,8 @@ private void QobuzDownloaderX_FormClosing(Object sender, FormClosingEventArgs e)
public string user_display_name { get; set; }
public string user_label { get; set; }
+ public string latestWebResponse { get; set; }
+
public LoginForm()
{
InitializeComponent();
@@ -81,15 +86,22 @@ public LoginForm()
private async void LoginForm_Load(object sender, EventArgs e)
{
+ // Create new log file
+ Directory.CreateDirectory("logs");
+ logger = new Logger("logs\\loginForm_log-" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".txt");
+ logger.Debug("Logger started, login form loaded!");
+
// Round corners of form
Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 20, 20));
// Get and display version number.
+ logger.Info("QobuzDownlaoderX | Version " + Assembly.GetExecutingAssembly().GetName().Version.ToString());
versionNumber.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString();
aboutTextbox.Text = aboutTextbox.Text.Replace("%version%", Assembly.GetExecutingAssembly().GetName().Version.ToString());
if (!System.IO.File.Exists(dllCheck))
{
+ logger.Error("taglib-sharp.dll is missing from folder. Exiting.");
MessageBox.Show("taglib-sharp.dll missing from folder!\r\nPlease Make sure the DLL is in the same folder as QobuzDownloaderX.exe!", "ERROR",
MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
@@ -112,6 +124,10 @@ private async void LoginForm_Load(object sender, EventArgs e)
appidTextbox.Text = Settings.Default.savedAppID.ToString();
appSecretTextbox.Text = Settings.Default.savedSecret.ToString();
+ logger.Info("Currently saved username: " + username);
+ logger.Info("Currently saved app ID: " + Settings.Default.savedAppID.ToString());
+ logger.Info("Currently saved app secret: " + Settings.Default.savedSecret.ToString());
+
string emailPlaceholder = "e-mail";
string passwordPlaceholder = "password";
@@ -156,21 +172,25 @@ private async void LoginForm_Load(object sender, EventArgs e)
{
// Create HttpClient to grab version number from Github
var versionURLClient = new HttpClient();
+ logger.Debug("versionURLClient initialized");
// Run through TLS to allow secure connection.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
// Set user-agent to Firefox.
versionURLClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0");
- // Grab response from Github to get Track IDs from Album response.
+ // Grab response from Github to get version number.
+ logger.Debug("Starting request for latest GitHub version");
var versionURL = "https://api.github.com/repos/ImAiiR/QobuzDownloaderX/releases/latest";
var versionURLResponse = await versionURLClient.GetAsync(versionURL);
string versionURLResponseString = versionURLResponse.Content.ReadAsStringAsync().Result;
+ latestWebResponse = versionURLResponseString;
// Grab metadata from API JSON response
JObject joVersionResponse = JObject.Parse(versionURLResponseString);
// Grab latest version number
string version = (string)joVersionResponse["tag_name"];
+ logger.Debug("Recieved version: " + version);
// Grab changelog
changes = (string)joVersionResponse["body"];
@@ -180,15 +200,19 @@ private async void LoginForm_Load(object sender, EventArgs e)
if (currentVersion.Contains(newVersion))
{
// Do nothing. All is good.
+ logger.Debug("Current version and new version match!");
}
else
{
+ logger.Warning("Current version and new version do not match!");
+ logger.Debug("Enabling update button");
updateButton.Enabled = true;
updateButton.Visible = true;
}
}
catch
{
+ logger.Error("Connection to GitHub failed, unable to grab latest version.");
DialogResult dialogResult = MessageBox.Show("Connection to GitHub to check for an update has failed.\r\nWould you like to check for an update manually?\r\n\r\nYour current version is " + Assembly.GetExecutingAssembly().GetName().Version.ToString(), "QBDLX | GitHub Connection Failed", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
@@ -205,6 +229,7 @@ private async void LoginForm_Load(object sender, EventArgs e)
private void exitButton_Click(object sender, EventArgs e)
{
+ logger.Debug("Exiting.");
Application.Exit();
}
@@ -294,10 +319,12 @@ private void passwordTextbox_KeyDown(object sender, KeyEventArgs e)
private void loginButton_Click(object sender, EventArgs e)
{
+ logger.Debug("Logging in...");
#region Check if textboxes are valid
if (emailTextbox.Text == "e-mail" | emailTextbox.Text == null | emailTextbox.Text == "id" | emailTextbox.Text == "")
{
// If there's no email typed in. Ignore if using token to login.
+ logger.Warning("emailTextbox does not contain proper values for logging in.");
if (altLoginLabel.Text.Contains("PASSWORD") == false)
{
loginText.Invoke(new Action(() => loginText.Text = "no e-mail or id, please input email first"));
@@ -308,6 +335,7 @@ private void loginButton_Click(object sender, EventArgs e)
if (passwordTextbox.Text == "password" | passwordTextbox.Text == "token")
{
// If there's no password typed in.
+ logger.Warning("passwordTextbox does not contain proper values for logging in.");
loginText.Invoke(new Action(() => loginText.Text = "no password or token typed, please input password first"));
return;
}
@@ -321,6 +349,7 @@ private void loginButton_Click(object sender, EventArgs e)
Settings.Default.savedPassword = password;
Settings.Default.Save();
+ logger.Debug("Starting loginBackground...");
loginBackground.RunWorkerAsync();
}
@@ -333,15 +362,19 @@ private void loginBackground_DoWork(object sender, DoWorkEventArgs e)
if (appidTextbox.Text == null | appidTextbox.Text == "" | appSecretTextbox.Text == null | appSecretTextbox.Text == "")
{
+ logger.Debug("No saved/custom app ID given, will get a new ID from Qobuz");
// Grab app_id & login
app_id = QoService.GetAppID().App_ID;
+ logger.Info("App ID: " + app_id);
if (Settings.Default.savedAltLoginValue == false)
{
+ logger.Debug("Logging in with e-mail and password");
QoUser = QoService.Login(app_id, username, password, null);
}
else
{
+ logger.Debug("Logging in with token");
QoUser = QoService.Login(app_id, null, null, password);
}
@@ -349,17 +382,22 @@ private void loginBackground_DoWork(object sender, DoWorkEventArgs e)
user_id = QoUser.UserInfo.Id.ToString();
user_display_name = QoUser.UserInfo.DisplayName;
+ logger.Info("User ID: " + user_id);
+ logger.Info("User display name: " + user_display_name);
+
// Grab user details & send to QBDLX
+ logger.Debug("Sending values to main form");
qbdlx.user_id = user_id;
qbdlx.user_display_name = user_display_name;
- try { qbdlx.user_label = QoUser.UserInfo.Credential.Parameters.ShortLabel; } catch { }
+ try { qbdlx.user_label = QoUser.UserInfo.Credential.Parameters.ShortLabel; } catch { logger.Warning("Attempt to grab user's short label from API has failed. Continuing."); }
// Grab profile image
- try { qbdlx.user_avatar = QoUser.UserInfo.Avatar.Replace(@"\", null).Replace("s=50", "s=20"); } catch { }
+ try { qbdlx.user_avatar = QoUser.UserInfo.Avatar.Replace(@"\", null).Replace("s=50", "s=20"); } catch { logger.Warning("Attempt to grab user's avatar from API has failed. Continuing."); }
// Set app_secret
app_secret = QoService.GetAppSecret(app_id, user_auth_token).App_Secret;
+ logger.Info("App secret: " + app_secret);
// Re-enable login button, and send app_id & app_secret to QBDLX
loginButton.Invoke(new Action(() => loginButton.Enabled = true));
@@ -376,15 +414,19 @@ private void loginBackground_DoWork(object sender, DoWorkEventArgs e)
}
else
{
+ logger.Debug("Using saved/custom app ID and secret");
// Use user-provided app_id & login
app_id = appidTextbox.Text;
+ logger.Info("App ID: " + app_id);
if (Settings.Default.savedAltLoginValue == false)
{
+ logger.Debug("Logging in with e-mail and password");
QoUser = QoService.Login(app_id, username, password, null);
}
else
{
+ logger.Debug("Logging in with token");
QoUser = QoService.Login(app_id, null, null, password);
}
@@ -392,17 +434,22 @@ private void loginBackground_DoWork(object sender, DoWorkEventArgs e)
user_id = QoUser.UserInfo.Id.ToString();
user_display_name = QoUser.UserInfo.DisplayName;
+ logger.Info("User ID: " + user_id);
+ logger.Info("User display name: " + user_display_name);
+
// Grab user details & send to QBDLX
+ logger.Debug("Sending values to main form");
qbdlx.user_id = user_id;
qbdlx.user_display_name = user_display_name;
- try { qbdlx.user_label = QoUser.UserInfo.Credential.Parameters.ShortLabel; } catch { }
+ try { qbdlx.user_label = QoUser.UserInfo.Credential.Parameters.ShortLabel; } catch { logger.Warning("Attempt to grab user's short label from API has failed. Continuing."); }
// Grab profile image
- try { qbdlx.user_avatar = QoUser.UserInfo.Avatar.Replace(@"\", null).Replace("s=50", "s=20"); } catch { }
+ try { qbdlx.user_avatar = QoUser.UserInfo.Avatar.Replace(@"\", null).Replace("s=50", "s=20"); } catch { logger.Warning("Attempt to grab user's avatar from API has failed. Continuing."); }
// Set user-provided app_secret
app_secret = appSecretTextbox.Text;
+ logger.Info("App secret: " + app_secret);
// Re-enable login button, and send app_id & app_secret to QBDLX
loginButton.Invoke(new Action(() => loginButton.Enabled = true));
@@ -419,6 +466,7 @@ private void loginBackground_DoWork(object sender, DoWorkEventArgs e)
}
// Hide this window & open QBDLX
+ logger.Debug("Login successful! Hiding this form, and launching main form.");
this.Invoke(new Action(() => this.Hide()));
Application.Run(qbdlx);
}
@@ -426,6 +474,8 @@ private void loginBackground_DoWork(object sender, DoWorkEventArgs e)
{
// If obtaining bundle.js info fails, show error info.
string loginError = loginException.ToString();
+ logger.Error("Login failed, error listed below.");
+ logger.Error("Error:\r\n" + loginException);
loginText.Invoke(new Action(() => loginText.Text = "login failed, error log saved"));
System.IO.File.WriteAllText(errorLog, loginError);
loginButton.Invoke(new Action(() => loginButton.Enabled = true));
@@ -435,6 +485,7 @@ private void loginBackground_DoWork(object sender, DoWorkEventArgs e)
private void cusotmLabel_Click(object sender, EventArgs e)
{
+ logger.Debug("Opening custom app ID and secret panel");
customPanel.Location = new Point(12, 82);
customPanel.Enabled = true;
customPanel.Visible = true;
@@ -490,6 +541,7 @@ private void altLoginLabel_Click(object sender, EventArgs e)
{
if (altLoginLabel.Text.Contains("TOKEN"))
{
+ logger.Debug("Swapping login method to token");
Settings.Default.savedAltLoginValue = true;
altLoginLabel.Text = "LOGIN WITH E-MAIL AND PASSWORD";
altLoginLabel.Location = new Point(48, 306);
@@ -503,6 +555,7 @@ private void altLoginLabel_Click(object sender, EventArgs e)
}
else
{
+ logger.Debug("Swapping login method to e-mail and password");
Settings.Default.savedAltLoginValue = false;
altLoginLabel.Text = "LOGIN WITH TOKEN";
altLoginLabel.Location = new Point(93, 306);
@@ -523,6 +576,7 @@ private void altLoginLabel_Click(object sender, EventArgs e)
private void aboutButton_Click(object sender, EventArgs e)
{
+ logger.Debug("Opening about panel");
aboutPanel.Location = new Point(12, 82);
aboutPanel.Enabled = true;
aboutPanel.Visible = true;
@@ -530,10 +584,21 @@ private void aboutButton_Click(object sender, EventArgs e)
private void closeAboutButton_Click(object sender, EventArgs e)
{
+ logger.Debug("Hiding about panel");
aboutPanel.Enabled = false;
aboutPanel.Visible = false;
}
+ private void customSaveButton_Click(object sender, EventArgs e)
+ {
+ logger.Debug("Saving custom app ID and secret...");
+ Settings.Default.savedAppID = appidTextbox.Text;
+ Settings.Default.savedSecret = appSecretTextbox.Text;
+ logger.Debug("Custom app ID and secret saved! Hiding custom values panel");
+ customPanel.Enabled = false;
+ customPanel.Visible = false;
+ }
+
private void altLoginLabel_MouseEnter(object sender, EventArgs e)
{
altLoginLabel.ForeColor = Color.FromArgb(140, 140, 140);
@@ -554,26 +619,41 @@ private void cusotmLabel_MouseLeave(object sender, EventArgs e)
customLabel.ForeColor = Color.FromArgb(100, 100, 100);
}
- private void customSaveButton_Click(object sender, EventArgs e)
- {
- Settings.Default.savedAppID = appidTextbox.Text;
- Settings.Default.savedSecret = appSecretTextbox.Text;
- customPanel.Enabled = false;
- customPanel.Visible = false;
- }
-
private void updateButton_Click(object sender, EventArgs e)
{
+ logger.Debug("Opening update information dialog");
DialogResult dialogResult = MessageBox.Show("New version of QBDLX is available!\r\n\r\nInstalled version - " + currentVersion + "\r\nLatest version - " + newVersion + "\r\n\r\nChangelog Below\r\n==============\r\n" + changes.Replace("\\r\\n", "\r\n") + "\r\n==============\r\n\r\nWould you like to update?", "QBDLX | Update Available", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
// If "Yes" is clicked, open GitHub page and close QBDLX.
+ logger.Debug("Opening GitHub page for latest update");
Process.Start("https://github.com/ImAiiR/QobuzDownloaderX/releases/latest");
+ logger.Debug("Exiting");
Application.Exit();
}
else if (dialogResult == DialogResult.No)
{
- // Ignore the update until next open.
+ // Ignore the update
+ logger.Info("Update ignored");
+ }
+ }
+
+ // For moving form with click and drag
+ private void qbdlxPictureBox_MouseMove(object sender, MouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Left)
+ {
+ ReleaseCapture();
+ SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
+ }
+ }
+
+ private void topPanel_MouseMove(object sender, MouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Left)
+ {
+ ReleaseCapture();
+ SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
}
}
diff --git a/QobuzDownloaderX/Properties/AssemblyInfo.cs b/QobuzDownloaderX/Properties/AssemblyInfo.cs
index d55f963..aa8f2c8 100644
--- a/QobuzDownloaderX/Properties/AssemblyInfo.cs
+++ b/QobuzDownloaderX/Properties/AssemblyInfo.cs
@@ -33,5 +33,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.2")]
-[assembly: AssemblyFileVersion("1.0.0.2")]
+[assembly: AssemblyVersion("1.0.0.3")]
+[assembly: AssemblyFileVersion("1.0.0.3")]
diff --git a/QobuzDownloaderX/Properties/Resources.Designer.cs b/QobuzDownloaderX/Properties/Resources.Designer.cs
index 479818a..dcd87cc 100644
--- a/QobuzDownloaderX/Properties/Resources.Designer.cs
+++ b/QobuzDownloaderX/Properties/Resources.Designer.cs
@@ -140,6 +140,16 @@ internal static System.Drawing.Bitmap qbdlx_new {
}
}
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap search {
+ get {
+ object obj = ResourceManager.GetObject("search", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
diff --git a/QobuzDownloaderX/Properties/Resources.resx b/QobuzDownloaderX/Properties/Resources.resx
index 8fa95f7..fd1ba70 100644
--- a/QobuzDownloaderX/Properties/Resources.resx
+++ b/QobuzDownloaderX/Properties/Resources.resx
@@ -151,4 +151,7 @@
..\Resources\alert.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\search.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
diff --git a/QobuzDownloaderX/QobuzDownloaderX.csproj b/QobuzDownloaderX/QobuzDownloaderX.csproj
index 8e10e6f..17c3d53 100644
--- a/QobuzDownloaderX/QobuzDownloaderX.csproj
+++ b/QobuzDownloaderX/QobuzDownloaderX.csproj
@@ -60,8 +60,8 @@
..\packages\taglib.2.1.0.0\lib\policy.2.0.taglib-sharp.dll
True
-
- ..\packages\QopenAPI.0.0.3.1\lib\net452\Qo(penAPI).dll
+
+ ..\packages\QopenAPI.0.0.3.2\lib\net452\Qo(penAPI).dll
@@ -90,6 +90,7 @@
+
Form
@@ -188,6 +189,7 @@
+
diff --git a/QobuzDownloaderX/Resources/search.png b/QobuzDownloaderX/Resources/search.png
new file mode 100644
index 0000000..e657592
Binary files /dev/null and b/QobuzDownloaderX/Resources/search.png differ
diff --git a/QobuzDownloaderX/packages.config b/QobuzDownloaderX/packages.config
index 2514cd7..b571a37 100644
--- a/QobuzDownloaderX/packages.config
+++ b/QobuzDownloaderX/packages.config
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/QobuzDownloaderX/qbdlxForm.Designer.cs b/QobuzDownloaderX/qbdlxForm.Designer.cs
index 40100c8..c717f85 100644
--- a/QobuzDownloaderX/qbdlxForm.Designer.cs
+++ b/QobuzDownloaderX/qbdlxForm.Designer.cs
@@ -30,12 +30,13 @@ private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(qbdlxForm));
this.panel1 = new System.Windows.Forms.Panel();
+ this.searchButton = new System.Windows.Forms.Button();
this.welcomeLabel = new System.Windows.Forms.Label();
this.settingsButton = new System.Windows.Forms.Button();
this.logoutButton = new System.Windows.Forms.Button();
this.aboutButton = new System.Windows.Forms.Button();
this.downloaderButton = new System.Windows.Forms.Button();
- this.panel2 = new System.Windows.Forms.Panel();
+ this.logoPanel = new System.Windows.Forms.Panel();
this.versionNumber = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.downloaderPanel = new System.Windows.Forms.Panel();
@@ -127,8 +128,17 @@ private void InitializeComponent()
this.flacLowLabel2 = new System.Windows.Forms.Label();
this.flacMidLabel2 = new System.Windows.Forms.Label();
this.flacHighLabel2 = new System.Windows.Forms.Label();
+ this.movingLabel = new System.Windows.Forms.Label();
+ this.searchPanel = new System.Windows.Forms.Panel();
+ this.searchResultsPanel = new System.Windows.Forms.Panel();
+ this.searchResultsTablePanel = new System.Windows.Forms.TableLayoutPanel();
+ this.searchAlbumsButton = new System.Windows.Forms.Button();
+ this.searchTracksButton = new System.Windows.Forms.Button();
+ this.searchTextbox = new System.Windows.Forms.TextBox();
+ this.searchLabel = new System.Windows.Forms.Label();
+ this.searchingLabel = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
- this.panel2.SuspendLayout();
+ this.logoPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.downloaderPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.albumPictureBox)).BeginInit();
@@ -136,23 +146,45 @@ private void InitializeComponent()
this.aboutPanel.SuspendLayout();
this.extraSettingsPanel.SuspendLayout();
this.qualitySelectPanel.SuspendLayout();
+ this.searchPanel.SuspendLayout();
+ this.searchResultsPanel.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(13)))), ((int)(((byte)(13)))), ((int)(((byte)(13)))));
+ this.panel1.Controls.Add(this.searchButton);
this.panel1.Controls.Add(this.welcomeLabel);
this.panel1.Controls.Add(this.settingsButton);
this.panel1.Controls.Add(this.logoutButton);
this.panel1.Controls.Add(this.aboutButton);
this.panel1.Controls.Add(this.downloaderButton);
- this.panel1.Controls.Add(this.panel2);
+ this.panel1.Controls.Add(this.logoPanel);
this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(180, 577);
this.panel1.TabIndex = 0;
//
+ // searchButton
+ //
+ this.searchButton.FlatAppearance.BorderSize = 0;
+ this.searchButton.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(25)))), ((int)(((byte)(25)))));
+ this.searchButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18)))));
+ this.searchButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.searchButton.Font = new System.Drawing.Font("Nirmala UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.searchButton.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(147)))), ((int)(((byte)(147)))), ((int)(((byte)(147)))));
+ this.searchButton.Image = global::QobuzDownloaderX.Properties.Resources.search;
+ this.searchButton.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
+ this.searchButton.Location = new System.Drawing.Point(0, 166);
+ this.searchButton.Name = "searchButton";
+ this.searchButton.Size = new System.Drawing.Size(180, 66);
+ this.searchButton.TabIndex = 33;
+ this.searchButton.Text = "SEARCH";
+ this.searchButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ this.searchButton.UseVisualStyleBackColor = true;
+ this.searchButton.Click += new System.EventHandler(this.searchButton_Click);
+ //
// welcomeLabel
//
this.welcomeLabel.BackColor = System.Drawing.Color.Transparent;
@@ -212,7 +244,7 @@ private void InitializeComponent()
this.aboutButton.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(147)))), ((int)(((byte)(147)))), ((int)(((byte)(147)))));
this.aboutButton.Image = global::QobuzDownloaderX.Properties.Resources.info;
this.aboutButton.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
- this.aboutButton.Location = new System.Drawing.Point(0, 166);
+ this.aboutButton.Location = new System.Drawing.Point(0, 232);
this.aboutButton.Name = "aboutButton";
this.aboutButton.Size = new System.Drawing.Size(180, 66);
this.aboutButton.TabIndex = 1;
@@ -240,15 +272,16 @@ private void InitializeComponent()
this.downloaderButton.UseVisualStyleBackColor = true;
this.downloaderButton.Click += new System.EventHandler(this.downloaderButton_Click);
//
- // panel2
+ // logoPanel
//
- this.panel2.Controls.Add(this.versionNumber);
- this.panel2.Controls.Add(this.pictureBox1);
- this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
- this.panel2.Location = new System.Drawing.Point(0, 0);
- this.panel2.Name = "panel2";
- this.panel2.Size = new System.Drawing.Size(180, 100);
- this.panel2.TabIndex = 0;
+ this.logoPanel.Controls.Add(this.versionNumber);
+ this.logoPanel.Controls.Add(this.pictureBox1);
+ this.logoPanel.Dock = System.Windows.Forms.DockStyle.Top;
+ this.logoPanel.Location = new System.Drawing.Point(0, 0);
+ this.logoPanel.Name = "logoPanel";
+ this.logoPanel.Size = new System.Drawing.Size(180, 100);
+ this.logoPanel.TabIndex = 0;
+ this.logoPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.logoPanel_MouseMove);
//
// versionNumber
//
@@ -271,6 +304,7 @@ private void InitializeComponent()
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
+ this.pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove);
//
// downloaderPanel
//
@@ -285,7 +319,7 @@ private void InitializeComponent()
this.downloaderPanel.Controls.Add(this.albumPictureBox);
this.downloaderPanel.Controls.Add(this.inputTextbox);
this.downloaderPanel.Controls.Add(this.downloadLabel);
- this.downloaderPanel.Location = new System.Drawing.Point(153, 108);
+ this.downloaderPanel.Location = new System.Drawing.Point(444, 480);
this.downloaderPanel.Name = "downloaderPanel";
this.downloaderPanel.Size = new System.Drawing.Size(771, 577);
this.downloaderPanel.TabIndex = 1;
@@ -429,9 +463,11 @@ private void InitializeComponent()
this.downloadLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(147)))), ((int)(((byte)(147)))), ((int)(((byte)(147)))));
this.downloadLabel.Location = new System.Drawing.Point(13, 10);
this.downloadLabel.Name = "downloadLabel";
- this.downloadLabel.Size = new System.Drawing.Size(139, 25);
+ this.downloadLabel.Size = new System.Drawing.Size(579, 25);
this.downloadLabel.TabIndex = 0;
- this.downloadLabel.Text = "DOWNLOADER";
+ this.downloadLabel.Text = "DOWNLOADER " +
+ " ";
+ this.downloadLabel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.downloadLabel_MouseMove);
//
// settingsPanel
//
@@ -465,7 +501,7 @@ private void InitializeComponent()
this.settingsPanel.Controls.Add(this.selectFolderButton);
this.settingsPanel.Controls.Add(this.templatesLabel);
this.settingsPanel.Controls.Add(this.settingsLabel);
- this.settingsPanel.Location = new System.Drawing.Point(272, 503);
+ this.settingsPanel.Location = new System.Drawing.Point(524, 442);
this.settingsPanel.Name = "settingsPanel";
this.settingsPanel.Size = new System.Drawing.Size(771, 577);
this.settingsPanel.TabIndex = 1;
@@ -854,9 +890,11 @@ private void InitializeComponent()
this.settingsLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(147)))), ((int)(((byte)(147)))), ((int)(((byte)(147)))));
this.settingsLabel.Location = new System.Drawing.Point(13, 10);
this.settingsLabel.Name = "settingsLabel";
- this.settingsLabel.Size = new System.Drawing.Size(94, 25);
+ this.settingsLabel.Size = new System.Drawing.Size(554, 25);
this.settingsLabel.TabIndex = 1;
- this.settingsLabel.Text = "SETTINGS";
+ this.settingsLabel.Text = "SETTINGS " +
+ " ";
+ this.settingsLabel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.settingsLabel_MouseMove);
//
// userInfoTextbox
//
@@ -926,7 +964,7 @@ private void InitializeComponent()
this.aboutPanel.Controls.Add(this.userInfoTextbox);
this.aboutPanel.Controls.Add(this.aboutLabel);
this.aboutPanel.Controls.Add(this.userInfoLabel);
- this.aboutPanel.Location = new System.Drawing.Point(747, 132);
+ this.aboutPanel.Location = new System.Drawing.Point(356, 526);
this.aboutPanel.Name = "aboutPanel";
this.aboutPanel.Size = new System.Drawing.Size(771, 577);
this.aboutPanel.TabIndex = 1;
@@ -938,9 +976,11 @@ private void InitializeComponent()
this.aboutLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(147)))), ((int)(((byte)(147)))), ((int)(((byte)(147)))));
this.aboutLabel.Location = new System.Drawing.Point(13, 10);
this.aboutLabel.Name = "aboutLabel";
- this.aboutLabel.Size = new System.Drawing.Size(72, 25);
+ this.aboutLabel.Size = new System.Drawing.Size(552, 25);
this.aboutLabel.TabIndex = 1;
- this.aboutLabel.Text = "ABOUT";
+ this.aboutLabel.Text = "ABOUT " +
+ " ";
+ this.aboutLabel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.aboutLabel_MouseMove);
//
// extraSettingsPanel
//
@@ -973,7 +1013,7 @@ private void InitializeComponent()
this.extraSettingsPanel.Controls.Add(this.albumArtistCheckbox);
this.extraSettingsPanel.Controls.Add(this.extraSettingsLabel);
this.extraSettingsPanel.Font = new System.Drawing.Font("Nirmala UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.extraSettingsPanel.Location = new System.Drawing.Point(622, 73);
+ this.extraSettingsPanel.Location = new System.Drawing.Point(594, 403);
this.extraSettingsPanel.Name = "extraSettingsPanel";
this.extraSettingsPanel.Size = new System.Drawing.Size(771, 577);
this.extraSettingsPanel.TabIndex = 3;
@@ -1381,9 +1421,11 @@ private void InitializeComponent()
this.extraSettingsLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(147)))), ((int)(((byte)(147)))), ((int)(((byte)(147)))));
this.extraSettingsLabel.Location = new System.Drawing.Point(13, 10);
this.extraSettingsLabel.Name = "extraSettingsLabel";
- this.extraSettingsLabel.Size = new System.Drawing.Size(206, 25);
+ this.extraSettingsLabel.Size = new System.Drawing.Size(551, 25);
this.extraSettingsLabel.TabIndex = 1;
- this.extraSettingsLabel.Text = "ADDITIONAL SETTINGS";
+ this.extraSettingsLabel.Text = "ADDITIONAL SETTINGS " +
+ " ";
+ this.extraSettingsLabel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.extraSettingsLabel_MouseMove);
//
// qualitySelectButton
//
@@ -1520,21 +1562,152 @@ private void InitializeComponent()
this.flacHighLabel2.Text = "FLAC (24/192)";
this.flacHighLabel2.Click += new System.EventHandler(this.flacHighLabel2_Click);
//
+ // movingLabel
+ //
+ this.movingLabel.AutoSize = true;
+ this.movingLabel.BackColor = System.Drawing.Color.Transparent;
+ this.movingLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18)))));
+ this.movingLabel.Location = new System.Drawing.Point(179, 1);
+ this.movingLabel.Name = "movingLabel";
+ this.movingLabel.Size = new System.Drawing.Size(565, 13);
+ this.movingLabel.TabIndex = 6;
+ this.movingLabel.Text = "=================================================================================" +
+ "============";
+ this.movingLabel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.movingLabel_MouseMove);
+ //
+ // searchPanel
+ //
+ this.searchPanel.Controls.Add(this.searchResultsPanel);
+ this.searchPanel.Controls.Add(this.searchAlbumsButton);
+ this.searchPanel.Controls.Add(this.searchTracksButton);
+ this.searchPanel.Controls.Add(this.searchTextbox);
+ this.searchPanel.Controls.Add(this.searchLabel);
+ this.searchPanel.Controls.Add(this.searchingLabel);
+ this.searchPanel.Font = new System.Drawing.Font("Nirmala UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.searchPanel.Location = new System.Drawing.Point(689, 353);
+ this.searchPanel.Name = "searchPanel";
+ this.searchPanel.Size = new System.Drawing.Size(771, 577);
+ this.searchPanel.TabIndex = 29;
+ this.searchPanel.Visible = false;
+ //
+ // searchResultsPanel
+ //
+ this.searchResultsPanel.AutoScroll = true;
+ this.searchResultsPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
+ this.searchResultsPanel.Controls.Add(this.searchResultsTablePanel);
+ this.searchResultsPanel.Location = new System.Drawing.Point(18, 83);
+ this.searchResultsPanel.Name = "searchResultsPanel";
+ this.searchResultsPanel.Size = new System.Drawing.Size(733, 482);
+ this.searchResultsPanel.TabIndex = 10;
+ //
+ // searchResultsTablePanel
+ //
+ this.searchResultsTablePanel.ColumnCount = 4;
+ this.searchResultsTablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
+ this.searchResultsTablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.searchResultsTablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.searchResultsTablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 687F));
+ this.searchResultsTablePanel.Location = new System.Drawing.Point(3, 3);
+ this.searchResultsTablePanel.Name = "searchResultsTablePanel";
+ this.searchResultsTablePanel.RowCount = 1;
+ this.searchResultsTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
+ this.searchResultsTablePanel.Size = new System.Drawing.Size(710, 476);
+ this.searchResultsTablePanel.TabIndex = 0;
+ //
+ // searchAlbumsButton
+ //
+ this.searchAlbumsButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(13)))), ((int)(((byte)(13)))), ((int)(((byte)(13)))));
+ this.searchAlbumsButton.FlatAppearance.BorderSize = 0;
+ this.searchAlbumsButton.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(25)))), ((int)(((byte)(25)))));
+ this.searchAlbumsButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18)))));
+ this.searchAlbumsButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.searchAlbumsButton.Font = new System.Drawing.Font("Nirmala UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.searchAlbumsButton.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(147)))), ((int)(((byte)(147)))), ((int)(((byte)(147)))));
+ this.searchAlbumsButton.Location = new System.Drawing.Point(581, 46);
+ this.searchAlbumsButton.Name = "searchAlbumsButton";
+ this.searchAlbumsButton.Size = new System.Drawing.Size(82, 31);
+ this.searchAlbumsButton.TabIndex = 9;
+ this.searchAlbumsButton.Text = "RELEASES";
+ this.searchAlbumsButton.UseVisualStyleBackColor = false;
+ this.searchAlbumsButton.Click += new System.EventHandler(this.searchAlbumsButton_Click);
+ //
+ // searchTracksButton
+ //
+ this.searchTracksButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(13)))), ((int)(((byte)(13)))), ((int)(((byte)(13)))));
+ this.searchTracksButton.FlatAppearance.BorderSize = 0;
+ this.searchTracksButton.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(25)))), ((int)(((byte)(25)))));
+ this.searchTracksButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18)))));
+ this.searchTracksButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.searchTracksButton.Font = new System.Drawing.Font("Nirmala UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.searchTracksButton.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(147)))), ((int)(((byte)(147)))), ((int)(((byte)(147)))));
+ this.searchTracksButton.Location = new System.Drawing.Point(669, 46);
+ this.searchTracksButton.Name = "searchTracksButton";
+ this.searchTracksButton.Size = new System.Drawing.Size(82, 31);
+ this.searchTracksButton.TabIndex = 8;
+ this.searchTracksButton.Text = "TRACKS";
+ this.searchTracksButton.UseVisualStyleBackColor = false;
+ this.searchTracksButton.Click += new System.EventHandler(this.searchTracksButton_Click);
+ //
+ // searchTextbox
+ //
+ this.searchTextbox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
+ this.searchTextbox.BorderStyle = System.Windows.Forms.BorderStyle.None;
+ this.searchTextbox.Cursor = System.Windows.Forms.Cursors.IBeam;
+ this.searchTextbox.Font = new System.Drawing.Font("Nirmala UI", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.searchTextbox.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
+ this.searchTextbox.Location = new System.Drawing.Point(18, 48);
+ this.searchTextbox.Multiline = true;
+ this.searchTextbox.Name = "searchTextbox";
+ this.searchTextbox.Size = new System.Drawing.Size(557, 27);
+ this.searchTextbox.TabIndex = 7;
+ this.searchTextbox.Text = "Input your search...";
+ this.searchTextbox.WordWrap = false;
+ this.searchTextbox.Click += new System.EventHandler(this.searchTextbox_Click);
+ this.searchTextbox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.searchTextbox_KeyDown);
+ this.searchTextbox.Leave += new System.EventHandler(this.searchTextbox_Leave);
+ //
+ // searchLabel
+ //
+ this.searchLabel.AutoSize = true;
+ this.searchLabel.Font = new System.Drawing.Font("Nirmala UI", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.searchLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(147)))), ((int)(((byte)(147)))), ((int)(((byte)(147)))));
+ this.searchLabel.Location = new System.Drawing.Point(13, 10);
+ this.searchLabel.Name = "searchLabel";
+ this.searchLabel.Size = new System.Drawing.Size(550, 25);
+ this.searchLabel.TabIndex = 1;
+ this.searchLabel.Text = "SEARCH " +
+ " ";
+ this.searchLabel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.searchLabel_MouseMove);
+ //
+ // searchingLabel
+ //
+ this.searchingLabel.Font = new System.Drawing.Font("Nirmala UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.searchingLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(147)))), ((int)(((byte)(147)))), ((int)(((byte)(147)))));
+ this.searchingLabel.Location = new System.Drawing.Point(581, 49);
+ this.searchingLabel.Name = "searchingLabel";
+ this.searchingLabel.Size = new System.Drawing.Size(170, 25);
+ this.searchingLabel.TabIndex = 11;
+ this.searchingLabel.Text = "Searching...";
+ this.searchingLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.searchingLabel.Visible = false;
+ //
// qbdlxForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18)))));
this.ClientSize = new System.Drawing.Size(951, 577);
+ this.Controls.Add(this.movingLabel);
this.Controls.Add(this.qualitySelectPanel);
this.Controls.Add(this.qualitySelectButton);
this.Controls.Add(this.minimizeButton);
this.Controls.Add(this.exitButton);
- this.Controls.Add(this.extraSettingsPanel);
this.Controls.Add(this.panel1);
- this.Controls.Add(this.settingsPanel);
this.Controls.Add(this.downloaderPanel);
this.Controls.Add(this.aboutPanel);
+ this.Controls.Add(this.settingsPanel);
+ this.Controls.Add(this.extraSettingsPanel);
+ this.Controls.Add(this.searchPanel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "qbdlxForm";
@@ -1542,7 +1715,7 @@ private void InitializeComponent()
this.Text = "qbdlxForm";
this.Load += new System.EventHandler(this.qbdlxForm_Load);
this.panel1.ResumeLayout(false);
- this.panel2.ResumeLayout(false);
+ this.logoPanel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.downloaderPanel.ResumeLayout(false);
this.downloaderPanel.PerformLayout();
@@ -1555,14 +1728,18 @@ private void InitializeComponent()
this.extraSettingsPanel.PerformLayout();
this.qualitySelectPanel.ResumeLayout(false);
this.qualitySelectPanel.PerformLayout();
+ this.searchPanel.ResumeLayout(false);
+ this.searchPanel.PerformLayout();
+ this.searchResultsPanel.ResumeLayout(false);
this.ResumeLayout(false);
+ this.PerformLayout();
}
#endregion
private System.Windows.Forms.Panel panel1;
- private System.Windows.Forms.Panel panel2;
+ private System.Windows.Forms.Panel logoPanel;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button downloaderButton;
private System.Windows.Forms.Button settingsButton;
@@ -1578,7 +1755,6 @@ private void InitializeComponent()
private System.Windows.Forms.Label aboutLabel;
private System.Windows.Forms.Button logoutButton;
private System.Windows.Forms.Label welcomeLabel;
- private System.Windows.Forms.TextBox inputTextbox;
private System.Windows.Forms.PictureBox albumPictureBox;
private System.Windows.Forms.Label dateSlotLabel;
private System.Windows.Forms.Label albumSlotLabel;
@@ -1657,7 +1833,18 @@ private void InitializeComponent()
public System.Windows.Forms.CheckBox streamableCheckbox;
public System.Windows.Forms.TextBox templatesListTextbox;
private System.Windows.Forms.Label templatesListLabel;
- private System.Windows.Forms.Button downloadButton;
public System.Windows.Forms.CheckBox fixMD5sCheckbox;
+ private System.Windows.Forms.Label movingLabel;
+ private System.Windows.Forms.Button searchButton;
+ private System.Windows.Forms.Panel searchPanel;
+ private System.Windows.Forms.Label searchLabel;
+ private System.Windows.Forms.Button searchTracksButton;
+ private System.Windows.Forms.TextBox searchTextbox;
+ private System.Windows.Forms.Button searchAlbumsButton;
+ private System.Windows.Forms.Panel searchResultsPanel;
+ public System.Windows.Forms.TableLayoutPanel searchResultsTablePanel;
+ private System.Windows.Forms.Label searchingLabel;
+ public System.Windows.Forms.TextBox inputTextbox;
+ public System.Windows.Forms.Button downloadButton;
}
}
\ No newline at end of file
diff --git a/QobuzDownloaderX/qbdlxForm.cs b/QobuzDownloaderX/qbdlxForm.cs
index 4e94b14..c2028c4 100644
--- a/QobuzDownloaderX/qbdlxForm.cs
+++ b/QobuzDownloaderX/qbdlxForm.cs
@@ -16,11 +16,22 @@
using System.Net;
using System.Threading;
using QobuzDownloaderX.Properties;
+using System.IO;
+using static System.Net.Mime.MediaTypeNames;
+using QobuzDownloaderX.Download;
namespace QobuzDownloaderX
{
public partial class qbdlxForm : Form
{
+ public const int WM_NCLBUTTONDOWN = 0xA1;
+ public const int HT_CAPTION = 0x2;
+
+ [DllImportAttribute("user32.dll")]
+ public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
+ [DllImportAttribute("user32.dll")]
+ public static extern bool ReleaseCapture();
+
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
private static extern IntPtr CreateRoundRectRgn
(
@@ -37,15 +48,20 @@ int nHeightEllipse // height of ellipse
public Artist QoArtist = new Artist();
public Album QoAlbum = new Album();
public Item QoItem = new Item();
+ public SearchAlbumResult QoAlbumSearch = new SearchAlbumResult();
+ public SearchTrackResult QoTrackSearch = new SearchTrackResult();
public Favorites QoFavorites = new Favorites();
public Playlist QoPlaylist = new Playlist();
public QopenAPI.Label QoLabel = new QopenAPI.Label();
- public Stream QoStream = new Stream();
+ public QopenAPI.Stream QoStream = new QopenAPI.Stream();
public bool downloadPanelActive = false;
public bool aboutPanelActive = false;
public bool settingsPanelActive = false;
+ //Create logger for this form
+ public Logger logger { get; set; }
+
public string downloadLocation { get; set; }
public string artistTemplate { get; set; }
public string albumTemplate { get; set; }
@@ -68,12 +84,20 @@ int nHeightEllipse // height of ellipse
public string embeddedArtSize { get; set; }
public string savedArtSize { get; set; }
+ public string latestWebResponse { get; set; }
+
GetInfo getInfo = new GetInfo();
DownloadAlbum downloadAlbum = new DownloadAlbum();
DownloadTrack downloadTrack = new DownloadTrack();
+ SearchPanelHelper searchPanelHelper = new SearchPanelHelper();
public qbdlxForm()
{
+ // Create new log file
+ Directory.CreateDirectory("logs");
+ logger = new Logger("logs\\qbdlxForm_log-" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".txt");
+ logger.Debug("Logger started, QBDLX form initialized!");
+
InitializeComponent();
_qbdlxForm = this;
}
@@ -82,11 +106,13 @@ public qbdlxForm()
public void update(string text)
{
+ logger.Debug("Updating text with: " + text);
downloadOutput.Invoke(new Action(() => downloadOutput.Text = text));
}
public void updateTemplates()
{
+ logger.Debug("Updating templates");
artistTemplate = artistTemplateTextbox.Text;
albumTemplate = albumTemplateTextbox.Text;
trackTemplate = trackTemplateTextbox.Text;
@@ -96,11 +122,15 @@ public void updateTemplates()
private void qbdlxForm_Load(object sender, EventArgs e)
{
+ logger.Debug("QBDLX form loaded!");
+
// Round corners of form
Region = Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 20, 20));
// Set saved settings to correct places.
folderBrowser.SelectedPath = Settings.Default.savedFolder.ToString();
+ logger.Info("Saved download path: " + folderBrowser.SelectedPath);
+ logger.Debug("Setting saved download path to downloadLocation");
downloadLocation = folderBrowser.SelectedPath;
if (downloadLocation == null | downloadLocation == "")
{
@@ -160,6 +190,7 @@ private void qbdlxForm_Load(object sender, EventArgs e)
aboutPanel.Location = new Point(179, 0);
settingsPanel.Location = new Point(179, 0);
extraSettingsPanel.Location = new Point(179, 0);
+ searchPanel.Location = new Point(179, 0);
// Get and display version number.
versionNumber.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString();
@@ -171,16 +202,30 @@ private void qbdlxForm_Load(object sender, EventArgs e)
downloadPanelActive = true;
downloaderButton.BackColor = Color.FromArgb(18, 18, 18);
+ logger.Info("User diplay name: " + user_display_name);
+ logger.Info("User ID: " + user_id);
+ try { logger.Info("User e-amil: " + QoUser.UserInfo.Email); } catch (Exception ex) { logger.Error("Failed to get user e-mail, Error below:\r\n" + ex.ToString()); }
+ try { logger.Info("User country: " + QoUser.UserInfo.Country); } catch (Exception ex) { logger.Error("Failed to get user country, Error below:\r\n" + ex.ToString()); }
+ try { logger.Info("User subscription: " + QoUser.UserInfo.Subscription.Offer); } catch (Exception ex) { logger.Error("Failed to get user subscription, Error below:\r\n" + ex.ToString()); }
+ try { logger.Info("User subscription end date: " + QoUser.UserInfo.Subscription.EndDate); } catch (Exception ex) { logger.Error("Failed to get user subscription end date, Error below:\r\n" + ex.ToString()); }
+
// Set display_name to welcomeLabel
welcomeLabel.Text = welcomeLabel.Text.Replace("{username}", user_display_name);
- // Set user info in settings panel
- userInfoTextbox.Text = userInfoTextbox.Text
- .Replace("{user_id}", QoUser.UserInfo.Id.ToString())
+ // Set user info in about panel
+ try
+ {
+ userInfoTextbox.Text = userInfoTextbox.Text
+ .Replace("{user_id}", user_id)
.Replace("{user_email}", QoUser.UserInfo.Email)
.Replace("{user_country}", QoUser.UserInfo.Country)
.Replace("{user_subscription}", QoUser.UserInfo.Subscription.Offer)
.Replace("{user_subscription_expiration}", QoUser.UserInfo.Subscription.EndDate);
+ }
+ catch (Exception ex)
+ {
+ logger.Error("Failed to get user info for about section, continuing.");
+ }
downloadOutput.Text = "Welcome " + user_display_name + "!";
@@ -208,14 +253,24 @@ private void qualitySelectButton_Click(object sender, EventArgs e)
private void exitButton_Click(object sender, EventArgs e)
{
- Application.Exit();
+ logger.Debug("Exiting");
+ System.Windows.Forms.Application.Exit();
}
private void minimizeButton_Click(object sender, EventArgs e)
{
+ logger.Debug("Minimizing");
this.WindowState = FormWindowState.Minimized;
}
+ private void searchTextbox_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.KeyCode.Equals(Keys.Enter))
+ {
+ e.SuppressKeyPress = true;
+ }
+ }
+
private void inputTextbox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
@@ -225,13 +280,19 @@ private void inputTextbox_KeyDown(object sender, KeyEventArgs e)
}
}
- private async void getLinkType()
+ private void downloadButton_Click(object sender, EventArgs e)
+ {
+ getLinkType();
+ }
+
+ public async void getLinkType()
{
downloadOutput.Focus();
// Check if there's no selected path.
if (downloadLocation == null | downloadLocation == "" | downloadLocation == "no folder selected")
{
// If there is NOT a saved path.
+ logger.Warning("No path has been set! Remember to Choose a Folder!");
downloadOutput.Invoke(new Action(() => downloadOutput.Text = String.Empty));
downloadOutput.Invoke(new Action(() => downloadOutput.AppendText("No path has been set! Remember to Choose a Folder!\r\n")));
return;
@@ -477,6 +538,24 @@ private void inputTextbox_Leave(object sender, EventArgs e)
}
}
+ private void searchTextbox_Click(object sender, EventArgs e)
+ {
+ if (searchTextbox.Text == "Input your search...")
+ {
+ searchTextbox.Text = null;
+ searchTextbox.ForeColor = Color.FromArgb(200, 200, 200);
+ }
+ }
+
+ private void searchTextbox_Leave(object sender, EventArgs e)
+ {
+ if (searchTextbox.Text == null | searchTextbox.Text == "")
+ {
+ searchTextbox.ForeColor = Color.FromArgb(60, 60, 60);
+ searchTextbox.Text = "Input your search...";
+ }
+ }
+
private void openFolderButton_Click(object sender, EventArgs e)
{
// Open selcted folder
@@ -534,6 +613,7 @@ private void flacHighButton_CheckedChanged(object sender, EventArgs e)
if (flacHighButton.Checked == true)
{
+ logger.Debug("Setting format ID to 27");
format_id = "27";
audio_format = ".flac";
flacHighButton2.Checked = true;
@@ -549,6 +629,7 @@ private void flacHighButton2_CheckedChanged(object sender, EventArgs e)
if (flacHighButton2.Checked == true)
{
+ logger.Debug("Setting format ID to 27");
format_id = "27";
audio_format = ".flac";
flacHighButton.Checked = true;
@@ -564,6 +645,7 @@ private void flacMidButton_CheckedChanged(object sender, EventArgs e)
if (flacMidButton.Checked == true)
{
+ logger.Debug("Setting format ID to 7");
format_id = "7";
audio_format = ".flac";
flacMidButton2.Checked = true;
@@ -579,6 +661,7 @@ private void flacMidButton2_CheckedChanged(object sender, EventArgs e)
if (flacMidButton2.Checked == true)
{
+ logger.Debug("Setting format ID to 7");
format_id = "7";
audio_format = ".flac";
flacMidButton.Checked = true;
@@ -594,6 +677,7 @@ private void flacLowButton_CheckedChanged(object sender, EventArgs e)
if (flacLowButton.Checked == true)
{
+ logger.Debug("Setting format ID to 6");
format_id = "6";
audio_format = ".flac";
flacLowButton2.Checked = true;
@@ -609,6 +693,7 @@ private void flacLowButton2_CheckedChanged(object sender, EventArgs e)
if (flacLowButton2.Checked == true)
{
+ logger.Debug("Setting format ID to 6");
format_id = "6";
audio_format = ".flac";
flacLowButton.Checked = true;
@@ -624,6 +709,7 @@ private void mp3Button_CheckedChanged(object sender, EventArgs e)
if (mp3Button.Checked == true)
{
+ logger.Debug("Setting format ID to 5");
format_id = "5";
audio_format = ".mp3";
mp3Button2.Checked = true;
@@ -639,6 +725,7 @@ private void mp3Button2_CheckedChanged(object sender, EventArgs e)
if (mp3Button2.Checked == true)
{
+ logger.Debug("Setting format ID to 5");
format_id = "5";
audio_format = ".mp3";
mp3Button.Checked = true;
@@ -818,15 +905,18 @@ private void savedArtSizeSelect_SelectedIndexChanged(object sender, EventArgs e)
#region Navigation Buttons
private void logoutButton_Click(object sender, EventArgs e)
{
+ logger.Debug("Restarting program to logout");
// Could use some work, but this works.
Process.Start("QobuzDownloaderX.exe");
- Application.Exit();
+ System.Windows.Forms.Application.Exit();
}
private void aboutButton_Click(object sender, EventArgs e)
{
- // Make other panels invisable, make about panel visable
+ logger.Debug("Opening about panel");
+ // Make other panels invisable, make about panel visible
downloaderPanel.Visible = false;
+ searchPanel.Visible = false;
settingsPanel.Visible = false;
extraSettingsPanel.Visible = false;
aboutPanel.Visible = true;
@@ -839,13 +929,16 @@ private void aboutButton_Click(object sender, EventArgs e)
// Change button colors
downloaderButton.BackColor = Color.FromArgb(13, 13, 13);
settingsButton.BackColor = Color.FromArgb(13, 13, 13);
+ searchButton.BackColor = Color.FromArgb(13, 13, 13);
aboutButton.BackColor = Color.FromArgb(18, 18, 18);
}
private void settingsButton_Click(object sender, EventArgs e)
{
- // Make other panels invisable, make settings panel visable
+ logger.Debug("Opening settings panel");
+ // Make other panels invisable, make settings panel visible
downloaderPanel.Visible = false;
+ searchPanel.Visible = false;
aboutPanel.Visible = false;
settingsPanel.Visible = true;
@@ -858,13 +951,16 @@ private void settingsButton_Click(object sender, EventArgs e)
// Change button colors
downloaderButton.BackColor = Color.FromArgb(13, 13, 13);
aboutButton.BackColor = Color.FromArgb(13, 13, 13);
+ searchButton.BackColor = Color.FromArgb(13, 13, 13);
settingsButton.BackColor = Color.FromArgb(18, 18, 18);
}
- private void downloaderButton_Click(object sender, EventArgs e)
+ public void downloaderButton_Click(object sender, EventArgs e)
{
- // Make other panels invisable, make settings panel visable
+ logger.Debug("Opening download panel");
+ // Make other panels invisable, make settings panel visible
aboutPanel.Visible = false;
+ searchPanel.Visible = false;
settingsPanel.Visible = false;
extraSettingsPanel.Visible = false;
downloaderPanel.Visible = true;
@@ -877,13 +973,38 @@ private void downloaderButton_Click(object sender, EventArgs e)
// Change button colors
aboutButton.BackColor = Color.FromArgb(13, 13, 13);
settingsButton.BackColor = Color.FromArgb(13, 13, 13);
+ searchButton.BackColor = Color.FromArgb(13, 13, 13);
downloaderButton.BackColor = Color.FromArgb(18, 18, 18);
}
+ private void searchButton_Click(object sender, EventArgs e)
+ {
+ logger.Debug("Opening search panel");
+ // Make other panels invisable, make settings panel visible
+ aboutPanel.Visible = false;
+ settingsPanel.Visible = false;
+ extraSettingsPanel.Visible = false;
+ downloaderPanel.Visible = false;
+ searchPanel.Visible = true;
+
+ // Make this the active panel
+ aboutPanelActive = false;
+ settingsPanelActive = false;
+ downloadPanelActive = true;
+
+ // Change button colors
+ aboutButton.BackColor = Color.FromArgb(13, 13, 13);
+ settingsButton.BackColor = Color.FromArgb(13, 13, 13);
+ downloaderButton.BackColor = Color.FromArgb(13, 13, 13);
+ searchButton.BackColor = Color.FromArgb(18, 18, 18);
+ }
+
private void additionalSettingsButton_Click(object sender, EventArgs e)
{
- // Make other panels invisable, make settings panel visable
+ logger.Debug("Opening extra settings panel");
+ // Make other panels invisable, make settings panel visible
aboutPanel.Visible = false;
+ searchPanel.Visible = false;
downloaderPanel.Visible = false;
settingsPanel.Visible = false;
extraSettingsPanel.Visible = true;
@@ -896,13 +1017,16 @@ private void additionalSettingsButton_Click(object sender, EventArgs e)
// Change button colors
aboutButton.BackColor = Color.FromArgb(13, 13, 13);
downloaderButton.BackColor = Color.FromArgb(13, 13, 13);
+ searchButton.BackColor = Color.FromArgb(13, 13, 13);
settingsButton.BackColor = Color.FromArgb(18, 18, 18);
}
private void closeAdditionalButton_Click(object sender, EventArgs e)
{
- // Make other panels invisable, make settings panel visable
+ logger.Debug("Closing extra settings panel");
+ // Make other panels invisable, make settings panel visible
aboutPanel.Visible = false;
+ searchPanel.Visible = false;
downloaderPanel.Visible = false;
extraSettingsPanel.Visible = false;
settingsPanel.Visible = true;
@@ -915,6 +1039,7 @@ private void closeAdditionalButton_Click(object sender, EventArgs e)
// Change button colors
aboutButton.BackColor = Color.FromArgb(13, 13, 13);
downloaderButton.BackColor = Color.FromArgb(13, 13, 13);
+ searchButton.BackColor = Color.FromArgb(13, 13, 13);
settingsButton.BackColor = Color.FromArgb(18, 18, 18);
}
@@ -938,9 +1063,206 @@ private void downloadOutput_TextChanged(object sender, EventArgs e)
downloadOutput.ScrollToCaret();
}
- private void downloadButton_Click(object sender, EventArgs e)
+ #region Window Moving
+
+ // For moving form with click and drag
+ private void logoPanel_MouseMove(object sender, MouseEventArgs e)
{
- getLinkType();
+ if (e.Button == MouseButtons.Left)
+ {
+ ReleaseCapture();
+ SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
+ }
+ }
+
+ private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Left)
+ {
+ ReleaseCapture();
+ SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
+ }
+ }
+
+ private void movingLabel_MouseMove(object sender, MouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Left)
+ {
+ ReleaseCapture();
+ SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
+ }
+ }
+
+ private void downloadLabel_MouseMove(object sender, MouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Left)
+ {
+ ReleaseCapture();
+ SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
+ }
+ }
+
+ private void settingsLabel_MouseMove(object sender, MouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Left)
+ {
+ ReleaseCapture();
+ SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
+ }
+ }
+
+ private void extraSettingsLabel_MouseMove(object sender, MouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Left)
+ {
+ ReleaseCapture();
+ SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
+ }
+ }
+
+ private void aboutLabel_MouseMove(object sender, MouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Left)
+ {
+ ReleaseCapture();
+ SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
+ }
+ }
+
+ private void searchLabel_MouseMove(object sender, MouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Left)
+ {
+ ReleaseCapture();
+ SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
+ }
+ }
+
+ #endregion
+
+ private void searchAlbumsButton_Click(object sender, EventArgs e)
+ {
+ logger.Debug("Hiding search buttons");
+ searchAlbumsButton.Visible = false;
+ searchTracksButton.Visible = false;
+ searchingLabel.Visible = true;
+ searchResultsPanel.Hide();
+
+ string searchQuery = searchTextbox.Text;
+
+ if (string.IsNullOrEmpty(searchQuery))
+ {
+ logger.Debug("Search query was null, canceling");
+ searchResultsPanel.Show();
+ searchAlbumsButton.Visible = true;
+ searchTracksButton.Visible = true;
+ searchingLabel.Visible = false;
+ return;
+ }
+
+ try
+ {
+ logger.Debug("Search for releases started");
+ QoAlbumSearch = QoService.SearchAlbumsWithAuth(app_id, searchQuery, 25, 0, user_auth_token);
+ searchPanelHelper.PopulateTableAlbums(this, QoAlbumSearch);
+ }
+ catch (Exception ex)
+ {
+ logger.Error("Error occured during searchAlbumsButton_Click, error below:\r\n" + ex);
+ searchResultsPanel.Show();
+ searchAlbumsButton.Visible = true;
+ searchTracksButton.Visible = true;
+ searchingLabel.Visible = false;
+ return;
+ }
+ logger.Debug("Search completed!");
+ searchResultsPanel.Show();
+ searchAlbumsButton.Visible = true;
+ searchTracksButton.Visible = true;
+ searchingLabel.Visible = false;
+ return;
+ }
+
+ private void searchTracksButton_Click(object sender, EventArgs e)
+ {
+ logger.Debug("Hiding search buttons");
+ searchAlbumsButton.Visible = false;
+ searchTracksButton.Visible = false;
+ searchingLabel.Visible = true;
+ searchResultsPanel.Hide();
+
+ string searchQuery = searchTextbox.Text;
+
+ if (string.IsNullOrEmpty(searchQuery))
+ {
+ logger.Debug("Search query was null, canceling");
+ searchResultsPanel.Show();
+ searchAlbumsButton.Visible = true;
+ searchTracksButton.Visible = true;
+ searchingLabel.Visible = false;
+ return;
+ }
+
+ try
+ {
+ logger.Debug("Search for tracks started");
+ QoTrackSearch = QoService.SearchTracksWithAuth(app_id, searchQuery, 25, 0, user_auth_token);
+ searchPanelHelper.PopulateTableTracks(this, QoTrackSearch);
+ }
+ catch (Exception ex)
+ {
+ logger.Error("Error occured during searchTracksButton_Click, error below:\r\n" + ex);
+ searchResultsPanel.Show();
+ searchAlbumsButton.Visible = true;
+ searchTracksButton.Visible = true;
+ searchingLabel.Visible = false;
+ return;
+ }
+ logger.Debug("Search completed!");
+ searchResultsPanel.Show();
+ searchAlbumsButton.Visible = true;
+ searchTracksButton.Visible = true;
+ searchingLabel.Visible = false;
+ return;
+ }
+ }
+ public class Logger
+ {
+ private readonly string _filePath;
+
+ public Logger(string filePath)
+ {
+ _filePath = filePath;
+ }
+
+ public void Log(string message, string level)
+ {
+ var logMessage = $"[{DateTime.Now}] [{level}] {message}";
+
+ using (var writer = File.AppendText(_filePath))
+ {
+ writer.WriteLine(logMessage);
+ }
+ }
+
+ public void Debug(string message)
+ {
+ Log(message, "DEBUG");
+ }
+
+ public void Info(string message)
+ {
+ Log(message, "INFO");
+ }
+
+ public void Warning(string message)
+ {
+ Log(message, "WARNING");
+ }
+
+ public void Error(string message)
+ {
+ Log(message, "ERROR");
}
}
}