Created
May 6, 2016 00:22
-
-
Save ericholiveira/1cc37ec4a5a189ea6a3e9103b99570bf 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
"use strict"; | |
var Studio = require('studio'); | |
var reddit = require('./reddit'); | |
var youtubeModule = Studio.module('Youtube'); | |
var fetchFromYoutube = youtubeModule('fetch'); | |
var redditModule = Studio.module('Reddit'); | |
redditModule(function fetchSubreddit(path){ | |
return reddit('/r/videos/'+path).get(); | |
}); | |
var _fetchSubreddit = redditModule('fetchSubreddit'); | |
redditModule(function searchForContent(path){ | |
return _fetchSubreddit(path).then(function(redditResponse){ | |
var redditVideoInfo = redditResponse.data.children; | |
return Studio.promise.all(redditVideoInfo.map(function(info){return fetchFromYoutube(info.data.url);})); | |
}).then(function(videosInfo){ | |
return videosInfo.filter(function(info){return info!==null}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment