From e7b04a3991afeb9a7f111cd01cd558066f9db249 Mon Sep 17 00:00:00 2001 From: Trevor Date: Sun, 18 Aug 2024 13:44:29 -0400 Subject: [PATCH] Store SID cookie The SID cookie is used to ensure that the client "owns" their given checkForm token. If used in multiple HttpClients, they can all share an API token. --- DeezNET/Core.cs | 6 +++++- DeezNET/Directory.Build.props | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/DeezNET/Core.cs b/DeezNET/Core.cs index cddf742..52127b2 100644 --- a/DeezNET/Core.cs +++ b/DeezNET/Core.cs @@ -11,7 +11,8 @@ public DeezerClient() { _arl = ""; - _client = new HttpClient(); + _clientHandler = new() { CookieContainer = new() }; + _client = new HttpClient(_clientHandler); _client.DefaultRequestHeaders.Add("Accept-Language", "en-US,en;q=0.5"); _gwApi = new(_client, _arl); @@ -42,10 +43,13 @@ public async Task SetARL(string arl) public GWApi GWApi { get => _gwApi; } public PublicApi PublicApi { get => _publicApi; } public string ActiveARL { get => _arl; } + public string SID { get => _clientHandler.CookieContainer.GetCookies(_deezerUri).FirstOrDefault(c => c.Name == "sid")?.Value ?? ""; } private Downloader _downloader; private HttpClient _client; private GWApi _gwApi; private PublicApi _publicApi; private string _arl; + private HttpClientHandler _clientHandler; + private readonly Uri _deezerUri = new("https://deezer.com"); } \ No newline at end of file diff --git a/DeezNET/Directory.Build.props b/DeezNET/Directory.Build.props index c39933c..6826b6a 100644 --- a/DeezNET/Directory.Build.props +++ b/DeezNET/Directory.Build.props @@ -1,6 +1,6 @@  - 1.1.1 + 1.1.2 TrevTV Copyright (C) Trevor Jackson latest