Update the rest of the libraries for bluebird
This commit is contained in:
parent
90c1385fb3
commit
17de5e9b92
8 changed files with 591 additions and 144 deletions
|
@ -1,7 +1,8 @@
|
|||
"use strict";
|
||||
var parse = require('url').parse;
|
||||
var Promise = require('bluebird');
|
||||
var request = require('superagent');
|
||||
var Q = require('q');
|
||||
require('superagent-bluebird-promise');
|
||||
|
||||
module.exports.id = "youtube";
|
||||
|
||||
|
@ -19,7 +20,6 @@ var apiRoot = "https://www.googleapis.com/youtube/v3";
|
|||
module.exports.match = require('./url').match;
|
||||
|
||||
module.exports.search = function(data) {
|
||||
var deferred = Q.defer();
|
||||
var query, album;
|
||||
var type = data.type;
|
||||
|
||||
|
@ -33,13 +33,13 @@ module.exports.search = function(data) {
|
|||
|
||||
var path = "/search?part=snippet&q=" + encodeURIComponent(query) + "&type=video&videoCaption=any&videoCategoryId=10&key=" + credentials.key;
|
||||
|
||||
request.get(apiRoot + path, function(res) {
|
||||
return request.get(apiRoot + path).promise().then(function(res) {
|
||||
var result = res.body.items[0];
|
||||
|
||||
if (!result) {
|
||||
deferred.resolve({service:"youtube", type: "video"});
|
||||
return {service:"youtube", type: "video"};
|
||||
} else {
|
||||
deferred.resolve({
|
||||
return {
|
||||
service: "youtube",
|
||||
type: "video",
|
||||
id: result.id.videoId,
|
||||
|
@ -47,8 +47,7 @@ module.exports.search = function(data) {
|
|||
streamUrl: "https://www.youtube.com/watch?v=" + result.id.videoId,
|
||||
purchaseUrl: null,
|
||||
artwork: result.snippet.thumbnails.medium.url,
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue