This commit is contained in:
AiiR 2020-01-09 05:34:23 -05:00
parent 272babb837
commit 4e14909b22
3 changed files with 121 additions and 105 deletions

View File

@ -506,7 +506,7 @@ namespace QobuzDownloaderX
foreach (Match mtrack in Regex.Matches(trackinput, trackIdspattern, trackoptions)) foreach (Match mtrack in Regex.Matches(trackinput, trackIdspattern, trackoptions))
{ {
// Set default value for max length. // Set default value for max length.
const int MaxLength = 100; const int MaxLength = 36;
//output.Invoke(new Action(() => output.AppendText(string.Format("{0}\r\n", m.Groups["trackId"].Value)))); //output.Invoke(new Action(() => output.AppendText(string.Format("{0}\r\n", m.Groups["trackId"].Value))));
trackIdString = string.Format("{0}", mtrack.Groups["trackId"].Value); trackIdString = string.Format("{0}", mtrack.Groups["trackId"].Value);
@ -769,7 +769,7 @@ namespace QobuzDownloaderX
// Check if there is a version name. // Check if there is a version name.
if (versionName == null | versionName == "") if (versionName == null | versionName == "")
{ {
if (System.IO.File.Exists(discogPath + "\\" + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + audioFileType)) if (System.IO.File.Exists(discogPath + "\\" + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + audioFileType))
{ {
output.Invoke(new Action(() => output.AppendText("File for \"" + trackNumber.PadLeft(paddingLength, '0') + " " + trackName + "\" already exists. Skipping.\r\n"))); output.Invoke(new Action(() => output.AppendText("File for \"" + trackNumber.PadLeft(paddingLength, '0') + " " + trackName + "\" already exists. Skipping.\r\n")));
System.Threading.Thread.Sleep(800); System.Threading.Thread.Sleep(800);
@ -778,7 +778,7 @@ namespace QobuzDownloaderX
} }
else else
{ {
if (System.IO.File.Exists(discogPath + "\\" + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + " (" + versionNamePath + ")" + audioFileType)) if (System.IO.File.Exists(discogPath + "\\" + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + " (" + versionNamePath + ")" + audioFileType))
{ {
output.Invoke(new Action(() => output.AppendText("File for \"" + trackNumber.PadLeft(paddingLength, '0') + " " + trackName + " (" + versionName + ")" + "\" already exists. Skipping.\r\n"))); output.Invoke(new Action(() => output.AppendText("File for \"" + trackNumber.PadLeft(paddingLength, '0') + " " + trackName + " (" + versionName + ")" + "\" already exists. Skipping.\r\n")));
System.Threading.Thread.Sleep(800); System.Threading.Thread.Sleep(800);
@ -817,10 +817,10 @@ namespace QobuzDownloaderX
using (var stream = await client.GetStreamAsync(testURLBox.Text)) using (var stream = await client.GetStreamAsync(testURLBox.Text))
// Save single track in selected path. // Save single track in selected path.
if (versionName == null | versionName == "") if (versionNamePath == null | versionNamePath == "")
{ {
// If there is NOT a version name. // If there is NOT a version name.
using (var output = System.IO.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + " [" + albumIdDiscog + "]" + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + audioFileType)) using (var output = System.IO.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + " [" + albumIdDiscog + "]" + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + audioFileType))
{ {
await stream.CopyToAsync(output); await stream.CopyToAsync(output);
} }
@ -828,7 +828,7 @@ namespace QobuzDownloaderX
else else
{ {
// If there is a version name. // If there is a version name.
using (var output = System.IO.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + " [" + albumIdDiscog + "]" + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + " (" + versionNamePath + ")" + audioFileType)) using (var output = System.IO.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + " [" + albumIdDiscog + "]" + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + " (" + versionNamePath + ")" + audioFileType))
{ {
await stream.CopyToAsync(output); await stream.CopyToAsync(output);
} }
@ -864,7 +864,7 @@ namespace QobuzDownloaderX
if (versionName == null | versionName == "") if (versionName == null | versionName == "")
{ {
// If there is NOT a version name. // If there is NOT a version name.
var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + " [" + albumIdDiscog + "]" + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + audioFileType); var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + " [" + albumIdDiscog + "]" + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + audioFileType);
// For custom / troublesome tags. // For custom / troublesome tags.
TagLib.Id3v2.Tag t = (TagLib.Id3v2.Tag)tfile.GetTag(TagLib.TagTypes.Id3v2); TagLib.Id3v2.Tag t = (TagLib.Id3v2.Tag)tfile.GetTag(TagLib.TagTypes.Id3v2);
@ -987,7 +987,7 @@ namespace QobuzDownloaderX
else else
{ {
// If there is a version name. // If there is a version name.
var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + " [" + albumIdDiscog + "]" + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + " (" + versionNamePath + ")" + audioFileType); var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + " [" + albumIdDiscog + "]" + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + " (" + versionNamePath + ")" + audioFileType);
// For custom / troublesome tags. // For custom / troublesome tags.
TagLib.Id3v2.Tag t = (TagLib.Id3v2.Tag)tfile.GetTag(TagLib.TagTypes.Id3v2); TagLib.Id3v2.Tag t = (TagLib.Id3v2.Tag)tfile.GetTag(TagLib.TagTypes.Id3v2);
@ -1117,7 +1117,7 @@ namespace QobuzDownloaderX
if (versionName == null | versionName == "") if (versionName == null | versionName == "")
{ {
// If there is NOT a version name. // If there is NOT a version name.
var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + " [" + albumIdDiscog + "]" + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + audioFileType); var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + " [" + albumIdDiscog + "]" + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + audioFileType);
// For custom / troublesome tags. // For custom / troublesome tags.
var custom = (TagLib.Ogg.XiphComment)tfile.GetTag(TagLib.TagTypes.Xiph); var custom = (TagLib.Ogg.XiphComment)tfile.GetTag(TagLib.TagTypes.Xiph);
@ -1238,7 +1238,7 @@ namespace QobuzDownloaderX
else else
{ {
// If there is a version name. // If there is a version name.
var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + " [" + albumIdDiscog + "]" + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + " (" + versionNamePath + ")" + audioFileType); var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + " [" + albumIdDiscog + "]" + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + " (" + versionNamePath + ")" + audioFileType);
// For custom / troublesome tags. // For custom / troublesome tags.
var custom = (TagLib.Ogg.XiphComment)tfile.GetTag(TagLib.TagTypes.Xiph); var custom = (TagLib.Ogg.XiphComment)tfile.GetTag(TagLib.TagTypes.Xiph);
@ -1389,7 +1389,7 @@ namespace QobuzDownloaderX
{ {
// If there is an issue trying to, or during the download, show error info. // If there is an issue trying to, or during the download, show error info.
string error = downloadError.ToString(); string error = downloadError.ToString();
output.Invoke(new Action(() => output.Text = String.Empty)); output.Invoke(new Action(() => output.AppendText("\r\n\r\n")));
output.Invoke(new Action(() => output.AppendText("Track Download ERROR. Information below.\r\n\r\n"))); output.Invoke(new Action(() => output.AppendText("Track Download ERROR. Information below.\r\n\r\n")));
output.Invoke(new Action(() => output.AppendText(error))); output.Invoke(new Action(() => output.AppendText(error)));
output.Invoke(new Action(() => output.AppendText("\r\n\r\nIf some tracks aren't available for streaming on the album you're trying to download, try to manually download the available tracks individually."))); output.Invoke(new Action(() => output.AppendText("\r\n\r\nIf some tracks aren't available for streaming on the album you're trying to download, try to manually download the available tracks individually.")));
@ -1536,7 +1536,7 @@ namespace QobuzDownloaderX
foreach (Match m in Regex.Matches(input, trackIdspattern, options)) foreach (Match m in Regex.Matches(input, trackIdspattern, options))
{ {
// Set default value for max length. // Set default value for max length.
const int MaxLength = 100; const int MaxLength = 36;
// Grab matches for Track IDs // Grab matches for Track IDs
trackIdString = string.Format("{0}", m.Groups["trackId"].Value); trackIdString = string.Format("{0}", m.Groups["trackId"].Value);
@ -1589,6 +1589,7 @@ namespace QobuzDownloaderX
string decodedAlbumArtist = DecodeEncodedNonAsciiCharacters(unicodeAlbumArtist); string decodedAlbumArtist = DecodeEncodedNonAsciiCharacters(unicodeAlbumArtist);
albumArtist = decodedAlbumArtist; albumArtist = decodedAlbumArtist;
// Replace double slashes & path unfriendly characters
albumArtist = albumArtist.Replace(@"\\", @"\").Replace(@"\/", @"/"); albumArtist = albumArtist.Replace(@"\\", @"\").Replace(@"\/", @"/");
var albumArtistPath = albumArtist.Replace(@"\", "-").Replace(@"/", "-").Replace("\"", "''").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-"); var albumArtistPath = albumArtist.Replace(@"\", "-").Replace(@"/", "-").Replace("\"", "''").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-");
@ -1610,6 +1611,7 @@ namespace QobuzDownloaderX
string decodedPerformerName = DecodeEncodedNonAsciiCharacters(unicodePerformerName); string decodedPerformerName = DecodeEncodedNonAsciiCharacters(unicodePerformerName);
performerName = decodedPerformerName; performerName = decodedPerformerName;
// Replace double slashes & path unfriendly characters
performerName = performerName.Replace(@"\\", @"\").Replace(@"\/", @"/"); performerName = performerName.Replace(@"\\", @"\").Replace(@"\/", @"/");
var performerNamePath = performerName.Replace(@"\", "-").Replace(@"/", "-").Replace("\"", "''").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-"); var performerNamePath = performerName.Replace(@"\", "-").Replace(@"/", "-").Replace("\"", "''").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-");
@ -1632,6 +1634,7 @@ namespace QobuzDownloaderX
string decodedComposerName = DecodeEncodedNonAsciiCharacters(unicodeComposerName); string decodedComposerName = DecodeEncodedNonAsciiCharacters(unicodeComposerName);
composerName = decodedComposerName; composerName = decodedComposerName;
// Replace double slashes
composerName = composerName.Replace(@"\\", @"\").Replace(@"\/", @"/"); composerName = composerName.Replace(@"\\", @"\").Replace(@"\/", @"/");
// Album Name tag // Album Name tag
@ -1643,6 +1646,7 @@ namespace QobuzDownloaderX
string decodedAlbumName = DecodeEncodedNonAsciiCharacters(unicodeAlbumName); string decodedAlbumName = DecodeEncodedNonAsciiCharacters(unicodeAlbumName);
albumName = decodedAlbumName; albumName = decodedAlbumName;
// Replace double slashes & path unfriendly characters
albumName = albumName.Replace(@"\\", @"\").Replace(@"\/", @"/"); albumName = albumName.Replace(@"\\", @"\").Replace(@"\/", @"/");
var albumNamePath = albumName.Replace(@"\", "-").Replace(@"/", "-").Replace("\"", "''").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-"); var albumNamePath = albumName.Replace(@"\", "-").Replace(@"/", "-").Replace("\"", "''").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-");
@ -1665,6 +1669,7 @@ namespace QobuzDownloaderX
string decodedTrackName = DecodeEncodedNonAsciiCharacters(unicodeTrackName); string decodedTrackName = DecodeEncodedNonAsciiCharacters(unicodeTrackName);
trackName = decodedTrackName; trackName = decodedTrackName;
// Replace double slashes & path unfriendly characters
trackName = trackName.Replace(@"\\", @"\").Replace(@"\/", @"/"); trackName = trackName.Replace(@"\\", @"\").Replace(@"\/", @"/");
var trackNamePath = trackName.Replace(@"\", "-").Replace(@"/", "-").Replace("\"", "''").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-"); var trackNamePath = trackName.Replace(@"\", "-").Replace(@"/", "-").Replace("\"", "''").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-");
@ -1683,9 +1688,16 @@ namespace QobuzDownloaderX
string decodedVersionName = DecodeEncodedNonAsciiCharacters(unicodeVersionName); string decodedVersionName = DecodeEncodedNonAsciiCharacters(unicodeVersionName);
versionName = decodedVersionName; versionName = decodedVersionName;
// Replace double slashes & path unfriendly characters
versionName = versionName.Replace(@"\\", @"\").Replace(@"\/", @"/"); versionName = versionName.Replace(@"\\", @"\").Replace(@"\/", @"/");
var versionNamePath = versionName.Replace(@"\", "-").Replace(@"/", "-").Replace("\"", "''").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-"); var versionNamePath = versionName.Replace(@"\", "-").Replace(@"/", "-").Replace("\"", "''").Replace(":", "-").Replace("<", "-").Replace(">", "-").Replace("|", "-").Replace("?", "-").Replace("*", "-");
//// If name goes over 200 characters, limit it to 200
//if (trackNamePath.Length + versionNamePath.Length > MaxLength)
//{
// versionNamePath = null;
//}
// Genre tag // Genre tag
var genreLog = Regex.Match(trackRequest, "\"genre\":{\"id\":(?<notUsed>.*?),\"color\":\"(?<notUsed2>.*?)\",\"name\":\"(?<genreName>.*?)\",\\\"").Groups; var genreLog = Regex.Match(trackRequest, "\"genre\":{\"id\":(?<notUsed>.*?),\"color\":\"(?<notUsed2>.*?)\",\"name\":\"(?<genreName>.*?)\",\\\"").Groups;
var genre = genreLog[3].Value; var genre = genreLog[3].Value;
@ -1805,7 +1817,7 @@ namespace QobuzDownloaderX
// Check if there is a version name. // Check if there is a version name.
if (versionName == null | versionName == "") if (versionName == null | versionName == "")
{ {
if (System.IO.File.Exists(albumPath + "\\" + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + audioFileType)) if (System.IO.File.Exists(albumPath + "\\" + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + audioFileType))
{ {
output.Invoke(new Action(() => output.AppendText("File for \"" + trackNumber.PadLeft(paddingLength, '0') + " " + trackName + "\" already exists. Skipping.\r\n"))); output.Invoke(new Action(() => output.AppendText("File for \"" + trackNumber.PadLeft(paddingLength, '0') + " " + trackName + "\" already exists. Skipping.\r\n")));
System.Threading.Thread.Sleep(800); System.Threading.Thread.Sleep(800);
@ -1814,7 +1826,7 @@ namespace QobuzDownloaderX
} }
else else
{ {
if (System.IO.File.Exists(albumPath + "\\" + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + " (" + versionNamePath + ")" + audioFileType)) if (System.IO.File.Exists(albumPath + "\\" + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + " (" + versionNamePath + ")" + audioFileType))
{ {
output.Invoke(new Action(() => output.AppendText("File for \"" + trackNumber.PadLeft(paddingLength, '0') + " " + trackName + " (" + versionName + ")" + "\" already exists. Skipping.\r\n"))); output.Invoke(new Action(() => output.AppendText("File for \"" + trackNumber.PadLeft(paddingLength, '0') + " " + trackName + " (" + versionName + ")" + "\" already exists. Skipping.\r\n")));
System.Threading.Thread.Sleep(800); System.Threading.Thread.Sleep(800);
@ -1854,10 +1866,10 @@ namespace QobuzDownloaderX
using (var stream = await client.GetStreamAsync(testURLBox.Text)) using (var stream = await client.GetStreamAsync(testURLBox.Text))
// Save single track in selected path. // Save single track in selected path.
if (versionName == null | versionName == "") if (versionNamePath == null | versionNamePath == "")
{ {
// If there is NOT a version name. // If there is NOT a version name.
using (var output = System.IO.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + audioFileType)) using (var output = System.IO.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + audioFileType))
{ {
await stream.CopyToAsync(output); await stream.CopyToAsync(output);
} }
@ -1865,7 +1877,7 @@ namespace QobuzDownloaderX
else else
{ {
// If there is a version name. // If there is a version name.
using (var output = System.IO.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + " (" + versionNamePath + ")" + audioFileType)) using (var output = System.IO.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + " (" + versionNamePath + ")" + audioFileType))
{ {
await stream.CopyToAsync(output); await stream.CopyToAsync(output);
} }
@ -1898,7 +1910,7 @@ namespace QobuzDownloaderX
if (versionName == null | versionName == "") if (versionName == null | versionName == "")
{ {
// If there is NOT a version name. // If there is NOT a version name.
var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + audioFileType); var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + audioFileType);
// For custom / troublesome tags. // For custom / troublesome tags.
TagLib.Id3v2.Tag t = (TagLib.Id3v2.Tag)tfile.GetTag(TagLib.TagTypes.Id3v2); TagLib.Id3v2.Tag t = (TagLib.Id3v2.Tag)tfile.GetTag(TagLib.TagTypes.Id3v2);
@ -2021,7 +2033,7 @@ namespace QobuzDownloaderX
else else
{ {
// If there is a version name. // If there is a version name.
var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + " (" + versionNamePath + ")" + audioFileType); var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + " (" + versionNamePath + ")" + audioFileType);
// For custom / troublesome tags. // For custom / troublesome tags.
TagLib.Id3v2.Tag t = (TagLib.Id3v2.Tag)tfile.GetTag(TagLib.TagTypes.Id3v2); TagLib.Id3v2.Tag t = (TagLib.Id3v2.Tag)tfile.GetTag(TagLib.TagTypes.Id3v2);
@ -2151,7 +2163,7 @@ namespace QobuzDownloaderX
if (versionName == null | versionName == "") if (versionName == null | versionName == "")
{ {
// If there is NOT a version name. // If there is NOT a version name.
var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + audioFileType); var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + audioFileType);
// For custom / troublesome tags. // For custom / troublesome tags.
var custom = (TagLib.Ogg.XiphComment)tfile.GetTag(TagLib.TagTypes.Xiph); var custom = (TagLib.Ogg.XiphComment)tfile.GetTag(TagLib.TagTypes.Xiph);
@ -2272,7 +2284,7 @@ namespace QobuzDownloaderX
else else
{ {
// If there is a version name. // If there is a version name.
var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + " (" + versionNamePath + ")" + audioFileType); var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + " (" + versionNamePath + ")" + audioFileType);
// For custom / troublesome tags. // For custom / troublesome tags.
var custom = (TagLib.Ogg.XiphComment)tfile.GetTag(TagLib.TagTypes.Xiph); var custom = (TagLib.Ogg.XiphComment)tfile.GetTag(TagLib.TagTypes.Xiph);
@ -2430,7 +2442,7 @@ namespace QobuzDownloaderX
{ {
// If there is an issue trying to, or during the download, show error info. // If there is an issue trying to, or during the download, show error info.
string error = downloadError.ToString(); string error = downloadError.ToString();
output.Invoke(new Action(() => output.Text = String.Empty)); output.Invoke(new Action(() => output.AppendText("\r\n\r\n")));
output.Invoke(new Action(() => output.AppendText("Track Download ERROR. Information below.\r\n\r\n"))); output.Invoke(new Action(() => output.AppendText("Track Download ERROR. Information below.\r\n\r\n")));
output.Invoke(new Action(() => output.AppendText(error))); output.Invoke(new Action(() => output.AppendText(error)));
downloadButton.Invoke(new Action(() => downloadButton.Enabled = true)); downloadButton.Invoke(new Action(() => downloadButton.Enabled = true));
@ -2464,7 +2476,7 @@ namespace QobuzDownloaderX
{ {
#region If URL has "track" #region If URL has "track"
// Set default value for max length. // Set default value for max length.
const int MaxLength = 100; const int MaxLength = 36;
// Set "loc" as the selected path. // Set "loc" as the selected path.
String loc = folderBrowserDialog.SelectedPath; String loc = folderBrowserDialog.SelectedPath;
@ -2785,7 +2797,7 @@ namespace QobuzDownloaderX
// Check if there is a version name. // Check if there is a version name.
if (versionName == null | versionName == "") if (versionName == null | versionName == "")
{ {
if (System.IO.File.Exists(trackPath + "\\" + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + audioFileType)) if (System.IO.File.Exists(trackPath + "\\" + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + audioFileType))
{ {
output.Invoke(new Action(() => output.AppendText("File for \"" + trackNumber.PadLeft(paddingLength, '0') + " " + trackName + "\" already exists. Skipping.\r\n"))); output.Invoke(new Action(() => output.AppendText("File for \"" + trackNumber.PadLeft(paddingLength, '0') + " " + trackName + "\" already exists. Skipping.\r\n")));
System.Threading.Thread.Sleep(800); System.Threading.Thread.Sleep(800);
@ -2795,7 +2807,7 @@ namespace QobuzDownloaderX
} }
else else
{ {
if (System.IO.File.Exists(trackPath + "\\" + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + " (" + versionNamePath + ")" + audioFileType)) if (System.IO.File.Exists(trackPath + "\\" + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + " (" + versionNamePath + ")" + audioFileType))
{ {
output.Invoke(new Action(() => output.AppendText("File for \"" + trackNumber.PadLeft(paddingLength, '0') + " " + trackName + " (" + versionName + ")" + "\" already exists. Skipping.\r\n"))); output.Invoke(new Action(() => output.AppendText("File for \"" + trackNumber.PadLeft(paddingLength, '0') + " " + trackName + " (" + versionName + ")" + "\" already exists. Skipping.\r\n")));
System.Threading.Thread.Sleep(800); System.Threading.Thread.Sleep(800);
@ -2836,10 +2848,10 @@ namespace QobuzDownloaderX
using (var stream = await client.GetStreamAsync(testURLBox.Text)) using (var stream = await client.GetStreamAsync(testURLBox.Text))
// Save single track in selected path. // Save single track in selected path.
if (versionName == null | versionName == "") if (versionNamePath == null | versionNamePath == "")
{ {
// If there is NOT a version name. // If there is NOT a version name.
using (var output = System.IO.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + audioFileType)) using (var output = System.IO.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + audioFileType))
{ {
await stream.CopyToAsync(output); await stream.CopyToAsync(output);
} }
@ -2847,7 +2859,7 @@ namespace QobuzDownloaderX
else else
{ {
// If there is a version name. // If there is a version name.
using (var output = System.IO.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + " (" + versionNamePath + ")" + audioFileType)) using (var output = System.IO.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + " (" + versionNamePath + ")" + audioFileType))
{ {
await stream.CopyToAsync(output); await stream.CopyToAsync(output);
} }
@ -2880,7 +2892,7 @@ namespace QobuzDownloaderX
if (versionName == null | versionName == "") if (versionName == null | versionName == "")
{ {
// If there is NOT a version name. // If there is NOT a version name.
var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + audioFileType); var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + audioFileType);
// For custom / troublesome tags. // For custom / troublesome tags.
TagLib.Id3v2.Tag t = (TagLib.Id3v2.Tag)tfile.GetTag(TagLib.TagTypes.Id3v2); TagLib.Id3v2.Tag t = (TagLib.Id3v2.Tag)tfile.GetTag(TagLib.TagTypes.Id3v2);
@ -3003,7 +3015,7 @@ namespace QobuzDownloaderX
else else
{ {
// If there is a version name. // If there is a version name.
var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + " (" + versionNamePath + ")" + audioFileType); var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + " (" + versionNamePath + ")" + audioFileType);
// For custom / troublesome tags. // For custom / troublesome tags.
TagLib.Id3v2.Tag t = (TagLib.Id3v2.Tag)tfile.GetTag(TagLib.TagTypes.Id3v2); TagLib.Id3v2.Tag t = (TagLib.Id3v2.Tag)tfile.GetTag(TagLib.TagTypes.Id3v2);
@ -3133,7 +3145,7 @@ namespace QobuzDownloaderX
if (versionName == null | versionName == "") if (versionName == null | versionName == "")
{ {
// If there is NOT a version name. // If there is NOT a version name.
var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + audioFileType); var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + audioFileType);
// For custom / troublesome tags. // For custom / troublesome tags.
var custom = (TagLib.Ogg.XiphComment)tfile.GetTag(TagLib.TagTypes.Xiph); var custom = (TagLib.Ogg.XiphComment)tfile.GetTag(TagLib.TagTypes.Xiph);
@ -3254,7 +3266,7 @@ namespace QobuzDownloaderX
else else
{ {
// If there is a version name. // If there is a version name.
var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + " (" + versionNamePath + ")" + audioFileType); var tfile = TagLib.File.Create(loc + "\\" + albumArtistPath + "\\" + albumNamePath + "\\" + qualityPath + "\\" + discFolder + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath.Trim() + " (" + versionNamePath + ")" + audioFileType);
// For custom / troublesome tags. // For custom / troublesome tags.
var custom = (TagLib.Ogg.XiphComment)tfile.GetTag(TagLib.TagTypes.Xiph); var custom = (TagLib.Ogg.XiphComment)tfile.GetTag(TagLib.TagTypes.Xiph);
@ -3380,9 +3392,9 @@ namespace QobuzDownloaderX
{ {
// If there is an issue trying to, or during the download, show error info. // If there is an issue trying to, or during the download, show error info.
string error = downloadError.ToString(); string error = downloadError.ToString();
output.Invoke(new Action(() => output.AppendText("\r\n\r\n")));
output.Invoke(new Action(() => output.AppendText("Track Download ERROR. Information below.\r\n\r\n"))); output.Invoke(new Action(() => output.AppendText("Track Download ERROR. Information below.\r\n\r\n")));
output.Invoke(new Action(() => output.AppendText(error))); output.Invoke(new Action(() => output.AppendText(error)));
output.Invoke(new Action(() => output.AppendText("\r\nTrack name path = " + trackNumber.PadLeft(paddingLength, '0') + " " + trackNamePath + " (" + versionNamePath + ")" + audioFileType)));
downloadButton.Invoke(new Action(() => downloadButton.Enabled = true)); downloadButton.Invoke(new Action(() => downloadButton.Enabled = true));
return; return;
} }

View File

@ -232,6 +232,7 @@ namespace QobuzDownloaderX
Settings.Default.Save(); Settings.Default.Save();
loginText.Text = "Logging in + obtaining app_secret..."; loginText.Text = "Logging in + obtaining app_secret...";
loginButton.Enabled = false;
loginBG.RunWorkerAsync(); loginBG.RunWorkerAsync();
} }
@ -441,6 +442,7 @@ namespace QobuzDownloaderX
loginText.Invoke(new Action(() => loginText.Text = "Login Failed. Error Log saved")); loginText.Invoke(new Action(() => loginText.Text = "Login Failed. Error Log saved"));
System.IO.File.WriteAllText(errorLog, error); System.IO.File.WriteAllText(errorLog, error);
wr.Abort(); wr.Abort();
loginButton.Invoke(new Action(() => loginButton.Enabled = true));
return; return;
} }
@ -505,6 +507,7 @@ namespace QobuzDownloaderX
loginText.Invoke(new Action(() => loginText.Text = "Couldn't obtain app_secret. Error Log saved")); loginText.Invoke(new Action(() => loginText.Text = "Couldn't obtain app_secret. Error Log saved"));
System.IO.File.WriteAllText(errorLog, bundleError); System.IO.File.WriteAllText(errorLog, bundleError);
bundleWR.Abort(); bundleWR.Abort();
loginButton.Invoke(new Action(() => loginButton.Enabled = true));
return; return;
} }
@ -515,6 +518,7 @@ namespace QobuzDownloaderX
private void finishLogin(object sender, EventArgs e) private void finishLogin(object sender, EventArgs e)
{ {
loginButton.Invoke(new Action(() => loginButton.Enabled = true));
// If info is legit, go to the main form. // If info is legit, go to the main form.
qbdlx.appid = appidTextbox.Text; qbdlx.appid = appidTextbox.Text;
qbdlx.eMail = emailTextbox.Text; qbdlx.eMail = emailTextbox.Text;

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.9.6")] [assembly: AssemblyVersion("0.9.9.7")]
[assembly: AssemblyFileVersion("0.9.9.6")] [assembly: AssemblyFileVersion("0.9.9.7")]