From 88c42af139df0bacab94be16058a6b0166aba46b Mon Sep 17 00:00:00 2001 From: calzoneman Date: Tue, 2 Aug 2016 22:35:00 -0700 Subject: [PATCH 1/2] Add streamable.com support (#585) --- package.json | 2 +- player/update.coffee | 1 + src/get-info.js | 15 +++++++++++++++ src/utilities.js | 2 ++ www/js/player.js | 3 ++- www/js/util.js | 9 +++++++++ 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cc65b03f..45e97ab4 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "3.18.7", + "version": "3.19.0", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/player/update.coffee b/player/update.coffee index 0b4e959b..41a1c66a 100644 --- a/player/update.coffee +++ b/player/update.coffee @@ -15,6 +15,7 @@ TYPE_MAP = us: UstreamPlayer im: ImgurPlayer vm: VideoJSPlayer + sb: VideoJSPlayer window.loadMediaPlayer = (data) -> try diff --git a/src/get-info.js b/src/get-info.js index db007aad..fe1da38f 100644 --- a/src/get-info.js +++ b/src/get-info.js @@ -11,6 +11,7 @@ var mediaquery = require("cytube-mediaquery"); var YouTube = require("cytube-mediaquery/lib/provider/youtube"); var Vimeo = require("cytube-mediaquery/lib/provider/vimeo"); var Vidme = require("cytube-mediaquery/lib/provider/vidme"); +var Streamable = require("cytube-mediaquery/lib/provider/streamable"); /* * Preference map of quality => youtube formats. @@ -561,6 +562,20 @@ var Getters = { "vm", video.meta); process.nextTick(callback, false, media); }); + }, + + /* streamable */ + sb: function (id, callback) { + if (!/^[\w-]+$/.test(id)) { + process.nextTick(callback, "Invalid streamable.com ID"); + return; + } + + Streamable.lookup(id).then(video => { + const media = new Media(video.id, video.title, video.duration, + "sb", video.meta); + process.nextTick(callback, false, media); + }); } }; diff --git a/src/utilities.js b/src/utilities.js index 3e156a9b..1e039426 100644 --- a/src/utilities.js +++ b/src/utilities.js @@ -242,6 +242,8 @@ return id; case "hb": return "http://hitbox.tv/" + id; + case "sb": + return "https://streamable.com/" + id; default: return ""; } diff --git a/www/js/player.js b/www/js/player.js index 516ef6f2..d4bf9c2d 100644 --- a/www/js/player.js +++ b/www/js/player.js @@ -1273,7 +1273,8 @@ hb: HitboxPlayer, us: UstreamPlayer, im: ImgurPlayer, - vm: VideoJSPlayer + vm: VideoJSPlayer, + sb: VideoJSPlayer }; window.loadMediaPlayer = function(data) { diff --git a/www/js/util.js b/www/js/util.js index b66171b9..98651b47 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -52,6 +52,8 @@ function formatURL(data) { return data.id; case "hb": return "http://hitbox.tv/" + data.id; + case "sb": + return "https://streamable.com/" + data.id; default: return "#"; } @@ -1366,6 +1368,13 @@ function parseMediaLink(url) { }; } + if((m = url.match(/streamable\.com\/([\w-]+)/))) { + return { + id: m[1], + type: "sb" + }; + } + /* Shorthand URIs */ // To catch Google Plus by ID alone if ((m = url.match(/^(?:gp:)?(\d{21}_\d{19}_\d{19})/))) { From 8ebfb431ce96c88a828e50b5adc4dd990d46cde9 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Tue, 2 Aug 2016 22:40:29 -0700 Subject: [PATCH 2/2] Fix a bug with vid.me and streamable.com error handling --- src/get-info.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/get-info.js b/src/get-info.js index fe1da38f..c27ee2c5 100644 --- a/src/get-info.js +++ b/src/get-info.js @@ -561,6 +561,8 @@ var Getters = { 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); }); }, @@ -575,6 +577,8 @@ var Getters = { const media = new Media(video.id, video.title, video.duration, "sb", video.meta); process.nextTick(callback, false, media); + }).catch(function (err) { + callback(err.message || err, null); }); } };