2023-05-05 11:15:22 -05:00
|
|
|
const ytdl = require('ytdl-core')
|
|
|
|
const fs = require('fs')
|
|
|
|
const path = require('path')
|
|
|
|
const express = require('express')
|
|
|
|
|
|
|
|
const PORT = process.env.PORT || 8080
|
|
|
|
const app = express()
|
|
|
|
|
|
|
|
app.get("/download", (req, res) => {
|
2023-05-08 12:52:41 -05:00
|
|
|
const filename = req.query.filename
|
|
|
|
const url = req.query.url
|
2023-05-10 12:36:26 -05:00
|
|
|
const format = req.query.format
|
2023-05-05 11:15:22 -05:00
|
|
|
const quality = req.query.quality
|
2023-05-10 12:36:26 -05:00
|
|
|
|
|
|
|
res.header('Content-Disposition', `attachment; filename="${filename}.${format}"`);
|
|
|
|
ytdl(url, { 'format': format, 'quality': quality }).pipe(res);
|
2023-05-05 11:15:22 -05:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
app.use(express.static(path.join(__dirname, 'static')))
|
|
|
|
|
2023-05-10 12:36:26 -05:00
|
|
|
app.listen(PORT, function () {
|
2023-05-05 11:15:22 -05:00
|
|
|
console.log("Hosted on port " + PORT)
|
|
|
|
})
|