Skip to content

Instantly share code, notes, and snippets.

@yongfook
Created October 12, 2020 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yongfook/9b190dcb4a3e943edfa7fbf2ef5a3535 to your computer and use it in GitHub Desktop.
Save yongfook/9b190dcb4a3e943edfa7fbf2ef5a3535 to your computer and use it in GitHub Desktop.
var videos = []
const res = await fetch("https://api.pexels.com/videos/search?query="+inputData.keyword+"&per_page=50&min_duration=5&max_duration=20", {
headers: { 'Authorization': inputData.pexels_api_key }
}).then(res => res.json())
.then(json => {
videos = json['videos'].filter(function (el) {
return el['duration'] >= 8 && el['duration'] <= 20
})
});
return {link: videos[Math.floor(Math.random() * videos.length)]['video_files'][0]['link']};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment