Skip to content

Commit

Permalink
[CastIt.Youtube] Crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Apr 28, 2024
1 parent f886632 commit b976a20
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CastIt.Youtube/JsDescrambler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ public string JsDescramble(string s, string js)
//k.s(from stream map field "s") holds the input scrambled signature
//k.sp(from stream map field "sp") holds a parameter name(normally
//"signature" or "sig") to set with the output, descrambled signature
string descramblerPattern = @"(?<=[,&|]).(=).+(?=\(decodeURIComponent)";
string descramblerPattern = @"(?=[a-zA-Z]).(=).([a-zA-Z]).(?=\(decodeURIComponent)";
var descramblerMatch = Regex.Match(js, descramblerPattern);
if (string.IsNullOrEmpty(descramblerMatch.Value))
{
_logger.LogInformation($"{nameof(JsDescramble)}: Coudln't retrieve the descrambler function");
return s;
}

string descrambler = descramblerMatch.Value.Substring(descramblerMatch.Value.IndexOf("=", StringComparison.Ordinal) + 1);
//m=pt
string descrambler = descramblerMatch.Value.Trim().Substring(descramblerMatch.Value.IndexOf("=", StringComparison.Ordinal) + 1);
if (SpecialCharsExists(descrambler))
{
_logger.LogInformation($"{nameof(JsDescramble)}: Descrambler = {descrambler} contains special chars, escaping the first one");
Expand Down

0 comments on commit b976a20

Please sign in to comment.