From 7b52412f9f84bf9689187d488315216eaaf682ca Mon Sep 17 00:00:00 2001 From: James Bunton Date: Wed, 25 Nov 2015 01:42:02 +1100 Subject: [PATCH] changed script prefix/suffix --- youtube.cgi | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/youtube.cgi b/youtube.cgi index 7d39357..349842f 100755 --- a/youtube.cgi +++ b/youtube.cgi @@ -132,8 +132,8 @@ def get_player_config(doc): return json.loads(line[p1:p2]) def extract_js(script): - PREFIX = "(function(){" - SUFFIX = "})();\n" + PREFIX = "var _yt_player={};(function(g){var window=this;" + SUFFIX = ";})(_yt_player);\n" assert script.startswith(PREFIX) assert script.endswith(SUFFIX) @@ -168,21 +168,20 @@ def decode_signature(js_url, signature): var vm = require('vm'); var sandbox = { - window: { - location: { - hash: '', - href: '' - }, - history: { - pushState: function(){} - }, - navigator: {} + location: { + hash: '', + href: '', + protocol: 'http:' + }, + history: { + pushState: function(){} }, document: {}, navigator: {}, signature: %(signature)s, transformed_signature: null }; + sandbox.window = sandbox; var code_string = %(code)s + ';'; var exec_string = 'transformed_signature = %(func_name)s(signature);'; -- 2.39.2