feat(api): capture routes YouTube/Vimeo URLs to ingest.video

POST /api/capture with a youtube.com / youtu.be / vimeo.com URL
enqueues ingest.video (Python worker) instead of ingest.url
(Node worker). Detection by URL hostname; idempotency_key + response
shape unchanged.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-01 10:08:16 +10:00
parent 1ba7aae439
commit b10b68582d
2 changed files with 30 additions and 1 deletions

View File

@@ -69,4 +69,25 @@ describe('capture api', () => {
.send({ space_id: sp.id, url: 'https://example.com/a' });
expect(res.status).toBe(401);
});
it('POST /api/capture with YouTube URL enqueues ingest.video', async () => {
const res = await request(app).post('/api/capture').set(ownerHeaders)
.send({ space_id: sp.id, url: 'https://youtu.be/abc' });
expect(res.status).toBe(202);
expect(res.body.job_id).toBeTruthy();
const { default: jobsRepo } = { default: await import('../../lib/db/repos/jobs.js') };
const rows = await jobsRepo.list({ name: 'ingest.video' });
expect(rows.find(r => r.id === res.body.job_id)).toBeTruthy();
const urlRows = await jobsRepo.list({ name: 'ingest.url' });
expect(urlRows.find(r => r.id === res.body.job_id)).toBeFalsy();
});
it('POST /api/capture with vimeo URL enqueues ingest.video', async () => {
const res = await request(app).post('/api/capture').set(ownerHeaders)
.send({ space_id: sp.id, url: 'https://vimeo.com/123' });
expect(res.status).toBe(202);
const { default: jobsRepo } = { default: await import('../../lib/db/repos/jobs.js') };
const rows = await jobsRepo.list({ name: 'ingest.video' });
expect(rows.find(r => r.id === res.body.job_id)).toBeTruthy();
});
});