type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* List videos
* Lists up to 1000 videos from a single request. For a specific range, refer to the optional parameters.
*/
export async function main(
auth: Cloudflare,
account_identifier: string,
status:
| "pendingupload"
| "downloading"
| "queued"
| "inprogress"
| "ready"
| "error"
| undefined,
creator: string | undefined,
type: string | undefined,
asc: string | undefined,
search: string | undefined,
start: string | undefined,
end: string | undefined,
include_counts: string | undefined
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/accounts/${account_identifier}/stream`
);
for (const [k, v] of [
["status", status],
["creator", creator],
["type", type],
["asc", asc],
["search", search],
["start", start],
["end", end],
["include_counts", include_counts],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
"X-AUTH-EMAIL": auth.email,
"X-AUTH-KEY": auth.key,
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 297 days ago