mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
video: add support for experimental 'pywbvid=' selector to force video
type add optional YT original player rewrite fix non-local vars in flash player wb.js: remove hash when doing location check
This commit is contained in:
parent
e68c0413d1
commit
3b14e1ad40
@ -23,11 +23,22 @@ __wbvidrw = (function() {
|
|||||||
|
|
||||||
var found_embeds = false;
|
var found_embeds = false;
|
||||||
|
|
||||||
|
var vid_type = "html";
|
||||||
|
|
||||||
function check_videos() {
|
function check_videos() {
|
||||||
if (found_embeds) {
|
if (found_embeds) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// extract_type
|
||||||
|
if (window.location.hash) {
|
||||||
|
var m = window.location.hash.match(/_pywbvid=([\w]+)/);
|
||||||
|
if (m) {
|
||||||
|
vid_type = m[1];
|
||||||
|
console.log(vid_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var tags = [];
|
var tags = [];
|
||||||
|
|
||||||
var embeds = document.getElementsByTagName("embed");
|
var embeds = document.getElementsByTagName("embed");
|
||||||
@ -79,6 +90,7 @@ __wbvidrw = (function() {
|
|||||||
check_replacement(tags[i][0], tags[i][1]);
|
check_replacement(tags[i][0], tags[i][1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// special case: yt
|
// special case: yt
|
||||||
/*
|
/*
|
||||||
if (!found_embeds && wbinfo.url.indexOf("://www.youtube.com/watch") > 0) {
|
if (!found_embeds && wbinfo.url.indexOf("://www.youtube.com/watch") > 0) {
|
||||||
@ -101,7 +113,10 @@ __wbvidrw = (function() {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
var VIMEO_RX = /^https?:\/\/.*vimeo.*clip_id=([^&]+).*/;
|
var YT_RX = /^(https?:\/\/.*youtube.com)\/v\/([^&?]+)(.*)$/;
|
||||||
|
|
||||||
|
var VIMEO_RX = /^https?:\/\/.*vimeo.*clip_id=([^&]+)/;
|
||||||
|
|
||||||
|
|
||||||
function check_replacement(elem, src, no_retry) {
|
function check_replacement(elem, src, no_retry) {
|
||||||
if (!src || src.indexOf("javascript:") == 0) {
|
if (!src || src.indexOf("javascript:") == 0) {
|
||||||
@ -122,6 +137,14 @@ __wbvidrw = (function() {
|
|||||||
|
|
||||||
src = src.replace(VIMEO_RX, "http://player.vimeo.com/video/$1");
|
src = src.replace(VIMEO_RX, "http://player.vimeo.com/video/$1");
|
||||||
|
|
||||||
|
if (vid_type == "orig") {
|
||||||
|
var repl_src = src.replace(YT_RX, "$1/embed/$2?$3&controls=0");
|
||||||
|
if (repl_src != src) {
|
||||||
|
do_replace_iframe(elem, repl_src);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (window.yt) {
|
if (window.yt) {
|
||||||
delete window.yt;
|
delete window.yt;
|
||||||
}
|
}
|
||||||
@ -143,6 +166,7 @@ __wbvidrw = (function() {
|
|||||||
do_replace_iframe(elem, player_url);
|
do_replace_iframe(elem, player_url);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// end special case
|
// end special case
|
||||||
|
|
||||||
if (videoinfo.formats) {
|
if (videoinfo.formats) {
|
||||||
@ -165,6 +189,7 @@ __wbvidrw = (function() {
|
|||||||
iframe.width = dim[0];
|
iframe.width = dim[0];
|
||||||
iframe.height = dim[1];
|
iframe.height = dim[1];
|
||||||
iframe.src = url;
|
iframe.src = url;
|
||||||
|
iframe.setAttribute("frameborder", 0);
|
||||||
do_replace_elem(elem, iframe);
|
do_replace_elem(elem, iframe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +254,9 @@ __wbvidrw = (function() {
|
|||||||
if (type == "audio") {
|
if (type == "audio") {
|
||||||
htmlelem = document.createElement("audio");
|
htmlelem = document.createElement("audio");
|
||||||
}
|
}
|
||||||
replacement = init_html_player(htmlelem, type, width, height, info, thumb_url);
|
if (vid_type != "flash") {
|
||||||
|
replacement = init_html_player(htmlelem, type, width, height, info, thumb_url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +265,7 @@ __wbvidrw = (function() {
|
|||||||
if (!replacement) {
|
if (!replacement) {
|
||||||
replacement = document.createElement("div");
|
replacement = document.createElement("div");
|
||||||
|
|
||||||
vidId = "_wb_vid" + Date.now();
|
vidId = "_wb_vid" + Date.now() + Math.random();
|
||||||
replacement.setAttribute("id", vidId);
|
replacement.setAttribute("id", vidId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,7 +396,7 @@ __wbvidrw = (function() {
|
|||||||
|
|
||||||
url = wbinfo.prefix + url;
|
url = wbinfo.prefix + url;
|
||||||
|
|
||||||
config = {
|
var config = {
|
||||||
clip: {
|
clip: {
|
||||||
url: url,
|
url: url,
|
||||||
},
|
},
|
||||||
@ -379,9 +406,9 @@ __wbvidrw = (function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
opts = {
|
var opts = {
|
||||||
src: swf,
|
src: swf,
|
||||||
onFail: function() { alert("TEST"); }
|
onFail: function() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
var do_embed = function() {
|
var do_embed = function() {
|
||||||
|
@ -128,7 +128,10 @@ this.load = function() {
|
|||||||
window._wb_js_inited = true;
|
window._wb_js_inited = true;
|
||||||
|
|
||||||
if ((window.self == window.top) && wbinfo) {
|
if ((window.self == window.top) && wbinfo) {
|
||||||
if (wbinfo.top_url && (window.location.href != wbinfo.top_url) && wbinfo.mod != "bn_") {
|
|
||||||
|
var loc = window.location.href.replace(window.location.hash, "");
|
||||||
|
|
||||||
|
if (wbinfo.top_url && (loc != wbinfo.top_url) && wbinfo.mod != "bn_") {
|
||||||
// Auto-redirect to top frame
|
// Auto-redirect to top frame
|
||||||
window.location.replace(wbinfo.top_url);
|
window.location.replace(wbinfo.top_url);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user