Last active
September 26, 2025 15:00
-
-
Save zshanhui/6a2ebb66bb87a6d85263279640718e84 to your computer and use it in GitHub Desktop.
Simple method to pipe ytdl-node steam into Express endpoint POC
This file contains hidden or 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
| const ytdl = require('ytdl-core'); | |
| const express = require('express'); | |
| const app = express(); | |
| const videoID = 'http://www.youtube.com/watch?v='; | |
| app.use('mp3', express.static(__dirname + '/mp3')); | |
| app.get('/stream/:id', (req, res) => { | |
| console.log('video url >> ', videoID + req.params.id); | |
| const astream = ytdl(videoID + req.params.id, { | |
| quality: 251 | |
| }); | |
| astream | |
| .on('data', chunk => { | |
| console.log('Data chunck received >> ', chunk); | |
| // fs.appendFile('./mp3/new_media.m4a', chunk, err => { | |
| // if(err) throw err; | |
| // }); | |
| }) | |
| .pipe(res); | |
| }) | |
| app.listen(3000, () => console.log('Example app listening on port 3000!')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment