Defer to mediaquery for anonymous vimeo lookup

This commit is contained in:
calzoneman 2016-01-07 17:38:05 -08:00
parent eeaffe1f61
commit f46891b6ed
2 changed files with 7 additions and 45 deletions

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery", "author": "Calvin Montgomery",
"name": "CyTube", "name": "CyTube",
"description": "Online media synchronizer and chat", "description": "Online media synchronizer and chat",
"version": "3.13.0", "version": "3.13.1",
"repository": { "repository": {
"url": "http://github.com/calzoneman/sync" "url": "http://github.com/calzoneman/sync"
}, },

View File

@ -9,6 +9,7 @@ var Config = require("./config");
var ffmpeg = require("./ffmpeg"); var ffmpeg = require("./ffmpeg");
var mediaquery = require("cytube-mediaquery"); var mediaquery = require("cytube-mediaquery");
var YouTube = require("cytube-mediaquery/lib/provider/youtube"); var YouTube = require("cytube-mediaquery/lib/provider/youtube");
var Vimeo = require("cytube-mediaquery/lib/provider/vimeo");
/* /*
* Preference map of quality => youtube formats. * Preference map of quality => youtube formats.
@ -158,50 +159,11 @@ var Getters = {
return Getters.vi_oauth(id, callback); return Getters.vi_oauth(id, callback);
} }
var options = { Vimeo.lookup(id).then(video => {
host: "vimeo.com", video = new Media(video.id, video.title, video.duration, "vi");
port: 443, callback(null, video);
path: "/api/v2/video/" + id + ".json", }).catch(error => {
method: "GET", callback(error.message);
dataType: "jsonp",
timeout: 1000
};
urlRetrieve(https, options, function (status, data) {
switch (status) {
case 200:
break; /* Request is OK, skip to handling data */
case 400:
return callback("Invalid request", null);
case 403:
return callback("Private video", null);
case 404:
return callback("Video not found", null);
case 500:
case 503:
return callback("Service unavailable", null);
default:
return callback("HTTP " + status, null);
}
try {
data = JSON.parse(data);
data = data[0];
var seconds = data.duration;
var title = data.title;
var media = new Media(id, title, seconds, "vi");
callback(false, media);
} catch(e) {
var err = e;
/**
* This should no longer be necessary as the outer handler
* checks for HTTP 404
*/
if (buffer.match(/not found/))
err = "Video not found";
callback(err, null);
}
}); });
}, },