Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE-89] Videos that invoke AdvancedYoutubeVideoURLExtractor stopped working #90

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions source/parsers.d
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ struct EncryptionAlgorithm
this.javascript = javascript;
this.logger = logger;

string algorithm = javascript.matchOrFail!(`a\s*=\s*a\.split\(""\);\s*((.|\s)*?);\s*return a\.join\(""\)`, false);
//string algorithm = javascript.matchOrFail!(`\w=\w\.split\(""\);((.|\s)*?);return \w\.join\(""\)`, false);
string algorithm = javascript.matchOrFail!(`.=.\.split\(""\);((.|\s)*?);return .\.join\(""\)`, false);
logger.displayVerbose("Matched algorithm = ", algorithm);
string[] steps = algorithm.split(";");
foreach(step; steps.map!strip)
Expand Down Expand Up @@ -542,16 +543,19 @@ struct EncryptionAlgorithm

private void parseStepFunctionNames()
{
logger.displayVerbose("Attempting to match ", `([A-Za-z]{2}):function\(a\)\{a\.reverse\(\)\}`);
string flip = javascript.matchOrFail!(`([A-Za-z0-9]{2,}):function\(a\)\{a\.reverse\(\)\}`);
logger.displayVerbose("Attempting to match ", `([A-Za-z]{2}):function\(\w\)\{\w\.reverse\(\)\}`);
//string flip = javascript.matchOrFail!(`([A-Za-z0-9]{2,}):function\(\w\)\{\w\.reverse\(\)\}`);
string flip = javascript.matchOrFail!(`([A-Za-z0-9]{2,}):function\(.\)\{.\.reverse\(\)\}`);
logger.displayVerbose("Matched flip = ", flip);

logger.displayVerbose("Attempting to match removeFromStart ", `([A-Za-z]{2}):function\(a\)\{a\.reverse\(\)\}`);
string removeFromStart = javascript.matchOrFail!(`([A-Za-z0-9]{2,}):function\(a,b\)\{a\.splice\(0,b\)\}`);
logger.displayVerbose("Attempting to match removeFromStart ", `([A-Za-z]{2}):function\(\w\)\{\w\.reverse\(\)\}`);
//string removeFromStart = javascript.matchOrFail!(`([A-Za-z0-9]{2,}):function\(\w,\w\)\{\w\.splice\(0,\w\)\}`);
string removeFromStart = javascript.matchOrFail!(`([A-Za-z0-9]{2,}):function\(.,.\)\{.\.splice\(0,.\)\}`);
logger.displayVerbose("Matched removeFromStart = ", removeFromStart);

logger.displayVerbose("Attempting to match swapFirstCharacterWith ", `([A-Za-z]{2}):function\(a\)\{a\.reverse\(\)\}`);
string swapFirstCharacterWith = javascript.matchOrFail!(`([A-Za-z0-9]{2,}):function\(a,b\)\{var c=a\[0\];a\[0\]=a\[b%a\.length\];a\[b%a\.length\]=c\}`);
logger.displayVerbose("Attempting to match swapFirstCharacterWith ", `([A-Za-z]{2}):function\(\w\)\{\w\.reverse\(\)\}`);
//string swapFirstCharacterWith = javascript.matchOrFail!(`([A-Za-z0-9]{2,}):function\(\w,\w\)\{var \w=\w\[0\];\w\[0\]=\w\[\w%\w\.length\];\w\[\w%\w\.length\]=\w\}`);
string swapFirstCharacterWith = javascript.matchOrFail!(`([A-Za-z0-9]{2,}):function\(.,.\)\{var .=.\[0\];.\[0\]=.\[.%.\.length\];.\[.%.\.length\]=.\}`);
logger.displayVerbose("Matched swapFirstCharacterWith = ", swapFirstCharacterWith);

obfuscatedStepFunctionNames[flip] = "flip";
Expand Down Expand Up @@ -586,6 +590,15 @@ unittest
assert(signature == "AOq0QJ8wRQIgbJLlJRLLqu-RJ0ys8Rioy-CRtJLG_5t2WEHgLfRLCwgCIQDri728L1lXeqfbUSRArzq2N6Uf4AvLW76vl_tRRENKKg%3D%3D");
}

unittest
{
writeln("When video is VEVO song and player is 5b77d519, should correctly decrypt video signature".formatTitle());
scope(success) writeln("OK\n".formatSuccess());
auto algorithm = EncryptionAlgorithm("tests/5b77d519.js".readText(), new StdoutLogger());
string signature = algorithm.decrypt("AIr%3DIr%3DIrg5t2EOs4ZBPETDqTCNkf7vH5D1%3Dnyay7ljoINmBywAEiAOlwos8WCcqQKDOCA5XUorfTmIqe9Y4DYBnBw6MxbIuJAhIgRwsSdQfJJ");
assert(signature == "AJfQdSswRgIhAJuIbxM6wBnBYD4Y9eqImTJroUX5fCODKQqcCW8sowlOAiEAwyBmNIojl7yaynA1D5Hv7fkNCTqDTEPBZ4sOE2t5grI%3D");
}

struct ThrottlingAlgorithm
{
alias Step = Tuple!(string, ulong);
Expand Down
Loading