MCPcopy
hub / github.com/CapSoftware/Cap / parseVideoId

Function parseVideoId

apps/web/actions/admin/reprocess-video.ts:21–40  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

19}
20
21function parseVideoId(input: string) {
22 const trimmed = input.trim();
23 if (!trimmed) {
24 throw new Error("Enter a video ID or share URL");
25 }
26
27 try {
28 const url = new URL(trimmed);
29 const pathMatch = url.pathname.match(/\/s\/([^/?#]+)/);
30 if (pathMatch?.[1]) {
31 return Video.VideoId.make(pathMatch[1]);
32 }
33 const lastSegment = url.pathname.split("/").filter(Boolean).at(-1);
34 if (lastSegment) {
35 return Video.VideoId.make(lastSegment);
36 }
37 } catch {}
38
39 return Video.VideoId.make(trimmed);
40}
41
42export async function adminReprocessVideo(input: string) {
43 await requireAdmin();

Callers 1

adminReprocessVideoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected