Skip to content

Commit

Permalink
1.0.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
ImAiiR committed Nov 24, 2024
1 parent ea9f128 commit 753ba68
Show file tree
Hide file tree
Showing 13 changed files with 361 additions and 194 deletions.
3 changes: 3 additions & 0 deletions QobuzDownloaderX/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@
<setting name="currentLanguage" serializeAs="String">
<value>EN</value>
</setting>
<setting name="postTemplateUsername" serializeAs="String">
<value>AiiR</value>
</setting>
</QobuzDownloaderX.Properties.Settings>
</userSettings>
</configuration>
18 changes: 8 additions & 10 deletions QobuzDownloaderX/Helpers/Download/DownloadAlbum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -52,7 +50,7 @@ private async Task DownloadArtwork(string downloadPath, Album album)
}
}

private async Task DeleteEmbeddedArtwork(string downloadPath)
private void DeleteEmbeddedArtwork(string downloadPath)
{
try
{
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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)");

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
13 changes: 6 additions & 7 deletions QobuzDownloaderX/Helpers/Download/DownloadFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Threading.Tasks;
using QopenAPI;
using QobuzDownloaderX.Properties;
using QobuzDownloaderX.Download;
using System.Text.RegularExpressions;

namespace QobuzDownloaderX
Expand Down Expand Up @@ -43,7 +42,7 @@ public async Task<string> 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);

Expand Down Expand Up @@ -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())
{
Expand All @@ -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())
{
Expand All @@ -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");
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions QobuzDownloaderX/Helpers/Download/DownloadTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using QopenAPI;
using System.IO;
using QobuzDownloaderX.Properties;
using QobuzDownloaderX.Download;

namespace QobuzDownloaderX
{
Expand Down Expand Up @@ -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");
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions QobuzDownloaderX/Helpers/SearchPanelHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 0 additions & 7 deletions QobuzDownloaderX/Helpers/Theming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 753ba68

Please sign in to comment.