From bdd4744b8c969e481a430474c0a483931923f12b Mon Sep 17 00:00:00 2001 From: Calvin Montgomery Date: Fri, 4 Apr 2014 20:03:34 -0500 Subject: [PATCH] Add support for Vimeo's OAuth ("advanced") API This allows for authenticated API requests. Currently, the only reason you would want to use this is to be able to add videos that are marked private but still embeddable. --- config.template.yaml | 10 ++++++++++ lib/get-info.js | 25 ++++++++++++++++++++++++- lib/server.js | 2 +- package.json | 5 +++-- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/config.template.yaml b/config.template.yaml index d570e858..e54a63bc 100644 --- a/config.template.yaml +++ b/config.template.yaml @@ -97,6 +97,16 @@ aliases: # Workaround for Vimeo blocking my domain vimeo-workaround: false +# OPTIONAL: Use Vimeo's OAuth API instead of the anonymous API. +# This allows you to add private videos that have embedding enabled. +# See https://developer.vimeo.com/apps/new to register for this API. +# Note that in order to use this feature you must agree to Vimeo's +# Terms of Service and License Agreement. +vimeo-oauth: + enabled: true + consumer-key: '' + secret: '' + # Regular expressions for defining reserved user and channel names and page titles # The list of regular expressions will be joined with an OR, and compared without # case sensitivity. diff --git a/lib/get-info.js b/lib/get-info.js index 572aa298..9948150f 100644 --- a/lib/get-info.js +++ b/lib/get-info.js @@ -402,7 +402,30 @@ var Getters = { null, null, function (err, data, res) { - console.log(err, data); + if (err) { + return callback(err, null); + } + + try { + data = JSON.parse(data); + + if (data.stat !== "ok") { + return callback(data.err.msg, null); + } + + var video = data.video[0]; + + if (video.embed_privacy !== "anywhere") { + return callback("Embedding disabled", null); + } + + var id = video.id; + var seconds = parseInt(video.duration); + var title = video.title; + callback(null, new Media(id, title, seconds, "vi")); + } catch (e) { + callback("Error handling Vimeo response", null); + } }); }, diff --git a/lib/server.js b/lib/server.js index 2dfafd85..3b9868a1 100644 --- a/lib/server.js +++ b/lib/server.js @@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -const VERSION = "3.0.0-RC2"; +const VERSION = "3.0.1"; var singleton = null; var Config = require("./config"); diff --git a/package.json b/package.json index d855a0b0..51b2d407 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "3.0.0-RC2", + "version": "3.0.1", "repository": { "url": "http://github.com/calzoneman/sync" }, @@ -15,6 +15,7 @@ "nodemailer": "~0.6.0", "cookie": "~0.1.0", "yamljs": "~0.1.4", - "express-minify": "0.0.7" + "express-minify": "0.0.7", + "oauth": "^0.9.11" } }