diff --git a/QobuzDownloaderX/App.config b/QobuzDownloaderX/App.config
index 7a0b8ad..828eae1 100644
--- a/QobuzDownloaderX/App.config
+++ b/QobuzDownloaderX/App.config
@@ -163,6 +163,9 @@
EN
+
+ AiiR
+
diff --git a/QobuzDownloaderX/Helpers/Download/DownloadAlbum.cs b/QobuzDownloaderX/Helpers/Download/DownloadAlbum.cs
index 696df2a..966fee7 100644
--- a/QobuzDownloaderX/Helpers/Download/DownloadAlbum.cs
+++ b/QobuzDownloaderX/Helpers/Download/DownloadAlbum.cs
@@ -33,16 +33,14 @@ class DownloadAlbum
PaddingNumbers padNumber = new PaddingNumbers();
DownloadTrack downloadTrack = new DownloadTrack();
DownloadFile downloadFile = new DownloadFile();
- RenameTemplates renameTemplates = new RenameTemplates();
GetInfo getInfo = new GetInfo();
- FixMD5 fixMD5 = new FixMD5();
private async Task DownloadArtwork(string downloadPath, Album album)
{
try
{
qbdlxForm._qbdlxForm.logger.Debug("Downloading artwork...");
- await downloadFile.downloadArtwork(downloadPath, album);
+ await downloadFile.DownloadArtwork(downloadPath, album);
qbdlxForm._qbdlxForm.logger.Debug("Artwork download complete");
}
catch (Exception ex)
@@ -52,7 +50,7 @@ private async Task DownloadArtwork(string downloadPath, Album album)
}
}
- private async Task DeleteEmbeddedArtwork(string downloadPath)
+ private void DeleteEmbeddedArtwork(string downloadPath)
{
try
{
@@ -81,7 +79,7 @@ private async Task DownloadGoodiesAsync(string downloadPath, Album album)
}
qbdlxForm._qbdlxForm.logger.Debug("Downloading goody...");
- await downloadFile.downloadGoody(downloadPath, album, goody);
+ await downloadFile.DownloadGoody(downloadPath, album, goody);
qbdlxForm._qbdlxForm.logger.Debug("Goody download complete");
getInfo.updateDownloadOutput($"{qbdlxForm._qbdlxForm.downloadOutputDone}\r\n");
}
@@ -112,7 +110,7 @@ private async Task DownloadTracksAsync(string app_id, string album_id, string fo
}
}
- public async Task 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)
+ public async Task DownloadAlbumAsync(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)");
@@ -154,7 +152,7 @@ public async Task downloadAlbum(string app_id, string album_id, string format_id
await DownloadTracksAsync(app_id, album_id, format_id, audio_format, user_auth_token, app_secret, downloadLocation, artistTemplate, albumTemplate, trackTemplate, QoAlbum);
// Delete image used for embedding artwork
- await DeleteEmbeddedArtwork(downloadPath);
+ DeleteEmbeddedArtwork(downloadPath);
// Set current output text
getInfo.outputText = qbdlxForm._qbdlxForm.downloadOutput.Text;
@@ -210,20 +208,20 @@ private void WritePostTemplate(Album album)
if (album.MaximumBitDepth > 16)
{
sw.WriteLine($"[format=FLAC / Lossless ({album.MaximumBitDepth.ToString()}bit/{album.MaximumSamplingRate.ToString()}kHz) / WEB]");
- sw.WriteLine("Uploaded by @AiiR");
+ sw.WriteLine($"Uploaded by @{Settings.Default.postTemplateUsername.ToString()}");
sw.WriteLine("");
sw.WriteLine("DOWNLOAD");
sw.WriteLine("REPLACE THIS WITH URL");
sw.WriteLine("[/format]");
}
sw.WriteLine("[format=FLAC / Lossless / WEB]");
- sw.WriteLine("Uploaded by @AiiR");
+ sw.WriteLine($"Uploaded by @{Settings.Default.postTemplateUsername.ToString()}");
sw.WriteLine("");
sw.WriteLine("DOWNLOAD");
sw.WriteLine("REPLACE THIS WITH URL");
sw.WriteLine("[/format]");
sw.WriteLine("[format=MP3 / 320 / WEB]");
- sw.WriteLine("Uploaded by @AiiR");
+ sw.WriteLine($"Uploaded by @{Settings.Default.postTemplateUsername.ToString()}");
sw.WriteLine("");
sw.WriteLine("DOWNLOAD");
sw.WriteLine("REPLACE THIS WITH URL");
diff --git a/QobuzDownloaderX/Helpers/Download/DownloadFile.cs b/QobuzDownloaderX/Helpers/Download/DownloadFile.cs
index f0d4ad1..fe19469 100644
--- a/QobuzDownloaderX/Helpers/Download/DownloadFile.cs
+++ b/QobuzDownloaderX/Helpers/Download/DownloadFile.cs
@@ -4,7 +4,6 @@
using System.Threading.Tasks;
using QopenAPI;
using QobuzDownloaderX.Properties;
-using QobuzDownloaderX.Download;
using System.Text.RegularExpressions;
namespace QobuzDownloaderX
@@ -43,7 +42,7 @@ public async Task createPath(string downloadLocation, string artistTempl
});
}
- public async Task downloadStream(string streamUrl, string downloadPath, string filePath, string audio_format, Album QoAlbum, Item QoItem)
+ public async Task 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);
@@ -145,7 +144,7 @@ public async Task downloadStream(string streamUrl, string downloadPath, string f
}
}
- public async Task downloadArtwork(string downloadPath, Album QoAlbum)
+ public async Task DownloadArtwork(string downloadPath, Album QoAlbum)
{
using (var client = new WebClient())
{
@@ -159,17 +158,17 @@ public async Task downloadArtwork(string downloadPath, Album QoAlbum)
if (!File.Exists(downloadPath + @"Cover.jpg"))
{
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"); }
+ try { await client.DownloadFileTaskAsync(QoAlbum.Image.Large.Replace("_600", "_" + qbdlxForm._qbdlxForm.savedArtSize), downloadPath + @"Cover.jpg"); } catch { qbdlxForm._qbdlxForm.logger.Error("Failed to Download Cover Art"); }
}
if (!File.Exists(downloadPath + qbdlxForm._qbdlxForm.embeddedArtSize + @".jpg"))
{
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"); }
+ try { await client.DownloadFileTaskAsync(QoAlbum.Image.Large.Replace("_600", "_" + qbdlxForm._qbdlxForm.embeddedArtSize), downloadPath + qbdlxForm._qbdlxForm.embeddedArtSize + @".jpg"); } catch { qbdlxForm._qbdlxForm.logger.Error("Failed to Download Cover Art"); }
}
}
}
- public async Task downloadGoody(string downloadPath, Album QoAlbum, Goody QoGoody)
+ public async Task DownloadGoody(string downloadPath, Album QoAlbum, Goody QoGoody)
{
using (var client = new WebClient())
{
@@ -178,7 +177,7 @@ public async Task downloadGoody(string downloadPath, Album QoAlbum, Goody QoGood
// Download goody to the download path
Directory.CreateDirectory(Path.GetDirectoryName(downloadPath));
- client.DownloadFile(QoGoody.Url, downloadPath + renameTemplates.GetSafeFilename(QoAlbum.Title) + " (" + QoGoody.Id + @").pdf");
+ await client.DownloadFileTaskAsync(QoGoody.Url, downloadPath + renameTemplates.GetSafeFilename(QoAlbum.Title) + " (" + QoGoody.Id + @").pdf");
}
}
}
diff --git a/QobuzDownloaderX/Helpers/Download/DownloadTrack.cs b/QobuzDownloaderX/Helpers/Download/DownloadTrack.cs
index 5c87377..a132a27 100644
--- a/QobuzDownloaderX/Helpers/Download/DownloadTrack.cs
+++ b/QobuzDownloaderX/Helpers/Download/DownloadTrack.cs
@@ -3,7 +3,6 @@
using QopenAPI;
using System.IO;
using QobuzDownloaderX.Properties;
-using QobuzDownloaderX.Download;
namespace QobuzDownloaderX
{
@@ -80,7 +79,7 @@ private async Task DownloadAndSaveTrack(string app_id, string format_id, string
else { getInfo.updateDownloadOutput($"{qbdlxForm._qbdlxForm.downloadOutputDownloading} - {QoItem.Position.ToString().PadLeft(paddedTrackLength, '0')} {trackName}..."); }
// Download stream
- await downloadFile.downloadStream(streamURL, downloadPath, filePath, audio_format, QoAlbum, QoItem);
+ await downloadFile.DownloadStream(streamURL, downloadPath, filePath, audio_format, QoAlbum, QoItem);
getInfo.updateDownloadOutput($" {qbdlxForm._qbdlxForm.downloadOutputDone}\r\n");
}
@@ -124,7 +123,7 @@ public async Task DownloadTrackAsync(string downloadType, string app_id, string
}
// Download cover art
- try { await downloadFile.downloadArtwork(downloadPath, QoAlbum); } catch { qbdlxForm._qbdlxForm.logger.Error("Failed to Download Cover Art"); }
+ try { await downloadFile.DownloadArtwork(downloadPath, QoAlbum); } catch { qbdlxForm._qbdlxForm.logger.Error("Failed to Download Cover Art"); }
// Check for Existing File
if (CheckForExistingFile(filePath, paddedTrackLength, QoItem)) return;
@@ -175,7 +174,7 @@ public async Task DownloadPlaylistTrackAsync(string app_id, string album_id, str
if (CheckForExistingFile(filePath, paddedTrackLength, QoItem)) return;
// Download cover art
- try { await downloadFile.downloadArtwork(downloadPath, QoAlbum); } catch { Console.WriteLine("Failed to Download Cover Art"); }
+ try { await downloadFile.DownloadArtwork(downloadPath, QoAlbum); } catch { Console.WriteLine("Failed to Download Cover Art"); }
// Download and Save Track
await DownloadAndSaveTrack(app_id, format_id, user_auth_token, app_secret, QoAlbum, QoItem, QoPlaylist, downloadPath, filePath, audio_format, paddedTrackLength);
diff --git a/QobuzDownloaderX/Helpers/SearchPanelHelper.cs b/QobuzDownloaderX/Helpers/SearchPanelHelper.cs
index c1ba723..296c58b 100644
--- a/QobuzDownloaderX/Helpers/SearchPanelHelper.cs
+++ b/QobuzDownloaderX/Helpers/SearchPanelHelper.cs
@@ -15,21 +15,21 @@ class SearchPanelHelper
public SearchAlbumResult QoAlbumSearch = new SearchAlbumResult();
public SearchTrackResult QoTrackSearch = new SearchTrackResult();
- public async Task SearchInitiate(string searchType, string app_id, string searchQuery, string user_auth_token)
+ public void SearchInitiate(string searchType, string app_id, string searchQuery, string user_auth_token)
{
if (searchType == "releases")
{
QoAlbumSearch = QoService.SearchAlbumsWithAuth(app_id, searchQuery, 25, 0, user_auth_token);
- await PopulateTableAlbums(qbdlxForm._qbdlxForm, QoAlbumSearch);
+ PopulateTableAlbums(qbdlxForm._qbdlxForm, QoAlbumSearch);
}
else if (searchType == "tracks")
{
QoTrackSearch = QoService.SearchTracksWithAuth(app_id, searchQuery, 25, 0, user_auth_token);
- await PopulateTableTracks(qbdlxForm._qbdlxForm, QoTrackSearch);
+ PopulateTableTracks(qbdlxForm._qbdlxForm, QoTrackSearch);
}
}
- public async Task PopulateTableAlbums(qbdlxForm mainForm, SearchAlbumResult QoAlbumSearch)
+ public void PopulateTableAlbums(qbdlxForm mainForm, SearchAlbumResult QoAlbumSearch)
{
// Access the "items" array from the response
var albums = QoAlbumSearch.Albums.Items;
@@ -131,7 +131,7 @@ public async Task PopulateTableAlbums(qbdlxForm mainForm, SearchAlbumResult QoAl
});
}
- public async Task PopulateTableTracks(qbdlxForm mainForm, SearchTrackResult QoTrackSearch)
+ public void PopulateTableTracks(qbdlxForm mainForm, SearchTrackResult QoTrackSearch)
{
// Access the "items" array from the response
var tracks = QoTrackSearch.Tracks.Items;
diff --git a/QobuzDownloaderX/Helpers/Theming.cs b/QobuzDownloaderX/Helpers/Theming.cs
index 9a0986f..f8d1e0b 100644
--- a/QobuzDownloaderX/Helpers/Theming.cs
+++ b/QobuzDownloaderX/Helpers/Theming.cs
@@ -103,7 +103,6 @@ public void ApplyTheme(Control parent)
{
if (control is Button button)
{
- qbdlxForm._qbdlxForm.logger.Info("Setting button theme for button: " + button.Name);
button.ForeColor = ColorTranslator.FromHtml(_currentTheme.ButtonText);
button.FlatAppearance.MouseOverBackColor = ColorTranslator.FromHtml(_currentTheme.HighlightedButtonBackground);
button.FlatAppearance.MouseDownBackColor = ColorTranslator.FromHtml(_currentTheme.ClickedButtonBackground);
@@ -123,7 +122,6 @@ public void ApplyTheme(Control parent)
}
else if (control is Label label)
{
- qbdlxForm._qbdlxForm.logger.Info("Setting label theme for label: " + label.Name);
if (label.Name == "versionNumber") { if (parent.Name == "LoginForm") { label.BackColor = ColorTranslator.FromHtml(_currentTheme.MainPanelBackground); } else { label.BackColor = ColorTranslator.FromHtml(_currentTheme.SidePanelBackground); } }
// Apply specific colors for specific panels if needed
@@ -133,7 +131,6 @@ public void ApplyTheme(Control parent)
}
else if (control is TextBox textBox)
{
- qbdlxForm._qbdlxForm.logger.Info("Setting textBox theme for textBox: " + textBox.Name);
textBox.ForeColor = ColorTranslator.FromHtml(_currentTheme.TextBoxText);
// Apply specific colors for specific panels if needed
@@ -147,8 +144,6 @@ public void ApplyTheme(Control parent)
}
else if (control is PictureBox pictureBox)
{
- qbdlxForm._qbdlxForm.logger.Info("Setting textBox theme for textBox: " + pictureBox.Name);
-
// Apply specific colors for specific panels if needed
pictureBox.BackColor = pictureBox.Name == "logoPictureBox"
? ColorTranslator.FromHtml(_currentTheme.SidePanelBackground)
@@ -183,8 +178,6 @@ public void ApplyTheme(Control parent)
}
else if (control is Panel panel)
{
- qbdlxForm._qbdlxForm.logger.Info("Setting panel theme for panel: " + panel.Name);
-
if (panel.Name == "emailPanel" || panel.Name == "passwordPanel") { continue; }
// Apply specific colors for specific panels if needed
diff --git a/QobuzDownloaderX/Helpers/Updating.cs b/QobuzDownloaderX/Helpers/Updating.cs
index 7f7fd03..f5d61e4 100644
--- a/QobuzDownloaderX/Helpers/Updating.cs
+++ b/QobuzDownloaderX/Helpers/Updating.cs
@@ -1,12 +1,157 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+using System.Collections.Generic;
+using System.IO;
+using System;
+using Newtonsoft.Json.Linq;
+using System.Net.Http;
using System.Threading.Tasks;
+using System.Reflection;
+using System.Net;
namespace QobuzDownloaderX.Helpers
{
- internal class Updating
+ public class TranslationUpdater
{
+ // List of language files
+ private static readonly Dictionary LanguageFiles = new Dictionary
+ {
+ { "en.json", "Languages/en.json" },
+ { "ru.json", "Languages/ru.json" },
+ { "zh-cn.json", "Languages/zh-cn.json" }
+ };
+
+ public static async Task CheckAndUpdateLanguageFiles()
+ {
+ using (HttpClient client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Add("User-Agent", "TranslationUpdater");
+
+ foreach (var languageFile in LanguageFiles)
+ {
+ string fileName = languageFile.Key;
+ string localFilePath = languageFile.Value;
+
+ string apiUrl = $"https://api.github.com/repos/ImAiiR/QobuzDownloaderX/contents/QobuzDownloaderX/Resources/{localFilePath}";
+
+ try
+ {
+ HttpResponseMessage response = await client.GetAsync(apiUrl);
+ if (response.IsSuccessStatusCode)
+ {
+ string jsonResponse = await response.Content.ReadAsStringAsync();
+ JObject fileMetadata = JObject.Parse(jsonResponse);
+
+ // Retrieve the download URL for the remote file
+ string downloadUrl = fileMetadata["download_url"]?.ToString();
+ if (!string.IsNullOrEmpty(downloadUrl))
+ {
+ // Fetch the remote file content
+ string remoteContent = await client.GetStringAsync(downloadUrl);
+
+ // Parse the "TranslationUpdatedOn" field from the remote file
+ JObject remoteJson = JObject.Parse(remoteContent);
+ string remoteUpdatedOnString = remoteJson["TranslationUpdatedOn"]?.ToString();
+
+ // Parse the local file's "TranslationUpdatedOn" field
+ if (File.Exists(localFilePath.ToLower()))
+ {
+ string localContent = File.ReadAllText(localFilePath.ToLower());
+ JObject localJson = JObject.Parse(localContent);
+ string localUpdatedOnString = localJson["TranslationUpdatedOn"]?.ToString();
+
+ // Compare updated date
+ if (remoteUpdatedOnString != localUpdatedOnString)
+ {
+ File.WriteAllText(localFilePath.ToLower(), remoteContent);
+ qbdlxForm._qbdlxForm.logger.Debug($"File {fileName} updated successfully.");
+ }
+ else
+ {
+ qbdlxForm._qbdlxForm.logger.Debug($"File {fileName} is already up-to-date.");
+ }
+ }
+ else
+ {
+ // Local file does not exist, download it
+ File.WriteAllText(localFilePath.ToLower(), remoteContent);
+ qbdlxForm._qbdlxForm.logger.Debug($"File {fileName} downloaded successfully.");
+ }
+ }
+ else
+ {
+ qbdlxForm._qbdlxForm.logger.Error($"Failed to retrieve the download URL for {fileName}.");
+ }
+ }
+ else
+ {
+ qbdlxForm._qbdlxForm.logger.Error($"Failed to fetch metadata for {fileName}: {response.StatusCode}");
+ }
+ }
+ catch (Exception ex)
+ {
+ qbdlxForm._qbdlxForm.logger.Error($"Error updating {fileName}: {ex.Message}");
+ }
+ }
+ }
+ }
+ }
+
+ public static class VersionChecker
+ {
+ public static async Task<(bool isUpdateAvailable, string newVersion, string currentVersion, string changes)> CheckForUpdate()
+ {
+ string changes = string.Empty;
+ string currentVersion = string.Empty;
+ string newVersion = string.Empty;
+ bool isUpdateAvailable = false;
+
+ try
+ {
+ // Initialize HttpClient to grab version number from GitHub
+ using (var versionURLClient = new HttpClient())
+ {
+ qbdlxForm._qbdlxForm.logger.Debug("versionURLClient initialized");
+
+ // Configure TLS for 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");
+
+ // Request the latest release from GitHub
+ qbdlxForm._qbdlxForm.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 = await versionURLResponse.Content.ReadAsStringAsync();
+
+ // Parse the JSON response
+ JObject joVersionResponse = JObject.Parse(versionURLResponseString);
+
+ // Extract version number and changelog
+ newVersion = (string)joVersionResponse["tag_name"];
+ qbdlxForm._qbdlxForm.logger.Debug("Received version from GitHub: " + newVersion);
+ changes = (string)joVersionResponse["body"];
+
+ // Get the current version from the assembly
+ currentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
+
+ // Compare versions
+ if (!currentVersion.Contains(newVersion))
+ {
+ isUpdateAvailable = true;
+ qbdlxForm._qbdlxForm.logger.Debug("New version available: " + newVersion);
+ }
+ else
+ {
+ qbdlxForm._qbdlxForm.logger.Debug("Current version matches the latest version.");
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ qbdlxForm._qbdlxForm.logger.Error("Connection to GitHub failed: " + ex.Message);
+ }
+
+ return (isUpdateAvailable, newVersion, currentVersion, changes);
+ }
}
}
diff --git a/QobuzDownloaderX/LoginForm/LoginForm.cs b/QobuzDownloaderX/LoginForm/LoginForm.cs
index 0936005..1ce4656 100644
--- a/QobuzDownloaderX/LoginForm/LoginForm.cs
+++ b/QobuzDownloaderX/LoginForm/LoginForm.cs
@@ -2,15 +2,13 @@
using System;
using System.ComponentModel;
using System.Drawing;
-using System.Net;
using System.IO;
using System.Diagnostics;
using System.Windows.Forms;
using System.Reflection;
using System.Runtime.InteropServices;
-using System.Net.Http;
using QopenAPI;
-using Newtonsoft.Json.Linq;
+using QobuzDownloaderX.Helpers;
namespace QobuzDownloaderX
{
@@ -43,6 +41,7 @@ private void QobuzDownloaderX_FormClosing(Object sender, FormClosingEventArgs e)
private readonly Theming themeManager = new Theming();
private LanguageManager languageManager;
qbdlxForm qbdlx = new qbdlxForm();
+ Logger logger = qbdlxForm._qbdlxForm.logger;
Service QoService = new Service();
User QoUser;
@@ -50,9 +49,6 @@ 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; }
@@ -134,47 +130,8 @@ private void UpdateUILanguage()
altLoginLabel.Text = altLoginLabelToken;
}
- private async void LoginForm_Load(object sender, EventArgs e)
+ private void SetSavedValues()
{
- // 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));
-
- 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();
- }
- // Bring to center of screen.
- CenterToScreen();
-
- // Set and load theme
- themeManager.LoadTheme(Settings.Default.currentTheme);
- themeManager.ApplyTheme(this);
-
- // Set and load language
- languageManager = new LanguageManager();
- languageManager.LoadLanguage($"languages/{Settings.Default.currentLanguage.ToLower()}.json");
- UpdateUILanguage();
-
- if (Properties.Settings.Default.UpgradeRequired)
- {
- Properties.Settings.Default.Upgrade();
- Properties.Settings.Default.UpgradeRequired = false;
- Properties.Settings.Default.Save();
- }
-
- // 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());
-
// Set saved settings to correct places.
username = Settings.Default.savedEmail.ToString();
password = Settings.Default.savedPassword.ToString();
@@ -219,64 +176,83 @@ private async void LoginForm_Load(object sender, EventArgs e)
passwordTextbox.ForeColor = ColorTranslator.FromHtml(themeManager._currentTheme.PlaceholderTextBoxText);
passwordTextbox.Text = passwordPlaceholder;
}
+ }
+
+ private void InitializeTheme()
+ {
+ themeManager.LoadTheme(Settings.Default.currentTheme);
+ themeManager.ApplyTheme(this);
+ }
+ private void InitializeLanguage()
+ {
+ languageManager = new LanguageManager();
+ languageManager.LoadLanguage($"languages/{Settings.Default.currentLanguage.ToLower()}.json");
+ UpdateUILanguage();
+ }
+
+ private async void CheckForNewVersion()
+ {
try
{
- // 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 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"];
-
- currentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
- newVersion = version;
-
- if (currentVersion.Contains(newVersion))
- {
- // Do nothing. All is good.
- logger.Debug("Current version and new version match!");
- }
- else
+ var (isUpdateAvailable, _newVersion, _currentVersion, _changes) = await VersionChecker.CheckForUpdate();
+
+ changes = _changes;
+ newVersion = _newVersion;
+ currentVersion = _currentVersion;
+
+ if (isUpdateAvailable)
{
- logger.Warning("Current version and new version do not match!");
- logger.Debug("Enabling update button");
+ logger.Warning("An update is available.");
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)
- {
- // If "Yes" is clicked, open GitHub page and close QBDLX.
- Process.Start("https://github.com/ImAiiR/QobuzDownloaderX/releases/latest");
- Application.Exit();
- }
else
{
- // Ignore the update until next open.
+ logger.Debug("No update needed.");
}
}
+ catch (Exception ex)
+ {
+ logger.Error($"Connection to GitHub to check for an update has failed: {ex.Message}");
+ }
+ }
+
+ private async void LoginForm_Load(object sender, EventArgs e)
+ {
+ // Upgrade previous settings to current version
+ if (Properties.Settings.Default.UpgradeRequired)
+ {
+ Properties.Settings.Default.Upgrade();
+ Properties.Settings.Default.UpgradeRequired = false;
+ Properties.Settings.Default.Save();
+ }
+
+ // Round corners of form
+ Region = Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 20, 20));
+
+ 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();
+ }
+
+ // Center program + Set theme, language, saved values + Check for update on GitHub
+ CenterToScreen();
+ InitializeTheme();
+ InitializeLanguage();
+ SetSavedValues();
+ CheckForNewVersion();
+
+ // 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());
+
+ // Check for language updates
+ await TranslationUpdater.CheckAndUpdateLanguageFiles();
}
private void exitButton_Click(object sender, EventArgs e)
diff --git a/QobuzDownloaderX/MainForm/qbdlxForm.cs b/QobuzDownloaderX/MainForm/qbdlxForm.cs
index 0c7191a..ded7ead 100644
--- a/QobuzDownloaderX/MainForm/qbdlxForm.cs
+++ b/QobuzDownloaderX/MainForm/qbdlxForm.cs
@@ -35,6 +35,13 @@ private static extern IntPtr CreateRoundRectRgn
int nHeightEllipse // height of ellipse
);
+ // Create logger for this form
+ public Logger logger { get; set; }
+
+ // Create theme and language options
+ public Theme theme { get; set; }
+ public LanguageManager languageManager;
+
public Service QoService = new Service();
public User QoUser = new User();
public Artist QoArtist = new Artist();
@@ -52,9 +59,6 @@ int nHeightEllipse // height of ellipse
public bool settingsPanelActive = false;
private bool firstLoadComplete = 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; }
@@ -78,10 +82,6 @@ int nHeightEllipse // height of ellipse
public string savedArtSize { get; set; }
public string themeName { get; set; }
- // Create theme and language options
- public Theme theme { get; set; }
- public LanguageManager languageManager;
-
#region Language
public string userInfoTextboxPlaceholder { get; set; }
public string albumLabelPlaceholder { get; set; }
@@ -120,7 +120,7 @@ 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 = new Logger("logs\\log_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".txt");
logger.Debug("Logger started, QBDLX form initialized!");
InitializeComponent();
@@ -522,7 +522,7 @@ public async void getLinkType()
break;
}
updateAlbumInfoLabels(QoAlbum);
- await Task.Run(() => downloadAlbum.downloadAlbum(app_id, qobuz_id, format_id, audio_format, user_auth_token, app_secret, downloadLocation, artistTemplate, albumTemplate, trackTemplate, QoAlbum));
+ await Task.Run(() => downloadAlbum.DownloadAlbumAsync(app_id, qobuz_id, format_id, audio_format, user_auth_token, app_secret, downloadLocation, artistTemplate, albumTemplate, trackTemplate, QoAlbum));
// Say the downloading is finished when it's completed.
getInfo.outputText = qbdlxForm._qbdlxForm.downloadOutput.Text;
getInfo.updateDownloadOutput("\r\n" + downloadOutputCompleted);
@@ -574,7 +574,7 @@ public async void getLinkType()
await Task.Run(() => getInfo.getAlbumInfoLabels(app_id, album_id, user_auth_token));
QoAlbum = getInfo.QoAlbum;
updateAlbumInfoLabels(QoAlbum);
- await Task.Run(() => downloadAlbum.downloadAlbum(app_id, qobuz_id, format_id, audio_format, user_auth_token, app_secret, downloadLocation, artistTemplate, albumTemplate, trackTemplate, QoAlbum));
+ await Task.Run(() => downloadAlbum.DownloadAlbumAsync(app_id, qobuz_id, format_id, audio_format, user_auth_token, app_secret, downloadLocation, artistTemplate, albumTemplate, trackTemplate, QoAlbum));
}
catch
{
@@ -597,7 +597,7 @@ public async void getLinkType()
await Task.Run(() => getInfo.getAlbumInfoLabels(app_id, album_id, user_auth_token));
QoAlbum = getInfo.QoAlbum;
updateAlbumInfoLabels(QoAlbum);
- await Task.Run(() => downloadAlbum.downloadAlbum(app_id, qobuz_id, format_id, audio_format, user_auth_token, app_secret, downloadLocation, artistTemplate, albumTemplate, trackTemplate, QoAlbum));
+ await Task.Run(() => downloadAlbum.DownloadAlbumAsync(app_id, qobuz_id, format_id, audio_format, user_auth_token, app_secret, downloadLocation, artistTemplate, albumTemplate, trackTemplate, QoAlbum));
}
catch
{
@@ -622,7 +622,7 @@ public async void getLinkType()
await Task.Run(() => getInfo.getAlbumInfoLabels(app_id, album_id, user_auth_token));
QoAlbum = getInfo.QoAlbum;
updateAlbumInfoLabels(QoAlbum);
- await Task.Run(() => downloadAlbum.downloadAlbum(app_id, album_id, format_id, audio_format, user_auth_token, app_secret, downloadLocation, artistTemplate, albumTemplate, trackTemplate, QoAlbum));
+ await Task.Run(() => downloadAlbum.DownloadAlbumAsync(app_id, album_id, format_id, audio_format, user_auth_token, app_secret, downloadLocation, artistTemplate, albumTemplate, trackTemplate, QoAlbum));
}
catch
{
@@ -670,7 +670,7 @@ public async void getLinkType()
await Task.Run(() => getInfo.getAlbumInfoLabels(app_id, album_id, user_auth_token));
QoAlbum = getInfo.QoAlbum;
updateAlbumInfoLabels(QoAlbum);
- await Task.Run(() => downloadAlbum.downloadAlbum(app_id, album_id, format_id, audio_format, user_auth_token, app_secret, downloadLocation, artistTemplate, albumTemplate, trackTemplate, QoAlbum));
+ await Task.Run(() => downloadAlbum.DownloadAlbumAsync(app_id, album_id, format_id, audio_format, user_auth_token, app_secret, downloadLocation, artistTemplate, albumTemplate, trackTemplate, QoAlbum));
}
catch
{
@@ -1429,21 +1429,25 @@ public void Log(string message, string level)
public void Debug(string message)
{
+ Console.WriteLine($"DEBUG | {message}");
Log(message, "DEBUG");
}
public void Info(string message)
{
+ Console.WriteLine($"INFO | {message}");
Log(message, "INFO");
}
public void Warning(string message)
{
+ Console.WriteLine($"WARNING | {message}");
Log(message, "WARNING");
}
public void Error(string message)
{
+ Console.WriteLine($"ERROR | {message}");
Log(message, "ERROR");
}
}
diff --git a/QobuzDownloaderX/Properties/Settings.Designer.cs b/QobuzDownloaderX/Properties/Settings.Designer.cs
index 0a81135..ffcea12 100644
--- a/QobuzDownloaderX/Properties/Settings.Designer.cs
+++ b/QobuzDownloaderX/Properties/Settings.Designer.cs
@@ -634,5 +634,17 @@ public string currentLanguage {
this["currentLanguage"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("AiiR")]
+ public string postTemplateUsername {
+ get {
+ return ((string)(this["postTemplateUsername"]));
+ }
+ set {
+ this["postTemplateUsername"] = value;
+ }
+ }
}
}
diff --git a/QobuzDownloaderX/Properties/Settings.settings b/QobuzDownloaderX/Properties/Settings.settings
index 205d331..7609405 100644
--- a/QobuzDownloaderX/Properties/Settings.settings
+++ b/QobuzDownloaderX/Properties/Settings.settings
@@ -155,5 +155,8 @@
EN
+
+ AiiR
+
\ No newline at end of file
diff --git a/QobuzDownloaderX/QobuzDownloaderX.csproj b/QobuzDownloaderX/QobuzDownloaderX.csproj
index 550d4e9..28fac54 100644
--- a/QobuzDownloaderX/QobuzDownloaderX.csproj
+++ b/QobuzDownloaderX/QobuzDownloaderX.csproj
@@ -83,39 +83,16 @@
-
-
-
+
+
+
-
- Form
-
-
- Form1.cs
-
-
- Form
-
-
- AboutForm.cs
-
-
- Form
-
-
- LoginForm-v2.cs
-
-
- Form
-
-
- searchForm.cs
-
+
Form
@@ -124,26 +101,14 @@
-
+
Form
-
+
qbdlxForm.cs
-
-
- Form1.cs
-
-
- AboutForm.cs
-
-
- LoginForm-v2.cs
-
-
- searchForm.cs
-
+
LoginForm.cs
@@ -157,7 +122,7 @@
Resources.resx
True
-
+
qbdlxForm.cs
@@ -170,12 +135,11 @@
Settings.settings
True
-
- Always
-
+
+
@@ -208,12 +172,11 @@
-
-
-
+
- xcopy /y /i "$(ProjectDir)Resources\Languages\*.json" "$(TargetDir)languages\"
+ xcopy /y /i "$(ProjectDir)Resources\Languages\*.json" "$(TargetDir)languages\"
+xcopy /y /i "$(ProjectDir)Resources\themes.json" "$(TargetDir)"