Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
[release] build lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Bourrousse committed Sep 10, 2019
1 parent c885826 commit beadd30
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/providers/youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var fetchUrl = function fetchUrl(videoId, part) {
return "https://www.googleapis.com/youtube/v3/videos?part=" + part + "&id=" + videoId + "&key=" + provider.apiKey;
};

var searchUrl = function searchUrl(query, token) {
var searchUrl = function searchUrl(query, token, order) {
var url;
url = 'https://www.googleapis.com/youtube/v3/search' + ("?part=snippet&type=video&key=" + provider.apiKey) + ("&q=" + query);

Expand All @@ -36,6 +36,10 @@ var searchUrl = function searchUrl(query, token) {
url = url + "&pageToken=" + token;
}

if (order) {
url = url + "&order=" + order;
}

return url;
};

Expand Down Expand Up @@ -112,9 +116,9 @@ var provider = {
return resolve(_.compact(["<iframe src=\"" + getUrl(videoId) + "\"", 'frameborder="0"', _.get(provider, 'embed.width') ? "width=\"" + provider.embed.width + "\"" : null, _.get(provider, 'embed.height') ? "height=\"" + provider.embed.height + "\"" : null, '></iframe>']).join(' '));
});
},
search: function search(query, token) {
search: function search(query, token, order) {
var result = [];
return fetch(searchUrl(query, token), {
return fetch(searchUrl(query, token, order), {
timeout: 10000,
headers: provider.headers
}).then(function (res) {
Expand All @@ -128,7 +132,7 @@ var provider = {
}));
}).then(function (res) {
var formattedVideos = res.map(function (item) {
var _$get = _.get(item, 'items.0'),
var _$get = _.get(item, 'items.0', {}),
id = _$get.id,
_$get$snippet = _$get.snippet,
title = _$get$snippet.title,
Expand Down

0 comments on commit beadd30

Please sign in to comment.