Last active
December 10, 2015 00:29
-
-
Save azhurb/4351538 to your computer and use it in GitHub Desktop.
Fix youtube (issue #1432)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Index: external/youtube/js/base-funcs.js | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>UTF-8 | |
| =================================================================== | |
| --- external/youtube/js/base-funcs.js (revision 3411) | |
| +++ external/youtube/js/base-funcs.js (revision ) | |
| @@ -247,7 +247,7 @@ | |
| { | |
| if (request.readyState == 4 && request.status == 200) { | |
| log("Url " + url + " get done"); | |
| - parseYoutubePage(request.responseText); // call to function parse YouTube html | |
| + parseYoutubePage_new(request.responseText); // call to function parse YouTube html | |
| //parseVideoInfo(request.responseText); | |
| setTimeout(function(){stb.EnableSetCookieFrom(".youtube.com", true);}, 500);// | |
| // enabled cookie receiving from domain '.youtube.com' | |
| @@ -314,22 +314,69 @@ | |
| r[i] = unescape(r[i]); | |
| r[i] = unescape(r[i]); | |
| r[i] = unescape(r[i]); | |
| + var sig = /sig=(([^&])*)/igm.exec(r[i])[1]; | |
| + r[i]=r[i].replace(/&sig=(([^&])*)/igm,"") | |
| + var params = r[i].split("&"); | |
| + var json_object = {}; | |
| + var new_params; | |
| + for(var y = 0;y<params.length;y++){ | |
| + //console.log("\n"+params[y]); | |
| + new_params = params[y].split("="); | |
| + new_params[1] = new_params[1].replace(/;.*/ig,""); | |
| + json_object[new_params[0]] = new_params[1]; | |
| + //console.log("\n"+new_params[0]+" : "+new_params[1]); | |
| + //log("json_object["+new_params[0]+"]="+json_object[new_params[0]]); | |
| + } | |
| var m = /itag\=(\d{1,})/.exec(r[i]); | |
| r[i] = r[i].substr(r[i].indexOf('http://')); | |
| - | |
| + | |
| var splited = r[i].split(';'); | |
| var link = splited[0]; | |
| - if (splited.length > 1){ | |
| - //console.log(splited[1]); | |
| - var sig = /sig=([^&]*)/.exec(splited[1]); | |
| - sig = sig[1] || ''; | |
| - }else{ | |
| - sig = ''; | |
| - } | |
| + console.log(link); | |
| str+=m[1]+':\''+link+'&signature='+sig+'\','; | |
| } | |
| str = str.substr(0, str.length - 1) + '})'; | |
| //console.log(str); | |
| + if(!playNow || playNow == true) { | |
| + player.play(eval(str)); // call player | |
| + } | |
| +} | |
| + | |
| +function parseYoutubePage_new(html, playNow) { | |
| + var s = /amp\;url_encoded_fmt_stream_map=(.*?)amp\;/.exec(html); | |
| + log('\n\n'+s.length+'\n\n'); | |
| + log('\n\n'+s[1]+'\n\n'); | |
| + var str = '({'; | |
| + var r = s[1].split('%2C'); | |
| + for(var i=0;i<r.length;i++){ | |
| + //r[i] = r[i].replace('url%3D', ''); | |
| + r[i] = decodeURIComponent(r[i]); | |
| + r[i] = decodeURIComponent(r[i]); | |
| + r[i] = decodeURIComponent(r[i]); | |
| + r[i] = unescape(r[i]); | |
| + r[i] = unescape(r[i]); | |
| + r[i] = unescape(r[i]); | |
| + var sig = /sig=(([^&])*)/igm.exec(r[i])[1]; | |
| + r[i]=r[i].replace(/&sig=(([^&])*)/igm,""); | |
| + var link = r[i].substr(r[i].indexOf('http://')).replace(/\?.*/ig,""); | |
| + r[i] = r[i].replace(/url\=[\s\S]*videoplayback\?/,""); | |
| + var params = r[i].split("&"); | |
| + var json_object = {}; | |
| + var new_params; | |
| + for(var y = 0;y<params.length;y++){ | |
| + new_params = params[y].split("="); | |
| + new_params[1] = new_params[1].replace(/;.*/ig,""); | |
| + json_object[new_params[0]] = new_params[1]; | |
| + } | |
| + var m = /itag\=(\d{1,})/.exec(r[i]); | |
| + str+=m[1]+':\''+link; | |
| + str+="?signature="+sig; | |
| + for(var z in json_object){ | |
| + str+="&"+z+"="+json_object[z]; | |
| + } | |
| + str+='\','; | |
| + } | |
| + str = str.substr(0, str.length - 1) + '})'; | |
| if(!playNow || playNow == true) { | |
| player.play(eval(str)); // call player | |
| } | |
| @@ -390,4 +437,4 @@ | |
| } | |
| } | |
| } | |
| -} | |
| +} | |
| \ No newline at end of file | |
| Index: external/youtube/js/variables.js | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>UTF-8 | |
| =================================================================== | |
| --- external/youtube/js/variables.js (revision 3411) | |
| +++ external/youtube/js/variables.js (revision ) | |
| @@ -1,9 +1,9 @@ | |
| var version='1.0.3', | |
| - pages={"back":"../services.html"}, | |
| + pages={"back":"file:///home/web/services.html"}, | |
| def = {"lang":"en"}, | |
| current = { | |
| "mode": { | |
| - "debug":true, // create a _log and insert into #debug div | |
| + "debug":false, // create a _log and insert into #debug div | |
| "emulate":false, // set "true" if you wanna test version in browser | |
| "show_all_keydowns":false | |
| }, | |
| @@ -209,4 +209,4 @@ | |
| ], | |
| _GET=new Array(), | |
| proxy_string='', | |
| - proxy_enable=false; | |
| \ No newline at end of file | |
| + proxy_enable=false; | |
| Index: external/youtube/js/common.js | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>UTF-8 | |
| =================================================================== | |
| --- external/youtube/js/common.js (revision 3411) | |
| +++ external/youtube/js/common.js (revision ) | |
| @@ -39,6 +39,11 @@ | |
| if(proxy_string.length>1) { | |
| proxy_enable=true; | |
| } | |
| + pages.back = decodeURIComponent(window.location.search.match(/\?referrer\=.*/)); | |
| + pages.back = pages.back.replace(/\?referrer\=/, ''); | |
| + if(pages.back == null || pages.back == "null" || pages.back == ""){ | |
| + pages.back = "file:///home/web/services.html"; | |
| + } | |
| /* | |
| win = { "width":720, "height":480 }; | |
| win = { "width":720, "height":576 }; | |
| @@ -310,4 +315,4 @@ | |
| Deferred.next(function() { | |
| loading.hide(); // hide loading layer and enable management from keyboard | |
| }); | |
| -} | |
| \ No newline at end of file | |
| +} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment