From dcc056455eda4845a0e0533d041ea91a1da0c729 Mon Sep 17 00:00:00 2001 From: Raphix Date: Sun, 31 Aug 2025 16:57:13 +0200 Subject: [PATCH] Version 1.1.3 - Modfication du Proxy --- package.json | 2 +- src/player/Method/Youtube.js | 10 ++++++---- src/utils/GlobalVars.js | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 3817157..bce4849 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chopin-backend", - "version": "1.1.2", + "version": "1.1.3", "description": "Discord Bot for music - Fetching everywhere !", "main": "src/main.js", "nodemonConfig": { diff --git a/src/player/Method/Youtube.js b/src/player/Method/Youtube.js index 5e7d51c..16a1d26 100644 --- a/src/player/Method/Youtube.js +++ b/src/player/Method/Youtube.js @@ -2,7 +2,6 @@ const {createAudioResource, VoiceConnectionStatus, createAudioPlayer, StreamType const {LogType} = require('loguix') const clog = new LogType("Youtube-Stream") const ytdl = require('@distube/ytdl-core') -const { getRandomIPv6 } = require("@distube/ytdl-core/lib/utils"); const { __glob } = require('../../utils/GlobalVars'); const fs = require('fs'); @@ -18,9 +17,11 @@ async function getStream(song) { 'Chrome/116.0.5845.97 Safari/537.36', 'Accept-Language': 'en-US,en;q=0.9' }; + var cookies = await JSON.parse(await fs.readFileSync(__glob.COOKIES, 'utf-8')); - ytdl.createAgent(cookies) - let stream = ytdl(song.url, { + const proxy = await JSON.parse(await fs.readFileSync(__glob.PROXY, 'utf-8')); + const agent = ytdl.createProxyAgent(proxy, cookies) + let stream = ytdl(song.url, { quality: 'highestaudio', highWaterMark: 1 << 30, liveBuffer: 20000, @@ -28,7 +29,8 @@ async function getStream(song) { bitrate: 128, requestOptions: { headers: headers, - } + }, + agent: agent, }); return stream diff --git a/src/utils/GlobalVars.js b/src/utils/GlobalVars.js index 916edac..6cb290f 100644 --- a/src/utils/GlobalVars.js +++ b/src/utils/GlobalVars.js @@ -17,7 +17,8 @@ const __glob = { MEDIA_DB: root + path.sep + "data" + path.sep + "media.json", VERSION: version, CHANGELOG_PATH: root + path.sep + "CHANGELOG.html", - COOKIES: root + path.sep + "data" + path.sep + "cookies.json" + COOKIES: root + path.sep + "data" + path.sep + "cookies.json", + PROXY: root + path.sep + "data" + path.sep + "proxy.json" } module.exports = {__glob} \ No newline at end of file