From 3962e0f68230997397471d69289f391cf1ad9c25 Mon Sep 17 00:00:00 2001 From: AiiR <22158489+ImAiiR@users.noreply.github.com> Date: Mon, 20 Jul 2020 17:17:03 -0400 Subject: [PATCH] 0.9.9.18 0.9.9.18 --- QobuzDownloaderX/Form1.cs | 92 +++++++++++++++------ QobuzDownloaderX/Properties/AssemblyInfo.cs | 4 +- 2 files changed, 68 insertions(+), 28 deletions(-) diff --git a/QobuzDownloaderX/Form1.cs b/QobuzDownloaderX/Form1.cs index b6b7224..7d12a57 100644 --- a/QobuzDownloaderX/Form1.cs +++ b/QobuzDownloaderX/Form1.cs @@ -232,22 +232,27 @@ namespace QobuzDownloaderX // return date.ToString("yyyy-MM-dd"); //} - - + static string DecodeEncodedNonAsciiCharacters(string value) { - return Regex.Replace( + if (value != null) + { + return Regex.Replace( value, @"\\u(?[a-zA-Z0-9]{4})", m => { return ((char)int.Parse(m.Groups["Value"].Value, NumberStyles.HexNumber)).ToString(); }); + } + else + { + return null; + } } static string GetMd5Hash(MD5 md5Hash, string input) { - // Convert the input string to a byte array and compute the hash. byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input)); @@ -672,8 +677,12 @@ namespace QobuzDownloaderX albumArtistPath = GetSafeFilename(albumArtist); albumArtistTextBox.Invoke(new Action(() => albumArtistTextBox.Text = albumArtist)); - performerName = (string)joTrackResponse["performer"]["name"]; performerName = DecodeEncodedNonAsciiCharacters(performerName); - performerNamePath = GetSafeFilename(performerName); + try + { + performerName = (string)joTrackResponse["performer"]["name"]; performerName = DecodeEncodedNonAsciiCharacters(performerName); + performerNamePath = GetSafeFilename(performerName); + } + catch { performerName = null; performerNamePath = null; /*Set to null and Ignore if fails*/ } try { composerName = (string)joTrackResponse["composer"]["name"]; composerName = DecodeEncodedNonAsciiCharacters(composerName); } catch { /*Ignore if fails*/ } @@ -804,9 +813,12 @@ namespace QobuzDownloaderX albumArtistPath = albumArtistPath.Substring(0, MaxLength).TrimEnd(); } - if (performerNamePath.Length > MaxLength) + if (performerName != null) { - performerNamePath = performerNamePath.Substring(0, MaxLength).TrimEnd(); + if (performerNamePath.Length > MaxLength) + { + performerNamePath = performerNamePath.Substring(0, MaxLength).TrimEnd(); + } } if (albumNamePath.Length > MaxLength) @@ -1470,8 +1482,12 @@ namespace QobuzDownloaderX albumArtistPath = GetSafeFilename(albumArtist); albumArtistTextBox.Invoke(new Action(() => albumArtistTextBox.Text = albumArtist)); - performerName = (string)joTrackResponse["performer"]["name"]; performerName = DecodeEncodedNonAsciiCharacters(performerName); - performerNamePath = GetSafeFilename(performerName); + try + { + performerName = (string)joTrackResponse["performer"]["name"]; performerName = DecodeEncodedNonAsciiCharacters(performerName); + performerNamePath = GetSafeFilename(performerName); + } + catch { performerName = null; performerNamePath = null; /*Set to null and Ignore if fails*/ } try { composerName = (string)joTrackResponse["composer"]["name"]; composerName = DecodeEncodedNonAsciiCharacters(composerName); } catch { /*Ignore if fails*/ } @@ -1602,9 +1618,12 @@ namespace QobuzDownloaderX albumArtistPath = albumArtistPath.Substring(0, MaxLength).TrimEnd(); } - if (performerNamePath.Length > MaxLength) + if (performerName != null) { - performerNamePath = performerNamePath.Substring(0, MaxLength).TrimEnd(); + if (performerNamePath.Length > MaxLength) + { + performerNamePath = performerNamePath.Substring(0, MaxLength).TrimEnd(); + } } if (albumNamePath.Length > MaxLength) @@ -2269,8 +2288,12 @@ namespace QobuzDownloaderX albumArtistPath = GetSafeFilename(albumArtist); albumArtistTextBox.Invoke(new Action(() => albumArtistTextBox.Text = albumArtist)); - performerName = (string)joTrackResponse["performer"]["name"]; performerName = DecodeEncodedNonAsciiCharacters(albumArtist); - performerNamePath = GetSafeFilename(performerName); + try + { + performerName = (string)joTrackResponse["performer"]["name"]; performerName = DecodeEncodedNonAsciiCharacters(performerName); + performerNamePath = GetSafeFilename(performerName); + } + catch { performerName = null; performerNamePath = null; /*Set to null and Ignore if fails*/ } try { composerName = (string)joTrackResponse["composer"]["name"]; composerName = DecodeEncodedNonAsciiCharacters(composerName); } catch { /*Ignore if fails*/ } @@ -2401,9 +2424,12 @@ namespace QobuzDownloaderX albumArtistPath = albumArtistPath.Substring(0, MaxLength).TrimEnd(); } - if (performerNamePath.Length > MaxLength) + if (performerName != null) { - performerNamePath = performerNamePath.Substring(0, MaxLength).TrimEnd(); + if (performerNamePath.Length > MaxLength) + { + performerNamePath = performerNamePath.Substring(0, MaxLength).TrimEnd(); + } } if (albumNamePath.Length > MaxLength) @@ -3035,10 +3061,14 @@ namespace QobuzDownloaderX albumArtistPath = GetSafeFilename(albumArtist); albumArtistTextBox.Invoke(new Action(() => albumArtistTextBox.Text = albumArtist)); - performerName = (string)joTrackResponse["performer"]["name"]; performerName = DecodeEncodedNonAsciiCharacters(performerName); - performerNamePath = GetSafeFilename(performerName); + try + { + performerName = (string)joTrackResponse["performer"]["name"]; performerName = DecodeEncodedNonAsciiCharacters(performerName); + performerNamePath = GetSafeFilename(performerName); + } + catch { performerName = null; performerNamePath = null; /*Set to null and Ignore if fails*/ } - try { composerName = (string)joTrackResponse["composer"]["name"]; composerName = DecodeEncodedNonAsciiCharacters(composerName); } catch { /*Ignore if fails*/ } + try { composerName = (string)joTrackResponse["composer"]["name"]; composerName = DecodeEncodedNonAsciiCharacters(composerName); } catch { composerName = null; /*Set to null and Ignore if fails*/ } advisory = (string)joTrackResponse["parental_warning"]; @@ -3167,9 +3197,12 @@ namespace QobuzDownloaderX albumArtistPath = albumArtistPath.Substring(0, MaxLength).TrimEnd(); } - if (performerNamePath.Length > MaxLength) + if (performerName != null) { - performerNamePath = performerNamePath.Substring(0, MaxLength).TrimEnd(); + if (performerNamePath.Length > MaxLength) + { + performerNamePath = performerNamePath.Substring(0, MaxLength).TrimEnd(); + } } if (albumNamePath.Length > MaxLength) @@ -3748,10 +3781,14 @@ namespace QobuzDownloaderX albumArtistPath = GetSafeFilename(albumArtist); albumArtistTextBox.Invoke(new Action(() => albumArtistTextBox.Text = albumArtist)); - performerName = (string)joResponse2["performer"]["name"]; performerName = DecodeEncodedNonAsciiCharacters(performerName); - performerNamePath = GetSafeFilename(performerName); + try + { + performerName = (string)joResponse2["performer"]["name"]; performerName = DecodeEncodedNonAsciiCharacters(performerName); + performerNamePath = GetSafeFilename(performerName); + } + catch { performerName = null; performerNamePath = null; /*Set to null and Ignore if fails*/ } - try { composerName = (string)joResponse2["composer"]["name"]; composerName = DecodeEncodedNonAsciiCharacters(composerName); } catch { /*Ignore if fails*/ } + try { composerName = (string)joResponse2["composer"]["name"]; composerName = DecodeEncodedNonAsciiCharacters(composerName); } catch { composerName = null; /*Set to null and Ignore if fails*/ } advisory = (string)joResponse2["parental_warning"]; @@ -3880,9 +3917,12 @@ namespace QobuzDownloaderX albumArtistPath = albumArtistPath.Substring(0, MaxLength).TrimEnd(); } - if (performerNamePath.Length > MaxLength) + if (performerName != null) { - performerNamePath = performerNamePath.Substring(0, MaxLength).TrimEnd(); + if (performerNamePath.Length > MaxLength) + { + performerNamePath = performerNamePath.Substring(0, MaxLength).TrimEnd(); + } } if (albumNamePath.Length > MaxLength) diff --git a/QobuzDownloaderX/Properties/AssemblyInfo.cs b/QobuzDownloaderX/Properties/AssemblyInfo.cs index 46d2555..f0ac623 100644 --- a/QobuzDownloaderX/Properties/AssemblyInfo.cs +++ b/QobuzDownloaderX/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.9.9.17")] -[assembly: AssemblyFileVersion("0.9.9.17")] +[assembly: AssemblyVersion("0.9.9.18")] +[assembly: AssemblyFileVersion("0.9.9.18")]