Removed more unnessacary stuff

This commit is contained in:
Violet 2023-08-24 16:00:33 +00:00
parent 84c93a21e8
commit d603b974f0
5 changed files with 52 additions and 176 deletions

View file

@ -8,9 +8,15 @@ const ytdl = require('ytdl-core'),
const PORT = process.env.PORT || 8080
const app = express()
app.use(bodyParser.urlencoded({ extended: false }))
process.on('uncaughtException', (err, origin) => {
fs.writeSync(
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
);
});
var jsonParser = bodyParser.json()
app.use(bodyParser.urlencoded({ extended: false }))
app.get("/download", (req, res) => {
const filename = req.query.filename
@ -18,6 +24,11 @@ app.get("/download", (req, res) => {
const format = req.query.format
const quality = req.query.quality
if (!ytdl.validateURL("https://www.youtube.com/video/_FJGQ7Hae2I)")) {
res.send("Invalid URL!")
return
}
if (format != "mp4" && format != "webm") {
res.header('Content-Disposition', `attachment; filename="${filename}.${format};"`);