Add support for proxies
This commit is contained in:
parent
9f4a2bc560
commit
84d4379f16
2 changed files with 10 additions and 2 deletions
|
@ -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=
|
|
@ -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<Uint
|
|||
|
||||
return new ReadableStream({
|
||||
start(controller) {
|
||||
const args = ['--no-write-thumbnail', '-o', '-'].filter(Boolean);
|
||||
const args = ['--no-write-thumbnail', '-o', '-'];
|
||||
|
||||
|
||||
if (HTTPS_PROXY) {
|
||||
args.push('--proxy', HTTPS_PROXY)
|
||||
}
|
||||
|
||||
if (mimeType?.includes('audio')) {
|
||||
args.push(
|
||||
|
|
Loading…
Add table
Reference in a new issue