Dumb update

This commit is contained in:
0d0 2025-04-22 23:54:19 +02:00
parent e6096f2cd2
commit 9f36097598

View file

@ -1,7 +1,6 @@
import { create } from 'youtube-dl-exec';
import { create, type Flags } from 'youtube-dl-exec';
import { env } from '$env/dynamic/private';
import { spawn } from 'node:child_process';
import supportedFormats from '$lib/common/supportedFormats.json';
import { logger, mimeTypeMap } from '$lib/server/helpers';
const YTDLP_PATH: string = env.YTDLP_PATH as string;
@ -13,7 +12,7 @@ export const ytdl = create(YTDLP_PATH);
* Fetch YouTube metadata (title, uploader/artist)
*/
export async function getYouTubeMetadata(link: string) {
const options = {
const options: Flags = {
dumpSingleJson: true,
noCheckCertificates: true,
noWarnings: true,
@ -66,10 +65,13 @@ export function streamYouTube(link: string, format: string): ReadableStream<Uint
process.stdout.on('data', (chunk) => {
try {
controller.enqueue(chunk);
} catch (ex) {
} catch () {
process.kill();
}
});
process.stderr.on('data', (chunk) => logger.debug(chunk.toString()));
process.stdout.on('end', () => {
try {