Skip to content

Instantly share code, notes, and snippets.

@ericholiveira
Created May 6, 2016 00:22
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 ericholiveira/1cc37ec4a5a189ea6a3e9103b99570bf to your computer and use it in GitHub Desktop.
Save ericholiveira/1cc37ec4a5a189ea6a3e9103b99570bf to your computer and use it in GitHub Desktop.
"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