Skip to content

Instantly share code, notes, and snippets.

@coderaiser
Last active August 29, 2015 14:00
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 coderaiser/f1ce9146004a0a2d7100 to your computer and use it in GitHub Desktop.
Save coderaiser/f1ce9146004a0a2d7100 to your computer and use it in GitHub Desktop.
express youtube
(function() {
'use strict';
var express = require('express'),
app = express(),
ytdl = require('ytdl'),
EXT = 'mp4',
URL = 'https://www.youtube.com/watch?v=',
PORT = 8888;
app.get('/:id', function(req, res) {
var id = req.params.id;
download(res, id);
});
app.listen(PORT);
function download(res, id) {
ytdl(URL + id, {
filter: filter
}).pipe(res);
}
function filter(format) {
var is = format.container === EXT;
return is;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment