From 7f4e2a8882fd1b0ef72459ea80d56c4434c76d5e Mon Sep 17 00:00:00 2001 From: Calvin Montgomery Date: Thu, 12 Jun 2014 20:29:12 -0700 Subject: [PATCH] Fix a few issues --- lib/channel/playlist.js | 16 +++++++++++++++- lib/config.js | 4 ++-- lib/web/webserver.js | 3 +++ www/js/util.js | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/channel/playlist.js b/lib/channel/playlist.js index bca2486a..172b4990 100644 --- a/lib/channel/playlist.js +++ b/lib/channel/playlist.js @@ -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(); diff --git a/lib/config.js b/lib/config.js index 37d6645c..a7d6b855 100644 --- a/lib/config.js +++ b/lib/config.js @@ -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; } } } diff --git a/lib/web/webserver.js b/lib/web/webserver.js index 736e0e54..64d2f1e0 100644 --- a/lib/web/webserver.js +++ b/lib/web/webserver.js @@ -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); } diff --git a/www/js/util.js b/www/js/util.js index e0bc3a31..7eb821ae 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -602,7 +602,7 @@ function showUserOptions() { */ var conninfo = "Connection Information: " + "Connected to " + IO_URL + " ("; - if (IO_URL === IO_URLS["ipv6-ssl"] || IO_URL === IO_URLS["ipv6-nossl"]) { + if (IO_V6) { conninfo += "IPv6, "; } else { conninfo += "IPv4, ";