Removing the converter, moving it to a seperate project

This commit is contained in:
Violet 2023-08-24 13:48:41 +00:00
parent 72d25bf5e1
commit 84c93a21e8
2 changed files with 1 additions and 83 deletions

View file

@ -3,22 +3,11 @@ const ytdl = require('ytdl-core'),
path = require('path'),
express = require('express'),
ffmpeg = require('fluent-ffmpeg'),
bodyParser = require('body-parser'),
multer = require('multer')
bodyParser = require('body-parser')
const PORT = process.env.PORT || 8080
const app = express()
const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, 'uploads/')
},
filename: function (req, file, cb) {
const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9)
cb(null, file.fieldname + '-' + uniqueSuffix + '-' + file.originalname)
}
})
app.use(bodyParser.urlencoded({ extended: false }))
var jsonParser = bodyParser.json()
@ -43,26 +32,6 @@ app.get("/download", (req, res) => {
});
const upload = multer({ limits: { fieldSize: 100_000_000 }, storage: storage })
app.post("/convert", upload.single('video'), (req, res) => {
console.log(req.file.path)
const filename = req.body.filename
const vid = req.file.path
const format = req.body.format
var proc = new ffmpeg({ source: vid })
.format(format)
.pipe(res)
.on("end", () => {
console.log("AAAA")
fs.unlinkSync(req.file.path)
})
res.header('Content-Disposition', `attachment; filename="${filename}.${format}"`);
});
app.use(express.static(path.join(__dirname, 'static')))
app.listen(PORT, function () {

View file

@ -1,51 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4"
crossorigin="anonymous"></script> -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<link rel="stylesheet" href="/style.css">
<title>Video Converter</title>
</head>
<body>
<h1>Video Converter <p>v0.3</p>
<hr>
</h1>
<form action="/convert" method="post" target="_blank" enctype="multipart/form-data">
<p style="margin-bottom: 1px;">File:</p>
<input required type="file" name="video">
<p>Filename:</p>
<input required id="filename" placeholder="Enter filename" name="filename"><br>
<p>Format:</p>
<select required id="format" name="format">
<option disabled>Video Options</option>
<option value="mp4">.mp4</option>
<option value="webm">.webm</option>
<option value="mov">.mov</option>
<option value="flv">.flv</option>
<option value="avi">.avi</option>
<option value="mpeg">.mpeg</option>
<option disabled>Audio Options</option>
<option value="wmv">.wmv</option>
<option value="mp3">.mp3</option>
</select>
<input type="submit" placeholder="test">
</form>
<hr>
<!-- <p><a>Please consider donating</a> or host the website yourself! (Check github below for more info)</p><br> -->
<p>Please consider hosting the project yourself! (Check github for more details)</p>
<p>Check out the <a id="github" href="https://github.com/Violets-puragtory/YoutubeConverter">Github page</a> to
learn how to host it yourself, how it works, report bugs, and more.</p>
</body>
</html>