Update download method
This commit is contained in:
parent
e82c027ad9
commit
08578eef0b
5 changed files with 128 additions and 23 deletions
|
@ -5,7 +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;
|
||||
const HTTPS_PROXY: string = env.HTTPS_PROXY as string;
|
||||
|
||||
export const ytdl = create(YTDLP_PATH);
|
||||
|
||||
|
@ -13,17 +13,22 @@ export const ytdl = create(YTDLP_PATH);
|
|||
* Fetch YouTube metadata (title, uploader/artist)
|
||||
*/
|
||||
export async function getYouTubeMetadata(link: string) {
|
||||
return await ytdl(link, {
|
||||
const options = {
|
||||
dumpSingleJson: true,
|
||||
noCheckCertificates: true,
|
||||
noWarnings: true,
|
||||
preferFreeFormats: true,
|
||||
proxy: HTTPS_PROXY ? HTTPS_PROXY : ''
|
||||
});
|
||||
}
|
||||
|
||||
if (HTTPS_PROXY) {
|
||||
options.proxy = HTTPS_PROXY;
|
||||
}
|
||||
|
||||
return await ytdl(link, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams the YouTube video/audio using yt-dlp
|
||||
* Streams the YouTube video/audio using youtube-dl-exec
|
||||
*/
|
||||
export function streamYouTube(link: string, format: string): ReadableStream<Uint8Array> {
|
||||
logger.debug(`Starting to stream: ${link}`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue