diff --git a/player/update.coffee b/player/update.coffee index 2ef64883..858f04a9 100644 --- a/player/update.coffee +++ b/player/update.coffee @@ -18,6 +18,7 @@ TYPE_MAP = vm: VideoJSPlayer hl: HLSPlayer sb: VideoJSPlayer + tc: VideoJSPlayer window.loadMediaPlayer = (data) -> try diff --git a/src/config.js b/src/config.js index 7a4b8e59..7e47c7e2 100644 --- a/src/config.js +++ b/src/config.js @@ -385,6 +385,8 @@ function preprocessConfig(cfg) { if (cfg["twitch-client-id"]) { require("cytube-mediaquery/lib/provider/twitch-vod").setClientID( cfg["twitch-client-id"]); + require("cytube-mediaquery/lib/provider/twitch-clip").setClientID( + cfg["twitch-client-id"]); } else { LOGGER.warn("No Twitch Client ID set. Twitch VOD links will " + "not work. See twitch-client-id in config.template.yaml and " + diff --git a/src/get-info.js b/src/get-info.js index 882a7d09..4ac437c1 100644 --- a/src/get-info.js +++ b/src/get-info.js @@ -12,6 +12,7 @@ var Vidme = require("cytube-mediaquery/lib/provider/vidme"); var Streamable = require("cytube-mediaquery/lib/provider/streamable"); var GoogleDrive = require("cytube-mediaquery/lib/provider/googledrive"); var TwitchVOD = require("cytube-mediaquery/lib/provider/twitch-vod"); +var TwitchClip = require("cytube-mediaquery/lib/provider/twitch-clip"); import { LoggerFactory } from '@calzoneman/jsli'; const LOGGER = LoggerFactory.getLogger('get-info'); @@ -391,6 +392,25 @@ var Getters = { }); }, + /* twitch clip */ + tc: function (id, callback) { + var m = id.match(/^([A-Za-z]+)$/); + if (m) { + id = m[1]; + } else { + process.nextTick(callback, "Invalid Twitch VOD ID"); + return; + } + + TwitchClip.lookup(id).then(video => { + const media = new Media(video.id, video.title, video.duration, + "tc", video.meta); + process.nextTick(callback, false, media); + }).catch(function (err) { + callback(err.message || err, null); + }); + }, + /* ustream.tv */ us: function (id, callback) { /** diff --git a/src/utilities.js b/src/utilities.js index cf37bfb1..523cf121 100644 --- a/src/utilities.js +++ b/src/utilities.js @@ -244,6 +244,8 @@ return id; case "sb": return "https://streamable.com/" + id; + case "tc": + return "https://clips.twitch.tv/" + id; default: return ""; } diff --git a/www/js/player.js b/www/js/player.js index d26638a2..36812368 100644 --- a/www/js/player.js +++ b/www/js/player.js @@ -1519,7 +1519,8 @@ im: ImgurPlayer, vm: VideoJSPlayer, hl: HLSPlayer, - sb: VideoJSPlayer + sb: VideoJSPlayer, + tc: VideoJSPlayer }; window.loadMediaPlayer = function(data) { diff --git a/www/js/util.js b/www/js/util.js index a8b9f357..25d3ee0d 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -54,6 +54,8 @@ function formatURL(data) { return data.id; case "sb": return "https://streamable.com/" + data.id; + case "tc": + return "https://clips.twitch.tv/" + data.id; default: return "#"; } @@ -1284,6 +1286,13 @@ function parseMediaLink(url) { }; } + if ((m = url.match(/clips\.twitch\.tv\/([A-Za-z]+)/))) { + return { + id: m[1], + type: "tc" + }; + } + if((m = url.match(/twitch\.tv\/(?:.*?)\/([cv])\/(\d+)/))) { return { id: m[1] + m[2],