From bf957436f0aa18c831d903943f4e3f9eb1d4c0a4 Mon Sep 17 00:00:00 2001 From: max Date: Sun, 2 Nov 2025 19:45:41 +0100 Subject: [PATCH] [CHANGE] Disabled signature challenge. Need to run js. --- Manager.YouTube/YouTubeClient.cs | 53 +++++++++++++++++--------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/Manager.YouTube/YouTubeClient.cs b/Manager.YouTube/YouTubeClient.cs index 23942e1..dbbd1fb 100644 --- a/Manager.YouTube/YouTubeClient.cs +++ b/Manager.YouTube/YouTubeClient.cs @@ -5,12 +5,10 @@ using System.Text.Json; using System.Text.Json.Nodes; using DotBased.Logging; using DotBased.Monads; -using Manager.YouTube.Interpreter; using Manager.YouTube.Models; using Manager.YouTube.Models.Innertube; using Manager.YouTube.Parsers; using Manager.YouTube.Parsers.Json; -using Manager.YouTube.Util.Cipher; namespace Manager.YouTube; @@ -115,7 +113,7 @@ public sealed class YouTubeClient : IDisposable return videoParseResult; } - await DecipherSignatures(videoParseResult.Value, state); + //await DecipherSignaturesAsync(videoParseResult.Value, state); return videoParseResult.Value; } @@ -176,10 +174,10 @@ public sealed class YouTubeClient : IDisposable public async Task RotateCookiesPageAsync(string origin = NetworkService.Origin, int ytPid = 1) { - /*if (IsAnonymous) + if (IsAnonymous) { return ResultError.Fail("Anonymous clients cannot rotate cookies!"); - }*/ + } if (string.IsNullOrWhiteSpace(origin)) { @@ -387,7 +385,7 @@ public sealed class YouTubeClient : IDisposable return ResultError.Fail("Failed to get datasyncIds! Client not logged in."); } - private async Task DecipherSignatures(YouTubeVideo video, ClientState state) + /*private async Task DecipherSignaturesAsync(YouTubeVideo video, ClientState state) { var streamingData = video.StreamingData; if (streamingData == null) @@ -395,35 +393,40 @@ public sealed class YouTubeClient : IDisposable _logger.Debug("No streaming data available, skipping decipher."); return; } + + if (string.IsNullOrWhiteSpace(state.PlayerJsUrl)) + { + _logger.Warning("No player js url found."); + } var formatsWithCipher = streamingData.Formats.Concat(streamingData.AdaptiveFormats).Where(x => !string.IsNullOrWhiteSpace(x.SignatureCipher)).ToList(); if (formatsWithCipher.Count == 0) { - _logger.Debug("Skipping decipher, no signatures found to decipher."); - return; + _logger.Debug("Skipping signature decipher, no signatures found to decipher."); + } + + if (string.IsNullOrWhiteSpace(streamingData.ServerAbrStreamingUrl)) + { + _logger.Warning("No ABR streaming url available."); + } + + var abrStreamUri = new Uri(streamingData.ServerAbrStreamingUrl); + var queries = HttpUtility.ParseQueryString(abrStreamUri.Query); + var nSig = queries.Get("n"); + + if (string.IsNullOrWhiteSpace(nSig)) + { + _logger.Warning("No N signature found."); } - var jsEngineResult = await JavaScriptEngineManager.GetPlayerEngine(state.PlayerJsUrl ?? ""); + /*var jsEngineResult = await JavaScriptEngineManager.GetPlayerEngine(state.PlayerJsUrl ?? ""); if (!jsEngineResult.IsSuccess) { _logger.Warning(jsEngineResult.Error?.Description ?? "Failed to get player script engine."); return; } - + var engine = jsEngineResult.Value; - engine.InitializePlayer(); - - /*var decipherDecoderResult = await CipherManager.GetDecoderAsync(state, this); - if (!decipherDecoderResult.IsSuccess) - { - _logger.Warning(decipherDecoderResult.Error?.Description ?? "Failed to get the cipher decoder!"); - return; - } - var decoder = decipherDecoderResult.Value; - - foreach (var format in formatsWithCipher) - { - format.Url = decoder.Decipher(format.SignatureCipher); - }*/ - } + engine.InitializePlayer();#1# + }*/ } \ No newline at end of file