Update media item

Script actimo Verified

by hugo697 ยท 11/5/2024

The script

Submitted by hugo697 Bun
Verified 572 days ago
1
//native
2
type Actimo = {
3
	apiKey: string
4
}
5

6
export async function main(
7
	auth: Actimo,
8
	id: string,
9
	body: { description?: string; title?: string; video_filters?: string } & {
10
		metadata?: string
11
		shared?: false | true
12
	}
13
) {
14
	const url = new URL(`https://actimo.com/api/v1/media/${id}`)
15

16
	const response = await fetch(url, {
17
		method: 'PUT',
18
		headers: {
19
			'api-key': auth.apiKey,
20
			'Content-Type': 'application/json'
21
		},
22
		body: JSON.stringify(body)
23
	})
24

25
	if (!response.ok) {
26
		const text = await response.text()
27
		throw new Error(`${response.status} ${text}`)
28
	}
29

30
	return await response.json()
31
}
32