mirror of https://github.com/calzoneman/sync.git
Vimeo workaround
This commit is contained in:
parent
6d6bf69828
commit
eaf01f4d8a
|
@ -45,6 +45,7 @@ var defaults = {
|
||||||
"ytv3apikey" : "",
|
"ytv3apikey" : "",
|
||||||
"enable-ytv3" : false,
|
"enable-ytv3" : false,
|
||||||
"ytv2devkey" : "",
|
"ytv2devkey" : "",
|
||||||
|
"vimeo-workaround" : false,
|
||||||
"stat-interval" : 3600000,
|
"stat-interval" : 3600000,
|
||||||
"stat-max-age" : 86400000,
|
"stat-max-age" : 86400000,
|
||||||
"alias-purge-interval" : 3600000,
|
"alias-purge-interval" : 3600000,
|
||||||
|
|
|
@ -357,7 +357,7 @@ var Getters = {
|
||||||
callback("API failure", null);
|
callback("API failure", null);
|
||||||
return;
|
return;
|
||||||
} else if(status !== 200) {
|
} else if(status !== 200) {
|
||||||
callback("YTv2 HTTP " + status, null);
|
callback("Vimeo HTTP " + status, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -702,6 +702,40 @@ var Getters = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function VimeoIsADoucheCopter(id, cb) {
|
||||||
|
var options = {
|
||||||
|
host: "player.vimeo.com",
|
||||||
|
path: "/video/" + id
|
||||||
|
};
|
||||||
|
|
||||||
|
var parse = function (data) {
|
||||||
|
var i = data.indexOf("a={");
|
||||||
|
var j = data.indexOf("};", i);
|
||||||
|
var json = data.substring(i+2, j+1);
|
||||||
|
try {
|
||||||
|
json = JSON.parse(json);
|
||||||
|
var codec = json.request.files.codecs[0];
|
||||||
|
var files = json.request.files[codec];
|
||||||
|
cb(files);
|
||||||
|
} catch (e) {
|
||||||
|
cb({});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
http.get(options, function (res) {
|
||||||
|
res.setEncoding("utf-8");
|
||||||
|
var buffer = "";
|
||||||
|
|
||||||
|
res.on("data", function (data) {
|
||||||
|
buffer += data;
|
||||||
|
});
|
||||||
|
|
||||||
|
res.on("end", function () {
|
||||||
|
parse(buffer);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Getters: Getters,
|
Getters: Getters,
|
||||||
getMedia: function (id, type, callback) {
|
getMedia: function (id, type, callback) {
|
||||||
|
@ -710,5 +744,6 @@ module.exports = {
|
||||||
} else {
|
} else {
|
||||||
callback("Unknown media type '" + type + "'", null);
|
callback("Unknown media type '" + type + "'", null);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
VimeoIsADoucheCopter: VimeoIsADoucheCopter
|
||||||
};
|
};
|
||||||
|
|
|
@ -68,6 +68,9 @@ Media.prototype.fullupdate = function() {
|
||||||
if (this.params) {
|
if (this.params) {
|
||||||
x.params = this.params;
|
x.params = this.params;
|
||||||
}
|
}
|
||||||
|
if (this.direct) {
|
||||||
|
x.direct = this.direct;
|
||||||
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,4 +82,9 @@ Media.prototype.timeupdate = function() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Media.prototype.reset = function () {
|
||||||
|
delete this.currentTime;
|
||||||
|
delete this.direct;
|
||||||
|
};
|
||||||
|
|
||||||
exports.Media = Media;
|
exports.Media = Media;
|
||||||
|
|
|
@ -13,6 +13,8 @@ ULList = require("./ullist").ULList;
|
||||||
var AsyncQueue = require("./asyncqueue");
|
var AsyncQueue = require("./asyncqueue");
|
||||||
var Media = require("./media").Media;
|
var Media = require("./media").Media;
|
||||||
var AllPlaylists = {};
|
var AllPlaylists = {};
|
||||||
|
var Server = require("./server");
|
||||||
|
var VimeoIsADoucheCopter = require("./get-info").VimeoIsADoucheCopter;
|
||||||
|
|
||||||
function PlaylistItem(media, uid) {
|
function PlaylistItem(media, uid) {
|
||||||
this.media = media;
|
this.media = media;
|
||||||
|
@ -212,6 +214,7 @@ Playlist.prototype.addMedia = function (data) {
|
||||||
var m = new Media(data.id, data.title, data.seconds, data.type);
|
var m = new Media(data.id, data.title, data.seconds, data.type);
|
||||||
m.object = data.object;
|
m.object = data.object;
|
||||||
m.params = data.params;
|
m.params = data.params;
|
||||||
|
m.direct = data.direct;
|
||||||
var item = this.makeItem(m);
|
var item = this.makeItem(m);
|
||||||
item.queueby = data.queueby;
|
item.queueby = data.queueby;
|
||||||
item.temp = data.temp;
|
item.temp = data.temp;
|
||||||
|
@ -257,6 +260,7 @@ Playlist.prototype.next = function() {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var it = this.current;
|
var it = this.current;
|
||||||
|
it.media.reset();
|
||||||
|
|
||||||
if (it.temp) {
|
if (it.temp) {
|
||||||
if (this.remove(it.uid)) {
|
if (this.remove(it.uid)) {
|
||||||
|
@ -290,6 +294,7 @@ Playlist.prototype.jump = function(uid) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var it = this.current;
|
var it = this.current;
|
||||||
|
it.media.reset();
|
||||||
|
|
||||||
this.current = jmp;
|
this.current = jmp;
|
||||||
|
|
||||||
|
@ -338,29 +343,41 @@ Playlist.prototype.lead = function(lead) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Playlist.prototype.startPlayback = function (time) {
|
Playlist.prototype.startPlayback = function (time) {
|
||||||
if(!this.current || !this.current.media)
|
var self = this;
|
||||||
|
if (!self.current || !self.current.media) {
|
||||||
return false;
|
return false;
|
||||||
if (!this.leading) {
|
}
|
||||||
this.current.media.paused = false;
|
|
||||||
this.current.media.currentTime = time || 0;
|
if (self.current.media.type === "vi" &&
|
||||||
this.on("changeMedia")(this.current.media);
|
!self.current.media.direct &&
|
||||||
|
Server.getServer().cfg["vimeo-workaround"]) {
|
||||||
|
VimeoIsADoucheCopter(self.current.media.id, function (direct) {
|
||||||
|
self.current.media.direct = direct;
|
||||||
|
self.startPlayback(time);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!self.leading) {
|
||||||
|
self.current.media.paused = false;
|
||||||
|
self.current.media.currentTime = time || 0;
|
||||||
|
self.on("changeMedia")(self.current.media);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
time = time || -3;
|
time = time || -3;
|
||||||
this.current.media.paused = time < 0;
|
self.current.media.paused = time < 0;
|
||||||
this.current.media.currentTime = time;
|
self.current.media.currentTime = time;
|
||||||
|
|
||||||
var pl = this;
|
if(self._leadInterval) {
|
||||||
if(this._leadInterval) {
|
clearInterval(self._leadInterval);
|
||||||
clearInterval(this._leadInterval);
|
self._leadInterval = false;
|
||||||
this._leadInterval = false;
|
|
||||||
}
|
}
|
||||||
this.on("changeMedia")(this.current.media);
|
self.on("changeMedia")(self.current.media);
|
||||||
if(!isLive(this.current.media.type)) {
|
if(!isLive(self.current.media.type)) {
|
||||||
this._lastUpdate = Date.now();
|
self._lastUpdate = Date.now();
|
||||||
this._leadInterval = setInterval(function() {
|
self._leadInterval = setInterval(function() {
|
||||||
pl._leadLoop();
|
self._leadLoop();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1032,7 +1032,12 @@ Callbacks = {
|
||||||
$("#ytapiplayer_wrapper").remove();
|
$("#ytapiplayer_wrapper").remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data.type != PLAYER.type) {
|
if (data.type === "vi" && data.direct) {
|
||||||
|
data.type = "jw";
|
||||||
|
data.id = data.direct.sd.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.type != PLAYER.type) {
|
||||||
loadMediaPlayer(data);
|
loadMediaPlayer(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1086,7 +1086,8 @@ var constructors = {
|
||||||
"jw": JWPlayer,
|
"jw": JWPlayer,
|
||||||
"im": ImgurPlayer,
|
"im": ImgurPlayer,
|
||||||
"cu": CustomPlayer,
|
"cu": CustomPlayer,
|
||||||
"gd": GoogleDocsPlayer
|
"gd": GoogleDocsPlayer,
|
||||||
|
"me": MediaElementsPlayer
|
||||||
};
|
};
|
||||||
|
|
||||||
function loadMediaPlayer(data) {
|
function loadMediaPlayer(data) {
|
||||||
|
|
Loading…
Reference in New Issue