refactor: split telegram.ts into seperate files

This commit is contained in:
2025-05-22 15:36:38 +02:00
parent 001c524d73
commit 0beb3b1071
3 changed files with 150 additions and 103 deletions

View File

@@ -107,3 +107,24 @@ export function parseRating(rating: string | number) {
}
return rating;
}
export async function convertOggToMp3(
oggData: ArrayBuffer,
): Promise<Uint8Array> {
const ffmpeg = new Deno.Command("ffmpeg", {
args: ["-f", "ogg", "-i", "pipe:0", "-f", "mp3", "pipe:1"],
stdin: "piped",
stdout: "piped",
stderr: "null",
});
const process = ffmpeg.spawn();
const writer = process.stdin.getWriter();
await writer.write(new Uint8Array(oggData));
await writer.close();
const output = await process.output();
const { code } = await process.status;
if (code !== 0) throw new Error(`FFmpeg exited with code ${code}`);
return output.stdout;
}