[CHANGE] BackgroundServices

This commit is contained in:
max
2025-09-09 19:11:02 +02:00
parent d183803390
commit 2593d02a73
7 changed files with 188 additions and 17 deletions

View File

@@ -20,7 +20,7 @@ public sealed class YouTubeClient : IDisposable
public List<string> DatasyncIds { get; } = [];
public Cookie? SapisidCookie => CookieContainer.GetAllCookies()["SAPISID"];
public HttpClient HttpClient { get; }
private YouTubeClient(CookieCollection cookies, string userAgent)
{
if (string.IsNullOrWhiteSpace(userAgent))
@@ -38,6 +38,12 @@ public sealed class YouTubeClient : IDisposable
HttpClient = new HttpClient(GetHttpClientHandler());
}
/// <summary>
/// Loads the given cookies and fetch client state.
/// </summary>
/// <param name="cookies">The cookies to use for making requests. Empty collection for anonymous requests.</param>
/// <param name="userAgent">The user agent to use for the requests. Only WEB client is supported.</param>
/// <returns></returns>
public static async Task<Result<YouTubeClient>> CreateAsync(CookieCollection cookies, string userAgent)
{
var client = new YouTubeClient(cookies, userAgent);