-
-
Save yongfook/9b190dcb4a3e943edfa7fbf2ef5a3535 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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