Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const cors = require('cors');
- const ytdl = require('ytdl-core');
- const app = express();
- import { videoName } from '../script.js'
- app.use(cors());
- app.listen(4000, () => {
- console.log('[ server started at port 4000 ]');
- });
- app.get('/download', (req,res) => {
- var URL = req.query.URL;
- res.header('Content-Disposition', `attachment; filename=${videoName}.mp3`);
- ytdl(URL, {
- format: 'mp3'
- }).pipe(res);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement