From b7bc93f1948d8aac0065c5dc90f602e04c5dfaf5 Mon Sep 17 00:00:00 2001 From: Calvin Montgomery Date: Sun, 24 Dec 2017 11:19:30 -0800 Subject: [PATCH] Disable vid.me (RIP) --- package.json | 2 +- src/channel/mediarefresher.js | 60 ----------------------------------- src/channel/playlist.js | 21 +++++++++++- src/get-info.js | 16 +++------- src/utilities.js | 2 -- www/js/ui.js | 15 +++++++++ www/js/util.js | 2 -- 7 files changed, 40 insertions(+), 78 deletions(-) diff --git a/package.json b/package.json index bf03ea5d..ee21b81e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "3.51.13", + "version": "3.51.14", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/src/channel/mediarefresher.js b/src/channel/mediarefresher.js index aaa82261..457669a8 100644 --- a/src/channel/mediarefresher.js +++ b/src/channel/mediarefresher.js @@ -27,12 +27,6 @@ MediaRefresherModule.prototype.onPreMediaChange = function (data, cb) { pl._refreshing = false; cb(null, ChannelModule.PASSTHROUGH); }); - case "vm": - pl._refreshing = true; - return this.initVidme(data, function () { - pl._refreshing = false; - cb(null, ChannelModule.PASSTHROUGH); - }); default: return cb(null, ChannelModule.PASSTHROUGH); } @@ -76,58 +70,4 @@ MediaRefresherModule.prototype.initVimeo = function (data, cb) { }); }; -MediaRefresherModule.prototype.initVidme = function (data, cb) { - var self = this; - self.refreshVidme(data, cb); - - /* - * Refresh every 55 minutes. - * The expiration is 1 hour, but refresh 5 minutes early to be safe - */ - self._interval = setInterval(function () { - self.refreshVidme(data); - }, 55 * 60 * 1000); -}; - -MediaRefresherModule.prototype.refreshVidme = function (media, cb) { - var self = this; - - if (self.dead || self.channel.dead) { - self.unload(); - return; - } - - self.channel.refCounter.ref("MediaRefresherModule::refreshVidme"); - InfoGetter.getMedia(media.id, "vm", function (err, data) { - if (self.dead || self.channel.dead) { - return; - } - - if (err) { - self.channel.logger.log("[mediarefresher] Vidme refresh failed: " + err); - self.channel.refCounter.unref("MediaRefresherModule::refreshVidme"); - if (cb) { - process.nextTick(cb); - } - return; - } - - if (media !== self._media) { - self.channel.refCounter.unref("MediaRefresherModule::refreshVidme"); - if (cb) { - process.nextTick(cb); - } - return; - } - - self.channel.logger.log("[mediarefresher] Refreshed Vidme video with ID " + - media.id); - media.meta = data.meta; - self.channel.refCounter.unref("MediaRefresherModule::refreshVidme"); - if (cb) { - process.nextTick(cb); - } - }); -} - module.exports = MediaRefresherModule; diff --git a/src/channel/playlist.js b/src/channel/playlist.js index 65a342ef..3ef781a4 100644 --- a/src/channel/playlist.js +++ b/src/channel/playlist.js @@ -130,7 +130,11 @@ PlaylistModule.prototype.load = function (data) { var self = this; let { playlist, playlistPosition } = data; - if (typeof playlist !== "object" || !playlist.hasOwnProperty("pl")) { + if (typeof playlist !== "object") { + return; + } + + if (!playlist.hasOwnProperty("pl")) { LOGGER.warn( "Bad playlist for channel %s", self.channel.uniqueName @@ -156,6 +160,14 @@ PlaylistModule.prototype.load = function (data) { } } else if (item.media.type === "gd") { delete item.media.meta.gpdirect; + } else if (["vm", "jw"].includes(item.media.type)) { + // JW has been deprecated for a long time + // VM shut down in December 2017 + LOGGER.warn( + "Dropping playlist item with deprecated type %s", + item.media.type + ); + return; } var m = new Media(item.media.id, item.media.title, item.media.seconds, @@ -175,6 +187,13 @@ PlaylistModule.prototype.load = function (data) { i++; }); + // Sanity check, in case the current item happened to be deleted by + // one of the checks above + if (!self.current && self.meta.count > 0) { + self.current = self.items.first; + playlistPosition.time = -3; + } + self.meta.time = util.formatTime(self.meta.rawTime); self.startPlayback(playlistPosition.time); self.dirty = false; diff --git a/src/get-info.js b/src/get-info.js index 033ba5f8..a1ea12a1 100644 --- a/src/get-info.js +++ b/src/get-info.js @@ -512,18 +512,10 @@ var Getters = { /* vid.me */ vm: function (id, callback) { - if (!/^[\w-]+$/.test(id)) { - process.nextTick(callback, "Invalid vid.me ID"); - return; - } - - Vidme.lookup(id).then(video => { - const media = new Media(video.id, video.title, video.duration, - "vm", video.meta); - process.nextTick(callback, false, media); - }).catch(function (err) { - callback(err.message || err, null); - }); + process.nextTick( + callback, + "As of December 2017, vid.me is no longer in service." + ); }, /* streamable */ diff --git a/src/utilities.js b/src/utilities.js index 3d9bb3d2..3fc151c6 100644 --- a/src/utilities.js +++ b/src/utilities.js @@ -224,8 +224,6 @@ return "https://vimeo.com/" + id; case "dm": return "https://dailymotion.com/video/" + id; - case "vm": - return "https://vid.me/" + id; case "sc": return id; case "li": diff --git a/www/js/ui.js b/www/js/ui.js index 889afc3f..52ba5b91 100644 --- a/www/js/ui.js +++ b/www/js/ui.js @@ -367,6 +367,21 @@ function queue(pos, src) { var title = undefined; if (data.type === "fi") { title = $("#addfromurl-title-val").val(); + } else if (data.type === "vm") { + /* + * As of December 2017, vid.me is no longer in service. + * Leaving this temporarily to hopefully avoid confusion + * for people pasting old vid.me links. + * + * TODO: remove at some point in the future + */ + + Callbacks.queueFail({ + link: link, + msg: "As of December 2017, vid.me is no longer in service." + }); + + return; } if (data.id == null || data.type == null) { diff --git a/www/js/util.js b/www/js/util.js index 3297a240..282d969b 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -30,8 +30,6 @@ function formatURL(data) { return "https://vimeo.com/" + data.id; case "dm": return "https://dailymotion.com/video/" + data.id; - case "vm": - return "https://vid.me/" + data.id; case "sc": return data.id; case "li":