Use VideoJSPlayer for vimeo workaround

This commit is contained in:
calzoneman 2015-06-28 09:42:21 -07:00
parent b34f972629
commit 7fee1414e2
6 changed files with 43 additions and 120 deletions

View file

@ -1,3 +1,4 @@
var Vimeo = require("cytube-mediaquery/lib/provider/vimeo");
var ChannelModule = require("./module");
var Config = require("../config");
var InfoGetter = require("../get-info");
@ -7,6 +8,7 @@ function MediaRefresherModule(channel) {
ChannelModule.apply(this, arguments);
this._interval = false;
this._media = null;
this._playlist = channel.modules.playlist;
}
MediaRefresherModule.prototype = Object.create(ChannelModule.prototype);
@ -15,18 +17,26 @@ MediaRefresherModule.prototype.onPreMediaChange = function (data, cb) {
if (this._interval) clearInterval(this._interval);
this._media = data;
var pl = this._playlist;
switch (data.type) {
case "gd":
pl._refreshing = true;
return this.initGoogleDocs(data, function () {
pl._refreshing = false;
cb(null, ChannelModule.PASSTHROUGH);
});
case "gp":
pl._refreshing = true;
return this.initGooglePlus(data, function () {
pl._refreshing = false;
cb(null, ChannelModule.PASSTHROUGH);
});
case "vi":
pl._refreshing = true;
return this.initVimeo(data, function () {
pl._refreshing = false;
cb(null, ChannelModule.PASSTHROUGH);
});
default:
@ -55,18 +65,20 @@ MediaRefresherModule.prototype.initVimeo = function (data, cb) {
var self = this;
self.channel.activeLock.lock();
InfoGetter.vimeoWorkaround(data.id, function (hack) {
if (self.dead || self.channel.dead) {
Vimeo.extract(data.id).then(function (direct) {
if (self.dead || self.channel.dead)
return;
}
if (self._media === data) {
data.meta.direct = direct;
self.channel.logger.log("[mediarefresher] Refreshed vimeo video with ID " +
data.id);
data.meta.direct = hack;
}
self.channel.activeLock.release();
if (cb) cb();
}).catch(function (err) {
Logger.errlog.log("Unexpected vimeo::extract() fail: " + err.stack);
if (cb) cb();
});
};

View file

@ -3,7 +3,6 @@ var AsyncQueue = require("../asyncqueue");
var Media = require("../media");
var util = require("../utilities");
var InfoGetter = require("../get-info");
var vimeoWorkaround = InfoGetter.vimeoWorkaround;
var Config = require("../config");
var Flags = require("../flags");
var db = require("../database");
@ -90,7 +89,7 @@ function PlaylistModule(channel) {
this._leadInterval = false;
this._lastUpdate = 0;
this._counter = 0;
this._gdRefreshTimer = false;
this._refreshing = false;
if (this.channel.modules.chat) {
this.channel.modules.chat.registerCommand("/clean", this.handleClean.bind(this));
@ -167,11 +166,6 @@ PlaylistModule.prototype.unload = function () {
this._leadInterval = false;
}
if (this._gdRefreshTimer) {
clearInterval(this._gdRefreshTimer);
this._gdRefreshTimer = false;
}
this.channel = null;
};
@ -265,7 +259,7 @@ PlaylistModule.prototype.sendPlaylist = function (users) {
};
PlaylistModule.prototype.sendChangeMedia = function (users) {
if (!this.current || !this.current.media) {
if (!this.current || !this.current.media || this._refreshing) {
return;
}
@ -1116,8 +1110,6 @@ PlaylistModule.prototype.refreshGoogleDocs = function (cb) {
}
var abort = function () {
clearInterval(self._gdRefreshTimer);
self._gdRefreshTimer = false;
if (self.current) {
self.current.media.meta.object = self.current.media.meta.object || null;
self.current.media.meta.failed = true;