From: James Bunton Date: Tue, 24 Nov 2015 14:42:02 +0000 (+1100) Subject: changed script prefix/suffix X-Git-Url: https://code.delx.au/youtube-cgi/commitdiff_plain/7b52412f9f84bf9689187d488315216eaaf682ca changed script prefix/suffix --- 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);';