Removing the converter, moving it to a seperate project
This commit is contained in:
parent
72d25bf5e1
commit
84c93a21e8
2 changed files with 1 additions and 83 deletions
33
index.js
33
index.js
|
@ -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 () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue