Fix for google docs changing their video player:

This commit is contained in:
Calvin Montgomery 2014-08-06 20:12:57 -07:00
parent d94c596063
commit b7edfc31f9
6 changed files with 97 additions and 69 deletions

View file

@ -21,6 +21,10 @@ MediaRefresherModule.prototype.onPreMediaChange = function (data, cb) {
return this.initGoogleDocs(data, function () {
cb(null, ChannelModule.PASSTHROUGH);
});
case "gp":
return this.initGooglePlus(data, function () {
cb(null, ChannelModule.PASSTHROUGH);
});
case "vi":
return this.initVimeo(data, function () {
cb(null, ChannelModule.PASSTHROUGH);
@ -116,4 +120,52 @@ MediaRefresherModule.prototype.refreshGoogleDocs = function (media, cb) {
});
};
MediaRefresherModule.prototype.initGooglePlus = function (media, cb) {
var self = this;
if (self.dead || self.channel.dead) {
return;
}
self.channel.activeLock.lock();
InfoGetter.getMedia(media.id, "gp", function (err, data) {
if (self.dead || self.channel.dead) {
return;
}
switch (err) {
case "HTTP 302":
case "Video not found":
case "Private video":
self.channel.logger.log("[mediarefresher] Google+ refresh failed: " +
err);
self.channel.activeLock.release();
if (cb) cb();
return;
default:
if (err) {
self.channel.logger.log("[mediarefresher] Google+ refresh failed: " +
err);
Logger.errlog.log("Google+ refresh failed for ID " + media.id +
": " + err);
self.channel.activeLock.release();
if (cb) cb();
return;
}
}
if (media !== self._media) {
self.channel.activeLock.release();
if (cb) cb();
return;
}
self.channel.logger.log("[mediarefresher] Refreshed Google+ video with ID " +
media.id);
media.meta = data.meta;
self.channel.activeLock.release();
if (cb) cb();
});
};
module.exports = MediaRefresherModule;