diff --git a/Manager.YouTube/YouTubeClient.cs b/Manager.YouTube/YouTubeClient.cs index e16f28a..25ca253 100644 --- a/Manager.YouTube/YouTubeClient.cs +++ b/Manager.YouTube/YouTubeClient.cs @@ -202,6 +202,25 @@ public sealed class YouTubeClient : IDisposable return tempDatasyncId; } + public async Task RotateCookiesAsync() + { + if (IsAnonymous) + { + return ResultError.Fail("Anonymous clients cannot rotate cookies!"); + } + + try + { + var rotateRequest = new HttpRequestMessage(HttpMethod.Post, new Uri("https://accounts.youtube.com/RotateCookies")); + var response = await HttpClient.SendAsync(rotateRequest); + return !response.IsSuccessStatusCode ? ResultError.Fail($"Cookies rotation failed, status code: {response.StatusCode}") : Result.Success(); + } + catch (Exception e) + { + return ResultError.Error(e); + } + } + public void Dispose() { HttpClient.Dispose();