trying stuff

This commit is contained in:
localhost 2025-03-14 22:24:28 +01:00
parent 1b941498d6
commit e567028498
2 changed files with 12 additions and 2 deletions

View File

@ -1,4 +1,6 @@
require('dotenv').config()
const express = require('express')
const { randomDispatcher } = require('freebind');
const { Innertube, Utils } = require('@preservetube/youtube.js');
const hr = require('@tsmx/human-readable')
@ -7,6 +9,7 @@ const ffmpegStatic = require('ffmpeg-static')
const fs = require('node:fs')
const app = express()
const dispatcher = randomDispatcher(process.env.RANGE)
require('express-ws')(app)
ffmpeg.setFfmpegPath(ffmpegStatic)
@ -121,7 +124,12 @@ app.get('/videos/:id', async (req, res) => {
})
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');
if (info.playability_status.status !== 'OK') {
ws.send(`This video is not available for download (${info.playability_status.status} ${info.playability_status.reason}).`);

View File

@ -6,9 +6,11 @@
"dependencies": {
"@preservetube/youtube.js": "^13.1.0",
"@tsmx/human-readable": "^2.0.3",
"dotenv": "^16.4.7",
"express": "^4.21.1",
"express-ws": "^5.0.2",
"ffmpeg-static": "^5.2.0",
"fluent-ffmpeg": "^2.1.3"
"fluent-ffmpeg": "^2.1.3",
"freebind": "^0.2.2"
}
}