@@ -86,6 +86,8 @@ To access all replays for a browser session, you can list and access them via ur
8686
8787<CodeGroup >
8888``` typescript Typescript/Javascript
89+ import fs from ' fs' ;
90+ import { Buffer } from ' buffer' ;
8991// List all replays for the session
9092const replays = await kernel .browsers .replays .list (kernelBrowser .session_id );
9193
@@ -95,13 +97,21 @@ for (const replay of replays) {
9597
9698 // Download the mp4 file
9799 const videoData = await kernel .browsers .replays .download (
98- kernelBrowser . session_id ,
99- replay . replay_id
100+ replay . replay_id ,
101+ { id: kernelBrowser . session_id }
100102 );
103+
104+ const content = await videoData .blob ();
105+ const buffer = Buffer .from (await content .arrayBuffer ());
106+
107+ // Save to file
108+ const filename = ` replay-${replay .replay_id }-${kernelBrowser .session_id }.mp4 ` ;
109+ fs .writeFileSync (filename , buffer );
101110}
102111```
103112
104113``` python Python
114+ import aiofiles
105115# List all replays for the session
106116replays = client.browsers.replays.list(kernel_browser.session_id)
107117
@@ -111,8 +121,18 @@ for replay in replays:
111121
112122 # Download the mp4 file
113123 video_data = client.browsers.replays.download(
114- kernel_browser.session_id,
115- replay.replay_id
124+ replay_id = replay.replay_id,
125+ id = kernel_browser.session_id
116126 )
127+
128+ # Get the content as bytes
129+ content = video_data.read()
130+
131+ # Save to file using aiofiles
132+ filename = f " replay- { replay.replay_id} - { kernel_browser.session_id} .mp4 "
133+ async with aiofiles.open(filename, ' wb' ) as f:
134+ await f.write(content)
135+
136+ print (f " Saved replay to { filename} " )
117137```
118138</CodeGroup >
0 commit comments