Created
September 14, 2012 13:03
-
-
Save azhurb/3721788 to your computer and use it in GitHub Desktop.
Fix youtube
This file contains 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 3059) | |
+++ external/youtube/js/base-funcs.js (revision ) | |
@@ -247,7 +247,8 @@ | |
{ | |
if (request.readyState == 4 && request.status == 200) { | |
log("Url " + url + " get done"); | |
- parseYoutubePage(request.responseText); // call to function parse YouTube html | |
+ //parseYoutubePage(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' | |
} | |
@@ -322,6 +323,32 @@ | |
player.play(eval(str)); // call player | |
} | |
} | |
+ | |
+function parseVideoInfo(html, playNow){ | |
+ var s = /url_encoded_fmt_stream_map=(.*)/.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]); | |
+ var m = /itag\=(\d{1,})/.exec(r[i]); | |
+ if (!m){ | |
+ continue; | |
+ } | |
+ log('\n\nm='+m+'\n\n'); | |
+ r[i] = r[i].substr(r[i].indexOf('http://')); | |
+ str+=m[1]+':\''+r[i].split(';')[0]+'\','; | |
+ } | |
+ str = str.substr(0, str.length - 1) + '})'; | |
+ if(!playNow || playNow == true) { | |
+ player.play(eval(str)); // call player | |
+ } | |
+} | |
+ | |
function trimLeft(str) { | |
return str.replace(/^\s+/, ''); | |
} | |
Index: external/youtube/js/objs.js | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- external/youtube/js/objs.js (revision 3084) | |
+++ external/youtube/js/objs.js (revision ) | |
@@ -82,7 +82,8 @@ | |
player.scrolbar_width = 780; | |
} | |
player.obj = obj; | |
- var url = "http://www.youtube.com/watch?v=" + player.obj.id; | |
+ //var url = "http://www.youtube.com/watch?v=" + player.obj.id; | |
+ var url = "http://www.youtube.com/get_video_info?video_id=" + player.obj.id; | |
getHtmlByUrl(url); | |
player.current_step = 30; | |
byID('playModeInPlayer').className = current.playMode; | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment