[CHANGE] Add account dialog
This commit is contained in:
@@ -1,33 +1,27 @@
|
||||
using System.Net;
|
||||
using DotBased.Logging;
|
||||
using Manager.YouTube.Models.Innertube;
|
||||
|
||||
namespace Manager.YouTube;
|
||||
|
||||
public sealed class YouTubeClient : IDisposable
|
||||
{
|
||||
public string Id { get; private set; }
|
||||
public string AccountName { get; private set; }
|
||||
public string? UserAgent { get; private set; }
|
||||
public CookieContainer CookieContainer { get; }
|
||||
public string Id { get; private set; } = "";
|
||||
public string AccountName => ClientState?.UserAccountName ?? "";
|
||||
public string? UserAgent { get; set; }
|
||||
public CookieContainer CookieContainer { get; } = new();
|
||||
public ClientState? ClientState { get; private set; }
|
||||
public Cookie? SapisidCookie => CookieContainer.GetAllCookies()["SAPISID"];
|
||||
public HttpClient? GetHttpClient() => _httpClient;
|
||||
|
||||
private readonly ILogger? _logger;
|
||||
private HttpClient? _httpClient;
|
||||
|
||||
public YouTubeClient(CookieContainer cookieContainer, string userAgent, ILogger? logger = null)
|
||||
public YouTubeClient()
|
||||
{
|
||||
CookieContainer = cookieContainer;
|
||||
_logger = logger;
|
||||
UserAgent = userAgent;
|
||||
SetupClient();
|
||||
}
|
||||
|
||||
private void SetupClient()
|
||||
{
|
||||
_logger?.Information("Building http client...");
|
||||
_httpClient?.Dispose();
|
||||
|
||||
var clientHandler = new HttpClientHandler
|
||||
@@ -44,12 +38,10 @@ public sealed class YouTubeClient : IDisposable
|
||||
var state = await NetworkService.GetClientStateAsync(this);
|
||||
if (!state.IsSuccess)
|
||||
{
|
||||
_logger?.Warning("Error getting client state: {StateError}", state.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
ClientState = state.Value;
|
||||
_logger?.Information("Client state retrieved. With API key: {InnertubeApiKey}", ClientState.InnertubeApiKey);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
Reference in New Issue
Block a user