go back
This commit is contained in:
parent
4c9fa6f00c
commit
7128d15ad2
10
index.js
10
index.js
|
@ -1,6 +1,4 @@
|
||||||
require('dotenv').config()
|
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const { randomDispatcher } = require('freebind');
|
|
||||||
const { Innertube, Utils } = require('@preservetube/youtube.js');
|
const { Innertube, Utils } = require('@preservetube/youtube.js');
|
||||||
const hr = require('@tsmx/human-readable')
|
const hr = require('@tsmx/human-readable')
|
||||||
|
|
||||||
|
@ -9,7 +7,6 @@ const ffmpegStatic = require('ffmpeg-static')
|
||||||
const fs = require('node:fs')
|
const fs = require('node:fs')
|
||||||
|
|
||||||
const app = express()
|
const app = express()
|
||||||
const dispatcher = randomDispatcher(process.env.RANGE)
|
|
||||||
require('express-ws')(app)
|
require('express-ws')(app)
|
||||||
|
|
||||||
ffmpeg.setFfmpegPath(ffmpegStatic)
|
ffmpeg.setFfmpegPath(ffmpegStatic)
|
||||||
|
@ -124,12 +121,7 @@ app.get('/videos/:id', async (req, res) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
app.ws('/download/:id/:quality', async (ws, req) => {
|
app.ws('/download/:id/:quality', async (ws, req) => {
|
||||||
const yt = await Innertube.create({
|
const yt = await Innertube.create();
|
||||||
fetch: (input, init) => fetch(input, {
|
|
||||||
...init,
|
|
||||||
dispatcher: dispatcher
|
|
||||||
})
|
|
||||||
});
|
|
||||||
const info = await yt.getInfo(req.params.id, 'ANDROID');
|
const info = await yt.getInfo(req.params.id, 'ANDROID');
|
||||||
if (info.playability_status.status !== 'OK') {
|
if (info.playability_status.status !== 'OK') {
|
||||||
ws.send(`This video is not available for download (${info.playability_status.status} ${info.playability_status.reason}).`);
|
ws.send(`This video is not available for download (${info.playability_status.status} ${info.playability_status.reason}).`);
|
||||||
|
|
|
@ -6,11 +6,9 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@preservetube/youtube.js": "^13.1.0",
|
"@preservetube/youtube.js": "^13.1.0",
|
||||||
"@tsmx/human-readable": "^2.0.3",
|
"@tsmx/human-readable": "^2.0.3",
|
||||||
"dotenv": "^16.4.7",
|
|
||||||
"express": "^4.21.1",
|
"express": "^4.21.1",
|
||||||
"express-ws": "^5.0.2",
|
"express-ws": "^5.0.2",
|
||||||
"ffmpeg-static": "^5.2.0",
|
"ffmpeg-static": "^5.2.0",
|
||||||
"fluent-ffmpeg": "^2.1.3",
|
"fluent-ffmpeg": "^2.1.3"
|
||||||
"freebind": "^0.2.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue