Fix a few issues

This commit is contained in:
Calvin Montgomery 2014-06-12 20:29:12 -07:00
parent 6f737349db
commit 7f4e2a8882
4 changed files with 21 additions and 4 deletions

View File

@ -957,6 +957,16 @@ PlaylistModule.prototype._addItem = function (media, data, user, cb) {
}
};
function isExpired(media) {
if (media.meta.expiration && media.meta.expiration < Date.now()) {
return true;
} else if (media.type === "gd") {
return !media.object;
} else if (media.type === "vi") {
return !media.direct;
}
}
PlaylistModule.prototype.startPlayback = function (time) {
var self = this;
@ -979,7 +989,7 @@ PlaylistModule.prototype.startPlayback = function (time) {
return;
}
if (media.type === "gd" && !media.meta.object && !media.meta.failed) {
if (media.type === "gd" && isExpired(media) && !media.meta.failed) {
self.channel.activeLock.lock();
this.refreshGoogleDocs(function () {
self.channel.activeLock.release();
@ -1028,6 +1038,9 @@ PlaylistModule.prototype.startPlayback = function (time) {
if (media.type === "gd") {
this._gdRefreshTimer = setInterval(this.refreshGoogleDocs.bind(this), 3600000);
if (media.meta.expiration && media.meta.expiration < Date.now() + 3600000) {
setTimeout(this.refreshGoogleDocs.bind(this), media.meta.expiration - Date.now());
}
}
}
@ -1107,6 +1120,7 @@ PlaylistModule.prototype.refreshGoogleDocs = function (cb) {
}
self.current.media.meta = media.meta;
self.current.media.meta.expiration = Date.now() + 3600000;
self.channel.logger.log("[playlist] Auto-refreshed Google Doc video");
cb && cb();
self.channel.activeLock.release();

View File

@ -274,13 +274,13 @@ function preprocessConfig(cfg) {
if (srv.url) {
cfg.io["ipv4-ssl"] = srv.url;
} else {
cfg.io["ipv4-ssl"] = "https://" + srv.ip + ":" + srv.port;
cfg.io["ipv4-ssl"] = cfg.https["domain"] + ":" + srv.port;
}
} else if (!cfg.io["ipv4-nossl"]) {
if (srv.url) {
cfg.io["ipv4-nossl"] = srv.url;
} else {
cfg.io["ipv4-nossl"] = "http://" + srv.ip + ":" + srv.port;
cfg.io["ipv4-nossl"] = cfg.io["domain"] + ":" + srv.port;
}
}
}

View File

@ -172,15 +172,18 @@ function handleSocketConfig(req, res) {
var sioconfig = Config.get("sioconfig");
var iourl;
var ip = ipForRequest(req);
var ipv6 = false;
if (net.isIPv6(ip)) {
iourl = Config.get("io.ipv6-default");
ipv6 = true;
}
if (!iourl) {
iourl = Config.get("io.ipv4-default");
}
sioconfig += "var IO_URL='" + iourl + "';";
sioconfig += "var IO_V6=" + ipv6 + ";";
res.send(sioconfig);
}

View File

@ -602,7 +602,7 @@ function showUserOptions() {
*/
var conninfo = "<strong>Connection Information: </strong>" +
"Connected to <code>" + IO_URL + "</code> (";
if (IO_URL === IO_URLS["ipv6-ssl"] || IO_URL === IO_URLS["ipv6-nossl"]) {
if (IO_V6) {
conninfo += "IPv6, ";
} else {
conninfo += "IPv4, ";