From 46b79664a147c4fd7b4c804222045bc2e9105625 Mon Sep 17 00:00:00 2001 From: Mirko Da Corte Date: Tue, 29 Aug 2023 19:28:05 +0200 Subject: [PATCH] add cookie consent request bypass --- YoutubeDownloader/YoutubeClient.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/YoutubeDownloader/YoutubeClient.cs b/YoutubeDownloader/YoutubeClient.cs index 28cdb732..663e50af 100644 --- a/YoutubeDownloader/YoutubeClient.cs +++ b/YoutubeDownloader/YoutubeClient.cs @@ -40,11 +40,17 @@ public class YoutubeClient : IYoutubeClient /// public YoutubeClient(HttpClient http, IReadOnlyList initialCookies) { + // Add necessary cookies. + var cookies = new List(initialCookies) + { + new("SOCS", "CAESEwgDEgk0ODE3Nzk3MjQaAmVuIAEaBgiA_LyaBg") { Domain = "youtube.com" } //cookie consent request bypass + }; + var youtubeHttp = new HttpClient( - new YoutubeHttpHandler(http, initialCookies), + new YoutubeHttpHandler(http, cookies), true ); - + Videos = new VideoClient(youtubeHttp); Playlists = new PlaylistClient(youtubeHttp); Channels = new ChannelClient(youtubeHttp);