Edits history of script submission #20346 for ' Download videos (shutterstock)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Shutterstock = {
      token: string;
    };
    /**
     * Download videos
     * This endpoint redownloads videos that you have already received a license for.
     */
    export async function main(
      auth: Shutterstock,
      id: string,
      body: {
        auth_cookie?: { name: string; value: string };
        show_modal?: false | true;
        size?: "web" | "sd" | "hd" | "4k";
        verification_code?: string;
      },
    ) {
      const url = new URL(
        `https://api.shutterstock.com/v2/videos/licenses/${id}/downloads`,
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago