Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/core/src/content/transcript/providers/youtube/yt-dlp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,17 @@ export const fetchTranscriptWithYtDlp = async ({
if (result.notes.length > 0) notes.push(...result.notes);
return { text: result.text, provider: result.provider, error: result.error, notes };
} catch (error) {
if (
error instanceof Error &&
error.message.includes("unable to obtain file audio codec with ffprobe")
) {
return {
text: "",
provider: null,
error: null,
notes: [...notes, "yt-dlp: Media has no audio stream"],
};
}
return {
text: null,
provider: null,
Expand Down
26 changes: 26 additions & 0 deletions tests/transcript.yt-dlp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,32 @@ describe("yt-dlp transcript helper", () => {
expect(result.error?.message).toMatch(/yt-dlp exited with code 1/);
});

it("returns empty text and a note when yt-dlp fails with 'unable to obtain file audio codec'", async () => {
spawnMock.mockImplementation(() => {
const proc = new EventEmitter() as any;
proc.stdout = new PassThrough();
proc.stderr = new PassThrough();
process.nextTick(() => {
proc.stderr.write(
"ERROR: Postprocessing: WARNING: unable to obtain file audio codec with ffprobe\n",
);
proc.stderr.end();
process.nextTick(() => proc.emit("close", 1, null));
});
return proc;
});

const result = await fetchTranscriptWithYtDlp({
ytDlpPath: "/usr/bin/yt-dlp",
openaiApiKey: "OPENAI",
url: "https://youtu.be/dQw4w9WgXcQ",
});

expect(result.text).toBe("");
expect(result.error).toBeNull();
expect(result.notes).toContain("yt-dlp: Media has no audio stream");
});

it("passes --no-playlist to yt-dlp", async () => {
mockSpawnSuccess();
(globalThis.fetch as unknown as ReturnType<typeof vi.fn>).mockResolvedValue(
Expand Down