mirror of
https://github.com/NohamR/QobuzDownloaderX.git
synced 2026-05-17 12:27:11 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bcc81b8462 | ||
|
|
ba8b9e3eec | ||
|
|
1ead0ed343 | ||
|
|
3962e0f682 |
@@ -233,21 +233,26 @@ namespace QobuzDownloaderX
|
|||||||
// return date.ToString("yyyy-MM-dd");
|
// return date.ToString("yyyy-MM-dd");
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
static string DecodeEncodedNonAsciiCharacters(string value)
|
static string DecodeEncodedNonAsciiCharacters(string value)
|
||||||
{
|
{
|
||||||
return Regex.Replace(
|
if (value != null)
|
||||||
|
{
|
||||||
|
return Regex.Replace(
|
||||||
value,
|
value,
|
||||||
@"\\u(?<Value>[a-zA-Z0-9]{4})",
|
@"\\u(?<Value>[a-zA-Z0-9]{4})",
|
||||||
m =>
|
m =>
|
||||||
{
|
{
|
||||||
return ((char)int.Parse(m.Groups["Value"].Value, NumberStyles.HexNumber)).ToString();
|
return ((char)int.Parse(m.Groups["Value"].Value, NumberStyles.HexNumber)).ToString();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static string GetMd5Hash(MD5 md5Hash, string input)
|
static string GetMd5Hash(MD5 md5Hash, string input)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Convert the input string to a byte array and compute the hash.
|
// Convert the input string to a byte array and compute the hash.
|
||||||
byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
|
byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
|
||||||
|
|
||||||
@@ -640,7 +645,7 @@ namespace QobuzDownloaderX
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// Grab all Track IDs listed on the API.
|
// Grab all Track IDs listed on the API.
|
||||||
string trackIDsPattern = "\"version\":(?:.*?),\"id\":(?<trackId>.*?),";
|
string trackIDsPattern = "\"isrc\":\"(?:.*?)\"(?:.*?)\"version\":(?:.*?),\"id\":(?<trackId>.*?),";
|
||||||
string trackIDsInput = albumIDResponseString;
|
string trackIDsInput = albumIDResponseString;
|
||||||
RegexOptions trackIDsOptions = RegexOptions.Multiline;
|
RegexOptions trackIDsOptions = RegexOptions.Multiline;
|
||||||
|
|
||||||
@@ -672,8 +677,12 @@ namespace QobuzDownloaderX
|
|||||||
albumArtistPath = GetSafeFilename(albumArtist);
|
albumArtistPath = GetSafeFilename(albumArtist);
|
||||||
albumArtistTextBox.Invoke(new Action(() => albumArtistTextBox.Text = albumArtist));
|
albumArtistTextBox.Invoke(new Action(() => albumArtistTextBox.Text = albumArtist));
|
||||||
|
|
||||||
performerName = (string)joTrackResponse["performer"]["name"]; performerName = DecodeEncodedNonAsciiCharacters(performerName);
|
try
|
||||||
performerNamePath = GetSafeFilename(performerName);
|
{
|
||||||
|
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 { /*Ignore if fails*/ }
|
||||||
|
|
||||||
@@ -804,9 +813,12 @@ namespace QobuzDownloaderX
|
|||||||
albumArtistPath = albumArtistPath.Substring(0, MaxLength).TrimEnd();
|
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)
|
if (albumNamePath.Length > MaxLength)
|
||||||
@@ -1438,7 +1450,7 @@ namespace QobuzDownloaderX
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// Grab all Track IDs listed on the API.
|
// Grab all Track IDs listed on the API.
|
||||||
string trackIDsPattern = "\"version\":(?:.*?),\"id\":(?<trackId>.*?),";
|
string trackIDsPattern = "\"isrc\":\"(?:.*?)\"(?:.*?)\"version\":(?:.*?),\"id\":(?<trackId>.*?),";
|
||||||
string trackIDsInput = albumIDResponseString;
|
string trackIDsInput = albumIDResponseString;
|
||||||
RegexOptions trackIDsOptions = RegexOptions.Multiline;
|
RegexOptions trackIDsOptions = RegexOptions.Multiline;
|
||||||
|
|
||||||
@@ -1470,8 +1482,12 @@ namespace QobuzDownloaderX
|
|||||||
albumArtistPath = GetSafeFilename(albumArtist);
|
albumArtistPath = GetSafeFilename(albumArtist);
|
||||||
albumArtistTextBox.Invoke(new Action(() => albumArtistTextBox.Text = albumArtist));
|
albumArtistTextBox.Invoke(new Action(() => albumArtistTextBox.Text = albumArtist));
|
||||||
|
|
||||||
performerName = (string)joTrackResponse["performer"]["name"]; performerName = DecodeEncodedNonAsciiCharacters(performerName);
|
try
|
||||||
performerNamePath = GetSafeFilename(performerName);
|
{
|
||||||
|
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 { /*Ignore if fails*/ }
|
||||||
|
|
||||||
@@ -1602,9 +1618,12 @@ namespace QobuzDownloaderX
|
|||||||
albumArtistPath = albumArtistPath.Substring(0, MaxLength).TrimEnd();
|
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)
|
if (albumNamePath.Length > MaxLength)
|
||||||
@@ -2237,7 +2256,7 @@ namespace QobuzDownloaderX
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// Grab all Track IDs listed on the API.
|
// Grab all Track IDs listed on the API.
|
||||||
string trackIDsPattern = "\"version\":(?:.*?),\"id\":(?<trackId>.*?),";
|
string trackIDsPattern = "\"isrc\":\"(?:.*?)\"(?:.*?)\"version\":(?:.*?),\"id\":(?<trackId>.*?),";
|
||||||
string trackIDsInput = albumIDResponseString;
|
string trackIDsInput = albumIDResponseString;
|
||||||
RegexOptions trackIDsOptions = RegexOptions.Multiline;
|
RegexOptions trackIDsOptions = RegexOptions.Multiline;
|
||||||
|
|
||||||
@@ -2269,8 +2288,12 @@ namespace QobuzDownloaderX
|
|||||||
albumArtistPath = GetSafeFilename(albumArtist);
|
albumArtistPath = GetSafeFilename(albumArtist);
|
||||||
albumArtistTextBox.Invoke(new Action(() => albumArtistTextBox.Text = albumArtist));
|
albumArtistTextBox.Invoke(new Action(() => albumArtistTextBox.Text = albumArtist));
|
||||||
|
|
||||||
performerName = (string)joTrackResponse["performer"]["name"]; performerName = DecodeEncodedNonAsciiCharacters(albumArtist);
|
try
|
||||||
performerNamePath = GetSafeFilename(performerName);
|
{
|
||||||
|
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 { /*Ignore if fails*/ }
|
||||||
|
|
||||||
@@ -2401,9 +2424,12 @@ namespace QobuzDownloaderX
|
|||||||
albumArtistPath = albumArtistPath.Substring(0, MaxLength).TrimEnd();
|
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)
|
if (albumNamePath.Length > MaxLength)
|
||||||
@@ -3004,7 +3030,7 @@ namespace QobuzDownloaderX
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// Grab all Track IDs listed on the API.
|
// Grab all Track IDs listed on the API.
|
||||||
string trackIDsPattern = "\"version\":(?:.*?),\"id\":(?<trackId>.*?),";
|
string trackIDsPattern = "\"isrc\":\"(?:.*?)\"(?:.*?)\"version\":(?:.*?),\"id\":(?<trackId>.*?),";
|
||||||
string trackIDsInput = albumIDResponseString;
|
string trackIDsInput = albumIDResponseString;
|
||||||
RegexOptions trackIDsOptions = RegexOptions.Multiline;
|
RegexOptions trackIDsOptions = RegexOptions.Multiline;
|
||||||
|
|
||||||
@@ -3035,10 +3061,14 @@ namespace QobuzDownloaderX
|
|||||||
albumArtistPath = GetSafeFilename(albumArtist);
|
albumArtistPath = GetSafeFilename(albumArtist);
|
||||||
albumArtistTextBox.Invoke(new Action(() => albumArtistTextBox.Text = albumArtist));
|
albumArtistTextBox.Invoke(new Action(() => albumArtistTextBox.Text = albumArtist));
|
||||||
|
|
||||||
performerName = (string)joTrackResponse["performer"]["name"]; performerName = DecodeEncodedNonAsciiCharacters(performerName);
|
try
|
||||||
performerNamePath = GetSafeFilename(performerName);
|
{
|
||||||
|
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"];
|
advisory = (string)joTrackResponse["parental_warning"];
|
||||||
|
|
||||||
@@ -3167,9 +3197,12 @@ namespace QobuzDownloaderX
|
|||||||
albumArtistPath = albumArtistPath.Substring(0, MaxLength).TrimEnd();
|
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)
|
if (albumNamePath.Length > MaxLength)
|
||||||
@@ -3748,10 +3781,14 @@ namespace QobuzDownloaderX
|
|||||||
albumArtistPath = GetSafeFilename(albumArtist);
|
albumArtistPath = GetSafeFilename(albumArtist);
|
||||||
albumArtistTextBox.Invoke(new Action(() => albumArtistTextBox.Text = albumArtist));
|
albumArtistTextBox.Invoke(new Action(() => albumArtistTextBox.Text = albumArtist));
|
||||||
|
|
||||||
performerName = (string)joResponse2["performer"]["name"]; performerName = DecodeEncodedNonAsciiCharacters(performerName);
|
try
|
||||||
performerNamePath = GetSafeFilename(performerName);
|
{
|
||||||
|
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"];
|
advisory = (string)joResponse2["parental_warning"];
|
||||||
|
|
||||||
@@ -3880,9 +3917,12 @@ namespace QobuzDownloaderX
|
|||||||
albumArtistPath = albumArtistPath.Substring(0, MaxLength).TrimEnd();
|
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)
|
if (albumNamePath.Length > MaxLength)
|
||||||
|
|||||||
@@ -447,16 +447,27 @@ namespace QobuzDownloaderX
|
|||||||
{
|
{
|
||||||
loginBG.WorkerSupportsCancellation = true;
|
loginBG.WorkerSupportsCancellation = true;
|
||||||
|
|
||||||
// Create HttpClient to grab Track ID
|
// Create HttpClient for logging in using Napster / Rhapsody API.
|
||||||
var loginClient = new HttpClient();
|
var loginClient = new HttpClient();
|
||||||
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; //Make connection secure
|
||||||
|
loginClient.DefaultRequestHeaders.Add("Authorization", "Basic WlRKbE9XTmhaR1V0TnpsbVpTMDBaR1UyTFRrd1lqTXRaRGsxT0RSbE1Ea3dPRE01Ok1UUmpaVFZqTTJFdE9HVmxaaTAwT1RVM0xXRm1Oamt0TlRsbE9ERmhObVl5TnpJNQ=="); //This value is from logging in to the Napster Android app.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Create HttpClient to grab Track ID
|
||||||
|
var loginClient2 = new HttpClient();
|
||||||
// Run through TLS to allow secure connection.
|
// Run through TLS to allow secure connection.
|
||||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
|
||||||
// Set user-agent to Firefox.
|
// Set user-agent to Firefox.
|
||||||
loginClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0");
|
loginClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0");
|
||||||
|
|
||||||
|
var loginURL = "https://www.qobuz.com/api.json/0.2/user/login"; //Set base URL
|
||||||
|
var parameters = new Dictionary<string, string> { { "username", emailTextbox.Text }, { "email", emailTextbox.Text }, { "password", passwordTextbox.Text }, { "extra", "partner" }, { "app_id", appID } }; //Set email & password parameters
|
||||||
|
var encodedContent = new FormUrlEncodedContent(parameters); //Add parameters as encoded content to login
|
||||||
|
|
||||||
// Grab response from Rhapsody to get Track IDs from Album response.
|
// Grab response from Rhapsody to get Track IDs from Album response.
|
||||||
var loginUrl = "https://www.qobuz.com/api.json/0.2/user/login?email=" + emailTextbox.Text + "&password=" + passwordTextbox.Text + "&app_id=" + appID;
|
var loginUrl = "https://www.qobuz.com/api.json/0.2/user/login?email=" + emailTextbox.Text + "&password=" + passwordTextbox.Text + "&app_id=" + appID;
|
||||||
var loginResponse = await loginClient.GetAsync(loginUrl);
|
var loginResponse = await loginClient.PostAsync(loginURL, encodedContent);
|
||||||
string loginResponseString = loginResponse.Content.ReadAsStringAsync().Result;
|
string loginResponseString = loginResponse.Content.ReadAsStringAsync().Result;
|
||||||
|
|
||||||
// Grab metadata from API JSON response
|
// Grab metadata from API JSON response
|
||||||
|
|||||||
@@ -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.17")]
|
[assembly: AssemblyVersion("0.9.9.20")]
|
||||||
[assembly: AssemblyFileVersion("0.9.9.17")]
|
[assembly: AssemblyFileVersion("0.9.9.20")]
|
||||||
|
|||||||
Reference in New Issue
Block a user