//native
type Shutterstock = {
token: string;
};
/**
* Search for videos
* This endpoint searches for videos. If you specify more than one search parameter, the API uses an AND condition. Array parameters can be specified multiple times; in this case, the API uses an AND or an OR condition with those values, depending on the parameter. You can also filter search terms out in the `query` parameter by prefixing the term with NOT.
*/
export async function main(
auth: Shutterstock,
added_date: string | undefined,
added_date_start: string | undefined,
added_date_end: string | undefined,
aspect_ratio: "4_3" | "16_9" | "nonstandard" | undefined,
category: string | undefined,
contributor: string | undefined,
contributor_country: string | undefined,
duration: string | undefined,
duration_from: string | undefined,
duration_to: string | undefined,
fps: string | undefined,
fps_from: string | undefined,
fps_to: string | undefined,
keyword_safe_search: string | undefined,
language:
| "ar"
| "bg"
| "bn"
| "cs"
| "da"
| "de"
| "el"
| "en"
| "es"
| "fi"
| "fr"
| "gu"
| "he"
| "hi"
| "hr"
| "hu"
| "id"
| "it"
| "ja"
| "kn"
| "ko"
| "ml"
| "mr"
| "nb"
| "nl"
| "or"
| "pl"
| "pt"
| "ro"
| "ru"
| "sk"
| "sl"
| "sv"
| "ta"
| "te"
| "th"
| "tr"
| "uk"
| "ur"
| "vi"
| "zh"
| "zh-Hant"
| undefined,
license: string | undefined,
model: string | undefined,
orientation: "vertical" | "horizontal" | undefined,
page: string | undefined,
per_page: string | undefined,
people_age:
| "infants"
| "children"
| "teenagers"
| "20s"
| "30s"
| "40s"
| "50s"
| "60s"
| "older"
| undefined,
people_ethnicity: string | undefined,
people_gender: "male" | "female" | "both" | undefined,
people_number: string | undefined,
people_model_released: string | undefined,
query: string | undefined,
resolution: "4k" | "standard_definition" | "high_definition" | undefined,
safe: string | undefined,
sort: "newest" | "popular" | "relevance" | "random" | undefined,
view: "minimal" | "full" | undefined,
) {
const url = new URL(`https://api.shutterstock.com/v2/videos/search`);
for (const [k, v] of [
["added_date", added_date],
["added_date_start", added_date_start],
["added_date_end", added_date_end],
["aspect_ratio", aspect_ratio],
["category", category],
["contributor", contributor],
["contributor_country", contributor_country],
["duration", duration],
["duration_from", duration_from],
["duration_to", duration_to],
["fps", fps],
["fps_from", fps_from],
["fps_to", fps_to],
["keyword_safe_search", keyword_safe_search],
["language", language],
["license", license],
["model", model],
["orientation", orientation],
["page", page],
["per_page", per_page],
["people_age", people_age],
["people_ethnicity", people_ethnicity],
["people_gender", people_gender],
["people_number", people_number],
["people_model_released", people_model_released],
["query", query],
["resolution", resolution],
["safe", safe],
["sort", sort],
["view", view],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
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 235 days ago