From 84d4379f1670ef298c33f2a2a7d7bda6e7e422b5 Mon Sep 17 00:00:00 2001 From: 0d0 <0d0acre@esiliati.org> Date: Wed, 26 Feb 2025 16:10:43 +0100 Subject: [PATCH] Add support for proxies --- .env.example | 1 + src/lib/server/ytdlp.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index e7fa9d0..f069167 100644 --- a/.env.example +++ b/.env.example @@ -2,3 +2,4 @@ HOST=0.0.0.0 ORIGIN=https://dl.emersa.it YTDLP_PATH=./yt-dlp PUBLIC_VERSION=0.6.3 +HTTPS_PROXY= \ No newline at end of file diff --git a/src/lib/server/ytdlp.ts b/src/lib/server/ytdlp.ts index 0ff15fa..0ede591 100644 --- a/src/lib/server/ytdlp.ts +++ b/src/lib/server/ytdlp.ts @@ -5,6 +5,7 @@ import supportedFormats from '$lib/common/supportedFormats.json'; import { logger, mimeTypeMap } from '$lib/server/helpers'; const YTDLP_PATH: string = env.YTDLP_PATH as string; +const HTTPS_PROXY: string = env.v as string; export const ytdl = create(YTDLP_PATH); @@ -16,7 +17,8 @@ export async function getYouTubeMetadata(link: string) { dumpSingleJson: true, noCheckCertificates: true, noWarnings: true, - preferFreeFormats: true + preferFreeFormats: true, + proxy: HTTPS_PROXY ? HTTPS_PROXY : '' }); } @@ -34,7 +36,12 @@ export function streamYouTube(link: string, format: string): ReadableStream