File size: 657 Bytes
e2472ff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { promises as fs } from "node:fs"


console.log('generating shot..')
const response = await fetch("http://localhost:7860/shot", {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    token: process.env.VS_SECRET_ACCESS_TOKEN,
    shotPrompt: "video of a dancing cat"
  })
});

console.log('response:', response)
const buffer = await (response as any).buffer()

fs.writeFile(`./test-juju.mp4`, buffer)

// if called from an API, we ùight want to use streams instead:
// https://stackoverflow.com/questions/15713424/how-can-i-download-a-video-mp4-file-using-node-js