Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2019
1,693
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const express = require('express');
  2. const cors = require('cors');
  3. const ytdl = require('ytdl-core');
  4. const app = express();
  5.  
  6. import { videoName } from '../script.js'
  7.  
  8. app.use(cors());
  9. app.listen(4000, () => {
  10.     console.log('[ server started at port 4000 ]');
  11. });
  12.  
  13. app.get('/download', (req,res) => {
  14.     var URL = req.query.URL;
  15.     res.header('Content-Disposition', `attachment; filename=${videoName}.mp3`);
  16.     ytdl(URL, {
  17.         format: 'mp3'
  18.     }).pipe(res);
  19. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement