[CHANGE] Improved hash auth token gen. Added new cookie rotate
This commit is contained in:
@@ -202,6 +202,22 @@ public sealed class YouTubeClient : IDisposable
|
||||
return tempDatasyncId;
|
||||
}
|
||||
|
||||
public async Task<Result> RotateCookiesPageAsync(string origin = NetworkService.Origin, int ytPid = 1)
|
||||
{
|
||||
if (IsAnonymous)
|
||||
{
|
||||
return ResultError.Fail("Anonymous clients cannot rotate cookies!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(origin))
|
||||
{
|
||||
return ResultError.Fail("Origin is empty!");
|
||||
}
|
||||
|
||||
var rotatePageCookiesRequest = new HttpRequestMessage(HttpMethod.Get, new Uri($"https://accounts.youtube.com/RotateCookiesPage?origin={origin}&yt_pid={ytPid}"));
|
||||
return await NetworkService.MakeRequestAsync(rotatePageCookiesRequest, this, true);
|
||||
}
|
||||
|
||||
public async Task<Result> RotateCookiesAsync()
|
||||
{
|
||||
if (IsAnonymous)
|
||||
@@ -209,16 +225,8 @@ public sealed class YouTubeClient : IDisposable
|
||||
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);
|
||||
}
|
||||
var rotateRequest = new HttpRequestMessage(HttpMethod.Post, new Uri("https://accounts.youtube.com/RotateCookies"));
|
||||
return await NetworkService.MakeRequestAsync(rotateRequest, this, true);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
Reference in New Issue
Block a user