From b2a1f4ecfb47746b274481eb2c04c904fdce64f6 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Fri, 24 Jan 2020 14:11:59 -0800 Subject: Fix signature decryption. The function body regex was capturing some unrelated new code before the actual function body. Example: `function(a){a=a.split("");var b=[function(c,d){d=(d%c.length+c.length)%c.length;c.splice(-d).reverse().forEach(function(e){return c.unshift(e)}` If you look closely, the closing bracket doesn't match the opening one. I have added `{` to the `[^\}]+` part to make sure it only captures matching brackets. Additionally, I've added `return a\.join\(""\)` to the end for good measure. --- youtube/yt_data_extract/watch_extraction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube/yt_data_extract/watch_extraction.py b/youtube/yt_data_extract/watch_extraction.py index 3e6dcdf..1609f8d 100644 --- a/youtube/yt_data_extract/watch_extraction.py +++ b/youtube/yt_data_extract/watch_extraction.py @@ -457,7 +457,7 @@ def requires_decryption(info): # adapted from youtube-dl and invidious: # https://github.com/omarroth/invidious/blob/master/src/invidious/helpers/signatures.cr -decrypt_function_re = re.compile(r'function\(a\)\{(a=a\.split\(""\)[^\}]+)\}') +decrypt_function_re = re.compile(r'function\(a\)\{(a=a\.split\(""\)[^\}{]+)return a\.join\(""\)\}') op_with_arg_re = re.compile(r'[^\.]+\.([^\(]+)\(a,(\d+)\)') def extract_decryption_function(info, base_js): '''Insert decryption function into info. Return error string if not successful. -- cgit v1.2.3