Add yt-dlp proxy support

This commit is contained in:
Alex Thomassen 2024-10-07 16:52:52 +00:00
parent a745e28eb9
commit a68965e8a7
Signed by: Alex
GPG Key ID: 10BD786B5F6FF5DE
2 changed files with 18 additions and 0 deletions

View File

@ -53,6 +53,12 @@ module.exports = {
*/
ytDlpPath: './yt-dlp',
/**
* Proxy URL to use for yt-dlp
* Might be useful in some cases where your usual IP (e.g. shared datacenter IP) is blocked
*/
ytdlpProxy: null,
/**
* YouTube API key for search
*/

View File

@ -62,6 +62,11 @@ const player = createAudioPlayer();
const yt = new YouTube(config.youtubeApiKey);
const httpClient = axios.create();
let ytProxy = null as null | string;
if (config.ytdlpProxy) {
ytProxy = config.ytdlpProxy;
}
/**
* Bot state
*/
@ -466,6 +471,13 @@ async function queueUrl(message: Message, words: string[], options: Object | und
`${path}.%(ext)s`,
];
if (ytProxy) {
ytdlpParams = ytdlpParams.concat([
'--proxy',
ytProxy,
]);
}
if (!fullVideo) {
ytdlpParams = ytdlpParams.concat([
'--sponsorblock-remove',