File size: 512 Bytes
652f343
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { promises as fs } from "node:fs"

import { videoId, server } from "./config.mts"

console.log(`trying to download video ${videoId}`)

const response = await fetch(`${server}/${videoId}.mp4`, {
  method: "GET",
});

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

fs.writeFile(`./${videoId}.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